Added "Windows 8" for the OS information, also fixed that it always says "WinNT32" or something like that.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2221 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-10-29 15:16:55 +00:00
commit 43fd418d6f

View file

@ -35,17 +35,17 @@ namespace Greenshot.Helpers {
/// </summary> /// </summary>
public static class EnvironmentInfo { public static class EnvironmentInfo {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger("Greenshot"); private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger("Greenshot");
private static bool? isWindows = null; private static bool? isWindows = null;
public static bool IsWindows { public static bool IsWindows {
get { get {
if (isWindows.HasValue) { if (isWindows.HasValue) {
return isWindows.Value; return isWindows.Value;
} }
isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Windows"); isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win");
return isWindows.Value; return isWindows.Value;
} }
} }
public static string EnvironmentToString(bool newline) { public static string EnvironmentToString(bool newline) {
StringBuilder environment = new StringBuilder(); StringBuilder environment = new StringBuilder();
@ -74,13 +74,13 @@ namespace Greenshot.Helpers {
} }
if (IsWindows) { if (IsWindows) {
environment.Append(String.Format("OS: {0} {1} {2} x{3} modus Version = {4}", OSInfo.Name, OSInfo.Edition, OSInfo.ServicePack, OSInfo.Bits, OSInfo.VersionString)); environment.Append(String.Format("OS: {0} {1} {2} (x{3}) {4}", OSInfo.Name, OSInfo.Edition, OSInfo.ServicePack, OSInfo.Bits, OSInfo.VersionString));
if (newline) { if (newline) {
environment.AppendLine(); environment.AppendLine();
} else { } else {
environment.Append(", "); environment.Append(", ");
} }
// Get some important information for fixing GDI related Problems // Get some important information for fixing GDI related Problems
environment.Append("GDI object count: " + User32.GetGuiResourcesGDICount()); environment.Append("GDI object count: " + User32.GetGuiResourcesGDICount());
if (newline) { if (newline) {
environment.AppendLine(); environment.AppendLine();
@ -415,12 +415,11 @@ namespace Greenshot.Helpers {
/// <summary> /// <summary>
/// Gets the name of the operating system running on this computer. /// Gets the name of the operating system running on this computer.
/// </summary> /// </summary>
static public string Name static public string Name {
{ get {
get if (s_Name != null) {
{
if (s_Name != null)
return s_Name; //***** RETURN *****// return s_Name; //***** RETURN *****//
}
string name = "unknown"; string name = "unknown";
@ -428,91 +427,119 @@ namespace Greenshot.Helpers {
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX(); OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf( typeof( OSVERSIONINFOEX ) ); osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf( typeof( OSVERSIONINFOEX ) );
if (GetVersionEx( ref osVersionInfo )) if (GetVersionEx( ref osVersionInfo )) {
{
int majorVersion = osVersion.Version.Major; int majorVersion = osVersion.Version.Major;
int minorVersion = osVersion.Version.Minor; int minorVersion = osVersion.Version.Minor;
byte productType = osVersionInfo.wProductType;
switch (osVersion.Platform) short suiteMask = osVersionInfo.wSuiteMask;
{ switch (osVersion.Platform) {
case PlatformID.Win32Windows: case PlatformID.Win32Windows:
{ if (majorVersion == 4) {
if (majorVersion == 4) string csdVersion = osVersionInfo.szCSDVersion;
{ switch (minorVersion) {
string csdVersion = osVersionInfo.szCSDVersion; case 0:
switch (minorVersion) if (csdVersion == "B" || csdVersion == "C") {
{ name = "Windows 95 OSR2";
case 0: } else {
if (csdVersion == "B" || csdVersion == "C") name = "Windows 95";
name = "Windows 95 OSR2"; }
else break;
name = "Windows 95"; case 10:
if (csdVersion == "A") {
name = "Windows 98 Second Edition";
} else {
name = "Windows 98";
}
break;
case 90:
name = "Windows Me";
break;
}
}
break;
case PlatformID.Win32NT:
switch (majorVersion) {
case 3:
name = "Windows NT 3.51";
break;
case 4:
switch (productType) {
case 1:
name = "Windows NT 4.0";
break; break;
case 10: case 3:
if (csdVersion == "A") name = "Windows NT 4.0 Server";
name = "Windows 98 Second Edition";
else
name = "Windows 98";
break;
case 90:
name = "Windows Me";
break; break;
} }
} break;
break; case 5:
} switch (minorVersion) {
case 0:
case PlatformID.Win32NT: name = "Windows 2000";
{ break;
byte productType = osVersionInfo.wProductType; case 1:
switch (suiteMask) {
switch (majorVersion) case 0x0200:
{ name = "Windows XP Professional";
case 3: break;
name = "Windows NT 3.51"; default:
break; name = "Windows XP";
case 4: break;
switch (productType) }
{ break;
case 1: case 2:
name = "Windows NT 4.0"; switch (suiteMask) {
break; case 0x0200:
case 3: name = "Windows XP Professional x64";
name = "Windows NT 4.0 Server"; break;
break; case 0x0002:
} name = "Windows Server 2003 Enterprise";
break; break;
case 5: case 0x0080:
switch (minorVersion) name = "Windows Server 2003 Data Center";
{ break;
case 0: case 0x0400:
name = "Windows 2000"; name = "Windows Server 2003 Web Edition";
break; break;
case 1: case unchecked ((short)0x8000):
name = "Windows XP"; name = "Windows Home Server";
break; break;
case 2: default:
name = "Windows Server 2003"; name = "Windows Server 2003";
break; break;
} }
break; break;
case 6: }
switch (minorVersion) break;
{ case 6:
case 0: switch (minorVersion) {
name = "Windows Vista"; case 0:
break; switch (productType) {
case 1: case 3:
name = "Windows 7"; name = "Windows Server 2008";
break; break;
case 3: default:
name = "Windows Server 2008"; name = "Windows Vista";
break; break;
} }
break; break;
} case 1:
break; switch (productType) {
case 3:
name = "Windows Server 2008 R2";
break;
default:
name = "Windows 7";
break;
}
break;
case 2:
name = "Windows 8";
break;
}
break;
} }
break;
} }
} }
@ -655,11 +682,9 @@ namespace Greenshot.Helpers {
/// <summary> /// <summary>
/// Gets the full version string of the operating system running on this computer. /// Gets the full version string of the operating system running on this computer.
/// </summary> /// </summary>
static public string VersionString static public string VersionString {
{ get {
get return string.Format("{0}.{1} build {3} revision {2:X}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, Environment.OSVersion.Version.Revision, Environment.OSVersion.Version.Build);
{
return Environment.OSVersion.Version.ToString();
} }
} }
#endregion STRING #endregion STRING