SIMIN Posted May 5, 2008 Posted May 5, 2008 Hello, I want to detect if my application is running under XP, 2003 or Vista? (I know just one of these, no ther OS) How can I detect the current version? I have the following information but don't know how should I compare them? Dim MyVersion As Version = Environment.OSVersion.Version Dim XPVersion As New Version(5, 1, 0, 0) Dim ServerVersion As New Version(5, 2, 0, 0) Dim VistaVersion As New Version(6, 0, 0, 0) Quote
Administrators PlausiblyDamp Posted May 5, 2008 Administrators Posted May 5, 2008 The version class has a CompareTo method you could use. However http://www.codeproject.com/KB/system/osversion.aspx might be worth a look as somebody else has done all the hard work ;) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SIMIN Posted May 5, 2008 Author Posted May 5, 2008 To make it simple, can I say that this code is correct? I just want to detect Windows Version that's enough: If Environment.OSVersion.Version.Major = 5 Then If Environment.OSVersion.Version.Minor = 1 Then 'XP End If If Environment.OSVersion.Version.Minor = 2 Then '2003 End If End If If Environment.OSVersion.Version.Major = 6 Then 'Vista End If Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.