(Gast)
n/a Beiträge
|
Re: IP überprüfen
9. Sep 2003, 22:28
@Devil: hab ich schon versucht, funzt aber nicht!
@Chakotay1308: thx, hat geholfen!
Ich hab hier mal das ergebnis gepostet:
Delphi-Quellcode:
function IPExists( IP: string): boolean;
var
hICMP : DWORD;
pierWork : PICMP_ECHO_REPLY;
dwSize : DWORD;
UIP: Cardinal;
a, b, c, d: string;
begin
a := copy( IP, 1, pos(' .', IP)-1); delete( IP, 1, pos(' .', IP));
b := copy( IP, 1, pos(' .', IP)-1); delete( IP, 1, pos(' .', IP));
c := copy( IP, 1, pos(' .', IP)-1); delete( IP, 1, pos(' .', IP));
d := IP;
UIP := MAKELONG(MAKEWORD(StrToInt(a), StrToInt(b)),MAKEWORD(StrToInt(c), StrToInt(d)));
hICMP := IcmpCreateFile;
if hICMP = INVALID_HANDLE_VALUE then exit;
try
dwSize := SizeOf(ICMP_ECHO_REPLY) + 8;
pierWork := AllocMem(dwSize);
try
if IcmpSendEcho(hICMP,UIP, nil,0, nil,pierWork,dwSize,1000) = 0 then
result := false
else
result := true;
finally
FreeMem(pierWork,dwSize);
end;
finally
IcmpCloseHandle(hIcmp);
end;
end;
|
|
Zitat
|