原文地址:http://www.cnblogs.com/cyrix/articles/1708533.html
/// <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\"
posted on 2010-08-27 11:52
漂漂 阅读(742)
评论(0) 编辑 收藏 引用 所属分类:
c#开发