取IE浏览器的URL地址

firstalan 2002-09-14 04:48:25
大家好,小弟在这里想问一下怎么样才能取得当前活动IE窗体中URL中的内容读到编辑框中,哪位朋友知道请指教,谢谢。
...全文
110 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
firstalan 2002-09-16
  • 打赏
  • 举报
回复
我想请问大家一个问题,为什么我在用ShellExecute函数时,出错提示我没有定义该函数呢?它是用什么单元文件呢?希望大这尽快告诉我,谢谢!
naughtyboy 2002-09-15
  • 打赏
  • 举报
回复
uses ddeman;
.....
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('IE is not running!');
end;
westfly 2002-09-14
  • 打赏
  • 举报
回复
Borland公司提供的代码'unit Unit1;

interface

{
Copy the content of the Internet Explorer address Bar (the URL)

The API function GetWindowText do not returns the text entered in an Edit
box. We have to use another way to do that. In this case, I used the ClipBoar
as a 'middleware' to transfer the text among IE and this app.

This app was created using the IE 5.5. If the IE object names of your version
are not the same as used here, then use the WinSight32 to locate the correct
names.

Copyright?2001 DelphiBahia
Hugo Novaes
www.delphibahia.eti.br
hugo.novaes@delphibahia.eti.br
}

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

//Copy the text from the IE Address Bar Edit box.
function GetIEEditText(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
//Get the object class name.
GetClassName(wnd, wndClass, SizeOf(wndClass));
//Is the desired object?
if wndClass = 'Edit' then
begin
SendMessage(wnd, EM_SETSEL, 0, -1); //Select the whole text.
SendMessage(wnd, WM_COPY, 0, 0); //Copy it to the ClipBoard.
SendMessage(Param, WM_PASTE, 0, 0); //Paste from the ClipBoard to the Memo1.
SendMessage(Param, WM_CHAR, 13, 0); //Send ENTER to the Memo1.
Result := False; //Stop searching.
end else
Result := True; //Continue searching.
end;

//Searches the ComboBox where the edit box is on.
function GetIEAddres(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
//Get the object class name.
GetClassName(wnd, wndClass, SizeOf(wndClass));
//Is the desired object?
if wndClass = 'ComboBoxEx32' then
begin
EnumChildWindows(wnd, @GetIEEditText, Param); //Enum the child objects.
Result := False; //Stop searching.
end else
Result := True; //Continue searching.
end;

//Searchs the Internet Explorer.
function FindIExplorer(wnd: THandle; Param: Integer): Bool; stdcall;
var
wndClass: array[0..127] of char;
begin
//Get the object class name.
GetClassName(wnd, wndClass, SizeOf(wndClass));
//Is the Internet Explorer main form?
if wndClass = 'IEFrame' then
EnumChildWindows(wnd, @GetIEAddres, Param); //Enum the child objects.
Result := True; //Continue searching other IExplorer windows.
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//Enum all the Windows's windows. The LParam is the memo's handle.
EnumWindows(@FindIExplorer, Memo1.Handle);
end;

end.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧