Question Opening a URL to a specific target window/named instance?

ben.stevenson

New member
Joined
Jul 21, 2008
Messages
1
Programming Experience
5-10
Hi all,

I'm currently developing a desktop news application for the company I work for. This is in no way a web based application, however, it will open into our with our Intranet when a user clicks an article, and is linked to the corresponding page.

Now, this is the problem:

In one of the forms, I have a "mini" description of the current XML news article. The title of this article is a clickable LinkLabel. What I want to do, is open the LinkLabel into a new browser window BUT specifically target the browser named instance of "Intranet". We do not want more than one instance of the Intranet window open.

This would be similar to how Javascript works when you target a window by name - you either create a new instance (if non-existing) or focus the old one. We use this typically when opening the Intranet from the Application System. Users can't open a second instance due to the check in place via JS.

As i understand, the regular usage would be
VB.NET:
System.Diagnostics.Process.Start(url)
This is fine when just sending any old page address, but is limited in that it opens a new tab/instance when the command is sent - of course, as there is no target to check.

I've got half way there (i.e. finding the instance via window name) through the code below - which uses FindWindow via imported user32.dll:
VB.NET:
       Dim nWnd As IntPtr
        Dim ceroIntPtr As New IntPtr(0)
        Dim Wnd_name As String

        Wnd_name = "Notepad"
        nWnd = FindWindow(Wnd_name, Nothing)
        'show the info
        If nWnd.Equals(ceroIntPtr) Then
            MsgBox("App Not Running")
        Else
            MsgBox("App Running")
        End If

As you can see the example I'm using is notepad. But of course this would be the browser instance when in use as a check.

Any ideas on how to access the nWnd object and pass a URL to it - if this can be done?

Or another way round this i.e. invoking some sort of Javascript or system process call / shell? I have been Googling this for ages, and it doesn't seem like anyone on the entire Internet has done this yet ;)
 
Back
Top