怎么知道是XP还是WINDDOWS 7?

解决方案 »

  1.   

    SysInfo1.OSVersion=6.01 ?这样判断正常吗
      

  2.   


      可以根据系统目录判断的,因为xp和win7的目录不一样,如用户文件夹,希望我的回答能解决你的问题
      

  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
    Public OsName$, TmpStr$, Ary
    Private Sub Form_Activate()
        Ary = Array("", "Windows 95", "Windows 98", "Windows Me", "Windows NT4.0", "Windows 2000", "Windows XP", "Windows 2003", "Windows Vista", "Windows 7")
        MsgBox "您的操作系统是:" & Ary(GetVersion)
    End SubPublic Function GetVersion() As Long
        Dim OSInfo As OSVERSIONINFO
        Call GetVersionEx(OSInfo)
        OSInfo.dwOSVersionInfoSize = 148
        OSInfo.szCSDVersion = Space(128)
        Call GetVersionEx(OSInfo)
        Select Case OSInfo.dwPlatformID
           Case VER_PLATFORM_WIN32s
              OsName = "Windows 3.1"
           Case VER_PLATFORM_WIN32_WINDOWS
              OsName = "Windows 98"
           Case VER_PLATFORM_WIN32_NT
              OsName = "Windows NT"
        End Select
        TmpStr = OsName & "(" & OSInfo.dwMajorVersion & "." & OSInfo.dwMinorVersion & ")"
        If InStr(TmpStr$, "95") Then GetVersion = 1: Exit Function
        If InStr(TmpStr$, "98") Then GetVersion = 2: Exit Function
        If InStr(TmpStr$, "Me") Then GetVersion = 3: Exit Function
        If InStr(TmpStr$, "4.0") Then GetVersion = 4: Exit Function
        If InStr(TmpStr$, "5.0") Then GetVersion = 5: Exit Function
        If InStr(TmpStr$, "5.1") Then GetVersion = 6: Exit Function
        If InStr(TmpStr$, "5.2") Then GetVersion = 7: Exit Function
        If InStr(TmpStr$, "6.0") Then GetVersion = 8: Exit Function
        If InStr(TmpStr$, "6.1") Then GetVersion = 9
    End Function
    和我想的是一样的,就用这种了