zoukankan      html  css  js  c++  java
  • delphi中检测局域网ip能够ping通模块

    // 函数PingHost用于ping目标IP是否连通 // uses winsock    在uses中加入  winsock // 用法:  if PingHost(edit2.Text) then  edit1.Text:='已连接' else edit1.Text:='未连接' ; function TfrmQYinfo.PingHost(HostIP: string): boolean; type   PIPOptionInformation = ^TIPOptionInformation;   TIPOptionInformation = packed record     TTL: Byte;     TOS: Byte;     Flags: Byte;     OptionsSize: Byte;     OptionsData: pchar;   end;

      PIcmpEchoReply = ^TIcmpEchoReply;   TIcmpEchoReply = packed record     Address: DWORD;     Status: DWORD;     RTT: DWORD;     DataSize: WORD;     Reserved: WORD;     Data: Pointer;     Options: TIPOptionInformation;   end;   TIcmpCreateFile = function: THandle; stdcall;   TIcmpCloseHandle = function(IcmpHandle: THandle): boolean; stdcall;   TIcmpSendEcho = function(IcmpHandle: THandle;     DestinationAddress: DWORD;     RequestData: Pointer;     RequestSize: WORD;     RequestOptions: PIPOptionInformation;     ReplyBuffer: Pointer;     ReplySize: DWORD;     Timeout: DWORD     ): DWORD; stdcall; var   hICMP: THandle;   hICMPdll: THandle;   IcmpCreateFile: TIcmpCreateFile;   IcmpCloseHandle: TIcmpCloseHandle;   IcmpSendEcho: TIcmpSendEcho;   pIPE: PIcmpEchoReply; //   ICMP   Echo   reply   buffer   FIPAddress: DWORD;   FSize: DWORD;   FTimeOut: DWORD;   BufferSize: DWORD;   pReqData, pRevData: pchar;   MyString: string; begin   result := false;   hICMPdll := LoadLibrary('icmp.dll');   if hICMPdll = 0 then Exit;   @IcmpCreateFile := GetProcAddress(hICMPdll, 'IcmpCreateFile');   @IcmpCloseHandle := GetProcAddress(hICMPdll, 'IcmpCloseHandle');   @IcmpSendEcho := GetProcAddress(hICMPdll, 'IcmpSendEcho');

      hICMP := IcmpCreateFile;

      if (hICMP = INVALID_HANDLE_VALUE) then Exit;

      //如果提示下面这句话不正确的话,是因为在uses中没有加入winsock   FIPAddress := inet_addr(pchar(HostIP)); //delphi2010改为 :  inet_addr(PANSIChar(ansistring(HostIP)));   MyString := 'Hello'; //send   data   buffer   pReqData := pchar(MyString);

      FSize := 40; //receive   data   buffer   BufferSize := SizeOf(TIcmpEchoReply) + FSize;   GetMem(pIPE, BufferSize);   FillChar(pIPE^, SizeOf(pIPE^), 0);   GetMem(pRevData, FSize);   pIPE^.Data := pRevData;   FTimeOut := 50; //超时时间,毫秒   try     result := IcmpSendEcho(hICMP, FIPAddress, pReqData,       Length(MyString), nil, pIPE, BufferSize, FTimeOut) > 0;   finally     IcmpCloseHandle(hICMP);     FreeLibrary(hICMPdll);     FreeMem(pRevData);     FreeMem(pIPE);   end; end;

  • 相关阅读:
    go基础1:Hello world与变量声明
    linux 根据端口号查看占用进程的pid
    攻防世界web新手练习区WP
    github下载慢解决方法
    玩转MSFconsole
    中国蚁剑AntSword安装
    burpsuite出现Payload set 1: Invalid number settings的解决办法
    在同一台电脑上同时安装Python2和Python3
    msf转移木马进程
    网站后台爆破工具:WebCrack
  • 原文地址:https://www.cnblogs.com/bingege/p/7953563.html
Copyright © 2011-2022 走看看