?
Solved

How to know wich Operational System on the computer ?

Posted on 2003-03-13
7
Medium Priority
?
199 Views
Last Modified: 2010-05-01
I want to know wich O.S.
How can I check it in VB?
0
Comment
Question by:Vadimka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:aelatik
ID: 8126821
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
 
LVL 14

Expert Comment

by:aelatik
ID: 8126828
You can also get the info with the 'Sysinfo' component:

msgbox SysInfo1.OSPlatform
( the number returns OS )
0
 

Author Comment

by:Vadimka
ID: 8126830
and how to differ between win2000 and XP ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:aelatik
ID: 8126861
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
 

Accepted Solution

by:
NeilW_73 earned 320 total points
ID: 8127162
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8127369
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
 

Expert Comment

by:NeilW_73
ID: 8157855
Thanks for the points Vadimka!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question