Thread: Talking to Internet Explorer

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    25

    Talking to Internet Explorer

    Hello, everyone.

    I'd like to make my own custom IE toolbar that would analyze the URL and the HTML of the Web pages and (say) display an alert if the page contains some harmful content. I've figured out how to create the toolbar and attach it to IE. I can obtain the Explorer window handle and extract the URL from the address ComboBox, but what about the page HTML? Does Internet Explorer provide some API for getting it? And how do I hook my function so that it gets called whenever a page is loaded?

    Any help would be highly appreciated.

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    25
    All right, I've figured it out by myself (or rather, found a tutorial all by myself ) For those interested, here it is: http://www.codeproject.com/atl/#IE+%...rer+plug%2Dins

    Now if I just understood what the hesk is going on with all those COM interfaces... Basically, I've got a pointer to an IWebBrowser2, which lets me do all sorts of cool things -- that include, of course, getting the raw HTML. I tried to do it like this:
    Code:
    IDispatch *pDispatch = NULL;
    
    hr = m_pWebBrowser2->get_Document(&pDispatch);
    
    if (SUCCEEDED(hr))
    {
    	MessageBox(0, "Got IDispatch", 0, 0);
    
    	IHTMLDocument2 * pHTMLDocument = NULL;
    
    	hr = pDispatch->QueryInterface(IID_IHTMLDocument2, (void **) pHTMLDocument);
    	pDispatch->Release();
    
    	if (SUCCEEDED(hr))
    	{
    		MessageBox(0, "Got IHTMLDocument2", 0, 0);
    and, of course, Internet Explorer crashed, because the QueryInterface threw an exception (Code 0xc0000005, Flags 0x0, Record 0x0; that's "Access Violation"). And it's COM, it's not supposed to throw exceptions, whatever the circumstances; in the worst case it might return an error code. So, um... would you happen to know what might be the problem?

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    I think you may have a hard time getting any useful information about programming IE from anyone here. Most of us are standards compliance/anti-spyware pedants and consequently use Mozilla Firefox or Opera as a web browser (and they use a completely different programming model to IE).

    But thanks for the enlightenment.

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    25
    Oh, all right; thanks anyway. I only chose IE because I couldn't make head nor tail of the other browsers', er, programming models; plus, I now dabble a little in ATL, so that's two benefits for the price of one . When I will have finished the IE extension, I'll try to adapt it for Firefox, too -- if I ever manage to load my DLL using their JavaScript(tm)

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    	hr = pDispatch->QueryInterface(IID_IHTMLDocument2, (void **) &pHTMLDocument);
    For future reference, 0xc0000005 is STATUS_ACCESS_VIOLATION (from WinNT.h), and is usually caused by trying to read or write from an invalid memory address. In this case, you were trying to write to the memory address NULL.

    You may wish to check out DispHelper, especially the IE sample.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. disabling internet explorer
    By p_k in forum Tech Board
    Replies: 6
    Last Post: 04-11-2007, 03:32 AM
  2. Internet Explorer
    By Joanna in forum Tech Board
    Replies: 7
    Last Post: 04-25-2004, 02:28 AM
  3. will not erase this history for internet explorer
    By HelpPLease123 in forum Tech Board
    Replies: 8
    Last Post: 11-02-2002, 01:18 AM
  4. Drag and drop from Internet Explorer
    By Echidna in forum Windows Programming
    Replies: 5
    Last Post: 10-02-2002, 02:14 AM
  5. closing microsoft internet explorer
    By canine in forum Windows Programming
    Replies: 11
    Last Post: 03-19-2002, 09:12 AM