Within the manifest tool settings, you can define an additional manifest snippet that Visual Studio will merge with the default one. The default manifest will still provide the <dpiAware>
tag, to serve as the fallback for older versions of the OS that don't understand the <dpiAwareness>
tag.
Steps:
- Open project configuration, select "Manifest Tool" > "Input and Output".
In the field "Additional Manifest Files", enter the filename of the manifest snippet you want to include. The path is relative to your project folder.
The snippet looks like this. Note that I removed the <dpiAware>
tag from the MSDN sample:
<?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>
From the "DPI Awareness" combobox select "High DPI Aware". As written above, this is the fallback value for older Windows versions.
Result:
This is the merged manifest for a Win32 project I created using the application wizard. It is embedded in the resources of the application.
<?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>
If you get two <dpiAware>
tags, you forgot to remove the <dpiAware>
from the manifest snippet.