首页  编辑  

取得IE地址栏的handle

Tags: /超级猛料/OS.操作系统/IE.扩展/工具栏和工具单元/   Date Created:
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 // ComboBoxEx32可以改成Edit.
    begin
        SendMessage(H, WM_GETTEXT, 255, longint(@url));
        SendMessage(H, WM_SETTEXT, 255, longint(pchar('http://www.sohu.com')));
        SendMessage(H, WM_KEYDOWN, VK_Return, 1);
        // 你说的是加这一句吗??不行啊。   改成Edit就可以,相当于在地址栏敲回车
        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.findbuttonClick(Sender: TObject);
begin
    ListBox1.Clear;
    Enumwindows(@callbackproc, 0);
end;

end.