zoukankan      html  css  js  c++  java
  • 在Visual Studio中构建启动时申请管理员权限的程序(UAC支持)

    这几天写了几个修改注册表的程序,因为需要管理员权限,所以就搜了一下如何构建启动时申请管理员权限的程序(UAC支持,也就是程序左下角多了个小盾牌)。

    其实方法很简单,就是修改manifest文件中执行权限为即可。具体方法如下:

    1. 在项目上选择添加新项->常规->应用程序清单文件(Add->Add new item->Application Manifest File),将app.manifest文件添加至项目中。
    2. 打开该文件,在requestedExecutionLevel节中, 把level值改为requireAdministrator,重新编译即可。

    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
            <security>
                <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
                    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
                </requestedPrivileges>
                <applicationRequestMinimum>
                    <defaultAssemblyRequest permissionSetReference="Custom" />
                    <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
                </applicationRequestMinimum>
            </security>
        </trustInfo>
    </asmv1:assembly>

  • 相关阅读:
    微信小程序用setData修改数组或对象中的一个属性值,超好用,最简单的实现方法,不容错过!大神们 都 在 看 的方法!!!
    pythonchallenge1
    pythonchallenge4
    pythonchallenge7
    pythonchallenge9
    pythonchallenge8
    pythonchallenge2
    pythonchallenge0
    递归排序
    pythonchallenge3
  • 原文地址:https://www.cnblogs.com/TianFang/p/1517379.html
Copyright © 2011-2022 走看看