In my application, I get the screen resolution with this code:
SystemInformation.PrimaryMonitorSize
And I get the DPI with this code:
using (Graphics g = Graphics.FromHdc(NativeMethods.GetDC(IntPtr.Zero)))
{
dpiX = g.DpiX;
dpiY = g.DpiY;
}
This works fine in most situations. But when the code runs on a Vista machine with Aero turned on, and the user has set the monitor to use a high DPI, bizarre results come back.
Lets say the user has set the machine to run at 1024 x 768 and has the DPI at 144, the code above will return a resolution of 683 x 512 and a DPI of 96.
However, if Aero is turned off, the results come back as I would expect them. What is Aero doing and how can I get the true resolution and DPI?