Internet explorer 使用VB6检测Internet Explorer版本

Internet explorer 使用VB6检测Internet Explorer版本,internet-explorer,vb6,version-detection,Internet Explorer,Vb6,Version Detection,我正在更新一个旧版应用程序,它有一些功能可以检测安装的Internet Explorer版本,只是用于显示和错误报告,而不是因为需要任何组件。用于IE版本检测的代码基本上是来自(作者:Kay Christian Hansen,VBnet-Randy Birch)的代码。不幸的是,这段代码没有检测到IE版本大于IE6 因此,我想知道,目前公认的检测Internet Explorer安装版本的VB6方法是什么 谢谢。您可以访问注册表来执行此操作 HKEY_LOCAL_MACHINE\SOFTWARE

我正在更新一个旧版应用程序,它有一些功能可以检测安装的Internet Explorer版本,只是用于显示和错误报告,而不是因为需要任何组件。用于IE版本检测的代码基本上是来自(作者:Kay Christian Hansen,VBnet-Randy Birch)的代码。不幸的是,这段代码没有检测到IE版本大于IE6

因此,我想知道,目前公认的检测Internet Explorer安装版本的VB6方法是什么


谢谢。

您可以访问注册表来执行此操作

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version.
对于IE 10及以上,您应该检查

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion.

我到处找,什么也没找到。不知什么原因,有点晦涩难懂。我确实找到了这个链接,其中有人发布了一个解决方案,但我无法让它完全工作!:)我不是一个真正的vb人,所以也许你可以。如果您感兴趣,请点击以下链接:

编辑:

实际上,我错过了该页面底部的一些代码,这些代码在获得IE版本时似乎运行良好。我稍微简化了他的代码:

Dim oFS = CreateObject("Scripting.FileSystemObject")
Dim version = oFS.GetFileVersion("c:\windows\system32\ieframe.dll")
MsgBox("Your IE version is: " & version)

希望这有帮助

下面是我用来获取文件版本信息的类:

Option Explicit 'property storage variables Private m_strCompanyName As String Private m_strFileDescription As String Private m_strFileVersion As String Private m_strInternalName As String Private m_strCopyright As String Private m_strOriginalFileName As String Private m_strProductName As String Private m_strProductVersion As String Private m_strPrivateBuild As String Private m_strSpecialBuild As String Private m_strComments As String Private m_strLegalTrademark As String Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwhandle As Long, ByVal dwlen As Long, lpData As Any) As Long Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long Private Declare Function GetSystemDirectory Lib "Kernel32" Alias "GetSystemDirectoryA" (ByVal Path As String, ByVal cbBytes As Long) As Long Private Declare Function lstrcpy Lib "Kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long Private Declare Sub MoveMemory Lib "Kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal Source As Long, ByVal Length As Long) Private Declare Function OpenFile Lib "Kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long Private Const OFS_MAXPATHNAME = 128 Private Const OF_EXIST = &H4000 Private Const INVALID_HANDLE_VALUE = -1 Private Type OFSTRUCT cBytes As Byte fFixedDisk As Byte nErrCode As Long Reserved1 As Long Reserved2 As Long szPathName(OFS_MAXPATHNAME) As Byte End Type Public Function GetVersionInfo(ByRef lpFile As String) As Boolean Dim buffer As String Dim rc As Long Dim FullFileName As String Dim sFName As String Dim lBufferLen As Long Dim lDummy As Long On Error GoTo errGetVersionInfo If FileExists(lpFile) Then buffer = String(255, 0) '*** Get size **** lBufferLen = GetFileVersionInfoSize(lpFile, lDummy) If lBufferLen 0 Then Dim bytebuffer(255) As Byte MoveMemory bytebuffer(0), lVerPointer, lBufferLen Dim Lang_Charset_String As String Dim HexNumber As Long HexNumber = CLng(bytebuffer(2)) + CLng(bytebuffer(3)) * &H100 + _ CLng(bytebuffer(0)) * &H10000 + CLng(bytebuffer(1)) * &H1000000 Lang_Charset_String = Hex(HexNumber) 'now we change the order of the language id and code page 'and convert it into a string representation. 'For example, it may look like 040904E4 'Or to pull it all apart: '04------ = SUBLANG_ENGLISH_USA '--09---- = LANG_ENGLISH ' ----04E4 = 1252 = Codepage for Windows:Multilingual Do While Len(Lang_Charset_String) 0 End If 'lBufferLen INVALID_HANDLE_VALUE Then FileExists = True Else FileExists = False End If End Function Friend Property Get CompanyName() As String CompanyName = m_strCompanyName End Property Private Property Let CompanyName(ByVal vNewValue As String) m_strCompanyName = Trim$(vNewValue) End Property Friend Property Get FileDescription() As String FileDescription = m_strFileDescription End Property Private Property Let FileDescription(ByVal vNewValue As String) m_strFileDescription = Trim$(vNewValue) End Property Friend Property Get FileVersion() As String FileVersion = m_strFileVersion End Property Private Property Let FileVersion(ByVal vNewValue As String) m_strFileVersion = Trim$(vNewValue) End Property Friend Property Get InternalName() As String InternalName = m_strInternalName End Property Private Property Let InternalName(ByVal vNewValue As String) m_strInternalName = Trim$(vNewValue) End Property Friend Property Get Copyright() As String Copyright = m_strCopyright End Property Private Property Let Copyright(ByVal vNewValue As String) m_strCopyright = Trim$(vNewValue) End Property Friend Property Get OriginalFileName() As String OriginalFileName = m_strOriginalFileName End Property Private Property Let OriginalFileName(ByVal vNewValue As String) m_strOriginalFileName = Trim$(vNewValue) End Property Friend Property Get ProductName() As String ProductName = m_strProductName End Property Private Property Let ProductName(ByVal vNewValue As String) m_strProductName = Trim$(vNewValue) End Property Friend Property Get ProductVersion() As String ProductVersion = m_strProductVersion End Property Private Property Let ProductVersion(ByVal vNewValue As String) m_strProductVersion = Trim$(vNewValue) End Property Friend Property Get PrivateBuild() As String ProductVersion = m_strPrivateBuild End Property Private Property Let PrivateBuild(ByVal vNewValue As String) m_strPrivateBuild = Trim$(vNewValue) End Property Friend Property Get SpecialBuild() As String ProductVersion = m_strSpecialBuild End Property Private Property Let SpecialBuild(ByVal vNewValue As String) m_strSpecialBuild = Trim$(vNewValue) End Property Friend Property Get Comments() As String Comments = m_strComments End Property Private Property Let Comments(ByVal vNewValue As String) m_strComments = vNewValue End Property Friend Property Get LegalTrademark() As String LegalTrademark = m_strLegalTrademark End Property Private Property Let LegalTrademark(ByVal vNewValue As String) m_strLegalTrademark = vNewValue End Property 选项显式 '属性存储变量 私有m_strCompanyName作为字符串 私有m_strFileDescription作为字符串 私有m_strFileVersion作为字符串 私有m_strInternalName作为字符串 专用m_strCopyright As字符串 私有m_strOriginalFileName作为字符串 私有m_strProductName作为字符串 私有m_strProductVersion作为字符串 私有m_strprivate生成为字符串 专用m_strSpecialBuild As String 私有m_strComments作为字符串 私有m_strlegal商标作为字符串 私有声明函数GetFileVersionInfo Lib“Version.dll”别名“GetFileVersionInfo”(ByVal lptstrFilename为字符串,ByVal dwhandle为长,ByVal dwlen为长,lpData为任意)为长 私有声明函数GetFileVersionInfoSize Lib“Version.dll”别名“GetFileVersionInfoSizeA”(ByVal lptstrFilename为字符串,lpdwHandle为长)为长 私有声明函数GetSystemDirectory Lib“Kernel32”别名“GetSystemDirectoryA”(ByVal路径为字符串,ByVal cbBytes为长)为长 私有声明函数lstrcpy Lib“Kernel32”别名“lstrcpyA”(ByVal lpString1为String,ByVal lpString2为Long)为Long Private Declare Sub MoveMemory Lib“Kernel32”别名“rtlmovemory”(dest为Any,ByVal Source为Long,ByVal Length为Long) 私有声明函数OpenFile Lib“Kernel32”(ByVal lpFileName作为字符串,lpreseponbuff作为of结构,ByVal wStyle作为Long)作为Long 私有声明函数VerQueryValue Lib“Version.dll”别名“VerQueryValue”(pBlock为任意,ByVal LPSUBLOCK为字符串,lplpBuffer为任意,puLen为长)为长 S_MAXPATHNAME的私有常量=128 _EXIST的私有常量=&H4000 私有常量无效\u句柄\u值=-1 私有结构类型 作为字节的cBytes fFixedDisk作为字节 nErrCode尽可能长 保留的时间尽可能长 保留的时间尽可能长 szPathName(OFS_MAXPATHNAME)作为字节 端型 作为布尔值的公共函数GetVersionInfo(ByRef lpFile作为字符串) 将缓冲区设置为字符串 如长 将FullFileName设置为字符串 将sFName设置为字符串 暗淡的乌弗伦一样长 朦胧如长 关于错误转到errGetVersionInfo 如果文件存在(lpFile),则 缓冲区=字符串(255,0) “***获取大小**** lBufferLen=getFileVersionInfo大小(lpFile,lDummy) 如果lBufferLen为0,则 Dim bytebuffer(255)作为字节 按缓冲区(0)、lVerPointer、lBufferLen移动内存 Dim Lang_Charset_字符串作为字符串 数字越长越好 HexNumber=CLng(bytebuffer(2))+CLng(bytebuffer(3))*&H100+_ CLng(bytebuffer(0))*&H10000+CLng(bytebuffer(1))*&H1000000 Lang_Charset_String=Hex(HexNumber) '现在我们更改语言id和代码页的顺序 '并将其转换为字符串表示形式。 例如,它可能看起来像040904E4 “或者把它全部拆开: '04---------苏朗(英国)美国 '--09---=朗朗英语 '----04E4=1252=Windows的代码页:多语言 Do While Len(Lang\u Charset\u字符串)0 如果'lBufferLen无效\u句柄\u值,则结束 FileExists=True 其他的 FileExists=False 如果结束 端函数 Friend属性获取CompanyName()作为字符串 CompanyName=m\u strCompanyName 端属性 私有属性Let CompanyName(ByVal vNewValue作为字符串) m_strCompanyName=Trim$(vNewValue) 端属性 Friend属性获取FileDescription()作为字符串 FileDescription=m_strFileDescription 端属性 私有属性Let FileDescription(ByVal vNewValue作为字符串) m_strFileDescription=Trim$(vNewValue) 端属性 Friend属性获取FileVersion()作为字符串 FileVersion=m_strFileVersion 端属性 私有属性Let FileVersion(ByVal vNewValue作为字符串) m_strFileVersion=Trim$(vNewValue) 端属性 Friend属性获取InternalName()作为字符串 InternalName=m_strInternalName 端属性 私有属性Let InternalName(ByVal vNewValue作为字符串) m_strInternalName=Trim$(vNewValue) 端属性 Friend属性以字符串形式获取版权() 版权所有=m_strCopyright 端属性 私有财产出租版权(ByVal vNewValue作为字符串) m_strCopyright=Trim$(vNewValue) 端属性 Friend属性获取OriginalFileName()作为字符串 OriginalFileName=m_strOriginalFileName 端属性 私有属性Let OriginalFileName(ByVal vNewValue作为字符串) m_strOriginalFileName=Trim$(vNewValue) 端属性 好友属性获取ProductName()作为字符串 ProductName=m\u strProductName 端属性 私有属性Let ProductName(ByVal vNewValue作为字符串) m_strProductName=Trim$(vNewValue) 端属性 Friend属性获取ProductVersion()作为字符串 ProductVersion=m_strProductVersion 端属性 私有财产出租产品版本(