本文整理汇总了C#中OSVERSIONINFOEX类的典型用法代码示例。如果您正苦于以下问题:C# OSVERSIONINFOEX类的具体用法?C# OSVERSIONINFOEX怎么用?C# OSVERSIONINFOEX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OSVERSIONINFOEX类属于命名空间,在下文中一共展示了OSVERSIONINFOEX类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WinVersion
// Static Constructor
static WinVersion()
{
osvi = new OSVERSIONINFOEX();
osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(
typeof(OSVERSIONINFOEX)
);
GetVersionEx(ref osvi);
_IsWOW64();
_Is64BitOS();
}
开发者ID:kostaslamda,项目名称:win-installer,代码行数:12,代码来源:WinVersion.cs
示例2: AutoSelect
static string AutoSelect(string asfile)
{
if (!File.Exists(asfile))
return null;
string[] lines = File.ReadAllLines(asfile);
OSVERSIONINFOEX osvi = new OSVERSIONINFOEX();
osvi.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osvi);
GetVersionEx(ref osvi);
string cpuarch = Enum.GetName(typeof(CpuArchitecture), Configuration.RealCpuArch);
string result = null;
foreach (string l in lines) {
string[] items = l.Split(' ');
uint val = 0;
if (items.Length < 5)
continue;
if (!UInt32.TryParse(items[0], out val) || val != osvi.dwMajorVersion)
continue;
else if (!UInt32.TryParse(items[1], out val) || val != osvi.dwMinorVersion)
continue;
else if (!UInt32.TryParse(items[2], out val) || val != osvi.wProductType)
continue;
else if (items[3] != cpuarch)
continue;
result = items[4];
break;
}
return result;
}
开发者ID:rcarz,项目名称:fusion,代码行数:36,代码来源:Program.cs
示例3: VerifyVersionInfo
public static extern bool VerifyVersionInfo(ref OSVERSIONINFOEX lpVersionInfo, VersionTypeMask dwTypeMask, ulong dwlConditionMask);
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:1,代码来源:Kernel32.cs
示例4: GetVersionEx
internal static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:1,代码来源:SafeNativeMethods.cs
示例5: GetVersion
/// <summary>
/// Determine OS version
/// </summary>
/// <returns></returns>
public static WindowsVersion GetVersion()
{
WindowsVersion ret = WindowsVersion.Unknown;
OSVERSIONINFOEX info = new OSVERSIONINFOEX();
info.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
GetVersionEx(ref info);
// Get OperatingSystem information from the system namespace.
System.OperatingSystem osInfo = System.Environment.OSVersion;
// Determine the platform.
switch (osInfo.Platform)
{
// Platform is Windows 95, Windows 98, Windows 98 Second Edition, or Windows Me.
case System.PlatformID.Win32Windows:
switch (osInfo.Version.Minor)
{
case 0:
ret = WindowsVersion.Windows95;
break;
case 10:
ret = WindowsVersion.Windows98;
break;
case 90:
ret = WindowsVersion.WindowsMe;
break;
}
break;
// Platform is Windows NT 3.51, Windows NT 4.0, Windows 2000, or Windows XP.
case System.PlatformID.Win32NT:
switch (osInfo.Version.Major)
{
case 3:
ret = WindowsVersion.WindowsNT351;
break;
case 4:
ret = WindowsVersion.WindowsNT4;
break;
case 5:
switch (osInfo.Version.Minor)
{
case 0:
ret = WindowsVersion.Windows2000;
break;
case 1:
ret = WindowsVersion.WindowsXP;
break;
case 2:
int i = GetSystemMetrics(SM_SERVERR2);
if (i != 0)
{
//Server 2003 R2
ret = WindowsVersion.WindowsServer2003;
}
else
{
if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION)
{
//XP Pro x64
ret = WindowsVersion.WindowsXP;
}
else
{
ret = WindowsVersion.WindowsServer2003;
}
break;
}
break;
}
break;
case 6:
switch (osInfo.Version.Minor)
{
case 0:
if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION)
ret = WindowsVersion.WindowsVista;
else
ret = WindowsVersion.WindowsServer2008;
break;
case 1:
if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION)
ret = WindowsVersion.Windows7;
else
ret = WindowsVersion.WindowsServer2008R2;
break;
case 2:
if (info.wProductType == (byte)WinPlatform.VER_NT_WORKSTATION)
ret = WindowsVersion.Windows8;
else
ret = WindowsVersion.WindowsServer2012;
break;
case 3:
ret = WindowsVersion.WindowsServer2012R2;
break;
//.........这里部分代码省略.........
开发者ID:jonwbstr,项目名称:Websitepanel,代码行数:101,代码来源:OS.cs
示例6: IsOSAsReported
/// <summary>
/// Checks whether the OS version reported via GetVersionEx matches that of VerifyVersionInfo
/// When running in compatibility mode GetVersionEx can return the value of the
/// compatibility setting rather than the actual OS
/// </summary>
/// <param name="majorVersion">Reported OS Major Version</param>
/// <param name="minorVersion">Reported OS Minor Version</param>
/// <param name="buildVersion">Reported OS Build Version</param>
/// <param name="productType">Reported OS Product Type</param>
/// <param name="servicePack">Reported OS Major Service Pack Version</param>
/// <returns>True if actual OS matches reported one</returns>
private static bool IsOSAsReported(int majorVersion, int minorVersion, int buildVersion, byte productType, short servicePack)
{
ulong condition = 0;
var osVersionInfo = new OSVERSIONINFOEX
{
dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX)),
dwMajorVersion = majorVersion,
dwMinorVersion = minorVersion,
dwBuildNumber = buildVersion,
wProductType = productType,
wServicePackMajor = servicePack
};
condition = VerSetConditionMask(condition, VER_MAJORVERSION, VER_EQUAL);
condition = VerSetConditionMask(condition, VER_MINORVERSION, VER_EQUAL);
condition = VerSetConditionMask(condition, VER_PRODUCT_TYPE, VER_EQUAL);
condition = VerSetConditionMask(condition, VER_SERVICEPACKMAJOR, VER_EQUAL);
condition = VerSetConditionMask(condition, VER_BUILDVERSION, VER_EQUAL);
return VerifyVersionInfo(ref osVersionInfo, VER_MAJORVERSION | VER_MINORVERSION | VER_PRODUCT_TYPE |
VER_SERVICEPACKMAJOR | VER_BUILDVERSION, condition);
}
开发者ID:HeinA,项目名称:MediaPortal-1,代码行数:31,代码来源:OSInfo.cs
示例7: VerifyVersionInfo
private static extern bool VerifyVersionInfo(ref OSVERSIONINFOEX osVersionInfo, [In] uint dwTypeMask, [In] UInt64 dwlConditionMask);
开发者ID:HeinA,项目名称:MediaPortal-1,代码行数:1,代码来源:OSInfo.cs
示例8: GetOSProductType
/// <summary>
/// Returns the product type of the operating system running on this computer.
/// </summary>
/// <returns>A string containing the the operating system product type.</returns>
public static string GetOSProductType()
{
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof (OSVERSIONINFOEX));
if (!GetVersionEx(ref osVersionInfo)) return string.Empty;
switch (OSMajorVersion)
{
case 4:
if (OSProductType == NT_WORKSTATION)
{
// Windows NT 4.0 Workstation
return " Workstation";
}
if (OSProductType == NT_SERVER)
{
// Windows NT 4.0 Server
return " Server";
}
return string.Empty;
case 5:
if (GetSystemMetrics(SM_MEDIACENTER))
{
return " Media Center";
}
if (GetSystemMetrics(SM_TABLETPC))
{
return " Tablet PC";
}
if (OSProductType == NT_WORKSTATION)
{
if ((osVersionInfo.wSuiteMask & VER_SUITE_EMBEDDEDNT) == VER_SUITE_EMBEDDEDNT)
{
//Windows XP Embedded
return " Embedded";
}
return (osVersionInfo.wSuiteMask & VER_SUITE_PERSONAL) == VER_SUITE_PERSONAL ? " Home" : " Professional";
// Windows XP / Windows 2000 Professional
}
if (OSProductType == NT_SERVER || OSProductType == NT_DOMAIN_CONTROLLER)
{
if (OSMinorVersion == 0)
{
if ((osVersionInfo.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
{
// Windows 2000 Datacenter Server
return " Datacenter Server";
}
if ((osVersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE) == VER_SUITE_ENTERPRISE)
{
// Windows 2000 Advanced Server
return " Advanced Server";
}
// Windows 2000 Server
return " Server";
}
if (OSMinorVersion == 2)
{
if ((osVersionInfo.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
{
// Windows Server 2003 Datacenter Edition
return " Datacenter Edition";
}
if ((osVersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE) == VER_SUITE_ENTERPRISE)
{
// Windows Server 2003 Enterprise Edition
return " Enterprise Edition";
}
if ((osVersionInfo.wSuiteMask & VER_SUITE_STORAGE_SERVER) == VER_SUITE_STORAGE_SERVER)
{
// Windows Server 2003 Storage Edition
return " Storage Edition";
}
if ((osVersionInfo.wSuiteMask & VER_SUITE_COMPUTE_SERV) == VER_SUITE_COMPUTE_SERV)
{
// Windows Server 2003 Compute Cluster Edition
return " Compute Cluster Edition";
}
if ((osVersionInfo.wSuiteMask & VER_SUITE_BLADE) == VER_SUITE_BLADE)
{
// Windows Server 2003 Web Edition
return " Web Edition";
}
// Windows Server 2003 Standard Edition
return " Standard Edition";
}
}
break;
case 6:
int strProductType;
GetProductInfo(osVersionInfo.dwMajorVersion, osVersionInfo.dwMinorVersion, 0, 0, out strProductType);
switch (strProductType)
{
case PRODUCT_ULTIMATE:
case PRODUCT_ULTIMATE_E:
case PRODUCT_ULTIMATE_N:
//.........这里部分代码省略.........
开发者ID:HeinA,项目名称:MediaPortal-1,代码行数:101,代码来源:OSInfo.cs
示例9: VerifyVersionInfo
public static extern bool VerifyVersionInfo(ref OSVERSIONINFOEX versionInfo,
int typeMask,
ulong conditionMask);
开发者ID:swi-to-yap,项目名称:swicli,代码行数:3,代码来源:SWICFFITests-example.cs
示例10: IsWindowsServerInternal
internal static Boolean IsWindowsServerInternal()
{
// Initialize OSVERSIONINFOEX structure
OSVERSIONINFOEX osvi = new OSVERSIONINFOEX();
osvi.dwOSVersionInfoSize = (UInt32)Marshal.SizeOf(typeof(OSVERSIONINFOEX));
osvi.wProductType = VER_NT_WORKSTATION;
// Initialize condition mask
UInt64 conditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
// Verify version info
return !VerifyVersionInfo(ref osvi, VER_PRODUCT_TYPE, conditionMask);
}
开发者ID:fschneidereit,项目名称:VersionHelpers,代码行数:13,代码来源:VersionHelpers.cs
示例11: IsWindowsVersionOrGreater
/// <summary>
/// Indicates if the current OS version matches, or is greater than, the provided version
/// information. This method is useful in confirming a version of Windows Server that
/// doesn't share a version number with a client release.
/// </summary>
/// <remarks>
/// You should only use this method if the other provided version helper methods do not fit
/// your scenario.
/// </remarks>
/// <exception cref="System.ArgumentOutOfRangeException">
/// <paramref name="majorVersion"/> is smaller than 5 or <paramref name="minorVersion"/>
/// and/or <paramref name="servicePackMajor"/> are smaller than 0.
/// </exception>
/// <param name="majorVersion">The major OS version number.</param>
/// <param name="minorVersion">The minor OS version number.</param>
/// <param name="servicePackMajor">The major Service Pack version number.</param>
/// <returns>True if the specified version matches, or is greater than, the version of the
/// current Windows OS; otherwise, false.</returns>
public static Boolean IsWindowsVersionOrGreater(Int32 majorVersion, Int32 minorVersion,
Int32 servicePackMajor)
{
// Validate arguments
if (majorVersion < 5) {
// Error: Major version cannot be smaller than 5
throw new ArgumentOutOfRangeException("majorVersion");
}
if (minorVersion < 0) {
// Error: Minor version cannot be negative
throw new ArgumentOutOfRangeException("minorVersion");
}
if (servicePackMajor < 0) {
// Error: Major service pack version cannot be negative
throw new ArgumentOutOfRangeException("servicePackMajor");
}
// Initialize OSVERSIONINFOEX structure
OSVERSIONINFOEX osvi = new OSVERSIONINFOEX();
osvi.dwOSVersionInfoSize = (UInt32)Marshal.SizeOf(typeof(OSVERSIONINFOEX));
osvi.dwMajorVersion = (UInt32)majorVersion;
osvi.dwMinorVersion = (UInt32)minorVersion;
osvi.wServicePackMajor = (UInt16)servicePackMajor;
// Initialize condition mask
UInt64 conditionMask =
VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(0,
VER_MAJORVERSION,
VER_GREATER_EQUAL),
VER_MINORVERSION,
VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR,
VER_GREATER_EQUAL);
// Verify version info
return VerifyVersionInfo(ref osvi,
VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,
conditionMask);
}
开发者ID:fschneidereit,项目名称:VersionHelpers,代码行数:61,代码来源:VersionHelpers.cs
示例12: GetVersionEx
private static extern bool GetVersionEx(ref OSVERSIONINFOEX versionInfo);
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:1,代码来源:SystemUtilities.cs
示例13: GetOSServicePack
/// <summary>
/// Returns the service pack information of the operating system running on this computer.
/// </summary>
/// <returns>A string containing the the operating system service pack information.</returns>
public static string GetOSServicePack()
{
OSVERSIONINFOEX versionInfo = new OSVERSIONINFOEX();
versionInfo.VersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (!GetVersionEx(ref versionInfo))
{
return string.Empty;
}
else
{
return " " + versionInfo.ServicePackVersion;
}
}
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:19,代码来源:SystemUtilities.cs
示例14: GetOSProductType
/// <summary>
/// Returns the product type of the operating system running on this computer.
/// </summary>
/// <returns>A string containing the the operating system product type.</returns>
public static string GetOSProductType()
{
OSVERSIONINFOEX versionInfo = new OSVERSIONINFOEX();
OperatingSystem info = System.Environment.OSVersion;
versionInfo.VersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (!GetVersionEx(ref versionInfo))
{
return string.Empty;
}
else
{
if (info.Version.Major == 4)
{
if (versionInfo.ProductType == VERNTWORKSTATION)
{
// Windows NT 4.0 Workstation
return " Workstation";
}
else if (versionInfo.ProductType == VERNTSERVER)
{
// Windows NT 4.0 Server
return " Server";
}
else
{
return string.Empty;
}
}
else if (info.Version.Major == 5)
{
if (versionInfo.ProductType == VERNTWORKSTATION)
{
if ((versionInfo.SuiteMask & VERSUITEPERSONAL) == VERSUITEPERSONAL)
{
// Windows XP Home Edition
return " Home Edition";
}
else
{
// Windows XP / Windows 2000 Professional
return " Professional";
}
}
else if (versionInfo.ProductType == VERNTSERVER)
{
if (info.Version.Minor == 0)
{
if ((versionInfo.SuiteMask & VERSUITEDATACENTER) == VERSUITEDATACENTER)
{
// Windows 2000 Datacenter Server
return " Datacenter Server";
}
else if ((versionInfo.SuiteMask & VERSUITEENTERPRISE) == VERSUITEENTERPRISE)
{
// Windows 2000 Advanced Server
return " Advanced Server";
}
else
{
// Windows 2000 Server
return " Server";
}
}
else
{
if ((versionInfo.SuiteMask & VERSUITEDATACENTER) == VERSUITEDATACENTER)
{
// Windows Server 2003 Datacenter Edition
return " Datacenter Edition";
}
else if ((versionInfo.SuiteMask & VERSUITEENTERPRISE) == VERSUITEENTERPRISE)
{
// Windows Server 2003 Enterprise Edition
return " Enterprise Edition";
}
else if ((versionInfo.SuiteMask & VERSUITEBLADE) == VERSUITEBLADE)
{
// Windows Server 2003 Web Edition
return " Web Edition";
}
else
{
// Windows Server 2003 Standard Edition
return " Standard Edition";
}
}
}
}
}
return string.Empty;
}
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:98,代码来源:SystemUtilities.cs
示例15: GetOSInfo
private void GetOSInfo()
{
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = (uint)Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (!GetVersionEx(ref osVersionInfo))
{
this._version = "Unknown";
this._servicePack = 0;
return;
}
string osName = "";
SYSTEM_INFO systemInfo = new SYSTEM_INFO();
GetSystemInfo(ref systemInfo);
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32Windows:
{
switch (osVersionInfo.dwMajorVersion)
{
case 4:
{
switch (osVersionInfo.dwMinorVersion)
{
case 0:
if (osVersionInfo.szCSDVersion == "B" ||
osVersionInfo.szCSDVersion == "C")
osName += "Windows 95 R2";
else
osName += "Windows 95";
break;
case 10:
if (osVersionInfo.szCSDVersion == "A")
osName += "Windows 98 SE";
else
osName += "Windows 98";
break;
case 90:
osName += "Windows ME";
break;
}
}
break;
}
}
break;
case PlatformID.Win32NT:
{
switch (osVersionInfo.dwMajorVersion)
{
case 3:
osName += "Windows NT 3.5.1";
break;
case 4:
osName += "Windows NT 4.0";
break;
case 5:
{
switch (osVersionInfo.dwMinorVersion)
{
case 0:
osName += "Windows 2000";
break;
case 1:
osName += "Windows XP";
break;
case 2:
{
if (osVersionInfo.wSuiteMask == VER_SUITE_WH_SERVER)
osName += "Windows Home Server";
else if (osVersionInfo.wProductType == VER_NT_WORKSTATION && systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
osName += "Windows XP";
else
osName += GetSystemMetrics(SM_SERVERR2) == 0 ? "Windows Server 2003" : "Windows Server 2003 R2";
}
break;
}
}
break;
case 6:
{
switch (osVersionInfo.dwMinorVersion)
{
case 0:
osName += osVersionInfo.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008";
break;
case 1:
osName += osVersionInfo.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2";
break;
case 2:
osName += osVersionInfo.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 8";
//.........这里部分代码省略.........
开发者ID:hpie,项目名称:hpie,代码行数:101,代码来源:WindowsOperatingSystem.cs
示例16: GetOSProductType
/// <summary>
/// Returns the product type of the operating system running on this computer.
/// </summary>
/// <returns>A string containing the the operating system product type.</returns>
public static string GetOSProductType()
{
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
OperatingSystem osInfo = Environment.OSVersion;
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (!GetVersionEx(ref osVersionInfo))
{
return "";
}
else
{
if (osInfo.Version.Major == 4) // Windows NT
{
if (osVersionInfo.wProductType == VER_NT_WORKSTATION)
{
// Windows NT 4.0 Workstation
return "Workstation";
}
else if (osVersionInfo.wProductType == VER_NT_SERVER)
{
// Windows NT 4.0 Server
return "Server";
}
else
{
return "";
}
}
else if (osInfo.Version.Major >= 5) // Windows 2000 or later
{
if (osVersionInfo.wProductType == VER_NT_WORKSTATION)
{
if ((osVersionInfo.wSuiteMask & VER_SUITE_PERSONAL) == VER_SUITE_PERSONAL)
{
// Windows XP Home Edition
return "Home Edition";
}
else
{
// Windows XP / Windows 2000 Professional
return "Professional";
}
}
else // Server or Domain Controller
{
if ((osVersionInfo.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
{
// Windows Server 2003 Datacenter Edition
return "Datacenter Edition";
}
else if ((osVersionInfo.wSuiteMask & VER_SUITE_ENTERPRISE) == VER_SUITE_ENTERPRISE)
{
// Windows Server 2003 Enterprise Edition
return "Enterprise Edition";
}
else if ((osVersionInfo.wSuiteMask & VER_SUITE_BLADE) == VER_SUITE_BLADE)
{
// Windows Server 2003 Web Edition
return "Web Edition";
}
else if ((osVersionInfo.wSuiteMask & VER_SUITE_COMPUTE_SERVER) == VER_SUITE_COMPUTE_SERVER)
{
// Windows Server 2003 Web Edition
return "Compute Cluster Edition";
}
else if ((osVersionInfo.wSuiteMask & VER_SUITE_STORAGE_SERVER) == VER_SUITE_STORAGE_SERVER)
{
// Windows Server 2003 Web Edition
return "Storage Server Edition";
}
else if ((osVersionInfo.wSuiteMask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER)
{
// Windows Server 2003 Web Edition
return "Home Server Edition";
}
else
{
// Windows Server 2003 Standard Edition
return "Standard Edition";
}
}
}
}
return "";
}
开发者ID:hoeness2,项目名称:mcebuddy2,代码行数:92,代码来源:OSVersion.cs
示例17: GetOSServicePack
/// <summary>
/// Returns the service pack information of the operating system running on this computer.
/// </summary>
/// <returns>A string containing the the operating system service pack information.</returns>
public static string GetOSServicePack()
{
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (!GetVersionEx(ref osVersionInfo))
{
return "";
}
else
{
return " " + osVersionInfo.szCSDVersion;
}
}
开发者ID:hoeness2,项目名称:mcebuddy2,代码行数:19,代码来源:OSVersion.cs
示例18: GetVersionEx
public static extern bool GetVersionEx(ref OSVERSIONINFOEX lpVersionInfo);
开发者ID:swi-to-yap,项目名称:swicli,代码行数:1,代码来源:SWICFFITests-example.cs
示例19: GetOSServicePack
/// <summary>
/// Returns the service pack information of the operating system running on this computer.
/// </summary>
/// <returns>A string containing the the operating system service pack information.</returns>
public static string GetOSServicePack()
{
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof (OSVERSIONINFOEX));
return !GetVersionEx(ref osVersionInfo) ? string.Empty : osVersionInfo.szCSDVersion;
}
开发者ID:HeinA,项目名称:MediaPortal-1,代码行数:10,代码来源:OSInfo.cs
示例20: GetOS
public static WINDOWS_OS? GetOS()
{
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
OperatingSystem osInfo = Environment.OSVersion;
osVersionInfo.dwOSVersionInfoSize =
Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (!GetVersionEx(ref osVersionInfo))
{
return null;
}
else
{
if (osInfo.Version.Major == 5)
{
if (osVersionInfo.wProductType == VER_NT_WORKSTATION)
{
if (osInfo.Version.Minor == 0)
{
return WINDOWS_OS.Windows2000;
}
else
{
return WINDOWS_OS.WindowsXP;
}
}
else if (osVersionInfo.wProductType == VER_NT_SERVER)
{
if (osInfo.Version.Minor == 0)
{
return WINDOWS_OS.Windows2000Server;
}
else if (osInfo.Version.Minor == 2)
{
return WINDOWS_OS.WindowsServer2003;
}
}
}
else if (osInfo.Version.Major == 6)
{
if (osVersionInfo.wProductType == VER_NT_WORKSTATION)
{
if (osInfo.Version.Minor == 0)
{
return WINDOWS_OS.WindowsVista;
}
else if (osInfo.Version.Minor == 1)
{
return WINDOWS_OS.Windows7;
}
}
else if (osVersionInfo.wProductType == VER_NT_SERVER)
{
if (osInfo.Version.Minor == 0)
{
return WINDOWS_OS.WindowsServer2008;
}
else if (osInfo.Version.Minor == 1)
{
return WINDOWS_OS.WindowsServer2008R2;
}
}
}
}
return null;
}
开发者ID:ryanski44,项目名称:VM-Automation-Framework,代码行数:68,代码来源:Main.cs
注:本文中的OSVERSIONINFOEX类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论