unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
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}
function WinErrorAsString(AErrCode: DWORD): String;
var
lng: integer;
begin
SetLength(Result, MAX_PATH + 1);
lng := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
nil,
AErrCode,
LANG_SYSTEM_DEFAULT,
PChar(Result),
MAX_PATH,
nil);
if lng > 0 then
SetLength(Result, lng)
else
Result := 'Unknown error';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hndl: HWND;
lng: integer;
main: HWND;
url: string;
begin
main := FindWindow('IEFrame', nil);
if main <> 0 then
begin
hndl := FindWindowEx(main, 0, 'Worker', nil);
if hndl <> 0 then
begin
hndl := FindWindowEx(hndl, 0, 'ReBarWindow32', nil);
if hndl <> 0 then
begin
hndl := FindWindowEx(hndl, 0, 'ComboBoxEx32', nil);
if hndl <> 0 then
begin
hndl := FindWindowEx(hndl, 0, 'ComboBox', nil);
if hndl <> 0 then
begin
hndl := FindWindowEx(hndl, 0, 'Edit', nil);
if hndl <> 0 then
begin
lng := SendMessage(hndl, WM_GETTEXTLENGTH, 0, 0);
SetLength(url, lng);
lng := SendMessage(hndl, WM_GETTEXT, lng + 1, lParam(PChar(url)));
if lng > 0 then
begin
SetLength(url, lng);
Edit1.Text := url;
end
else
begin
Edit1.Text := WinErrorAsString(GetLastError);
end;
end;
end;
end;
end;
end;
end;
end;
end. |
|