Private 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 Long
Sub ShowIE()
Dim myReg As New Registry, KeyFound As Boolean
Dim HasIE As Boolean, msg As String
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 Sub
Private 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 Long
Sub 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 Sub
Private 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 Long
Public 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
// 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