VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 读取 Windows 的版本
发表评论(0)作者:, 平台:, 阅读:8995, 日期:2000-04-06
读取 Windows 的版本

Public Const VER_PLATFORM_WIN32s = 0

Public Const VER_PLATFORM_WIN32_WINDOWS = 1

Public Const VER_PLATFORM_WIN32_NT = 2


Type OSVERSIONINFO

dwOSVersionInfoSize As Long

dwMajorVersion As Long

dwMinorVersion As Long

dwBuildNumber As Long

dwPlatformId As Long

szCSDVersion As String * 128

End Type


Declare Function GetVersionEx Lib "Kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Boolean


Sub GetVersionEx_test()

Dim Ver As OSVERSIONINFO, S As String

Ver.dwOSVersionInfoSize = Len(Ver)

GetVersionEx Ver

S = "版本:" & PlatformName(Ver) & vbCrLf & vbCrLf

S = S & "编号:" & Ver.dwMajorVersion & "." & Ver.dwMinorVersion

S = S & "." & Ver.dwBuildNumber Mod 65536 ' Low Word is Build No.

MsgBox S, , "版本及编号"

End Sub


Function PlatformName(Ver As OSVERSIONINFO)

Select Case Ver.dwPlatformId

Case VER_PLATFORM_WIN32_WINDOWS

If Ver.dwMajorVersion = 4 And Ver.dwMinorVersion = 10 Then

PlatformName = "Windows 98"

Else

PlatformName = "Windows 95"

End If

Case VER_PLATFORM_WIN32_NT

PlatformName = "Windows NT"

Case Else

PlatformName = "Win32s"

End Select

End Function


Sub Main()

GetVersionEx_test

End Sub