Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

GetVersionEx (kernel32)
 
.
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
[ DllImport( "kernel32" )]
static extern bool GetVersionEx( OSVERSIONINFO osvi );  

// This must be used if OSVERSIONINFO is defined as a class
[ DllImport( "kernel32" )]
static extern bool GetVersionEx( [In, Out] OSVERSIONINFO osvi );

VB.Net Signatures:

Shared <DllImport("kernel32")> Function GetVersionEx(osvi As OSVERSIONINFO) As Boolean

User-Defined Types:

OSVERSIONINFO

Notes:

None.

Tips & Tricks:

Please add some!

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( osvi2 );

GetVersionEx( ref osvi2 );

Console.WriteLine( "Struct size:   {0}", osvi2.OSVersionInfoSize );

Alternative Managed API:

System.Environment.OSVersion property

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions