Get OS information in VB.Net

Wednesday, July 9, 2008

?How to Get OS Version in VB.Net
'''' This Function Is written in vb.net Which will return the version of OS

Public Function GetOSVersion() As String
Dim osInfo As OperatingSystem
Dim sAns As String
osInfo = System.Environment.OSVersion
With osInfo
Select Case .Platform
Case .Platform.Win32Windows
Select Case (.Version.Minor)
Case 0
sAns = "Windows 95"
Case 10
If .Version.Revision.ToString() = "2222A" Then
sAns = "Windows 98 Second Edition"
Else
sAns = "Windows 98"
End If
Case 90
sAns = "Windows Me"
End Select
Case .Platform.Win32NT

Select Case (.Version.Major)
Case 3
sAns = "Windows NT 3.51"
Case 4
sAns = "Windows NT 4.0"
Case 5

If .Version.Minor = 0 Then
sAns = "Windows 2000"
ElseIf .Version.Minor = 1 Then
sAns = "Windows XP"
ElseIf .Version.Minor = 2 Then
sAns = "Windows Server 2003"
Else 'Future version maybe update 'as needed sAns = "Unknown Version"
End If
Case 6
sAns = "Windows Vista"
End Select
End Select
End With
Return sAns
End Function

0 comments

Post a Comment