function URLInfo(sBrowerPrgFile, sServiceName: string; Netscape: boolean; var Title: string): pChar;
{
参数说明:
sBrowerPrgFile: 浏览器exe文件的完整路径名
sServiceName: 浏览器的DDE-Service名字
Netscape是'Netscape',IE是'iexplore'
Title: 返回当前网页的title
返回值: pChar的字符串
}
var
DDEClientConv: TDDEClientConv;
StartPtr, EndPtr: pchar;
browserWinName: string;
begin
result:= #0;
Title:= '';
if (sBrowerPrgFile = '') or (not FileExists(sBrowerPrgFile)) then
raise EBrowserNotFoundError.create('****!浏览器应用程序不存在!');
ddeClientConv:= TDDEClientConv.Create( nil );
try
with ddeClientConv do
begin
ServiceApplication := sBrowerPrgFile;
SetLink( sServiceName,'WWW_GetWindowInfo');
StartPtr:= RequestData('0xFFFFFFFF');
end;
finally
ddeClientConv.Free;
end;
if startPtr^ = #0 then
exit;
{skip leading "}
inc(StartPtr);
EndPtr:= StartPtr;
{proceed to next "}
while (EndPtr^ <> '"') do
inc(EndPtr);
{terminate URL string}
EndPtr^:= #0;
result:= StartPtr;
{skip ","}
StartPtr:= EndPtr+3;
if Netscape then
inc(StartPtr,12);
EndPtr:= StartPtr;
if Netscape then
while (EndPtr^ <> ']') do
inc(EndPtr)
else
while (EndPtr^ <> '"') do
inc(EndPtr);
EndPtr^:= #0;
Title:= strPas(StartPtr);
end;