W
wqhatnet
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟最近做一个小程序,可是下面的代码老是不能正常工作
特来请教
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j: integer;
vi: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
if spDisp = nil then continue;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
ie1.Quit
end;
end;
end;
上面的代码有的时候行,有的时候不行,主要是这两个地方
spDisp.QueryInterface( iWebBrowser2, IE1 );
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
诸位仁兄有没有办法解决?
特来请教
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j: integer;
vi: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
if spDisp = nil then continue;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
ie1.Quit
end;
end;
end;
上面的代码有的时候行,有的时候不行,主要是这两个地方
spDisp.QueryInterface( iWebBrowser2, IE1 );
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
诸位仁兄有没有办法解决?