Article ID: 304721 - View products that this article applies to.
This article was previously published under Q304721
For a Microsoft Visual Basic .NET version of this article, see 304722
For a Microsoft Visual C++ .NET version of this article, see 307393
This article refers to the following Microsoft .NET Framework Class Library namespace:
This step-by-step article shows you how to build the GetServicePack method.
The OSVersion property, which is provided for obtaining operating system (OS) information, does not contain a member that provides service pack information. To determine what service pack is installed, you must call the GetVersionEx API function directly. Typically, it is better to avoid this practice; the .NET Framework provides access to the underlying API sets in a much more consistent (and easier to use) manner than by calling the individual API functions.
When you must call an API function directly, you can do this through the Interop layer of the .NET Framework. The sample code in this article gives a method, GetServicePack, that returns the service pack level.
NOTE: The OSVERSIONINFO structure contains a fixed-length string, szCSDVersion. Because fixed-length strings are no longer supported, you must provide the marshalling information for this member. Do this by using the attribute (denoted by ) preceding the member name.
Article ID: 304721 - Last Review: October 6, 2004 - Revision: 1.0
Contact us for more help