Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Operating System details in VB 1

Status
Not open for further replies.

netizen

Programmer
Aug 27, 2002
24
0
0
IN
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.

thanks much,

Netizen
 
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 = &quot;: &quot; & Left(OS.szCSDVersion, InStr(OS.szCSDVersion, Chr(0)) - 1)

GetWindowsVers_pFs = GetWindowsVers_pFs & &quot; &quot; & OS.dwMajorVersion & &quot;.&quot; & OS.dwMinorVersion & &quot; (Build &quot; & OS.dwBuildNumber & sCSDVersion & &quot;)&quot;

End Function [/b][/i][/u][sub]*******************************************************
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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top