Wednesday, April 29, 2009

Get Version Windows

'Get Version Windows



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 Declare Function GetVersionEx
Lib "kernel32"
Alias _

"GetVersionExA" (lpVersionInformation As
OSVERSIONINFO) As Long



Private Sub Form_Load()

Dim OSInfo As OSVERSIONINFO, PId
As String

'Set the graphical mode to persistent

Me.AutoRedraw = True

'Set the structure size

OSInfo.dwOSVersionInfoSize = Len(OSInfo)

'Get the Windows version

Ret& = GetVersionEx(OSInfo)

'Check for errors

If Ret& = 0 Then MsgBox "Error Getting Version Information":
Exit Sub

'Print the information to the form



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



 

No comments:

Post a Comment