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.