procedure TForm1.Button2Click(Sender: TObject); const maxx = 30; var ShellWindow: IShellWindows; nCount: integer; spDisp: IDispatch; i: integer; vi: OleVariant; IE1: IWebBrowser2; begin listbox1.clear; ShellWindow := CoShellWindows.Create; nCount := ShellWindow.Count; for i := 0 to nCount - 1 do begin vi := i; try spDisp := ShellWindow.Item(vi); except exit end; if (spDisp <> nil) then begin try spDisp.QueryInterface(iWebBrowser2, IE1); except on EAccessViolation do begin exit end; end; if (IE1 <> nil) then begin if copy(IE1.Get_LocationURL(),1,4)='http' then showmessage('已打开IE'); listbox1.items.add(IE1.Get_LocationURL()); end; end; end; deletefile(extractfilepath(paramstr(0)) + 'Address.d' + inttostr(maxx)); for i := maxx - 1 downto 0 do renamefile(extractfilepath(paramstr(0)) + 'Address.d' + format('%.2d', [i]), 'Address.d' + format('%.2d', [i + 1])); listbox1.items.savetofile(extractfilepath(paramstr(0)) + 'Address.d00');
const
maxx = 30;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i: integer;
vi: OleVariant;
IE1: IWebBrowser2;
begin
listbox1.clear;
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
try
spDisp := ShellWindow.Item(vi);
except
exit
end;
if (spDisp <> nil) then
begin
try
spDisp.QueryInterface(iWebBrowser2, IE1);
except
on EAccessViolation do
begin
exit
end;
end;
if (IE1 <> nil) then
begin
if copy(IE1.Get_LocationURL(),1,4)='http' then
showmessage('已打开IE');
listbox1.items.add(IE1.Get_LocationURL());
end;
end;
end;
deletefile(extractfilepath(paramstr(0)) + 'Address.d' + inttostr(maxx));
for i := maxx - 1 downto 0 do
renamefile(extractfilepath(paramstr(0)) + 'Address.d' + format('%.2d', [i]), 'Address.d' + format('%.2d', [i + 1]));
listbox1.items.savetofile(extractfilepath(paramstr(0)) + 'Address.d00');