type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
dde:TDDEClientConv;
begin
dde:=TDDEClientConv.create(self);
if dde.setlink('Iexplore','WWW_GetWindowInfo') then
edit1.text:=dde.requestdata('0xffffffff,sURL,sTitle')
else
showmessage('explore is not running');
end;
我这里有个更简单的
uses ddeman;
procedure TForm1.Button1Click(Sender:TObject);
var
dde:TDdeClientConv;
begin
dde:=TDdeClientConv.Create(self);
if dde.setLink('Iexpore','www_GetWindowInfo') then
Edit1.Text:=dde.RequestData('0xffffffff,sURL,sTitle')
else
Showmessage('Explore is not running');
end;
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));
fmMain.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 TfmMain.Button3Click(Sender: TObject);
begin
listbox1.Clear;
Enumwindows(@callbackproc,0);
end;
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));
fmMain.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 TfmMain.Button3Click(Sender: TObject);
begin
listbox1.Clear;
Enumwindows(@callbackproc,0);
end;