views:

51

answers:

1

I have an application that I've been using to parse data from an HTML document. The application has been working for a few years until this week when the QueryInterface method for the IID_IPersistStreamInit started failing. The call to QueryInterface is returning -2147467262 which fails the SUCCEEDED(hr) test. Any ideas why this quit working?

Thanks, Wade

if (!myIE->IsValid())
   return;

HRESULT hr;
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
LPPERSISTSTREAM lpPersistStream = NULL;

lpDispatch = myIE->GetHtmlDocument(); 

ASSERT(lpDispatch);

if (lpDispatch == NULL)
  AfxMessageBox("Couldn't get IHTMLDocument2 interface!");    
else
{ 
   hr = lpDispatch->QueryInterface(IID_IPersistStreamInit, (void**) &lpPersistStream);
   if (SUCCEEDED(hr) && lpPersistStream != NULL)
A: 

At what point are you executing the code above? In case it's not done, you should execute it only after the followings:

  1. Navigating to about:blank to have mshtml loaded properly
  2. Make sure the DocumentComplete event is called, meaning the navigation has completed, before you move on.

Only then is it safe to ask for the stream interface. For more, see Loading HTML content from a Stream.

Now, if all this is known and taken care of, you might pursue the solution from the other direction. The error code means "No such interface supported". I'd try finding out what is the component that contains that interface, and then re-register it. But given this is IE stuff you're dealing with, I kind of doubt it's installation got screwed.

eran
I am navigating to a web page like http://www.google.com/ or a HTML document on my local machine. I wait until the page is done loading before pressing the button to view or save the source. The QueryInterface call is failing on all files I've tried. I am guessing that maybe an IE update got pushed onto my machine between Friday and Monday; breaking this program.
I should add that the call to GetHtmlDocument() is successful.
This might be stupid, but still - IE hasn't been working on my workstation today, possibly due to some update. Rebooting fixed it. Have you tried rebooting you workstation after the problem appeared?
eran
Yes, I shutdown my laptop at the end of each day and painfully start fresh the next morning. The program hasn't worked today or yesterday. I'll go try on another machine.
Yep, still works on a PC in our lab running with an older version of IE (6.x). It quit working on my laptop with 7.0.5730.11CO sometime between Friday morning and Monday morning.