[VB.NET]取得Internet Explorer版本

  • 9225
  • 0
  • 2010-08-02

取得Internet Explorer版本

在藍色小舖中有人問到這個問題,解決方式有兩種

1. 透過查詢登錄檔機碼
   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version

2. 呼叫IE,透過 JavaScript的userAgent方法取得版本

程式碼

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' 呼叫 IE,並透過JavaScript的 userAgent 取得版本
        Dim IE As Object = CreateObject("InternetExplorer.Application")
        IE.Navigate("about:blank")
        IE.Document.write("<script language=JavaScript>document.write(navigator.userAgent)</script>")
        MsgBox(IE.Document.body.outertext)
        IE = Nothing
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        '透過讀取登錄檔機碼
        Dim WshShell As Object = CreateObject("WScript.Shell")  '建立 Wsh Shell 物件
        MsgBox("您的IE版本為 " & WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version"))
    End Sub

 參考

http://www.blueshop.com.tw/board/show.asp?subcde=BRD20090227145349R3C&fumcde=FUM200501271723350KG&rplcnt=4