在清单工具设置中,您可以定义 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>
从清单片段中删除。