var
ICMPHandle: HMODULE;
ICMPCreateFile : TIcmpCreateFile;
ICMPCloseHandle: TIcmpCloseHandle;
ICMPSendEcho: TIcmpSendEcho;
function LoadICMPDll: boolean;
begin
ICMPHandle := LoadLibrary('icmp.dll');
if ICMPHandle = 0 then
Result := False
else
begin
@ICMPCreateFile := GetProcAddress(ICMPHandle, pchar('IcmpCreateFile'));
@ICMPCloseHandle := GetProcAddress(ICMPHandle, pchar('IcmpCloseHandle'));
@ICMPSendEcho := GetProcAddress(ICMPHandle, pchar('IcmpSendEcho'));
Result := True;
end;
end;
procedure UnLoadICMP;
begin
if ICMPHandle <> 0 then
FreeLibrary(ICMPHandle);
end;
{ TPingTHread }
{ TPingTHread }
constructor TPingTHread.Create(PingParam: TPingParam; RsltStrings: TStrings);
var
WSAData: TWSAData;
// Phe : PHostEnt;
begin
Inherited Create(False);
if WSAStartup($101, WSAData) <> 0 then
Terminate;
if not LoadICMPDll then
Terminate;
FIPStr := PingParam.PingIP;
FIP := inet_addr(pchar(PingParam.PingIP));
{ if FIP = INADDR_NONE then
begin
Phe := GetHostByName(PChar(PingParam.PingIP));
if Phe = nil then
begin
raise Exception.Create('Unknow Host!');
Terminate;
end else
FIP := longint(plongint(Phe^.h_addr_list^)^);
end; }