CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1

    get Handle from a launched IE browser

    Does anyone have a way that I can get the handle from an IE browser launched from my vb application?
    I want to be able to check if that handle is present in windows later. See if the browser is still open. So I can send data to the internet explorer browser if need be based on the handle.
    Thank you very much in advance for your time and consideration,
    Mark

  2. #2

    Question Re: get Handle from a launched IE browser

    Is this possible?

  3. #3
    Join Date
    Jan 2002
    Location
    Quebec/Canada
    Posts
    124

    Re: get Handle from a launched IE browser

    This api may do what you want :

    Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    If the function succeeds, the return value is the instance handle of the application that was run, or the handle of a dynamic data exchange (DDE) server application.


    This information is from the Api-Guide software : http://www.mentalis.org/

  4. #4

    Re: get Handle from a launched IE browser

    What if I have to launch the application like this :

    RetVal = Shell(sBrowser & " " & wurl, vbNormalFocus)

    When sBrowser is the location of iexplorer.exe. The RetVal of this is a 4 digit number. When I use IsWindow to find it. It turns up false because the handle is incorrect.

    I can't seem to get this to work, I tried several things but this does not launch the browser :

    RetVal = ShellExecute(FMain.hwnd, "", "iexplore.exe", "www.yahoo.com", "C:\Program Files\Internet Explorer", 0)

  5. #5
    Join Date
    Sep 2004
    Posts
    135

    Which handle?

    Do you want the handle of the main IE window (i.e.including title bar) or the handle of the client area (i.e. the area in which page is loaded)?

  6. #6

    Exclamation Re: get Handle from a launched IE browser

    The handle of the main IE window. The client area I do not need, at least not now. I need the handle of the main IE window to see if its still present and then pass it different addresses to go to. If the browser window is not there I will open another and then pass in the address. Basically we have an application when the user gets a phone call we have images stored on a local intranet that can be brought up once we send the browser an address. We don't want to keep opening new browser instances everytime they need to look at an image.

  7. #7
    Join Date
    Sep 2004
    Posts
    135

    FindWindow

    FindWindow can be used to find a window with classname as IEFrame. This will give the handle of the main IE window. But it will work only if one browser window is open at a time. Otherwise also, you will get a handle of an IE window, but it may not be the window that you want.

  8. #8
    Join Date
    Aug 2003
    Location
    India
    Posts
    81

    Re: get Handle from a launched IE browser

    try this simple code

    shell("start http://www.cisindia.net")


    Hope that helps

  9. #9

    Re: FindWindow

    Quote Originally Posted by avinash_sahay
    FindWindow can be used to find a window with classname as IEFrame. This will give the handle of the main IE window. But it will work only if one browser window is open at a time. Otherwise also, you will get a handle of an IE window, but it may not be the window that you want.

    What if I use IsWindow(hwnd as long, etc, etc) won't it always look to find the window with that handle regardless if there are more IExplorer browser's open?

    Quote Originally Posted by cancer10
    try this simple code

    shell("start http://www.cisindia.net")


    Hope that helps
    I can't get that code to work in VB6. But this does work

    RetVal = Shell(sBrowser & " " & wurl, vbNormalFocus)
    where sBrowser is the full path of your internet explorer.exe and wurl is the url you want to display. I just want the handle of that window that I am launching.

    Quote Originally Posted by Heulsay
    If the function succeeds, the return value is the instance handle of the application that was run, or the handle of a dynamic data exchange (DDE) server application.
    I just can't get that to launch the browser. But it looks like if I had the handle of an already open browser then I could pass it commands?
    Last edited by Mark_Lane; September 24th, 2004 at 06:43 AM.

  10. #10
    Join Date
    Aug 2003
    Location
    India
    Posts
    81

    Re: FindWindow

    Quote Originally Posted by Mark_Lane
    What if I use IsWindow(hwnd as long, etc, etc) won't it always look to find the window with that handle regardless if there are more IExplorer browser's open?



    I can't get that code to work in VB6. But this does work


    My above said code will not work if u r on any NT based windows like 2000, XP, 2003, NT 4.0, etc

  11. #11

    Re: FindWindow

    Quote Originally Posted by cancer10
    My above said code will not work if u r on any NT based windows like 2000, XP, 2003, NT 4.0, etc
    Okay, thanks for the response! Which platforms will it work on ... for anyone browsing this forum who may be curious?

  12. #12
    Join Date
    Aug 2003
    Location
    India
    Posts
    81

    Exclamation Re: FindWindow

    Quote Originally Posted by Mark_Lane
    Okay, thanks for the response! Which platforms will it work on ... for anyone browsing this forum who may be curious?


    It will work on 95/98/98SE/ and Mellinuim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured