Skip to content

Instantly share code, notes, and snippets.

@kg
Created August 12, 2017 03:25
Show Gist options
  • Save kg/72c2bd328192546cfbd36ea33350413f to your computer and use it in GitHub Desktop.
Save kg/72c2bd328192546cfbd36ea33350413f to your computer and use it in GitHub Desktop.
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