QT开发之exe增加管理员权限

1、适用于mingw32编译器

创建一个txt文档,然后在里面添加

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>  
 <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>  
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">  
      <security>  
        <requestedPrivileges>  
          <requestedExecutionLevel level='requireAdministrator' uiAccess='false' />  
        </requestedPrivileges>  
      </security>  
    </trustInfo>  
 </assembly>  

然后将名称和格式修改为:app.manifest,放在和exe同一个目录下

然后在exe所在的目录中执行mt指令(mt指令在VS自带的“开发人员命令提示”工具中)
在这里插入图片描述
使用cd命令进入到文件所在目录
输入:

mt.exe -manifest "app.manifest" -outputresource:"exe名称.exe";#1

mt.exe -manifest “app.manifest” -outputresource:“exe名称.exe”;#1

运行完,就可以看见exe上带了一个盾牌的标志,此时exe已经加上管理员权限了

猜你喜欢

转载自blog.csdn.net/qq_45662588/article/details/120611068