private string GetServicePackInfo() { NativeMethods.OSVersionInfoEx versionInfo = new NativeMethods.OSVersionInfoEx(); versionInfo.VersionInfoSize = Marshal.SizeOf(typeof(NativeMethods.OSVersionInfoEx)); NativeMethods.GetVersionEx(ref versionInfo); return(versionInfo.CSDVersion); }
private string GetOSVersionInfo() { string version = "Unsupported Version"; NativeMethods.OSVersionInfoEx osvi = new NativeMethods.OSVersionInfoEx(); osvi.VersionInfoSize = Marshal.SizeOf(typeof(NativeMethods.OSVersionInfoEx)); NativeMethods.GetVersionEx(ref osvi); if (OsviConstant.SupportedPlatform == osvi.PlatformId && osvi.MajorVersion > 4) { if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT5 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.Windows2000) { version = "Windows 2000"; } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT5 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.WindowsXP) { version = "Windows XP"; } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT5 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.WindowsServer2003) { if (osvi.ProductType == (byte)OsviConstant.WorkStation) { version = "Windows XP Professional x64"; } else { version = "Windows Server 2003"; if (NativeMethods.GetSystemMetrics(OsviConstant.ServerR2) != 0) { version += " R2"; } } } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT6 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.WindowsVista) { if (osvi.ProductType == (byte)OsviConstant.WorkStation) { version = "Windows Vista"; } else { version = "Windows Server 2008"; } } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT6 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.Windows7) { if (osvi.ProductType == (byte)OsviConstant.WorkStation) { version = "Windows 7"; } else { version = "Windows Server 2008 R2"; } } } return(version); }
private string GetProductTypeInfo() { string product = String.Empty; NativeMethods.OSVersionInfoEx osvi = new NativeMethods.OSVersionInfoEx(); osvi.VersionInfoSize = Marshal.SizeOf(typeof(NativeMethods.OSVersionInfoEx)); NativeMethods.GetVersionEx(ref osvi); if (osvi.MajorVersion > 5) { uint productType = 0; NativeMethods.GetProductInfo( osvi.MajorVersion, osvi.MinorVersion, osvi.ServicePackMajor, osvi.ServicePackMinor, ref productType); switch (productType) { case (uint)OsviConstant.ProductInfo.Business: product = "Business Edition"; break; case (uint)OsviConstant.ProductInfo.BusinessN: product = "Business N Edition"; break; case (uint)OsviConstant.ProductInfo.ClusterServer: product = "HPC Edition"; break; case (uint)OsviConstant.ProductInfo.DatacenterServer: product = "Server Datacenter (Full)"; break; case (uint)OsviConstant.ProductInfo.DatacenterServerCore: product = "Server Datacenter (Core)"; break; case (uint)OsviConstant.ProductInfo.DataCenterServerCoreV: product = "Server Datacenter without Hyper-V (Core)"; break; case (uint)OsviConstant.ProductInfo.DataCenterServerV: product = "Server Datacenter without Hyper-V (Full)"; break; case (uint)OsviConstant.ProductInfo.Enterprise: product = "Enterprise Edition"; break; case (uint)OsviConstant.ProductInfo.EnterpriseE: product = "Enterprise E Edition"; break; case (uint)OsviConstant.ProductInfo.EnterpriseN: product = "Enterprise N Edition"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServer: product = "Server Enterprise (Full)"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerCore: product = "Server Enterprise (Core)"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerCoreV: product = "Server Enterprise without Hyper-V (Core)"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerIA64: product = "Server Enterprise for Itanium-based Systems"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerV: product = "Server Enterprise without Hyper-V (Full)"; break; case (uint)OsviConstant.ProductInfo.HomeBasic: product = "Home Basic Edition"; break; case (uint)OsviConstant.ProductInfo.HomeBasicE: product = "Home Basic E Edition"; break; case (uint)OsviConstant.ProductInfo.HomeBasicN: product = "Home Basic N Edition"; break; case (uint)OsviConstant.ProductInfo.HomePremium: product = "Home Premium Edition"; break; case (uint)OsviConstant.ProductInfo.HomePremiumE: product = "Home Premium E Edition"; break; case (uint)OsviConstant.ProductInfo.HomePremiumN: product = "Home Premium N Edition"; break; case (uint)OsviConstant.ProductInfo.HomeServer: product = "Home Server Edition"; break; case (uint)OsviConstant.ProductInfo.HyperV: product = "Microsoft Hyper-V Server"; break; case (uint)OsviConstant.ProductInfo.MediumBusinessServerManagement: product = "Windows Essential Business Server Management Server"; break; case (uint)OsviConstant.ProductInfo.MediumBusinessServerMessaging: product = "Windows Essential Business Server Messaging Server"; break; case (uint)OsviConstant.ProductInfo.MediumBusinessServerSecurity: product = "Windows Essential Business Server Security Server"; break; case (uint)OsviConstant.ProductInfo.Professional: product = "Professional Edition"; break; case (uint)OsviConstant.ProductInfo.ProfessionalE: product = "Professional E Edition"; break; case (uint)OsviConstant.ProductInfo.ProfessionalN: product = "Professional N Edition"; break; case (uint)OsviConstant.ProductInfo.ServerForSmallBusiness: product = "Windows Server 2008 for Windows Essential Server Solutions"; break; case (uint)OsviConstant.ProductInfo.ServerForSmallBusinessV: product = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions"; break; case (uint)OsviConstant.ProductInfo.ServerFoundation: product = "Server Foundation"; break; case (uint)OsviConstant.ProductInfo.SmallBusinessServer: product = "Windows Small Business Server"; break; case (uint)OsviConstant.ProductInfo.SmallBusinessServerPremium: product = "Windows Small Busines Server Premium"; break; case (uint)OsviConstant.ProductInfo.StandardServer: product = "Server Standard (Full)"; break; case (uint)OsviConstant.ProductInfo.StandardServerCore: product = "Server Standard (Core)"; break; case (uint)OsviConstant.ProductInfo.StandardServerCoreV: product = "Server Standard without Hyper-V (Core)"; break; case (uint)OsviConstant.ProductInfo.StandardServerV: product = "Server Standard without Hyper-V (Full)"; break; case (uint)OsviConstant.ProductInfo.Starter: product = "Starter Edition"; break; case (uint)OsviConstant.ProductInfo.StarterE: product = "Starter E Edition"; break; case (uint)OsviConstant.ProductInfo.StarterN: product = "Starter N Edition"; break; case (uint)OsviConstant.ProductInfo.StorageEnterpriseServer: product = "Storage Server Enterprise"; break; case (uint)OsviConstant.ProductInfo.StorageExpressServer: product = "Storage Server Express"; break; case (uint)OsviConstant.ProductInfo.StorageStandardServer: product = "Storage Server Standard"; break; case (uint)OsviConstant.ProductInfo.StorageWorkgroupServer: product = "Storage Server Workgroup"; break; case (uint)OsviConstant.ProductInfo.Ultimate: product = "Ultimate Edition"; break; case (uint)OsviConstant.ProductInfo.UltimateE: product = "Ultimate E Edition"; break; case (uint)OsviConstant.ProductInfo.UltimateN: product = "Ulitmate N Edition"; break; case (uint)OsviConstant.ProductInfo.Undefined: product = "Unknown Product"; break; case (uint)OsviConstant.ProductInfo.Unlicensed: product = "Unlicensed or Expired"; break; case (uint)OsviConstant.ProductInfo.WebServer: product = "Web Server (Full)"; break; case (uint)OsviConstant.ProductInfo.WebServerCore: product = "Web Server (Core)"; break; } } return(product); }
private string GetServicePackInfo() { NativeMethods.OSVersionInfoEx versionInfo = new NativeMethods.OSVersionInfoEx(); versionInfo.VersionInfoSize = Marshal.SizeOf(typeof(NativeMethods.OSVersionInfoEx)); NativeMethods.GetVersionEx(ref versionInfo); return versionInfo.CSDVersion; }
private string GetOSVersionInfo() { string version = "Unsupported Version"; NativeMethods.OSVersionInfoEx osvi = new NativeMethods.OSVersionInfoEx(); osvi.VersionInfoSize = Marshal.SizeOf(typeof(NativeMethods.OSVersionInfoEx)); NativeMethods.GetVersionEx(ref osvi); if (OsviConstant.SupportedPlatform == osvi.PlatformId && osvi.MajorVersion > 4) { if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT5 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.Windows2000) { version = "Windows 2000"; } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT5 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.WindowsXP) { version = "Windows XP"; } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT5 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.WindowsServer2003) { if (osvi.ProductType == (byte)OsviConstant.WorkStation) { version = "Windows XP Professional x64"; } else { version = "Windows Server 2003"; if (NativeMethods.GetSystemMetrics(OsviConstant.ServerR2) != 0) { version += " R2"; } } } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT6 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.WindowsVista) { if (osvi.ProductType == (byte)OsviConstant.WorkStation) { version = "Windows Vista"; } else { version = "Windows Server 2008"; } } if (osvi.MajorVersion == (int)OsviConstant.MajorVersion.NT6 && osvi.MinorVersion == (int)OsviConstant.MinorVersion.Windows7) { if (osvi.ProductType == (byte)OsviConstant.WorkStation) { version = "Windows 7"; } else { version = "Windows Server 2008 R2"; } } } return version; }
private string GetProductTypeInfo() { string product = String.Empty; NativeMethods.OSVersionInfoEx osvi = new NativeMethods.OSVersionInfoEx(); osvi.VersionInfoSize = Marshal.SizeOf(typeof(NativeMethods.OSVersionInfoEx)); NativeMethods.GetVersionEx(ref osvi); if (osvi.MajorVersion > 5) { uint productType = 0; NativeMethods.GetProductInfo( osvi.MajorVersion, osvi.MinorVersion, osvi.ServicePackMajor, osvi.ServicePackMinor, ref productType); switch (productType) { case (uint)OsviConstant.ProductInfo.Business: product = "Business Edition"; break; case (uint)OsviConstant.ProductInfo.BusinessN: product = "Business N Edition"; break; case (uint)OsviConstant.ProductInfo.ClusterServer: product = "HPC Edition"; break; case (uint)OsviConstant.ProductInfo.DatacenterServer: product = "Server Datacenter (Full)"; break; case (uint)OsviConstant.ProductInfo.DatacenterServerCore: product = "Server Datacenter (Core)"; break; case (uint)OsviConstant.ProductInfo.DataCenterServerCoreV: product = "Server Datacenter without Hyper-V (Core)"; break; case (uint)OsviConstant.ProductInfo.DataCenterServerV: product = "Server Datacenter without Hyper-V (Full)"; break; case (uint)OsviConstant.ProductInfo.Enterprise: product = "Enterprise Edition"; break; case (uint)OsviConstant.ProductInfo.EnterpriseE: product = "Enterprise E Edition"; break; case (uint)OsviConstant.ProductInfo.EnterpriseN: product = "Enterprise N Edition"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServer: product = "Server Enterprise (Full)"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerCore: product = "Server Enterprise (Core)"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerCoreV: product = "Server Enterprise without Hyper-V (Core)"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerIA64: product = "Server Enterprise for Itanium-based Systems"; break; case (uint)OsviConstant.ProductInfo.EnterpriseServerV: product = "Server Enterprise without Hyper-V (Full)"; break; case (uint)OsviConstant.ProductInfo.HomeBasic: product = "Home Basic Edition"; break; case (uint)OsviConstant.ProductInfo.HomeBasicE: product = "Home Basic E Edition"; break; case (uint)OsviConstant.ProductInfo.HomeBasicN: product = "Home Basic N Edition"; break; case (uint)OsviConstant.ProductInfo.HomePremium: product = "Home Premium Edition"; break; case (uint)OsviConstant.ProductInfo.HomePremiumE: product = "Home Premium E Edition"; break; case (uint)OsviConstant.ProductInfo.HomePremiumN: product = "Home Premium N Edition"; break; case (uint)OsviConstant.ProductInfo.HomeServer: product = "Home Server Edition"; break; case (uint)OsviConstant.ProductInfo.HyperV: product = "Microsoft Hyper-V Server"; break; case (uint)OsviConstant.ProductInfo.MediumBusinessServerManagement: product = "Windows Essential Business Server Management Server"; break; case (uint)OsviConstant.ProductInfo.MediumBusinessServerMessaging: product = "Windows Essential Business Server Messaging Server"; break; case (uint)OsviConstant.ProductInfo.MediumBusinessServerSecurity: product = "Windows Essential Business Server Security Server"; break; case (uint)OsviConstant.ProductInfo.Professional: product = "Professional Edition"; break; case (uint)OsviConstant.ProductInfo.ProfessionalE: product = "Professional E Edition"; break; case (uint)OsviConstant.ProductInfo.ProfessionalN: product = "Professional N Edition"; break; case (uint)OsviConstant.ProductInfo.ServerForSmallBusiness: product = "Windows Server 2008 for Windows Essential Server Solutions"; break; case (uint)OsviConstant.ProductInfo.ServerForSmallBusinessV: product = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions"; break; case (uint)OsviConstant.ProductInfo.ServerFoundation: product = "Server Foundation"; break; case (uint)OsviConstant.ProductInfo.SmallBusinessServer: product = "Windows Small Business Server"; break; case (uint)OsviConstant.ProductInfo.SmallBusinessServerPremium: product = "Windows Small Busines Server Premium"; break; case (uint)OsviConstant.ProductInfo.StandardServer: product = "Server Standard (Full)"; break; case (uint)OsviConstant.ProductInfo.StandardServerCore: product = "Server Standard (Core)"; break; case (uint)OsviConstant.ProductInfo.StandardServerCoreV: product = "Server Standard without Hyper-V (Core)"; break; case (uint)OsviConstant.ProductInfo.StandardServerV: product = "Server Standard without Hyper-V (Full)"; break; case (uint)OsviConstant.ProductInfo.Starter: product = "Starter Edition"; break; case (uint)OsviConstant.ProductInfo.StarterE: product = "Starter E Edition"; break; case (uint)OsviConstant.ProductInfo.StarterN: product = "Starter N Edition"; break; case (uint)OsviConstant.ProductInfo.StorageEnterpriseServer: product = "Storage Server Enterprise"; break; case (uint)OsviConstant.ProductInfo.StorageExpressServer: product = "Storage Server Express"; break; case (uint)OsviConstant.ProductInfo.StorageStandardServer: product = "Storage Server Standard"; break; case (uint)OsviConstant.ProductInfo.StorageWorkgroupServer: product = "Storage Server Workgroup"; break; case (uint)OsviConstant.ProductInfo.Ultimate: product = "Ultimate Edition"; break; case (uint)OsviConstant.ProductInfo.UltimateE: product = "Ultimate E Edition"; break; case (uint)OsviConstant.ProductInfo.UltimateN: product = "Ulitmate N Edition"; break; case (uint)OsviConstant.ProductInfo.Undefined: product = "Unknown Product"; break; case (uint)OsviConstant.ProductInfo.Unlicensed: product = "Unlicensed or Expired"; break; case (uint)OsviConstant.ProductInfo.WebServer: product = "Web Server (Full)"; break; case (uint)OsviConstant.ProductInfo.WebServerCore: product = "Web Server (Core)"; break; } } return product; }