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; |