有什么方法能识别windows的版本号,(api|dll|读注册表?)
能够区分出(9x/Me/2k/XP/2003)以及其Service Pack的版本.
本人现在正在用InstallShield 6.22做一个安装程序,需要识别具体的windows版本.
InstallShield程序自身智能识别win2000以前的操作系统版号。

解决方案 »

  1.   

    '用WMI,先工程-引用  Microsoft  WMI  Scripting  V1.1  Library
    Private Sub Command1_Click()
    Dim wmiObjSet   As SWbemObjectSet
           Dim obj   As SWbemObject
           Dim msg   As String
           Dim dtb   As String
           Dim d   As String
           Dim t   As String
           Dim bias   As Long
           On Local Error Resume Next
           Set wmiObjSet = GetObject("winmgmts:{impersonationLevel=impersonate}  ").InstancesOf("Win32_OperatingSystem  ")
           For Each obj In wmiObjSet
                   MsgBox "你当前使用的系统是    " & obj.Caption
           Next
    End Sub
    or:
    Public Function getVersion() As Long
       Dim osinfo As OSVERSIONINFO
       Dim retvalue As Integer
       osinfo.dwOSVersionInfoSize = 148
       osinfo.szCSDVersion = Space$(128)
       retvalue = GetVersionExA(osinfo)
       getVersion = osinfo.dwPlatformId
    End FunctionPrivate Sub Command1_Click()
    ttt = getVersion()
    If ttt = 1 Then
    MsgBox ("98")
    Else
    MsgBox ("xp")
    End If
    End Sub
      

  2.   

    Private Declare Function GetVersion Lib "kernel32" () As Long
    Public Function GetWinVersion() As String
        Dim Ver As Long, WinVer As Long
        Ver = GetVersion()
        WinVer = Ver And &HFFFF&
        'retrieve the windows version
        GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
    End Function
    Private Sub Form_Load()
        MsgBox "Windows version: " + GetWinVersion
    End Sub或者
      

  3.   


    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    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 Sub Form_Load()
        Dim OSInfo As OSVERSIONINFO, PId As String
        Me.AutoRedraw = True
        'Set the structure size
        OSInfo.dwOSVersionInfoSize = Len(OSInfo)
        'Get the Windows version
        Ret& = GetVersionEx(OSInfo)
        'Chack 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
      

  4.   

    (1). WMI
    (2). (API)GetVersionEx
    还有其他方法吗?我是要写到InstallScript中的。我想能够有多种方案,来对比一下,哪种方法更容易在InstallScript中实现。