unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; procedure Button1Click(Sender: TObject); function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall; Function GetURL(H:hwnd;lparam:longint):boolean;stdcall; private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}Function GetURL(H:hwnd;lparam:longint):boolean;stdcall; var str,url:array [0..254] of char; begin getclassname(h,@str,255); if strpas(@str)='ComboBoxEx32' then begin SendMessage(h,WM_GETTEXT,255,LongInt(@url)); form1.ListBox1.Items.Add(strpas(@url)); end; result:=true; end; function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall; var str:array [1..255] of char; begin getclassname(h,@str,255); if ((strpas(@str)='CabinetWClass') or (strpas(@str)='IEFrame')) then begin Enumchildwindows(h,@GetURL,0); end; result:=true; end;procedure TForm1.Button1Click(Sender: TObject); begin listbox1.Clear; Enumwindows(@callbackproc,0); end;end.
uses shellapi;
WinExec(pchar('command.com /c ping '+host+'>c:\hostip.txt'),sw_hide);
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall;
Function GetURL(H:hwnd;lparam:longint):boolean;stdcall;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}Function GetURL(H:hwnd;lparam:longint):boolean;stdcall;
var str,url:array [0..254] of char;
begin
getclassname(h,@str,255);
if strpas(@str)='ComboBoxEx32' then
begin
SendMessage(h,WM_GETTEXT,255,LongInt(@url));
form1.ListBox1.Items.Add(strpas(@url));
end;
result:=true;
end;
function callbackproc(H:HWnd;lparam:longint):Boolean;stdcall;
var str:array [1..255] of char;
begin
getclassname(h,@str,255);
if ((strpas(@str)='CabinetWClass') or (strpas(@str)='IEFrame')) then
begin
Enumchildwindows(h,@GetURL,0);
end;
result:=true;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.Clear;
Enumwindows(@callbackproc,0);
end;end.
getbyname()结合试用