Created
August 12, 2017 03:25
-
-
Save kg/72c2bd328192546cfbd36ea33350413f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsafe static Program () { | |
var dpiSetOk = false; | |
try { | |
var hr = Win32.SetProcessDpiAwareness(Win32.ProcessDpiAwareness.PROCESS_PER_MONITOR_DPI_AWARE); | |
if (hr != 0) | |
Console.WriteLine("SetProcessDpiAwareness={0}, LastError={1}", hr, Marshal.GetLastWin32Error()); | |
else | |
dpiSetOk = true; | |
} catch { | |
} | |
if (!dpiSetOk) { | |
var r = Win32.SetProcessDPIAware(); | |
if (r != 0) | |
Console.WriteLine("SetProcessDPIAware={0}, LastError={1}", r, Marshal.GetLastWin32Error()); | |
} | |
Console.OutputEncoding = Encoding.Unicode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment