如何在PB里实现检测“在线”和“离线”状态?

hxf0 2003-08-30 04:01:14

具体点就是可以软件运行时检测本机已连接在网上还是没有,根据状态的不同分别有不同的处理...

谢谢!
...全文
81 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
eastpond 2003-09-01
  • 打赏
  • 举报
回复
例 子给你发了,去邮件收一下
eastpond 2003-09-01
  • 打赏
  • 举报
回复
声明两个结构呀
type ust_ip_option_information from structure
character ttl
character tos
character flags
character optionssize
long optionsdata
end type

type ust_icmp_echo_reply from structure
unsignedlong address
unsignedlong status
unsignedlong roundtriphome
unsignedinteger datasize
unsignedinteger reserved
unsignedlong datapointer
ust_ip_option_information options
character data[250]
end type
hxf0 2003-08-30
  • 打赏
  • 举报
回复
re:jerrymao
谢谢。
我试了,出现以下情况
function long IcmpCreateFile() library "icmp.dll" //外部函数声明这一行通不过
信息:error: c0001: illegal data type ; ust_icmp_echo_reply

希望在QQ上聊聊。 十分感激! QQ:75935457
纳米茶 2003-08-30
  • 打赏
  • 举报
回复
还有,需要声明两个窗口内结构
type ust_ip_option_information from structure
character ttl
character tos
character flags
character optionssize
long optionsdata
end type

type ust_icmp_echo_reply from structure
unsignedlong address
unsignedlong status
unsignedlong roundtriphome
unsignedinteger datasize
unsignedinteger reserved
unsignedlong datapointer
ust_ip_option_information options
character data[250]
end type
纳米茶 2003-08-30
  • 打赏
  • 举报
回复
需要wsock32.dll,icmp.dll
//////////声明外部函数
function long inet_addr(ref string addr) library "wsock32.dll"
function long IcmpCloseHandle(long IcmpHandle) library "icmp.dll"
function long IcmpSendEcho (long IcmpHandle,long DestinationAddress,string requestData,integer requestSize,long requestOption,ref ust_icmp_echo_reply replyBuffer,long replySize,long timeout ) library "icmp.dll"
function long IcmpCreateFile() library "icmp.dll"
/*
//////////
假设www.163.com是永远开着的。
函数名:f_network_ping
传入:as_ipaddr string
返回:boolean
//////////
*/
ulong lul_NetAddress
long ll_hFile,ll_ret
string ls_Message=Space(20)
ust_icmp_echo_reply preturn
lul_NetAddress=inet_addr(as_ipaddr)
IF lul_NetAddress=-1 THEN RETURN FALSE

ll_hFile=IcmpCreateFile()
IF ll_hFile = 0 THEN RETURN FALSE
ll_ret=IcmpSendEcho(ll_hFile,lul_NetAddress,ls_Message,Len(ls_Message),0,preturn,282,200)
IcmpCloseHandle(ll_hfile)
RETURN ll_ret > 0
////////////////////////////////////////
程序中进行判断:
boolean lb_connect
lb_connect = f_network_ping('www.163.com')
if lb_connect = true then
messagebox('','已经连接到internet!')
else
messagebox('','无法连接到internet!')
end if
eastpond 2003-08-30
  • 打赏
  • 举报
回复
发不了,附件有1.3M
hxf0 2003-08-30
  • 打赏
  • 举报
回复
re:eastpond
hxf_0@sohu.com
eastpond 2003-08-30
  • 打赏
  • 举报
回复
给个邮箱,给你例子
eastpond 2003-08-30
  • 打赏
  • 举报
回复
up
hxf0 2003-08-30
  • 打赏
  • 举报
回复
Re:jerrymao
是的。
纳米茶 2003-08-30
  • 打赏
  • 举报
回复
是不是连接到internet?

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧