您的位置:首页 > 其它

获取浏览器的当前页面地址

2008-09-12 21:12 435 查看
function URLInfo(sBrowserPrgFile,sServiceName:string;NetScape:boolean;var Title:string):pchar;

var

DdeClientConv:TDDEClientConv;

StartPtr,EndPtr:pchar;

browseWinName:string;

{参数说明}

{

sBrowserPrgFile:浏览器EXE文件的完整路径名

sServiceName:浏览器的DDE-Service名字,如Netscape是Netscape,IE是'iexplore'

Title:返回当前网页的Title

返回值:pchar的字符串

}

begin

result :=#0;

Title :='';

if (sBrowserPrgFile='') or (not FileExists(sBrowserPrgFile)) then

raise EBrowserNotFoundError.Create('浏览器应用程序不存在!');

ddeClientConv :=TDDEClientConv.Create(nil);

try

with ddeClientConv do

begin

ServiceApplication :=sBrowserPrgFile;

SetLink(sServiceName,'WWW_GetWindowInfo');

StartPtr :=RequesttData('0xFFFFFFFF');

end;

finally

ddeClientConv.Free;

end;

if StartPen^=#0 then

exit;

inc(StartPtr);

EndPtr :=StartPtr;

while (EndPtr^<>'''') do

inc(EndPtr);

EndPtr^=#0;

result :=StartPtr;

StartPtr :=EndPtr+3;

if NetScape then

inc(StartPtr12);

EndPtr :=StartPtr;

if Netscape then

while (EndPtr^<>']') do

inc(EndPtr)

else

while (EndPtr^<>'''') do

inc(EndPtr);

EndPtr^ :=#0;

Title :=StrPas(StartPtr);

end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: