我的BHO做使用了shdocvw,mshtml类型库本来没有 IETest:=pUnkSite as IWebbrowser2;
IH:=IETest.document as ihtmldocument2;
这两句运行无误,可加上后出现错:Project IEXPLORE.exe raised exception class EOleException with message '未指定的错误'.Process stopped.UseStep or Run to continue.
请指教!!分不够可以再加!!!!代码如下:
function TIEBrowserHelper.SetSite(const pUnkSite: IUnknown): HResult;
var
CPC: IConnectionPointContainer;
IETest:IWebbrowser2;
IH:IHTMLDocument2;
begin
if Assigned(pUnkSite) then
begin IETest:=pUnkSite as IWebbrowser2;//有问题???
IH:=IETest.document as ihtmldocument2;;//有问题???
IE := pUnkSite as IWebbrowser2;
CPC := IE as IConnectionPointContainer;
CPC.FindConnectionPoint(DWebBrowserEvents2, CP);
CP.Advise(Self, Cookie);
if Helperform = nil then
begin
HelperForm := THelperForm.Create(nil);
HelperForm.Visible := True;
end;
end;
Result := S_OK
end;
IH:=IETest.document as ihtmldocument2;
这两句运行无误,可加上后出现错:Project IEXPLORE.exe raised exception class EOleException with message '未指定的错误'.Process stopped.UseStep or Run to continue.
请指教!!分不够可以再加!!!!代码如下:
function TIEBrowserHelper.SetSite(const pUnkSite: IUnknown): HResult;
var
CPC: IConnectionPointContainer;
IETest:IWebbrowser2;
IH:IHTMLDocument2;
begin
if Assigned(pUnkSite) then
begin IETest:=pUnkSite as IWebbrowser2;//有问题???
IH:=IETest.document as ihtmldocument2;;//有问题???
IE := pUnkSite as IWebbrowser2;
CPC := IE as IConnectionPointContainer;
CPC.FindConnectionPoint(DWebBrowserEvents2, CP);
CP.Advise(Self, Cookie);
if Helperform = nil then
begin
HelperForm := THelperForm.Create(nil);
HelperForm.Visible := True;
end;
end;
Result := S_OK
end;
IH:=IETest.document as ihtmldocument2
//有可能这时候BROWER未打开文档,
//这样就没有文档接口引用。。
//在这儿抓一下异常就是了。//看后面的代码操作都只是针对browser,所以不会报错。