gwilson
gwilson

Reputation: 73

Reusing browser/tab in VB.net

I am using Process.Start() to open a URL and it's great for a one-time use but if opening multiple URLs it creates either a new instance of the default browser or uses a new tab. I need to use the original tab.

Suggestions?

Upvotes: 1

Views: 923

Answers (1)

Karl Anderson
Karl Anderson

Reputation: 34846

For Internet Explorer, you will need to reference the shdocvw.dll COM component located, by default, at c:\windows\system32\shdocvw.dll. This COM component contains a ShellWindows object that you can use to determine if there is a running instance of Internet Explorer or not, like this:

Dim internetExplorerInstances As New ShellWindows()

Dim foundIE As Boolean = False
For Each ie As InternetExplorer In internetExplorerInstances
If ie.Name = "Windows Internet Explorer" Then
        ie.Navigate(ur, &H800)
        foundIE = True
        Exit For
    End If
Next

If Not foundIE Then
    ' Either do nothing or use Process.Start with a new browser instance
End If

For the other browsers, you are, unfortunately,out of luck, programmatically.

Upvotes: 1

Related Questions