原文地址: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
漂漂 閱讀(752)
評論(0) 編輯 收藏 引用 所屬分類:
c#開發