關於dpi awareness 的清單文件設置


要設置dpi 意識,一般是使用SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)來設置

 

具體可參考:Setting the default DPI awareness for a process

 

不過官方更建議使用清單文件來設置dpi意識,我介紹一下方法:

新建一個后綴為.manifest的文件,然后在其中添加如下代碼

<?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="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <application>
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
      <!-- legacy -->
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
      <!-- falls back to pm if pmv2 is not available -->
    </windowsSettings>
  </application>
</assembly>

保存后,在項目中添加這個文件,最后debug就可以了

請注意:也有其他方法可以設置dpi意識,看下圖

直接改選項就可以了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM