private static Version GetSystemVersion() { IntPtr hinst = WinAPI.GetModuleHandle("ntdll.dll"); RtlGetNtVersionNumbers func = (RtlGetNtVersionNumbers)WinAPI.GetFunctionAddress(hinst, "RtlGetNtVersionNumbers", typeof(RtlGetNtVersionNumbers)); if (func == null) { return(Environment.OSVersion.Version); } int dwMajor = 0, dwMinor = 0, dwBuildNumber = 0; func.Invoke(ref dwMajor, ref dwMinor, ref dwBuildNumber); dwBuildNumber &= 0xffff; return(new Version(dwMajor, dwMinor, dwBuildNumber)); }
public static void SetCurrentProcessDPIAware() { SetProcessDPIAware addrSetProcessDPIAware = (SetProcessDPIAware) WinAPI.GetFunctionAddress( WinAPI.GetModuleHandle("user32.dll"), "SetProcessDPIAware", typeof(SetProcessDPIAware)); if (addrSetProcessDPIAware != null) { addrSetProcessDPIAware(); } else { MessageBox.Show("DPI Unsupported"); } }