delphi:取得浏览器地址,网址(支持IE,FireFox)


本文整理自网络,侵删。

 

uses DDEMan;

function GetURL(Service: string): string;
var
ClDDE: TDDEClientConv;
temp: PChar;
begin
Result:='';
//create a new DDE Client object
ClDDE:=TDDEClientConv.Create(nil);
with ClDDE do
begin
SetLink(Service, 'WWW_GetWindowInfo');
temp := RequestData('0xFFFFFFFF');
Result := StrPas(temp);
StrDispose(temp);
CloseLink;
end;
ClDDE.Free;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
s1,s2,DDEString:string;
ipos:integer;

begin
if Pos('- Mozilla Firefox',stitle)>0 then
begin
DDEString:= GetUrl('firefox');
iPos:=Pos(',', DDEString);
s1:=Copy(DDEString,iPos+2,Length(DDEString)-iPos-5);
s2:=Copy(DDEString,2,iPos-3);
Edit1.Text:=s1;
Edit2.Text:=s2;
end
else if Pos('- Microsoft Internet Explorer',stitle)>0 then
begin
DDEString:= GetUrl('iexplore');
iPos:=Pos(',', DDEString);
s1:=Copy(DDEString,iPos+2,Length(DDEString)-iPos-5);
s2:=Copy(DDEString,2,iPos-3);
Edit1.Text:=s1;
Edit2.Text:=s2;
end ;
end;

相关阅读 >>

Delphi利用webbrowser登陆qq群文档

Delphi 方法的类型

Delphi xe中泛型数组的使用范例

Delphi idhttp基本使用方法

Delphi操作多显示器

Delphi 匹配中文的正则表达式

Delphi firemonkey中listboxaccessory图标切换

Delphi fastreport快速入门

Delphi 截取字符串的用法

Delphi 检查ip地址合法性

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...