Einzelnen Beitrag anzeigen

gast5

Registriert seit: 23. Jun 2011
25 Beiträge
 
#10

AW: Internet IP herausfinden

  Alt 24. Sep 2011, 13:55
hab jetzt zwar den code gefunden:

Delphi-Quellcode:
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, winsock, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }
  function GetIpAddressByName(const Lines:TStrings; const AHost: String): Boolean;
type
  PPInAddr= ^PInAddr;
var
  WSA: TWSAData;
  HostInfo: PHostEnt;
  Addr: PPInAddr;
begin
  Result:=False;
  if WSAStartUp($101, WSA) = 0 then
  begin
    try
      HostInfo:= getHostByName(PChar(AHost));
      Result:=HostInfo<>nil;
      if Result then
      begin
        Addr:=Pointer(HostInfo^.h_addr_list);
        if (Addr<>nil) AND (Addr^<>nil) then
        begin
          Repeat
            Lines.Add(StrPas(inet_ntoa(Addr^^)) ) ;
            inc(Addr);
          Until Addr^=nil;
        end;
      end;
    finally
     WSACleanup;
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if GetIpAddressByName (Listbox1.Items, ('http://automation.whatismyip.com/n09230945.asp') )then
   Showmessage('OK')
 else
   ShowMessage('Fehler');
end;

end.
Aber es zeigt mir Fehler an. Was habe ich falsch gemacht

Geändert von mkinzler (26. Sep 2011 um 19:02 Uhr) Grund: Delphi-Tags eingefügt
  Mit Zitat antworten Zitat