How to get OS information from the system (in two ways)
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 'System & API - How to get OS information from the system (in two ways) 'Using the SysInfo control: 'Drop a SysInfo control on the form 'Put the following code in a command button click event Private Sub cmdDetectOS_Click() Dim Msg As String Select Case sysInfo1.OSPlatform Case 0 Msg = "Unknown" Case 1 Msg = "Windows 95, ver. " & CStr(sysInfo1.OSVersion) & "(" & CStr(sysInfo1.OSBuild) & ")" Case 2 Msg = "Windows NT, ver. " & CStr(sysInfo1.OSVersion) & "(" & CStr(sysInfo1.OSBuild) & ")" End Select MsgBox "System: " & Msg End Sub 'Using API: Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type Private Declare Function GetVersionEx Lib "Kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long Public Sub GetWinPlatform() Dim osvi As OSVERSIONINFO Dim strCSDVersion As String osvi.dwOSVersionInfoSize = Len(osvi) If GetVersionEx(osvi) = 0 Then Exit Sub End If Select Case osvi.dwPlatformId Case 0 Debug.Print "Unknown" Case 1 Debug.Print "Windows 9x" Case 2 Debug.Print "Windows NT" End Select Debug.Print osvi.dwMajorVersion & "."; osvi.dwMinorVersion & " (Build " & osvi.dwBuildNumber & ")" Debug.Print "Service Packs: " & osvi.szCSDVersion End Sub |
Related posts:
- How to find/display Windows OS Version
- How to check whether the program is running under Win32 (i.e. any 32-bit operating system)
- How to list down all necessary Drive information
- How to Toggle CapsLock (in two ways)
- How to Toggle Num Lock (in two ways)
- How to Retrieve the FilePath from process identified using a hwnd
- How to Get Task Bar Information
- How to get the type of the Keyboard
- How to get BMP file information
- How to get Printer information like Status, Share Name, etc.