C# 判断操作系统类型
2009-02-03 11:01
375 查看
/// <summary>
/// Gets a value indicating if the process is running in 64 bit environment.
/// </summary>
public static unsafe bool IsRunningOn64Bit
{
get { return (sizeof(IntPtr) == sizeof(long)); }
}
/// <summary>
/// Gets a value indicating if the operating system is a Windows 2000 or a newer one.
/// </summary>
public static bool IsWindows2000OrNewer
{
get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major >= 5); }
}
/// <summary>
/// Gets a value indicating if the operating system is a Windows XP or a newer one.
/// </summary>
public static bool IsWindowsXpOrNewer
{
get
{
return
(Environment.OSVersion.Platform == PlatformID.Win32NT) &&
(
(Environment.OSVersion.Version.Major >= 6) ||
(
(Environment.OSVersion.Version.Major == 5) &&
(Environment.OSVersion.Version.Minor >= 1)
)
);
}
}
/// <summary>
/// Gets a value indicating if the operating system is a Windows Vista or a newer one.
/// </summary>
public static bool IsWindowsVistaOrNewer
{
get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major >= 6); }
}
编译项目:“可编译不安全代码”属性设置为true
方法如下:项目属性对话框->配置属性->生成->允许不安全代码块 设为"true\"
/// Gets a value indicating if the process is running in 64 bit environment.
/// </summary>
public static unsafe bool IsRunningOn64Bit
{
get { return (sizeof(IntPtr) == sizeof(long)); }
}
/// <summary>
/// Gets a value indicating if the operating system is a Windows 2000 or a newer one.
/// </summary>
public static bool IsWindows2000OrNewer
{
get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major >= 5); }
}
/// <summary>
/// Gets a value indicating if the operating system is a Windows XP or a newer one.
/// </summary>
public static bool IsWindowsXpOrNewer
{
get
{
return
(Environment.OSVersion.Platform == PlatformID.Win32NT) &&
(
(Environment.OSVersion.Version.Major >= 6) ||
(
(Environment.OSVersion.Version.Major == 5) &&
(Environment.OSVersion.Version.Minor >= 1)
)
);
}
}
/// <summary>
/// Gets a value indicating if the operating system is a Windows Vista or a newer one.
/// </summary>
public static bool IsWindowsVistaOrNewer
{
get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major >= 6); }
}
编译项目:“可编译不安全代码”属性设置为true
方法如下:项目属性对话框->配置属性->生成->允许不安全代码块 设为"true\"
相关文章推荐
- C#判断操作系统类型总结
- C#判断操作系统类型总结
- C#判断操作系统类型总结
- C#判断操作系统类型总结
- 深入C#判断操作系统类型的总结详解(转载)
- C#判断操作系统类型总结
- 深入C#判断操作系统类型的总结详解
- C#判断操作系统类型
- C#判断操作系统语言类型
- C#判断操作系统类型汇总
- C#判断操作系统类型总结
- H5案例分享:使用JS判断客户端、浏览器、操作系统类型
- python技巧31[判断操作系统类型]
- bat批处理判断系统32位或64位以及操作系统类型
- asp.net(C#)上传单个图片并判断图片的类型和大小
- python实例[判断操作系统类型]
- php 判断服务器操作系统的类型
- C#、ASP.NET通用工具类IsWhat?(可以判断数字、身份证、数据类型等等)
- c#判断磁盘驱动器类型的两种方法介绍