diff --git a/trunk/ProcessHacker.Native/OSVersion.cs b/trunk/ProcessHacker.Native/OSVersion.cs
index 14f83e652..8969d6af2 100644
--- a/trunk/ProcessHacker.Native/OSVersion.cs
+++ b/trunk/ProcessHacker.Native/OSVersion.cs
@@ -36,10 +36,10 @@ namespace ProcessHacker.Native
///
/// Windows 2000.
///
- Win2000 = 50,
+ TwoThousand = 50,
///
- /// Windows XP SP2, SP3.
+ /// Windows XP.
///
XP = 51,
@@ -49,24 +49,19 @@ namespace ProcessHacker.Native
Server2003 = 52,
///
- /// Windows Vista SP0, SP1, SP2, Windows Server 2008.
+ /// Windows Vista, Windows Server 2008.
///
Vista = 60,
///
- /// Windows 7 SP0.
+ /// Windows 7, Windows Server 2008 R2.
///
Seven = 61,
///
- /// An unreleased version of Windows.
+ /// An unknown version of Windows.
///
- Unreleased = int.MaxValue,
-
- ///
- /// An unsupported version of Windows.
- ///
- Unsupported = int.MinValue
+ Unknown = int.MaxValue
}
public static class OSVersion
@@ -86,6 +81,7 @@ namespace ProcessHacker.Native
private static bool _hasQueryLimitedInformation = false;
private static bool _hasSetAccessToken = false;
private static bool _hasTaskDialogs = false;
+ private static bool _hasThemes = false;
private static bool _hasUac = false;
private static bool _hasWin32ImageFileName = false;
@@ -93,66 +89,23 @@ namespace ProcessHacker.Native
{
System.Version version = Environment.OSVersion.Version;
- 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.TwoThousand;
+ 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
+ _windowsVersion = WindowsVersion.Unknown;
- //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 (IsAboveOrEqual(WindowsVersion.XP))
+ {
+ _hasThemes = true;
+ }
if (IsBelow(WindowsVersion.Vista))
{
@@ -250,6 +203,11 @@ namespace ProcessHacker.Native
get { return _hasTaskDialogs; }
}
+ public static bool HasThemes
+ {
+ get { return _hasThemes; }
+ }
+
public static bool HasUac
{
get { return _hasUac; }
diff --git a/trunk/ProcessHacker/Common/PhUtils.cs b/trunk/ProcessHacker/Common/PhUtils.cs
index 48b53f9f2..98790f5b4 100644
--- a/trunk/ProcessHacker/Common/PhUtils.cs
+++ b/trunk/ProcessHacker/Common/PhUtils.cs
@@ -382,7 +382,11 @@ namespace ProcessHacker.Common
/// A name of a theme.
public static void SetTheme(this Control control, string theme)
{
- Win32.SetWindowTheme(control.Handle, theme, null);
+ // Don't set on XP, doesn't look better than without SetWindowTheme.
+ if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista))
+ {
+ Win32.SetWindowTheme(control.Handle, theme, null);
+ }
}
///
diff --git a/trunk/ProcessHacker/Components/ExtendedTreeView.cs b/trunk/ProcessHacker/Components/ExtendedTreeView.cs
index a2f67aea7..5be7160e2 100644
--- a/trunk/ProcessHacker/Components/ExtendedTreeView.cs
+++ b/trunk/ProcessHacker/Components/ExtendedTreeView.cs
@@ -43,9 +43,9 @@ namespace ProcessHacker.Components
if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista))
{
Win32.SendMessage(this.Handle, (WindowMessage)TVM_SETEXTENDEDSTYLE, 0, TVS_EX_FADEINOUTEXPANDOS);
- HResult setThemeResult = Win32.SetWindowTheme(this.Handle, "explorer", null);
- setThemeResult.ThrowIf();
+ ProcessHacker.Common.PhUtils.SetTheme(this, "explorer");
}
+
base.OnHandleCreated(e);
}
}
diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs
index 6c29b1bcc..d8c439e7c 100644
--- a/trunk/ProcessHacker/Program/Program.cs
+++ b/trunk/ProcessHacker/Program/Program.cs
@@ -119,25 +119,20 @@ namespace ProcessHacker
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- //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
+ // Check OS support.
+
+ if (OSVersion.IsBelow(WindowsVersion.TwoThousand) || OSVersion.IsAbove(WindowsVersion.Seven))
+ {
+ PhUtils.ShowWarning("Your operating system is not supported by Process Hacker.");
+ }
+
+#if !DEBUG
// Setup exception handling at first opportunity to catch exceptions generatable anywhere.
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);