IWebBrowser2 Quit method failed with result E_FAIL

I place the web browser control in my own window. Here are the relevant steps:

CoGetClassObject(CLSID_WebBrowser, 
                 CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, 
                 NULL, IID_IClassFactory, (void **)&pClassFactory);

pClassFactory->CreateInstance(0, IID_IOleObject, (void **)&pObject);

pClassFactory->Release(); 

pObject->SetClientSite((IOleClientSite *)impl)
OleSetContainedObject((struct IUnknown *)pObject, true)
pObject->DoVerb(OLEIVERB_SHOW, NULL, (IOleClientSite *)impl, 0, hHpsWnd, &rect);

pWB->put_Visible(VARIANT_FALSE);

hr=pWB->Quit();

In the last statement above, the return value of hr is equal E_FAIL. The end result of this failure in my code is a leak of many resources. What am I doing wrong?

+3
source share
1 answer

Reading the documentation here , it states that the WebBrowser object (i.e. CLSID_WebBrowser) returns an error from the Quit method, because it does not make sense in the context. The Quit method will exit IE, which also uses the same interface for communication.

, , , COM-, .

+1

Source: https://habr.com/ru/post/1727258/


All Articles