|
-
Dec 2nd, 2011, 01:58 PM
#1
[RESOLVED] Checking the os
I'm building a website blocker, and it reads/writes the HOST file. I have it built for windows xp. I'm wanting to check the OS the person's using so that it can run the write code properly(b/c each OS the host file is in a different location). I was thinking about using
Code:
Environment.OSVersion.ToString()
in an if statement sorta like this:
Code:
If Environment.OSVersion.ToString() = "OS" Then
'the code that works for the OS in the = ""
End If
my problem is that I don't know how to set my .ToString() = "" any thoughts?
-
Dec 2nd, 2011, 02:35 PM
#2
Re: Checking the os
Use:
Environment.OSVersion.Version.ToString
That will give you Version.Subversion.Build.SomethingIDon'tKnow
But for XP, you'll get 5.1.xxxx.xxxx
for Vista you should get 6.0.xxxx.xxxx
for windows 7 you should get 6.1.xxxx.xxxx
Next you can just get the first three digits and compare then to a list:
vb.net Code:
Dim Version as String = Environment.OSVersion.Version.Tostring Dim ShortVersion as String = Version.SubString(0, 3) Dim VersionName as String Select Case ShortVersion Case "5.0" VersionName = "Windows 2000" 'Do Other Stuff Here Case "5.1" VersionName = "Windows XP" Case "6.0" VersionName = "Windows Vista" Case "6.1" VersionName = "Windows 7" End Select
A full list of windows versions can be found here:
http://www.msigeek.com/442/windows-os-version-numbers
-
Dec 2nd, 2011, 02:43 PM
#3
Member
-
Dec 2nd, 2011, 03:05 PM
#4
Re: Checking the os
Dude, I'm sorry when I went to look up where the host file is, it was the same in xp as it is in vista in 7. Thanks for the help though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|