Pegar o IP

Delphi

27/10/2003

Olá!!!

Estou precisando de uma função para pegar o IP da minha máquina quando eu conectar a internet!

Tipo assim:

1º testa se ta conectado
2º se estiver conectado Pega o IP
3º Envia o IP por e-mail (essa parte ja consegui)


grato,

Rafael


Biscoitorfa

Biscoitorfa

Curtidas 0

Respostas

Beppe

Beppe

27/10/2003

Putz, tah me parecendo cavalo de tróia...

Ataliba


GOSTEI 0
Brunodelphi

Brunodelphi

27/10/2003

Tente assim:

function GetIP:string;
//--> Declare a Winsock na clausula uses da unit
var
WSAData: TWSAData;
HostEnt: PHostEnt;
Name:string;
begin
WSAStartup(2, WSAData);
SetLength(Name, 255);
Gethostname(PChar(Name), 255);
SetLength(Name, StrLen(PChar(Name)));
HostEnt := gethostbyname(PChar(Name));
with HostEnt^ do
begin
Result := Format(´¬d.¬d.¬d.¬d´,
[Byte(h_addr^[0]),Byte(h_addr^[1]),
Byte(h_addr^[2]),Byte(h_addr^[3])]);
end;
WSACleanup;
end;


GOSTEI 0
Osocram

Osocram

27/10/2003

Isso naum funciona se eu tiver ADSL e o modem for do tipo router, neh?


GOSTEI 0
POSTAR