On Jul 23, 12:21 pm, "engteng" <pass...@gmail. comwrote:
How to display OS Name in short Name eg Win Vista SP1
Win XP
2003 SP2
>
Regards,
Tee ET
For XP,
You can you can manually define them in nested if-then blocks like the
following:
' --------Begin Code-----------
'Check and get full OSName
If My.Computer.Inf o.OSFullName.To String = _
"Microsoft Windows XP Professional" Then
'Check and get service pack version
If Environment.OSV ersion.ServiceP ack.ToString = _
"Service Pack 2" Then
MsgBox("Win XP SP2")
End If
ElseIf My.Computer.Inf o.OSFullName.To String = _
"Microsoft Windows XP Professional" Then
'Assuming no or other Service Packs are installed
' plus only XP is installed
MsgBox("Win XP")
End If
'.....Reproduce same for Vista
' ------End Code-----------
Or you can use substring method to fit OSName/SPVersion output to what
you desire.
My way of getting a proper OS version string + SP number:
Function GetOSVersion() As String
Dim os As OperatingSystem = Environment.OSV ersion
Dim displayName As String = "Win "
Dim origSp As String = os.ServicePack
If String.IsNullOr Empty(origSp) Then
origSp = ""
Else
origSp = origSp.Replace( "Service Pack", "").Trim()
End If
Select Case os.Platform
Case PlatformID.Win3 2Windows ' 95, 98, ME
Select Case os.Version.Mino r
Case 0 : displayName &= "95"
Case 10
displayName &= "98"
If os.Version.Revi sion.ToString() = "2222A" Then
displayName &= " SE"
End If
Case 90 : displayName &= "ME"
End Select
Case PlatformID.Win3 2NT
Select Case os.Version.Majo r
Case 3 : displayName &= "NT 3.51"
Case 4 : displayName &= "NT 4"
Case 5
Select Case os.Version.Mino r
Case 0 : displayName &= "2000"
Case 1 : displayName &= "XP"
Case 2 : displayName &= "2003"
End Select
Case 6 : displayName &= "Vista"
Case 7 : displayName &= "7"
End Select
End Select
If origSp.Length 0 AndAlso origSp <"0" Then
displayName &= " SP" & origSp
End If
Comment