Qt(在Windows上)将权限级别设置为“requireAdministrator”

我正在使用Qt Creator,努力使.exe文件以pipe理员身份运行。

通过在线阅读所有的解决scheme,我试图把这一行放在我的.pro文件中:

 QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'" 

但仍然当我检查我的.exe (使用记事本)它包含:

 <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> 

有人可以告诉我,如何添加requireAdministrator

临时解决scheme:直到现在我找不到一个解决scheme,所以我做了一个临时的黑客攻击。 我做了一个名为“LaunchAnother.exe”的.exe文件,它将使用以下代码启动我的“main.exe”:

 SHELLEXECUTEINFO shExInfo = {0}; shExInfo.cbSize = sizeof(shExInfo); shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; shExInfo.hwnd = 0; shExInfo.lpVerb = _T("runas"); // Operation to perform shExInfo.lpFile = _T("main.exe"); // Application to start shExInfo.lpParameters = ""; // Additional parameters shExInfo.lpDirectory = 0; shExInfo.nShow = SW_SHOW; shExInfo.hInstApp = 0; if (ShellExecuteEx(&shExInfo)) { WaitForSingleObject(shExInfo.hProcess, INFINITE); CloseHandle(shExInfo.hProcess); } 

还在等待更好的解决scheme。

Solutions Collecting From Web of "Qt(在Windows上)将权限级别设置为“requireAdministrator”"