qt编译管理员权限的程序

MSVC

msvc编译的话,只需要在.pro文件中加入以下语句:

cpp 复制代码
QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"

MinGW

mingw编译的话,有几个步骤:

1、在项目根目录下增加一个文件proce.manifest,增加内容如下:

cpp 复制代码
<?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>

2、在项目根目录下增加一个文件proce.rc增加内容如下:proce.manifest对应为第1步的文件名

cpp 复制代码
1 24 DISCARDABLE proce.manifest

3、在项目pro文件中增加RC_FILE = proce.rc

4、重新以管理员身份运行qt Creator软件,重新编译即可。

相关推荐
用户805533698038 小时前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
xcyxiner9 小时前
DicomViewer (vcpkg Windows和ubuntu编译)7
qt
Quz5 天前
QML Hello World 入门示例
qt
xcyxiner8 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner9 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner9 天前
DicomViewer (添加模型类)3
qt
xcyxiner10 天前
DicomViewer (目录调整) 2
qt
xcyxiner10 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
桥田智能12 天前
桥田智能 QT-650S:面向白车身焊装的 800kg 重载快换解决方案
开发语言·qt·系统架构
森G12 天前
75、服务器源码解析---------云视频服务项目
linux·服务器·网络·c++·qt