Article ID: 304721 - Last Review: October 6, 2004 - Revision: 1.0 How To Determine the Operating System Service Pack Level in Visual C# .NETThis article was previously published under Q304721 For a Microsoft Visual Basic .NET version of this article, see 304722
(http://support.microsoft.com/kb/304722/EN-US/
)
.
For a Microsoft Visual C++ .NET version of this article, see 307393 (http://support.microsoft.com/kb/307393/EN-US/ ) . This article refers to the following Microsoft .NET Framework Class Library namespace:
SUMMARY
This step-by-step article shows you how to build the GetServicePack method.
MORE INFORMATION
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 Translations
|

Back to the top
