Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

How to know wich Operational System on the computer ?

I want to know wich O.S.
How can I check it in VB?
0
Vadimka
Asked:
Vadimka
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now