代码
/// <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-04-09 17:55  sn_wolf  阅读(961)  评论(0编辑  收藏  举报