![]() |
IP überprüfen
wie kann ich überprüfen, ob eine IP existiert? Geht das überhaupt?
|
Re: IP überprüfen
Hi,
du kannst prüfen, ob sie gültig ist. Ansonsten kannst du die IP anpingen und wenn sie vorhanden ist, bekommst du eine Antwort. => ![]() Chris PS: Btw falsche Sparte. ;) |
Re: IP überprüfen
du könntest ein TClientSocket verwenden, Address auf die zu überprüfende IP setzen und dann Active auf true setzen. Das ganze in einem try-except-end block verpackt sieht das ganze dann so aus:
Delphi-Quellcode:
function IPExist(IP: string): boolean;
begin Client.Address := IP; try Client.Open Result := true except Result := false; end; end; |
Re: IP überprüfen
@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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz