C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Training   ASP.NET Web Hosting    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

Play Silverlight Games or Submit your Silverlight applications and earn 90% AdSense revenue.

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Resources » Articles » .NET Framework »

Determining operating system version and details


Posted Date: 26 May 2004    Resource Type: Articles    Category: .NET Framework
Author: Tony JohnMember Level: Diamond    
Rating: Points: 10



Retrieving information about the Operating System

The 'OperatingSystem' class in System namespace can be used to retrieve various information about the operating system in which the .NET code is running.

The 'Environment' class in System namespace has a property called 'OSVersion' which returns an object of type OperatingSystem.

The OperatingSystem class has two important properties :

1. Platform - returns a PlatformId which represents the operating system platform.

The PlatformId is an enum, which has the following values :

. Win32NT ( indicates the current OS is Windows NT, 2000 or XP )
. Win32Windows ( indicates the current OS is Windows95, 98 or ME )
. Win32S
. WinCE

2. Version - represents a Version object that describes the major version, minor version, build and revision of current operating system. The major version and minor version attributes can be used to determine which specific flavor of operating system is installed.

System.OperatingSystem osInfo = System.Environment.OSVersion;

string operatingSystem = "Unknown";

switch ( osInfo.Platform )
{
case System.PlatformID.Win32Windows:
// Current OS is Windows - can be Windows95, 98 or ME
switch ( osInfo.Version.Minor )
{
case 0:
operatingSystem = "Windows 95";
break;
case 10:
operatingSystem = "Windows 98";
break;
case 90:
operatingSystem = "Windows Me";
break;
}

break;

case System.PlatformID.Win32NT:
// Current OS is Windows NT, 2000 or XP
switch ( osInfo.Version.Major )
{
case 3:
operatingSystem = "Windows NT 3.51";
break;
case 4:
operatingSystem = "Windows NT 4.0";
break;
case 5:
if ( osInfo.Version.Minor == 0 )
operatingSystem = "Windows 2000";
else
operatingSystem = "Windows XP";

break;
}

break;

}


The following Microsoft Knowledge Base Articles provide more information and source code in VB.NET, C# and C++.

Ref :

1. http://support.microsoft.com/default.aspx?scid=kb;EN-US;304283
2. http://support.microsoft.com/default.aspx?scid=kb;EN-US;304289
3. http://support.microsoft.com/default.aspx?scid=kb;EN-US;307394




Responses

Author: ezhil murugan    17 Jun 2004Member Level: Bronze   Points : 0
came to know thro this article that .Net has an incredibly huge no. of classes doing various fascinating tasks


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to populate a TreeView control from an Access database....!
Previous Resource: Windows Management Instrumentation
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use