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>

  • 相关阅读:
    Dat2Rin.exe + runpkr00.exe 将*.T0* 数据转换成Rinex文件
    使用scipy.spatial.Delaunay 三角网的构建
    tinkphp3第三方类库引入问题
    git 撤销更改
    nginx各种配置
    elastic教程
    centos添加动态库默认搜索路径
    JSwebsocket问题:One or more reserved bits are on: reserved1 = 1, reserved2 = 1, reserved3 = 0
    关于脚本手动正常运行,放入crontab无效的问题
    mysql相关操作
  • 原文地址:https://www.cnblogs.com/TianFang/p/1517379.html
Copyright © 2011-2022 走看看