【问题标题】:Detect Internet Explorer Version using VB6使用 VB6 检测 Internet Explorer 版本
【发布时间】:2009-07-14 02:23:20
【问题描述】:

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

所以我想知道现在公认的检测 Internet Explorer 已安装版本的 VB6 方法是什么?

谢谢。

【问题讨论】:

    标签: internet-explorer vb6 version-detection


    【解决方案1】:

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

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version.
    

    对于 IE 10 及更高版本,您应该检查

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion.
    

    KB 969393

    【讨论】:

      【解决方案2】:

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

      选项显式 '属性存储变量 私有 m_strCompanyName 作为字符串 私有 m_strFileDescription 作为字符串 私有 m_strFileVersion 作为字符串 私有 m_strInternalName 作为字符串 私有 m_strCopyright 作为字符串 私有 m_strOriginalFileName 作为字符串 私有 m_strProductName 作为字符串 私有 m_strProductVersion 作为字符串 私有 m_strPrivateBuild 作为字符串 私有 m_strSpecialBuild 作为字符串 私有 m_strComments 作为字符串 私有 m_strLegalTrademark 作为字符串 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) 只要 Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) 只要 私有常量 OFS_MAXPATHNAME = 128 私有常量 OF_EXIST = &H4000 私有常量 INVALID_HANDLE_VALUE = -1 私有类型 OFSTRUCT cBytes 作为字节 fFixedDisk 作为字节 nErrCode 只要 保留1只要 保留2只要 szPathName(OFS_MAXPATHNAME) 作为字节 结束类型 公共函数 GetVersionInfo(ByRef lpFile As String) As Boolean 将缓冲区调暗为字符串 调暗 rc 只要 将 FullFileName 暗淡为​​字符串 暗淡 sFName 作为字符串 将 lBufferLen 变暗 Dim lDummy 只要 出错时转到 errGetVersionInfo If FileExists(lpFile) Then 缓冲区 = 字符串(255, 0) '*** 获取大小 **** lBufferLen = GetFileVersionInfoSize(lpFile, lDummy) 如果 lBufferLen 0 则 将 bytebuffer(255) 调暗为字节 MoveMemory bytebuffer(0), lVerPointer, lBufferLen 将 Lang_Charset_String 调暗为字符串 将十六进制数变暗 十六进制数 = CLng(bytebuffer(2)) + CLng(bytebuffer(3)) * &H100 + _ CLng(字节缓冲区(0)) * &H10000 + CLng(字节缓冲区(1)) * &H1000000 Lang_Charset_String = Hex(HexNumber) '现在我们改变语言ID和代码页的顺序 '并将其转换为字符串表示形式。 '例如,它可能看起来像 040904E4 '或者把它全部分开: '04-------- = SUBLANG_ENGLISH_USA '--09---- = LANG_ENGLISH ' ----04E4 = 1252 = Windows 的代码页:多语言 做而 Len(Lang_Charset_String) 0 End If 'lBufferLen INVALID_HANDLE_VALUE Then 文件存在 = 真 别的 文件存在 = 假 万一 结束功能 Friend 属性获取 CompanyName() 作为字符串 公司名称 = m_strCompanyName 结束属性 Private Property Let CompanyName(ByVal vNewValue As String) m_strCompanyName = Trim$(vNewValue) 结束属性 Friend 属性获取 FileDescription() 作为字符串 文件描述 = m_strFileDescription 结束属性 私有属性 Let FileDescription(ByVal vNewValue As String) m_strFileDescription = 修剪$(vNewValue) 结束属性 Friend 属性获取 FileVersion() 作为字符串 FileVersion = m_strFileVersion 结束属性 私有属性 Let FileVersion(ByVal vNewValue As String) m_strFileVersion = 修剪$(vNewValue) 结束属性 Friend 属性获取 InternalName() 作为字符串 内部名称 = m_str 内部名称 结束属性 Private Property Let InternalName(ByVal vNewValue As String) m_strInternalName = Trim$(vNewValue) 结束属性 朋友属性获取版权()作为字符串 版权所有 = m_strCopyright 结束属性 私有财产让版权(ByVal vNewValue 作为字符串) m_strCopyright = 修剪$(vNewValue) 结束属性 Friend 属性获取 OriginalFileName() 作为字符串 原始文件名 = m_strOriginalFileName 结束属性 私有属性 Let OriginalFileName(ByVal vNewValue As String) m_strOriginalFileName = Trim$(vNewValue) 结束属性 Friend 属性获取 ProductName() 作为字符串 ProductName = m_strProductName 结束属性 Private Property Let ProductName(ByVal vNewValue As String) m_strProductName = 修剪$(vNewValue) 结束属性 Friend 属性获取 ProductVersion() 作为字符串 ProductVersion = m_strProductVersion 结束属性 Private Property Let ProductVersion(ByVal vNewValue As String) m_strProductVersion = 修剪$(vNewValue) 结束属性 Friend 属性获取 PrivateBuild() 作为字符串 ProductVersion = m_strPrivateBuild 结束属性 Private Property Let PrivateBuild(ByVal vNewValue As String) m_strPrivateBuild = Trim$(vNewValue) 结束属性 Friend 属性获取 SpecialBuild() 作为字符串 ProductVersion = m_strSpecialBuild 结束属性 Private Property Let SpecialBuild(ByVal vNewValue As String) m_strSpecialBuild = Trim$(vNewValue) 结束属性 Friend 属性获取 Comments() 作为字符串 评论 = m_strComments 结束属性 私有属性让评论(ByVal vNewValue 作为字符串) m_strComments = vNewValue 结束属性 Friend 属性获取 LegalTrademark() 作为字符串 LegalTrademark = m_strLegalTrademark 结束属性 Private Property Let LegalTrademark(ByVal vNewValue As String) m_strLegalTrademark = vNewValue 结束属性

      这些是我对 IE 8 的结果。
      公司名称:微软公司
      文件描述:Internet Explorer
      产品版本:8.00.6001.18702 (longhorn_ie8_rtm(wmbla).090308-0339)
      内部名称:iexplore
      合法版权:© Microsoft Corporation。保留所有权利。
      原始文件名:IEXPLORE.EXE
      产品名称:Windows® Internet Explorer
      评论:Windows® Internet Explorer
      商标:Windows® Internet Explorer
      文件版本:8.00.6001.18702 (longhorn_ie8_rtm(wmbla).090308-0339)
      私人构建:
      特殊版本:

      【讨论】:

        【解决方案3】:

        我四处寻找,我真的找不到任何东西。由于某种原因有点晦涩。我确实找到了这个链接,有人在其中发布了解决方案,但我无法让它完全发挥作用! :) 我不是真正的 vb 人,所以也许你可以。如果您有兴趣,这是链接:

        http://www.visualbasicscript.com/m_64130/tm.htm

        编辑:

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

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

        希望这会有所帮助!

        【讨论】:

          猜你喜欢
          • 2023-03-25
          • 1970-01-01
          • 2015-05-29
          • 2012-11-29
          • 2012-03-10
          • 1970-01-01
          • 2013-03-16
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多