My initial instinct is to get the current DpiY setting of the system via a Graphics instance, but I cannot figure out how to get one.
Spellunking through Reflector I see that Microsoft manages it using unsafe code:
IntPtr dC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef);
try
{
using (Graphics graphics = Graphics.FromHdcInternal(dC))
{
float num = graphics.DpiY;
}
}
What is the managed equivalent way to construct a Graphics when i don't have a graphics?
I tried:
using (Graphics g = Graphics.FromHdc(IntPtr.Zero))
{
return font.GetHeight(g.DpiY);
}
But that throws a Value cannot be null exception.