WMI类多显示器(Win32_DesktopMonitor)返回的不正确的dpi

时间:2018-07-11 15:08:44

标签: c# wmi

我有两个显示器,分别设置为不同的dpi设置:120240(在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>

0 个答案:

没有答案