devxlogo

Determine the Windows version

Determine the Windows version

You don’t need to call any Windows API function in VB.NET to determine which version of Windows your application is running on, because this information is exposed by the Environment.OSVersion property. For example, if you run this code under Windows 2000:

Console.WriteLine(Environment.OSVersion.ToString)

then this is what appears in the console window:

Microsoft Windows NT 5.0.2195.0

The OSVersion property returns a System.OperatingSystem object, which exposes a few properties of its own. For example, you can use its Platform property to quickly test whether you’re under Windows 9x or Windows NT/2000/XP:

Select Case Environment.OSVersion.Platform    Case PlatformID.Win32Windows        ' Windows 95 or 98, but notice that only Win98 currently supports .NET    Case PlatformID.Win32NT        ' Windows NT, 2000, or XP    Case PlatformID.Win32S        ' Win32S (not applicable: this version doesn't support .NET)End Select

You can even test individual portions of the Windows system number by means of the Major, Minor, Build, and Revision properties of the object returned by the Environment.OSVersion.Version property:

If Environment.OSVersion.Version.Major = 5 Then    Console.WriteLine("Running under Windows 2000")End If 

See also  Is Machine Learning Automating Creativity in Graphic Design?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist