请问怎样才能判断本机是否安装了IE, 并且判断相应的IE版本? 需要用代码实现, 谢谢!
(IE 指的是Microsoft Internet Explorer)

解决方案 »

  1.   

    http://www.thousandvb.com/html/gb/weekly/day000307.htm
      

  2.   

    // This function returns Internet Explorer's major version number,
       // or 0 for others. It works by finding the "MSIE " string and
       // extracting the version number following the space, up to the decimal
       // point, ignoring the minor version number
       <SCRIPT LANGUAGE="JavaSCRIPT">
       function msieversion()
       {
          var ua = window.navigator.userAgent
          var msie = ua.indexOf ( "MSIE " )      if ( msie > 0 )      // If Internet Explorer, return version number
             return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
          else                 // If another browser, return 0
             return 0   }
       </SCRIPT>
      

  3.   


    Private Type DLLVERSIONINFO
        cbSize As Long
        dwMajorVersion As Long
        dwMinorVersion As Long
        dwBuildNumber As Long
        dwPlatformID As Long
    End TypePrivate Declare Function DllGetVersion Lib "Shlwapi.dll" (dwVersion As DLLVERSIONINFO) As LongPublic Function GetIEVersion() As String
        Dim tDLLVerInfo As DLLVERSIONINFO
        Dim lMajor As Long, lMinor As Long, lBuild As Long
        Dim r As Long
        tDLLVerInfo.cbSize = Len(tDLLVerInfo)
        r = DllGetVersion(tDLLVerInfo)
        If r = 0 Then
           With tDLLVerInfo
                lMajor = .dwMajorVersion
                lMinor = .dwMinorVersion
                lBuild = .dwBuildNumber
           End With
           GetIEVersion = lMajor & "." & lMinor & "." & lBuild
        Else
            GetIEVersion = ""
        End If
    End Function
    '调用
    Private Sub Form_Load()
        MsgBox "IE Ver:" & GetIEVersion
    End Sub
      

  4.   

    Option ExplicitPrivate Type DllVersionInfo
    cbSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    End Type
    Private Declare Function DllGetVersion Lib "Shlwapi.dll" (dwVersion As DllVersionInfo) As LongSub ShowIEVersion()
    Dim udtVersionInfo As DllVersionInfo, IEVersion As String
    udtVersionInfo.cbSize = Len(udtVersionInfo)
    DllGetVersion udtVersionInfo
    IEVersion = "Internet Explorer " & _
    udtVersionInfo.dwMajorVersion & "." & _
    udtVersionInfo.dwMinorVersion & "." & _
    udtVersionInfo.dwBuildNumber
    MsgBox IEVersion
    End SubPrivate Sub Form_Load()
    ShowIEVersion
    End Sub
      

  5.   

    完整代码 [先引用Registry Access Functions library(RegObj.dll)]:Option ExplicitPrivate Type DllVersionInfo
    cbSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    End Type
    Private Declare Function DllGetVersion Lib "Shlwapi.dll" (dwVersion As DllVersionInfo) As LongSub ShowIE()
    Dim myReg As New Registry, KeyFound As Boolean
    Dim HasIE As Boolean, msg As String
    msg = ""KeyFound = myReg.GetKeyValue(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE", "Path", msg)If KeyFound Then HasIE = (msg <> "")
    If HasIE Then
    msg = "Your system has installed Internet Explore" & vbCrLf & vbCrLf & "Path:      " & msg
    Dim udtVersionInfo As DllVersionInfo
    udtVersionInfo.cbSize = Len(udtVersionInfo)
    DllGetVersion udtVersionInfo
    msg = msg & vbCrLf & vbCrLf & "Version:  " & udtVersionInfo.dwMajorVersion & "." & udtVersionInfo.dwMinorVersion & "." & udtVersionInfo.dwBuildNumber
    Else
    msg = "Your system has not installed Internet Explore"
    End If
    Set myReg = Nothing
    MsgBox msg, 4096, "Internet Explore Information"
    End SubPrivate Sub Form_Load()
    ShowIE
    End Sub