@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Obtains extended information about the version of the operating system that is currently running. !!!!C# Signatures: // This must be used if OSVERSIONINFO is defined as a struct or Class - The previous [In,Out] parameter defined for // a class could cause buffer overrun errors. [ DllImport( "kernel32" )] static extern bool GetVersionEx( ref OSVERSIONINFO osvi ); !!!!VB.Net Signatures: ' This must be used if OSVERSIONINFO is defined as a struct <DllImport("kernel32")> _ Private Shared Function GetVersionEx(ByRef osvi As OSVERSIONINFO) As Boolean End Function ' This must be used if OSVERSIONINFO is defined as a class <DllImport("kernel32")> _ Private Shared Function GetVersionEx(<[In](), Out()> ByVal osvi As OSVERSIONINFO) As Boolean End Function !!!!User-Defined Types: [OSVERSIONINFO] !!!!Notes: None. !!!!Tips & Tricks: If you forget to set the OSVersionInfoSize field of the OSVERSIONINFO struct, the function will return false. GetLastError() will return: 127 ERROR_PROC_NOT_FOUND "The specified procedure could not be found." !!!!Sample Code: Using the OSVERSIONINFO class and corresponding signature: Console.WriteLine( "\nPassing OSVERSIONINFO as class" ); OSVERSIONINFO osvi = new OSVERSIONINFO(); osvi.OSVersionInfoSize = Marshal.SizeOf( osvi ); GetVersionEx( osvi ); Console.WriteLine( "Class size: {0}", osvi.OSVersionInfoSize ); Using the OSVERSIONINFO struct and corresponding signature: Console.WriteLine( "\nPassing OSVERSIONINFO as struct" ); OSVERSIONINFO osvi2 = new OSVERSIONINFO(); osvi2.OSVersionInfoSize = Marshal.SizeOf(ref typeof(OSVERSIONINFO) ); GetVersionEx( ref osvi2 ); Console.WriteLine( "Struct size: {0}", osvi2.OSVersionInfoSize ); !!!!Alternative Managed API: System.Environment.OSVersion@msdn property Friend Function IsWinVista() As Boolean Dim osInfo As System.OperatingSystem = System.Environment.OSVersion Return (osInfo.Platform = PlatformID.Win32NT AndAlso osInfo.Version.Major = 6) End Function Friend Function IsWinXP() As Boolean Dim osInfo As System.OperatingSystem = System.Environment.OSVersion Return (osInfo.Platform = PlatformID.Win32NT AndAlso osInfo.Version.Major = 5 AndAlso osInfo.Version.Minor >= 1) End Function Documentation: GetVersionEx@msdn on MSDN
Edit kernel32.GetVersion
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.