Fórum URL ativa no browser #344199
07/08/2007
0
Ola bom dia a todos, bom to ussando a seguinte função
Uses ddeman;
procedure TForm1.btnRefreshClick(Sender: TObject);
var
DDE:TDDEClientConv;
tro:string;
begin
DDE:=TDDEClientConv.Create(self);
if DDE.SetLink(´IExplore´,´WWW_GetWindowInfo´) then
begin
Memo1.Lines.Add(DDE.RequestData(´0xFFFFFFFF´));
// DDE.Free;
end;
end;
ele sempre me rotorna a utima url ativa do Browser e sempre vem a url ( ´http://www.clubedelphi.com.br/´,´clubedelphi.com.br´ ) a url e o titulo, gostaria de fazer ele pegar so a url e n so a utima todas as urls abertas, alguem pode me ajuda?
vlw
Uses ddeman;
procedure TForm1.btnRefreshClick(Sender: TObject);
var
DDE:TDDEClientConv;
tro:string;
begin
DDE:=TDDEClientConv.Create(self);
if DDE.SetLink(´IExplore´,´WWW_GetWindowInfo´) then
begin
Memo1.Lines.Add(DDE.RequestData(´0xFFFFFFFF´));
// DDE.Free;
end;
end;
ele sempre me rotorna a utima url ativa do Browser e sempre vem a url ( ´http://www.clubedelphi.com.br/´,´clubedelphi.com.br´ ) a url e o titulo, gostaria de fazer ele pegar so a url e n so a utima todas as urls abertas, alguem pode me ajuda?
vlw
Joilson Junior
Curtir tópico
+ 0
Responder
Posts
07/11/2007
Jener
procedure TForm1.GetCurrentURL(out URL,Title: string);
var
DDEClient: TDDEClientConv;
p,q: PChar;
i: Integer;
begin
DDEClient := TDDEClientConv.Create(nil);
try
with DDEClient do
if SetLink(´IExplore´, ´WWW_GetWindowInfo´) or
SetLink(´Netscape´, ´WWW_GetWindowInfo´) or
SetLink(´Mosaic´, ´WWW_GetWindowInfo´) or
SetLink(´Netscp6´, ´WWW_GetWindowInfo´) or
SetLink(´Opera´, ´WWW_GetWindowInfo´) or
SetLink(´Mozilla´, ´WWW_GetWindowInfo´) or
SetLink(´Firefox´, ´WWW_GetWindowInfo´) then
p := RequestData(´0xFFFFFFFF´)
else
exit;
if Assigned(p) then
try
q := p;
Assert(q^ = ´´´);
SetLength(URL,StrLen(q));
Inc(q);
i := 0;
while q^ <> ´´´ do
begin
if (q^ = ´\´) and (q[1] = ´´´) then
Inc(q);
Inc(i);
URL[i] := q^;
Inc(q);
end;
SetLength(URL,i);
SetLength(Title,StrLen(q));
i := 0;
Inc(q,3);
while q^ <> ´´´ do
begin
if (q^ = ´\´) and (q[1] = ´´´) then
Inc(q);
Inc(i);
Title[i] := q^;
Inc(q);
end;
SetLength(Title,i);
finally
StrDispose(p);
end
finally
DDEClient.Free;
end;
end;
***************************
Use assim:
var
URL, Text: string;
begin
GetCurrentURL(URL,Text);
Label1.Caption := URL;
end;
var
DDEClient: TDDEClientConv;
p,q: PChar;
i: Integer;
begin
DDEClient := TDDEClientConv.Create(nil);
try
with DDEClient do
if SetLink(´IExplore´, ´WWW_GetWindowInfo´) or
SetLink(´Netscape´, ´WWW_GetWindowInfo´) or
SetLink(´Mosaic´, ´WWW_GetWindowInfo´) or
SetLink(´Netscp6´, ´WWW_GetWindowInfo´) or
SetLink(´Opera´, ´WWW_GetWindowInfo´) or
SetLink(´Mozilla´, ´WWW_GetWindowInfo´) or
SetLink(´Firefox´, ´WWW_GetWindowInfo´) then
p := RequestData(´0xFFFFFFFF´)
else
exit;
if Assigned(p) then
try
q := p;
Assert(q^ = ´´´);
SetLength(URL,StrLen(q));
Inc(q);
i := 0;
while q^ <> ´´´ do
begin
if (q^ = ´\´) and (q[1] = ´´´) then
Inc(q);
Inc(i);
URL[i] := q^;
Inc(q);
end;
SetLength(URL,i);
SetLength(Title,StrLen(q));
i := 0;
Inc(q,3);
while q^ <> ´´´ do
begin
if (q^ = ´\´) and (q[1] = ´´´) then
Inc(q);
Inc(i);
Title[i] := q^;
Inc(q);
end;
SetLength(Title,i);
finally
StrDispose(p);
end
finally
DDEClient.Free;
end;
end;
***************************
Use assim:
var
URL, Text: string;
begin
GetCurrentURL(URL,Text);
Label1.Caption := URL;
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)