예제 #1
0
        public static bool VerifyOSDependency(ref PlatformDetector.OSDependency osd)
        {
            OperatingSystem osVersion = Environment.OSVersion;

            if ((long)osVersion.Version.Major == 4L)
            {
                return((long)osVersion.Version.Major >= (long)osd.dwMajorVersion);
            }
            NativeMethods.OSVersionInfoEx osvi = new NativeMethods.OSVersionInfoEx();
            osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf((object)osvi);
            osvi.dwMajorVersion      = osd.dwMajorVersion;
            osvi.dwMinorVersion      = osd.dwMinorVersion;
            osvi.dwBuildNumber       = osd.dwBuildNumber;
            osvi.dwPlatformId        = 0U;
            osvi.szCSDVersion        = (string)null;
            osvi.wServicePackMajor   = osd.wServicePackMajor;
            osvi.wServicePackMinor   = osd.wServicePackMinor;
            osvi.wSuiteMask          = osd.suiteName != null ? (ushort)PlatformDetector.NameMap.MapNameToMask(osd.suiteName, (PlatformDetector.NameMap[])PlatformDetector.Suites) : (ushort)0;
            osvi.bProductType        = osd.productName != null ? (byte)PlatformDetector.NameMap.MapNameToMask(osd.productName, (PlatformDetector.NameMap[])PlatformDetector.Products) : (byte)0;
            osvi.bReserved           = (byte)0;
            ulong ConditionMask = 0;
            uint  dwTypeMask    = (uint)(2 | ((int)osd.dwMinorVersion != 0 ? 1 : 0) | ((int)osd.dwBuildNumber != 0 ? 4 : 0) | (osd.suiteName != null ? 64 : 0) | (osd.productName != null ? 128 : 0) | ((int)osd.wServicePackMajor != 0 ? 32 : 0) | ((int)osd.wServicePackMinor != 0 ? 16 : 0));
            ulong num           = NativeMethods.VerSetConditionMask(ConditionMask, 2U, (byte)3);

            if ((int)osd.dwMinorVersion != 0)
            {
                num = NativeMethods.VerSetConditionMask(num, 1U, (byte)3);
            }
            if ((int)osd.dwBuildNumber != 0)
            {
                num = NativeMethods.VerSetConditionMask(num, 4U, (byte)3);
            }
            if (osd.suiteName != null)
            {
                num = NativeMethods.VerSetConditionMask(num, 64U, (byte)6);
            }
            if (osd.productName != null)
            {
                num = NativeMethods.VerSetConditionMask(num, 128U, (byte)1);
            }
            if ((int)osd.wServicePackMajor != 0)
            {
                num = NativeMethods.VerSetConditionMask(num, 32U, (byte)3);
            }
            if ((int)osd.wServicePackMinor != 0)
            {
                num = NativeMethods.VerSetConditionMask(num, 16U, (byte)3);
            }
            bool flag = NativeMethods.VerifyVersionInfo(osvi, dwTypeMask, num);

            if (!flag)
            {
                int lastWin32Error = Marshal.GetLastWin32Error();
                if (lastWin32Error != 1150)
                {
                    throw new Win32Exception(lastWin32Error);
                }
            }
            return(flag);
        }
예제 #2
0
 public OSDependency(NativeMethods.OSVersionInfoEx osvi)
 {
     this.dwMajorVersion = osvi.dwMajorVersion;
     this.dwMinorVersion = osvi.dwMinorVersion;
     this.dwMajorVersion = osvi.dwBuildNumber;
     this.dwMajorVersion = (uint)osvi.wServicePackMajor;
     this.dwMajorVersion = (uint)osvi.wServicePackMinor;
     this.suiteName      = PlatformDetector.NameMap.MapMaskToName((uint)osvi.wSuiteMask, (PlatformDetector.NameMap[])PlatformDetector.Suites);
     this.productName    = PlatformDetector.NameMap.MapMaskToName((uint)osvi.bProductType, (PlatformDetector.NameMap[])PlatformDetector.Products);
 }
예제 #3
0
 public static extern bool VerifyVersionInfo([In, Out] NativeMethods.OSVersionInfoEx osvi, [In] uint dwTypeMask, [In] ulong dwConditionMask);