How to know wich Operational System on the computer ?

I want to know wich O.S.
How can I check it in VB?
VadimkaAsked:
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.

aelatikCommented:
Quick sample from allapi.net

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
    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
0
aelatikCommented:
You can also get the info with the 'Sysinfo' component:

msgbox SysInfo1.OSPlatform
( the number returns OS )
0
VadimkaAuthor Commented:
and how to differ between win2000 and XP ?
0
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.

aelatikCommented:
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
Next
End Sub
0
NeilW_73Commented:
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_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2

Private Type OSVERSIONINFO
    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 tyOSVERSIONINFO As OSVERSIONINFO
    Dim sWindows As String
    Dim lVal As Long


    tyOSVERSIONINFO.dwOSVersionInfoSize = Len(tyOSVERSIONINFO)
    lVal = GetVersionEx(tyOSVERSIONINFO)
    Select Case tyOSVERSIONINFO.dwPlatformId
        Case VER_PLATFORM_WIN32_WINDOWS:
            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
0

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
EDDYKTCommented:
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

 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06042002.asp


for simple VB6

http://support.microsoft.com/default.aspx?scid=kb;EN-US;189249
0
NeilW_73Commented:
Thanks for the points Vadimka!
0
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.