diff --git a/trunk/ProcessHacker.Native/OSVersion.cs b/trunk/ProcessHacker.Native/OSVersion.cs index fcd5159fb..14f83e652 100644 --- a/trunk/ProcessHacker.Native/OSVersion.cs +++ b/trunk/ProcessHacker.Native/OSVersion.cs @@ -33,6 +33,11 @@ namespace ProcessHacker.Native public enum WindowsVersion { + /// + /// Windows 2000. + /// + Win2000 = 50, + /// /// Windows XP SP2, SP3. /// @@ -56,7 +61,12 @@ namespace ProcessHacker.Native /// /// An unreleased version of Windows. /// - Unreleased = int.MaxValue + Unreleased = int.MaxValue, + + /// + /// An unsupported version of Windows. + /// + Unsupported = int.MinValue } public static class OSVersion @@ -83,16 +93,66 @@ namespace ProcessHacker.Native { System.Version version = Environment.OSVersion.Version; - if (version.Major == 5 && version.Minor == 1) - _windowsVersion = WindowsVersion.XP; - else if (version.Major == 5 && version.Minor == 2) - _windowsVersion = WindowsVersion.Server2003; - else if (version.Major == 6 && version.Minor == 0) - _windowsVersion = WindowsVersion.Vista; - else if (version.Major == 6 && version.Minor == 1) - _windowsVersion = WindowsVersion.Seven; - else if ((version.Major == 6 && version.Minor > 1) || version.Major > 6) - _windowsVersion = WindowsVersion.Unreleased; + switch (version.Major) + { + case 5: + { + switch (version.Minor) + { + case 0: + _windowsVersion = WindowsVersion.Win2000; + break; + case 1: + _windowsVersion = WindowsVersion.XP; + break; + case 2: + _windowsVersion = WindowsVersion.Server2003; + break; + default: + break; //Not detected, jump to version.Major default + } + break; + } + case 6: + { + switch (version.Minor) + { + case 0: + _windowsVersion = WindowsVersion.Vista; + break; + case 1: + _windowsVersion = WindowsVersion.Seven; + break; + default: + break; //Not detected, jump to version.Major default + } + break; + } + default: + if (version.Major > 6 || version.Minor > 1) //check if newer than latest Windows release + { + _windowsVersion = WindowsVersion.Unreleased; + break; + } + else //OS version not detected and not newer than the newest Windows release + _windowsVersion = WindowsVersion.Unsupported; + break; + } + + //if (version.Major == 5 && version.Minor == 0) + // _windowsVersion = WindowsVersion.Win2000; + //else if (version.Major == 5 && version.Minor == 1) + // _windowsVersion = WindowsVersion.XP; + //else if (version.Major == 5 && version.Minor == 2) + // _windowsVersion = WindowsVersion.Server2003; + //else if (version.Major == 6 && version.Minor == 0) + // _windowsVersion = WindowsVersion.Vista; + //else if (version.Major == 6 && version.Minor == 1) + // _windowsVersion = WindowsVersion.Seven; + //else if ((version.Major == 6 && version.Minor > 1) || version.Major > 6) + // _windowsVersion = WindowsVersion.Unreleased; + //else + // _windowsVersion = WindowsVersion.Unsupported; if (IsBelow(WindowsVersion.Vista)) { diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index 5f7d089a1..6c29b1bcc 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -119,11 +119,24 @@ namespace ProcessHacker Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - if (Environment.Version.Major < 2) + //before parsing commandline arguments, check OS support. + if (OSVersion.IsBelow(WindowsVersion.Win2000)) + { + PhUtils.ShowError("This Operating System is not supported!"); + Environment.Exit(1); + } + else if (OSVersion.WindowsVersion == WindowsVersion.Unreleased) + { + PhUtils.ShowError("This Operating System is unreleased and not currently supported," + + "\nProcess Hacker support has not been tested so expect bugs and issues."); + } + + if (Environment.Version.Major < 2) { PhUtils.ShowError("You must have .NET Framework 2.0 or higher to use Process Hacker."); Environment.Exit(1); } + #if !DEBUG // Setup exception handling at first opportunity to catch exceptions generatable anywhere. Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);