请教,如何得知当前的WINDOWS是下面的哪一种呢?windows 95,98,nt4,me,2000,xp,2003,其他谢谢。

解决方案 »

  1.   

    Private 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
    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As LongDim myOs As OSVERSIONINFOPrivate Sub Command1_Click()
        GetVersionEx (myOs)
        MsgBox myOs.szCSDVersion
    End Sub
      

  2.   

    http://community.csdn.net/Expert/topic/3083/3083405.xml?temp=.6187555
      

  3.   

    http://dev.csdn.net/article/23/23717.shtm
      

  4.   

    '引用控件 Microsoft SysInfo Control 6.0
    Dim OS As StringWith SysInfo1
        Select Case .OSPlatform
            Case 0: OS = "Win32"
            Case 1:
                Select Case .OSVersion
                    Case 4: OS = "Win 95"
                    Case 4.1: OS = "Win 98"
                    Case 4.9: OS = "Wim Me"
                End Select
            Case 2:
                Select Case .OSVersion
                    Case 4: OS = "Win NT"
                    Case 5: OS = "Win 2000"
                    Case 6: OS = "Win XP"
                End Select
        End Select
        
        MsgBox "Build:" & .OSBuild & vbNewLine & _
            "Platform:" & OS & "(" & .OSPlatform & ")" & vbNewLine & _
            "Version:" & .OSVersion
    End With
      

  5.   

    Option ExplicitPublic Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As LongPublic 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
    Private Sub Command1_Click()
    Dim s As OSVERSIONINFOs.dwOSVersionInfoSize = 148Print GetVersionEx(s)Debug.Print s.dwBuildNumber
    Debug.Print s.dwMajorVersion
    Debug.Print s.dwMinorVersion
    Debug.Print s.dwOSVersionInfoSize
    Debug.Print s.dwPlatformId
    Debug.Print s.szCSDVersion
    End Sub
      

  6.   

    Public function OSType() as integer
        '******************************************************
        '*                                                    *
        '*   功能:判断操作系统类型  (只支持三种操作系统)      *
        '*                                                    *
        '*   OSType=1      Windows98                          *
        '*   OSType=2      win2000 professional               *
        '*   OSType=3      winXP professional                 *
        '*                                                    *
        '******************************************************
        Dim myVer As OSVERSIONINFO
        Dim q As Long
        sWinSysPath = GetSysDir()
        myVer.dwOSVersionInfoSize = 148
        q& = GetVersionEx(myVer)
      '主版本为4表示为 Win98
        If myVer.dwMajorVersion = 4 Then
            OStype = 1
        Else
            If myVer.dwMajorVersion = 5 Then
                If myVer.dwMinorVersion = 0 Then
                    OStype = 2
                Else
                    OStype = 3
                End If
            End If
        End If
     End Sub
      

  7.   

    没有错 winapi涵数GetVersionEx()
      

  8.   

    另一方法 读取注册表 Set RegEdit=CreateObject("WScript.Shell")  
    RegEdit.RegRead  (Value)
    vaule值 比如计算机名和计算机标识吧:  
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSUP中的Comment,ComputerName和WorkGroup 
          注册公司和用户名:  
    HKEY_USERS\.DEFAULT\Software\Microsoft\MS Setup (ACME)\UserInfo
      

  9.   

    Option Explicit
    Type OSVERSIONINFO
            dwOSVersionInfoSize As Long
            dwMajorVersion As Long
            dwMinorVersion As Long
            dwBuildNumber As Long
            dwPlatformId As Long
            szCSDVersion As String * 128
    End Type
    Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    Public Const SM_CLEANBOOT = 67
    Public Const SM_DEBUG = 22
    Public Const SM_SLOWMACHINE = 73
    Public Const VER_PLATFORM_WIN32s = 0
    Public Const VER_PLATFORM_WIN32_WINDOWS = 1
    Public Const VER_PLATFORM_WIN32_NT = 2Sub getwindowinfo()
        Dim winver As OSVERSIONINFO
        Dim nl As String
        Dim q As Long
        nl = Chr(10) & Chr(13)
        winver.dwOSVersionInfoSize = 148
        q& = GetVersionEx(winver)
        Label1.Caption = ""
        Label2.Caption = ""
        If winver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
            Label1.Caption = Label1.Caption & "Platform = Windows 95" & nl
        End If
        If winver.dwPlatformId = VER_PLATFORM_WIN32_NT Then
            Label1.Caption = Label1.Caption & "Platform = Windows NT" & nl
        End If
        Label1.Caption = Label1.Caption & "Version = " & winver.dwMajorVersion & "." & winver.dwMinorVersion & " Build " & (winver.dwBuildNumber And &HFFFF&) & nl
        Label2.Caption = "Windows is running in "
        If GetSystemMetrics(SM_CLEANBOOT) = 0 Then
            Label2.Caption = Label2.Caption & "normal mode." & nl
        End If
        If GetSystemMetrics(SM_CLEANBOOT) = 1 Then
            Label2.Caption = Label2.Caption & "safe mode." & nl
        End If
        If GetSystemMetrics(SM_CLEANBOOT) = 2 Then
            Label2.Caption = Label2.Caption & "safe mode with network." & nl
        End If
        If GetSystemMetrics(SM_DEBUG) = True Then
            Label2.Caption = Label2.Caption & "Windows Debugging Mode in operation" & nl
        End If
        If GetSystemMetrics(SM_SLOWMACHINE) = True Then
            Label2.Caption = Label2.Caption & "This machine is too slow to run Windows effectively." & nl
        End If
    End Sub
      

  10.   

    Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
    Public Type OSVERSIONINFO
       dwOSVersionInfoSize As Long
       dwMajorVersion As Long
       dwMinorVersion As Long
       dwBuildNumber As Long
       dwPlatformId As Long
       szCSDVersion As String * 128
    End TypePublic Function GetVersion() As String
       Dim osinfo As OSVERSIONINFO
       Dim retvalue As Integer   osinfo.dwOSVersionInfoSize = 148
       osinfo.szCSDVersion = Space$(128)
       retvalue = GetVersionExA(osinfo)   With osinfo
        Select Case .dwPlatformId
            Case 1
                    Select Case .dwMinorVersion
                        Case 0
                            GetVersion = "Windows 95"
                        Case 10
                            GetVersion = "Windows 98"
                        Case 90
                            GetVersion = "Windows Mellinnium"
                    End Select
            Case 2
                    Select Case .dwMajorVersion
                        Case 3
                            GetVersion = "Windows NT 3.51"
                        Case 4
                            GetVersion = "Windows NT 4.0"
                        Case 5
                            If .dwMinorVersion = 0 Then
                                GetVersion = "Windows 2000"
                            Else
                                GetVersion = "Windows XP"
                            End If
                    End Select
             Case Else
                   GetVersion = "Failed"
        End Select
       End With
    End Function