dd:=findwindow('IEFrame',nil); while dd<>0 then begin dd:=findwindow('IEFrame',nil);end;
H:=findwindow('IEFrame',nil); while (H<>0) do begin ShowMessage(IntToStr(H)); H:=findwindow('IEFrame',nil); end;结果死循环了!
function EnumIE(Hwnd:HWND;lParam:LPARAM):boolean;stdcall; var pBuf:PChar; begin GetMem(pBuf,200); ZeroMemory(pBuf,200); GetWindowText(Hwnd,pBuf,200); if Pos('Microsoft Internet Explorer',pBuf)>0 then Form1.Memo1.Lines.Add(pBuf); FreeMem(pBuf); Result:=True; end; procedure TForm1.FormCreate(Sender: TObject); begin EnumWindows(@EnumIE,0); end;
uses SHDocVwprocedure TForm1.Button2Click(Sender: TObject); var x: Integer; Sw: IShellWindows; begin sw := CoShellWindows.Create; for x := SW.Count - 1 downto 0 do begin ListBox1.Items.add(IntToStr(variant(Sw.Item(x)).hwnd)); end; end;
while dd<>0 then
begin
dd:=findwindow('IEFrame',nil);end;
while (H<>0) do
begin
ShowMessage(IntToStr(H));
H:=findwindow('IEFrame',nil);
end;结果死循环了!
var pBuf:PChar;
begin
GetMem(pBuf,200);
ZeroMemory(pBuf,200);
GetWindowText(Hwnd,pBuf,200);
if Pos('Microsoft Internet Explorer',pBuf)>0 then
Form1.Memo1.Lines.Add(pBuf);
FreeMem(pBuf);
Result:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
EnumWindows(@EnumIE,0);
end;
var
x: Integer;
Sw: IShellWindows;
begin
sw := CoShellWindows.Create;
for x := SW.Count - 1 downto 0 do
begin
ListBox1.Items.add(IntToStr(variant(Sw.Item(x)).hwnd));
end;
end;