jhwsr
jhwsr
采纳率0%
2015-02-12 03:44

PB调用icmpcreatefile错误

在PB中调用icmpcreatefile()时错误error calling external function icmpcreatefile at line 16 in function wf_ping of object w_main

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • lzp_lrp WorldMobile 6年前

    看一下你的icmp.dll这个动态是否存在

    点赞 评论 复制链接分享
  • lzp_lrp WorldMobile 6年前

    如何在PB中编写PING代码?
    问题描述:
    如何在PB中编写PING代码?
    解决方案:
    声明外部函数:

    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成功,反之失败

    点赞 评论 复制链接分享

相关推荐