设为首页 加入收藏

TOP

DELPHI 小结(十一)
2017-10-10 12:04:56 】 浏览:2933
Tags:DELPHI 小结
cmpclosehandle = nil) or (@icmpsendecho = nil) then begin
        result:=false;
        halt;
    end;
    hicmp := icmpcreatefile;
    if hicmp = invalid_handle_value then begin
      result:=false;
      halt;
    end;
  end else begin
    result:=false;
    halt;
  end;
// ------------------------------------------------------------
  address := inet_addr(pchar(ipaddr));
  if (address = inaddr_none) then begin
    phe := gethostbyname(pchar(ipaddr));
    if phe = nil then result:=false
    else begin
      address := longint(plongint(phe^.h_addr_list^)^);
      hostname := phe^.h_name;
      hostip := strpas(inet_ntoa(tinaddr(address)));
    end;
  end
  else begin
    phe := gethostbyaddr(@address, 4, pf_inet);
    if phe = nil then result:=false;
  end;

  if address = inaddr_none then
  begin
     result:=false;
  end;
  // get some data buffer space and put something in the packet to send
  buffersize := sizeof(ticmpechoreply) + size;
  getmem(preqdata, size);
  getmem(pdata, size);
  getmem(pipe, buffersize);
  fillchar(preqdata^, size, $aa);
  pipe^.data := pdata;

    // finally send the packet
  fillchar(ipopt, sizeof(ipopt), 0);
  ipopt.ttl := 64;
  npkts := icmpsendecho(hicmp, address, preqdata, size,
                        @ipopt, pipe, buffersize, timeout);
  if npkts = 0 then result:=false;

  // free those buffers
  freemem(pipe); freemem(pdata); freemem(preqdata);

// --------------------------------------------------------------
  icmpclosehandle(hicmp);
  freelibrary(hicmplib);
  // free winsock
  if wsacleanup <> 0 then result:=false;
end;


{=================================================================
  功  能:  检测计算机是否上网
  参  数:  无
  返回值:  成功:  true  失败: false;
  备 注:   uses wininet
  版 本:
     1.0  2002/10/07 13:33:00
=================================================================}
function internetconnected: boolean;
const
  // local system uses a modem to connect to the internet.
  internet_connection_modem      = 1;
  // local system uses a local area network to connect to the internet.
  internet_connection_lan        = 2;
  // local system uses a proxy server to connect to the internet.
  internet_connection_proxy      = 4;
  // local system's modem is busy with a non-internet connection.
  internet_connection_modem_busy = 8;
var
  dwconnectiontypes : dword;
begin
  dwconnectiontypes := internet_connection_modem+ internet_connection_lan
  + internet_c
首页 上一页 8 9 10 11 12 13 下一页 尾页 11/13/13
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Delphi的Socket编程步骤 下一篇【Spine】Spine Runtime for Delp..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目