Find en ip
Jeg har set på et andet sp. og fundet en pascal kode som jeg skal bruge. Men da jeg er nybegynder i pacal så har jeg problemer med resten. Er der en der kan hjælpe mig med resten?function GetIpFromHost (HostName: string): string;const
HTTP = \'http://\';
var
VersionRequested : Word;
WSAData : TWSAData;
Host : PHostEnt;
s : array [0..128] of Char;
begin
if LowerCase (Copy (HostName, 1, Length (HTTP))) = LowerCase (HTTP) then
Delete (HostName, 1, Length (HTTP));
VersionRequested := MakeWord (1, 1);
WSAStartup (VersionRequested, WSAData);
StrCopy (s, PChar (HostName));
Host := GetHostByName (@s);
if Host <> nil then Result := Inet_Ntoa (PInAddr (Host^.h_addr_list^)^)
else
Result := \'\';
WSACleanup;
end;
function GetLocalIp: string;
var
s : array [0..128] of Char;
begin
GetHostName (@s, 128);
Result := GetIpFromHost (string (s));
end;
function GetHostFromIp (IP: string): string;
var
VersionRequested : Word;
WSAData : TWSAData;
Addr : Longint;
Host : PHostEnt;
begin
VersionRequested := MakeWord (1, 1);
WSAStartup (VersionRequested, WSAData);
Addr := Inet_Addr (PChar (IP));
Host := GetHostByAddr (@Addr, SizeOf (Addr), PF_INET);
if Host <> nil then Result := Host^.h_name
else
Result := \'\';
WSACleanup;
end;
HJÆLP :-)
