dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: beginner
Jun 15, 2002

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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
 
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date