Hi! All,
I'm working with VB6 and i'd like to know through VB which Operating System I'm using? Is there a command to do it or any API??? Please let me know.
We just had a thread on this, but I cannot find it - maybe it got removed.
Try using the Microsoft SysInfo control (under PROJECT|COMPONENTS). The NT systems (NT,2000,XP) just return a different version number.
Using the SysInfo component has other advantages as you will see (methods and events).
Or just drop this into a module:
Private Const WIN32_PLATFORM = 1
Private Const WIN_NT_PLATFORM = 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 GetWindowsVers_pFs() As String
'public function - returns a string: Operating system version
Dim OS As OSVERSIONINFO
Dim sCSDVersion As String
OS.dwOSVersionInfoSize = Len(OS)
GetVersionEx OS
Select Case OS.dwPlatformId
Case WIN32_PLATFORM
If OS.dwMinorVersion > 9 Then
GetWindowsVers_pFs = "Windows 98"
Else
GetWindowsVers_pFs = "Windows 95"
End If
Case WIN_NT_PLATFORM
If OS.dwMajorVersion = 4 Then
GetWindowsVers_pFs = "Windows NT"
ElseIf OS.dwMajorVersion = 5 Then
If OS.dwMinorVersion = 0 Then
GetWindowsVers_pFs = "Windows 2000"
ElseIf OS.dwMinorVersion = 1 Then
GetWindowsVers_pFs = "Windows XP"
End If
End If
End Select
If InStr(OS.szCSDVersion, Chr(0)) <> 0 Then sCSDVersion = ": " & Left(OS.szCSDVersion, InStr(OS.szCSDVersion, Chr(0)) - 1)
End Function [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.