我有两个显示器,分别设置为不同的dpi设置:120
和240
(在Windows中为125%和250%)。我正在尝试在c#中获取这些设置,如下所示:
ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(
"SELECT * FROM Win32_DesktopMonitor");
foreach (ManagementObject monitor in managementObjectSearcher.Get())
{
dpi = (uint) monitor["PixelsPerXLogicalInch"];
Console.Write(dpi);
}
此代码段返回两次120
。为什么不返回正确的值?
顺便说一句app.manifest
包括:
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
</windowsSettings>
</application>