2009-07-14 16 views
2

レガシーアプリケーションをアップデートしています。インストールされているInternet Explorerのバージョンを検出する機能がいくつかあります。 IEのバージョン検出に使用されるコードは基本的にVBnet - DllGetVersion: Detailed Internet Explorer Version Infoのコードです(Kay-Christian Hansen、VBnet - Randy Birch)。残念ながら、このコードはIE6よりも大きなIEバージョンを検出しません。VB6を使用してInternet Explorerのバージョンを検出する

私は、インストールされたバージョンのInternet Explorerを検出するために受け入れられるVB6の方法が最近何であるのだろうか?

ありがとうございました。

答えて

2

は、私は、ファイルのバージョン情報を取得するために使用するクラスです:

 
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)
プライベートビルド:
特別ビルド:

3

これを行うには、レジストリにアクセスできます。 IE 10のために、あなたは私の周りを検索し、私は本当に何かを見つけることができませんでしたKB 969393

0

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion. 

ルックをチェックするべき上記

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version. 

。なんらかの理由であいまいなもの。私は誰かが解決策を投稿したこのリンクを見つけましたが、完全に機能するようにはできません! :)私は本当に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) 

これは役に立ちます。ここで

関連する問題