Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Determine the Windows version

Total Hit ( 3107)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
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:

Click here to copy the following block
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:

Click here to copy the following block
If Environment.OSVersion.Version.Major = 5 Then
  Console.WriteLine("Running under Windows 2000")
End If


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.