判断windows操作系统平台
判断当前Windows系统是win2000,winXP,winVista,win2003,win7...
private static IntPtr GetSysTrayWnd() { IntPtr handle = FindWindow("Shell_TrayWnd", null); handle = FindWindowEx(handle, IntPtr.Zero, "TrayNotifyWnd", null); if (IsWindowsXP || IsWindows2000 || IsWindows2003 || IsWindowsVista || IsWindows7) { if (IsWindows2000) { handle = FindWindowEx(handle, IntPtr.Zero, "ToolbarWindow32", null); return handle; } else { handle = FindWindowEx(handle, IntPtr.Zero, "SysPager", null); handle = FindWindowEx(handle, IntPtr.Zero, "ToolbarWindow32", null); return handle; } } else { return handle; } }
public static bool IsWindows2000 { get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 0); } } //C#判断操作系统是否为WindowsXP public static bool IsWindowsXP { get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 1); } } //C#判断操作系统是否为Windows2003 public static bool IsWindows2003 { get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor == 2); } } //C#判断操作系统是否为WindowsVista public static bool IsWindowsVista { get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor == 0); } } //C#判断操作系统是否为Windows7 public static bool IsWindows7 { get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor == 1); } }