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代码变异加密工具

Delphi 消息实现窗口最小化,最大化,关闭(Delphi)

Delphi 读取软件卸载信息和桌面图标列表

Delphi 检查ip地址合法性

Delphi 控制台 输入输出实例代码

Delphi 辨析 field、fielddef、fields、fielddefs、fieldlist、fielddeflist

Delphi 验证tstrings是否存在

Delphi 侧边栏隐藏窗体

Delphi 得到一个cuid用户唯一标识

Delphi 字符串中末位是双字节字符的处理(避免最后一位为乱码)

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



打赏

取消

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

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

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

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

评论

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