IWebBrowser2 Quit 方法失败并显示 E_FAIL 结果
我在自己的窗口中托管网络浏览器控件。以下是相关步骤:
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();
在上面的最后一个语句中,hr 返回值为 E_FAIL
。我的代码中此失败的最终结果是泄漏大量资源。我做错了什么?
I am hosting the web browser control in my own window. Here are the pertinent 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();
At the last statement above the hr return value is E_FAIL
. The end result of this failure in my code is leaking of a bunch of resources. What am I doing incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读文档此处它指出了WebBrowser对象(即 CLSID_WebBrowser)从 Quit 方法返回错误,因为它在上下文中没有意义。 Quit 方法将退出 IE 的进程外版本,该版本也使用相同的接口进行通信。
我唯一可以建议的是仔细检查您是否正在释放与浏览器相关的所有 COM 对象。
Reading the documenation here it states the WebBrowser object (i.e. CLSID_WebBrowser) returns an error from the Quit method because it does not make sense in context. The Quit method will quit the out of process version of IE which also uses the same interface to communicate.
Only thing I can suggest is double check you are releasing all COM object relating to the browser.