1. 程式人生 > >QT更改manifest檔案從而修改圖示、執行許可權以及處理判斷windows10系統出錯的問題

QT更改manifest檔案從而修改圖示、執行許可權以及處理判斷windows10系統出錯的問題

1、至於qt如何修改圖示和獲取UAC許可權,只需要幾個檔案邊可以實現,如

下 manifest.rc

#include <windows.h>
ID_ICON    ICON    DISCARDABLE    "qt.ico"
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "winadmin.exe.manifest"

winadmin.exe.manifest

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="2.0.0.0" processorArchitecture="X86"
  name="winadmin.myapp" type="win32" />
  <description>MY really cool awesome</description>
  <dependency />
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
   </trustInfo>
   <!-- padding to four-byte multiple file size including the byte order mark -->
  <!-- padding 123 -->
</assembly>

還需要在工程檔案(.pro)加入

RC_FILE=manifest.rc

2、Windows 8.1, Win10之後,通過GetVersion and GetVersionEx 方法獲取WIndows作業系統版本號的功能需要新增manifest檔案後才能查詢到,不然的話會查詢錯誤,比如win10系統返給一個win8系統等。

可修改manifest.fest檔案如下即可:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
      <!-- Windows 10 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <!-- Windows 8.1 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <!-- Windows 8 -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!-- Windows Vista -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!-- Windows 7 -->
    </application>
  </compatibility>

</assembly>

其餘如同第一點,將檔案新增到.rc檔案再新增到pro即可,就不多說了。