Einzelnen Beitrag anzeigen

mdx
(Gast)

n/a Beiträge
 
#21

Re: URLs aus Firefox-Instanzen auslesen

  Alt 25. Apr 2009, 08:22
Na toll, jetzt kommt wieder:
[DCC Fehler] E2033 Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen

Also, mein "kompletter" Code (Mal alles so wie du gemacht - Nur Test!)

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ddeman;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

procedure GetCurrentURL(out URL, Title: AnsiString);
var
   DDEClient : TDDEClientConv;
   p, q: PAnsiChar;
   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('Mozilla', 'WWW_GetWindowInfo') or
       SetLink('Firefox', 'WWW_GetWindowInfo') then
       p := RequestData('0xFFFFFFFF')
     else raise Exception.Create('Could not establish browser DDE link');
     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 else raise Exception.Create('Could not fetch browser data');
   finally
     DDEClient.Free;
   end;
end;
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
 url, title: String;
begin
  HIER KOMMT DER FEHLER--> GetCurrentURL(url, title);
  ShowMessage(url + #13#10 + title);
end;

end.
  Mit Zitat antworten Zitat