How to know wich Operational System on the computer ?

I want to know wich O.S.
How can I check it in VB?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Quick sample from

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type
Private Sub Form_Load()
    Dim OSInfo As OSVERSIONINFO, PId As String
    Me.AutoRedraw = True
    OSInfo.dwOSVersionInfoSize = Len(OSInfo)
    Ret& = GetVersionEx(OSInfo)
    If Ret& = 0 Then MsgBox "Error Getting Version Information": Exit Sub
    Select Case OSInfo.dwPlatformId
        Case 0
            PId = "Windows 32s "
        Case 1
            PId = "Windows 95/98"
        Case 2
            PId = "Windows NT "
    End Select
    Print "OS: " + PId
    Print "Win version:" + Str$(OSInfo.dwMajorVersion) + "." + LTrim(Str(OSInfo.dwMinorVersion))
    Print "Build: " + Str(OSInfo.dwBuildNumber)
End Sub

Happy programming,
Ayhan Elatik
You can also get the info with the 'Sysinfo' component:

msgbox SysInfo1.OSPlatform
( the number returns OS )
VadimkaAuthor Commented:
and how to differ between win2000 and XP ?
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Private Sub Form_Load()
Set OS_Set = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
For Each System In OS_Set
    a = a & "Name : " & System.Caption & vbCrLf
    a = a & "Version :" & System.Version & vbCrLf
    a = a & "Manufacturer : " & System.Manufacturer & vbCrLf
    a = a & "Build : " & System.BuildNumber & vbCrLf
    a = a & "Windows DIR : " & System.WindowsDirectory & vbCrLf
    a = a & "System Locale : " & System.Locale & vbCrLf
    a = a & "Total MEM Size : " & System.TotalVisibleMemorySize & vbCrLf
    a = a & "Free Physical MEM : " & System.FreePhysicalMemory & vbCrLf
    a = a & "Total Virtual MEM SIZE : " & System.TotalVirtualMemorySize & vbCrLf
    a = a & "Total Virtual MEM : " & System.FreeVirtualMemory & vbCrLf
    a = a & "Paging FILE SIZE : " & System.SizeStoredInPagingFiles & vbCrLf
    MsgBox a
End Sub
You could try the following. It is an extension to the comment provided by aelatik (includes distinction between 2000 and XP, 95 and 98 and ME).

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

Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_NT = 2

    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Public Function GetOSVersion() As String

    Dim sWindows As String
    Dim lVal As Long

    lVal = GetVersionEx(tyOSVERSIONINFO)
    Select Case tyOSVERSIONINFO.dwPlatformId
            Select Case tyOSVERSIONINFO.dwMinorVersion
                Case 0:
                    ' Windows 95.
                    sWindows = "95"
                Case 10:
                    ' Windows 98.
                    sWindows = "98"
                Case 90:
                    ' Windows ME.
                    sWindows = "ME"
            End Select
        Case VER_PLATFORM_WIN32_NT:
            If tyOSVERSIONINFO.dwMajorVersion = 5 And _
               tyOSVERSIONINFO.dwMinorVersion = 0 Then
                ' Windows 2000.
                sWindows = "2000"
            ElseIf tyOSVERSIONINFO.dwMajorVersion = 5 And _
               tyOSVERSIONINFO.dwMinorVersion = 1 Then
                ' Windows XP.
                sWindows = "XP"
            ElseIf tyOSVERSIONINFO.dwMajorVersion <= 4 Then
                ' Windows NT.
                sWindows = "NT"
            End If
    End Select

    ' Set return value.
    GetOSVersion = sWindows

End Function

Private Sub Form_Load()

    MsgBox "You are running Windows " & GetOSVersion()

End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try this

Although this is .NET code but it is an interop called to VB6 code

This can also show you server or professional or data center as well

for simple VB6;EN-US;189249
Thanks for the points Vadimka!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.