winapi - 如何使用我自己的清单文件并将其嵌入到使用 Visual Studio 2017 的可执行文件中?
问题描述
我正在尝试使用 PerMonitorV2 DPI 感知,它会在 DPI 更改时调整非客户区的大小。MSDN 文档建议使用清单设置 DPI 感知模式: 为进程设置默认 DPI 感知。
VS Configuration Properties 的 Manifest Tool 部分仅提供了三个 DPI Awareness 选项:None(不知道)、Hight DPI Aware和Per Monitor DPI Aware(似乎是 PerMonitorV1),所以我需要找到一些方法来覆盖这些 DPI 设置,但我不知道该怎么做。(我最好的猜测是以某种方式提供我自己的清单文件,而不是依靠 Visual Studio 来生成一个。)
解决方案
在清单工具设置中,您可以定义 Visual Studio 将与默认清单合并的附加清单片段。默认清单仍将提供<dpiAware>
标签,作为不理解<dpiAwareness>
标签的旧版本操作系统的后备。
脚步:
- 打开项目配置,选择“Manifest Tool”>“Input and Output”。
在“其他清单文件”字段中,输入要包含的清单片段的文件名。该路径是相对于您的项目文件夹的。
片段看起来像这样。请注意,我从MSDN 示例中删除了
<dpiAware>
标记:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <application xmlns="urn:schemas-microsoft-com:asm.v3"> <windowsSettings> <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> </windowsSettings> </application> </assembly>
从“DPI Awareness”组合框中选择“High DPI Aware”。如上所述,这是旧 Windows 版本的备用值。
结果:
这是我使用应用程序向导创建的 Win32 项目的合并清单。它嵌入在应用程序的资源中。
<?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 xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly>
如果你有两个<dpiAware>
标签,你忘了<dpiAware>
从清单片段中删除。
推荐阅读
- regex - Bash Regex 仅打印出匹配的字符串?
- node.js - express.js 中的参数?
- apache-spark - Spark - X ms 后执行器心跳超时
- javascript - D3:如何使用新数据更新分组栏
- uwp - 如何为 UWP 应用程序使用 OpenSSL dll
- javascript - 操作系统如何将事件与 dom 对象联系起来?
- fonts - 由于某些原因,我的一位用户看到所有数字都被星号“*”替换,这是为什么呢?
- python - 在 PyCharm 中找不到 TensorFlow 模块
- python-2.7 - Python npyscreen:如何从按钮按下启动表单?
- jquery - 点击链接后关闭手机版菜单