永发信息网

如何在PB中编写PING代码

答案:1  悬赏:80  手机版
解决时间 2021-01-20 06:50
  • 提问者网友:趣果有间
  • 2021-01-19 22:20
如何在PB中编写PING代码
最佳答案
  • 五星知识达人网友:轻熟杀无赦
  • 2021-01-19 23:36
解决方案:
声明外部函数:

Function ulong IcmpCreateFile () Library "icmp.dll"
Function long IcmpSendEcho (ulong IcmpHandle, ulong DestinationAddress, string RequestData,long RequestSize, long RequestOptions, Ref icmp_echo_reply ReplyBuffer, long ReplySize, long Timeout ) Library "icmp.dll" Alias for "IcmpSendEcho"
Function long IcmpCloseHandle (ulong IcmpHandle) Library "icmp.dll"
Function ulong inet_addr (string cp) Library "ws2_32.dll" Alias for "inet_addr"

代码:

ULong lul_address, lul_handle
Long ll_rc, ll_size
String ls_reply
icmp_echo_reply lstr_reply

lul_address = inet_addr(as_ipaddress)
If lul_address > 0 Then
lul_handle = IcmpCreateFile()
ll_size = Len(as_echomsg)
ll_rc = IcmpSendEcho(lul_handle, lul_address, &
as_echomsg, ll_size, 0, &
lstr_reply, 278, 200)
IcmpCloseHandle(lul_handle)
If ll_rc <> 0 Then
If lstr_reply.Status = 0 Then
ls_reply = String(lstr_reply.Data)
If ls_reply = as_echomsg Then
Return True
End If
End If
End If
End If

Return False

//True 表示PING成功,反之失败
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯