数据库

本类阅读TOP10

·SQL语句导入导出大全
·SQL Server日期计算
·SQL语句导入导出大全
·SQL to Excel 的应用
·Oracle中password file的作用及说明
·MS SQLServer OLEDB分布式事务无法启动的一般解决方案
·sqlserver2000数据库置疑的解决方法
·一个比较实用的大数据量分页存储过程
·如何在正运行 SQL Server 7.0 的服务器之间传输登录和密码
·SQL中两台服务器间使用连接服务器

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
如何在PB中编写PING代码?(改编)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

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




相关文章

相关软件