启用DPI意识设置无效VisualStudio 2017

问题描述

我希望我的程序能够感知DPI,但是我不想以编程方式设置认感知,因为根据Microsoft docs(https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process),不建议您这样做。项目配置中的“启用DPI意识”对清单或程序本身没有影响。

我做了什么: 我添加了清单文件

Added a manifest File

我还启用了DPI意识

set Enable DPI Awareness to Yes

清除+重建后,它会创建一个清单,但是我所得到的只是这个清单文件,没有任何dpi感知标签

   <?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' />
       </requestedPrivileges>
      </security>
     </trustInfo>
    </assembly>

我阅读了文档,但无法使其正常工作。手动编辑无济于事,因为清单是在生成生成的: https://docs.microsoft.com/en-us/cpp/build/understanding-manifest-generation-for-c-cpp-programs?view=vs-2019

希望可以为您提供帮助。我尝试尽快回答。如果您需要更多信息,请告诉我

解决方法

  • 这似乎是 VS2017 中的一个错误。如果你可以升级到 VS2019 你 应该升级。这为我解决了问题。

  • 如果你不能升级你可以右键单击.exe并启用
    辅助功能设置中的 dpi 感知标志。