Filipe35
Messages postés470Date d'inscriptionvendredi 14 novembre 2003StatutMembreDernière intervention23 octobre 2007
-
5 août 2005 à 23:20
Filipe35
Messages postés470Date d'inscriptionvendredi 14 novembre 2003StatutMembreDernière intervention23 octobre 2007
-
8 août 2005 à 10:05
Bonjour à tous
J'ai une question, j'ai l'adresse d'un site htttp://www.ogametut.free.fr
mais l'ip de ce dernier change souvent,et j'aimerais bien faire une fonction de ce type
Filipe35
Messages postés470Date d'inscriptionvendredi 14 novembre 2003StatutMembreDernière intervention23 octobre 20071 8 août 2005 à 10:05
J'ajoute Winsock dans les Uses
mais ce code ne marche toujours pas,
function HostEntAddress(const HostEnt: PHostEnt; const Index: Integer): TInAddr;
var P : ^PInAddr;
Q : PInAddr;
I : Integer;
begin
LongInt(Result.S_addr) := LongInt(INADDR_NONE);
if not Assigned(HostEnt) then
exit;
P := Pointer(HostEnt^.h_addr_list);
if not Assigned(P) then
exit;
Q := P^;
I := 0;
While Assigned(Q) and (I < Index) do
begin
Inc(P);
Inc(I);
Q := P^
end;
if Assigned(Q) then
Result := Q^;
end;
function IPAddressStr(const Address: TInAddr): String;
begin
Result := PChar(inet_ntoa(Address));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
HostEnt : pHostEnt;
index : integer;
ip : string;
begin
HostEnt := GetHostByName('http://www.ogametut.free.fr');
ip := IPAddressStr(HostEntAddress(HostEnt, Index));
showmessage(ip);