From 7a50523650335654b35d2e506c23b531ffde7d96 Mon Sep 17 00:00:00 2001 From: dmex04 Date: Sun, 18 Oct 2009 09:04:28 +0000 Subject: [PATCH] added OS Version string caching, removed duplicate OSVersion functions from TaskDialog git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2268 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- trunk/ProcessHacker.Native/OSVersion.cs | 6 +++++ .../Components/TaskDialog/TaskDialog.cs | 26 ------------------- trunk/ProcessHacker/Program/Program.cs | 2 +- trunk/ProcessHacker/Program/Save.cs | 2 +- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/trunk/ProcessHacker.Native/OSVersion.cs b/trunk/ProcessHacker.Native/OSVersion.cs index 9124044a6..4372ef25a 100644 --- a/trunk/ProcessHacker.Native/OSVersion.cs +++ b/trunk/ProcessHacker.Native/OSVersion.cs @@ -69,6 +69,7 @@ namespace ProcessHacker.Native private static int _bits = IntPtr.Size * 8; private static OSArch _arch = IntPtr.Size == 4 ? OSArch.I386 : OSArch.Amd64; private static WindowsVersion _windowsVersion; + private static string _versionString; private static ProcessAccess _minProcessQueryInfoAccess = ProcessAccess.QueryInformation; private static ThreadAccess _minThreadQueryInfoAccess = ThreadAccess.QueryInformation; @@ -146,6 +147,11 @@ namespace ProcessHacker.Native get { return _bits.ToString() + "-" + "bit"; } } + public static string VersionString + { + get { return !string.IsNullOrEmpty(_versionString) ? _versionString : _versionString = Environment.OSVersion.VersionString; } + } + public static OSArch Architecture { get { return _arch; } diff --git a/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs b/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs index 5feadabee..2bffca432 100644 --- a/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs +++ b/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs @@ -463,32 +463,6 @@ namespace ProcessHacker.Components this.Reset(); } - /// - /// Returns true if the current operating system supports TaskDialog. If false TaskDialog.Show should not - /// be called as the results are undefined but often results in a crash. - /// - public static bool IsAvailableOnThisOS - { - get - { - OperatingSystem os = Environment.OSVersion; - if (os.Platform != PlatformID.Win32NT) - { - return false; - } - - return (os.Version.CompareTo(TaskDialog.RequiredOSVersion) >= 0); - } - } - - /// - /// The minimum Windows version needed to support TaskDialog. - /// - public static Version RequiredOSVersion - { - get { return new Version(6, 0, 5243); } - } - /// /// The string to be used for the dialog box title. If this parameter is NULL, the filename of the executable program is used. /// diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index 760a6b1c4..21956c8c6 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -890,7 +890,7 @@ namespace ProcessHacker info.AppendLine("Process Hacker " + Application.ProductVersion); info.AppendLine("Process Hacker Build Time: " + Utils.GetAssemblyBuildDate(System.Reflection.Assembly.GetExecutingAssembly(), false).ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo)); info.AppendLine("CLR Version: " + Environment.Version.ToString()); - info.AppendLine("OS Version: " + Environment.OSVersion.VersionString + " (" + OSVersion.BitsString + ")"); + info.AppendLine("OS Version: " + OSVersion.VersionString + " (" + OSVersion.BitsString + ")"); info.AppendLine("Elevation: " + ElevationType.ToString()); info.AppendLine("Working set: " + Utils.FormatSize(Environment.WorkingSet)); diff --git a/trunk/ProcessHacker/Program/Save.cs b/trunk/ProcessHacker/Program/Save.cs index adb21907e..41d667ee4 100644 --- a/trunk/ProcessHacker/Program/Save.cs +++ b/trunk/ProcessHacker/Program/Save.cs @@ -106,7 +106,7 @@ namespace ProcessHacker StringBuilder sb = new StringBuilder(); sb.AppendLine("Process Hacker version " + Application.ProductVersion); - sb.AppendLine(Environment.OSVersion.ToString() + " (" + OSVersion.BitsString + ")"); + sb.AppendLine(OSVersion.VersionString + " (" + OSVersion.BitsString + ")"); return sb.ToString(); }