Jump to content
Nytro

[VB]Get OS Version

Recommended Posts

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Private Type OSVERSIONINFO
OSVersionInfoSize As Long
MajorVersion As Long
MinorVersion As Long
BuildNumber As Long
PlatformId As Long
szCSDVersion As String * 128
End Type
Private Type OSVERSIONINFOEX
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
wServicePackMajor As Integer
wServicePackMinor As Integer
wSuiteMask As Integer
wProductType As Byte
wReserved As Byte
End Type

Public Function GetWindowsVersion() As String
Dim OS As OSVERSIONINFO
Dim durum As Boolean
Dim version As String
OS.OSVersionInfoSize = Len(OS)
durum = GetVersionEx(OS)
version = OS.PlatformId & "." & OS.MajorVersion & "." & OS.MinorVersion
Select Case version
Case "1.4.0"
GetWindowsVersion = "Win 95"
Case "1.4.10"
GetWindowsVersion = "Win 98"
Case "1.4.98"
GetWindowsVersion = "Win ME"
Case "2.3.51"
GetWindowsVersion = "Win NT 3"
Case "2.4.0"
GetWindowsVersion = "Win NT 4"
Case "2.5.0"
GetWindowsVersion = "Win 2000"
Case "2.5.1"
GetWindowsVersion = "Win XP"
Case "2.6.0"
GetWindowsVersion = "Win Vista"
Case "2.6.1"
GetWindowsVersion = "Win Seven"
Case Else
GetWindowsVersion = "Unknown"
End Select
End Function

Private Sub Form_Load()
MsgBox GetWindowsVersion()
End Sub

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...