使用 VB6 检测 Internet Explorer 版本

发布于 2024-07-27 02:00:14 字数 389 浏览 5 评论 0原文

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

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

谢谢。

I'm updating a legacy app and it has some functionality that detects the version of Internet Explorer that's installed, just for display and error reporting not because any components are required. The code used for IE version detection is basically the code from VBnet - DllGetVersion: Detailed Internet Explorer Version Info (Author: Kay-Christian Hansen, VBnet - Randy Birch). Unfortunately this code doesn't detect IE version greater than IE6.

So I'm wondering what the accepted VB6 method of detecting the installed version of Internet Explorer is these days?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江南月 2024-08-03 02:00:14

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

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version.

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

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion.

查看 KB 969393

You could access registry to do that.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version.

For IE 10 and above you should to check

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion.

Look at KB 969393

一花一树开 2024-08-03 02:00:14

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

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

这些是我在 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)
私人构建:
特别打造:

Here is a class I use to get file version information:

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

These are my results for IE 8.
Company name: Microsoft Corporation
File description: Internet Explorer
Product version: 8.00.6001.18702 (longhorn_ie8_rtm(wmbla).090308-0339)
Internal name: iexplore
Legal copyright: © Microsoft Corporation. All rights reserved.
Original file name: IEXPLORE.EXE
Product name: Windows® Internet Explorer
Comments: Windows® Internet Explorer
Trademarks: Windows® Internet Explorer
File version: 8.00.6001.18702 (longhorn_ie8_rtm(wmbla).090308-0339)
Private build:
Special build:

南城追梦 2024-08-03 02:00:14

我环顾四周,并没有真正找到任何东西。 由于某种原因有点晦涩难懂。 我确实找到了这个链接,其中有人发布了解决方案,但我无法让它完全工作! :) 我不是一个真正的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)

希望这有帮助!

I searched around and I couldn't really find anything. Kind of obscure for some reason. I did find this link where someone posted a solution but I coulnd't get it to fully work! :) I'm not really a vb guy so maybe you could. Here's the link if your interested:

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

Edit:

I actually missed some code on the bottom of that page and that code seemed to work well in getting the version of IE. I kinda simplified his code a little bit:

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

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文