Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How can I compare between the operating system if it's win XP or less, then do some code, else if its win 7 do another code?

I know there is platform like this::
my.computer.operating system name or platform .getinfo

But how to do the first condition?

I hope you can help :-O
Posted
Updated 12-Jan-11 6:11am
v5
Comments
Dalek Dave 12-Jan-11 11:42am    
Edited for Grammar and Readability.

Use the Version Class[^] to check which OS you are on.

Sorry, CodeProject stopped responding before I was able to amend my answer to the OperatingSystem[^] class.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 12-Jan-11 11:58am    
Richard, you may be mixed up some things. This class per se does not help you to get OS information; you need Environment -- see my answer.
Sergey Alexandrovich Kryukov 12-Jan-11 14:33pm    
Sure, then my 5.
Use System.Environment class, the property Environment.OSVersion:

http://msdn.microsoft.com/en-us/library/system.environment.aspx[^]

http://msdn.microsoft.com/en-us/library/system.environment.osversion.aspx[^]

Basically, you do this:

C#
System.OperatingSystem os = System.Environment.OSVersion;


and learn what you need from os.
 
Share this answer
 
v3
Comments
Richard MacCutchan 12-Jan-11 13:43pm    
Yes, the system went down before I was able to correct my answer; see my update.
Аslam Iqbal 12-Jan-11 14:30pm    
Additionally add this: VerCheck = System.Environment.OSVersion.Version.Major... Have my 5.
Dalek Dave 12-Jan-11 15:24pm    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900