[Migrated content. Thread originally posted on 09 April 2004]
I am trying to call kernell32.dll to determine the version of Windows that the client (in a thin client environment) is running. If it weren't thin client, I would use WIN$VERSION, but this won't work in thin client for the client - only the server.I've had little experience calling DLLs and I cannot figure out how to make this one work. I've attached a simple VB example that does what I need, but I don't know how to "translate" this to COBOL syntax. Can anyone point me in the right direction? Or does anyone have a sample program already?
I'll be attending Gisle's class this Summer in San Diego and I'm sure after that class, I'll know how to do this, but I cannot wait until then!!
Thanks,
Rob
Public Declare Function GetVersionEx Lib "kernel32" Alias _
"GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
' dwPlatforID Constants
Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2
'-- End --'
Add this code to a form:
Private Sub Form_Load()
Dim tOSVer As OSVERSIONINFO
' First set length of OSVERSIONINFO
' structure size
tOSVer.dwOSVersionInfoSize = Len(tOSVer)
' Get version information
GetVersionEx tOSVer
' Determine OS type
With tOSVer
Select Case .dwPlatformId
Case VER_PLATFORM_WIN32_NT
' This is an NT version (NT/2000)
' If dwMajorVersion >= 5 then
' the OS is Win2000
If .dwMajorVersion >= 5 Then
Label1.Caption = "Windows 2000"
Else
Label1.Caption = "Windows NT"
End If
Case Else
' This is Windows 95/98/ME
If .dwMajorVersion >= 5 Then
Label1.Caption = "Windows ME"
ElseIf .dwMajorVersion = 4 And .dwMinorVersion > 0 Then
Label1.Caption = "Windows 98"
Else
Label1.Caption = "Windows 95"
End If
End Select
' Check for service pack
Label1.Caption = Label1.Caption & " " & Left(.szCSDVersion, _
InStr(1, .szCSDVersion, Chr$(0)))
' Get OS version
Label2.Caption = "Version: " & .dwMajorVersion & "." & _
.dwMinorVersion & "." & .dwBuildNumber
End With
End Sub
Private Sub Command1_Click()
Unload Me
End Sub



