示例#1
0
文件: WinVer.cs 项目: rikka0w0/Menu98
        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));
        }
示例#2
0
        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");
            }
        }