如何得到网络连接或连接失败的消息?

yansea 2003-11-07 05:04:15
具体内容是这样的,我需要捕获当网络连接开启或失败的消息,以便程序处理。
比如机器断网/上网时候触发的消息(这方面不是很了解,应该是个消息吧)。
请各位不吝赐教。
...全文
179 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
yansea 2003-11-21
  • 打赏
  • 举报
回复
^
aiirii 2003-11-20
  • 打赏
  • 举报
回复
每日一顶
pdbird 2003-11-14
  • 打赏
  • 举报
回复
我也想知道,关注中
yansea 2003-11-14
  • 打赏
  • 举报
回复
每日一顶
XGZ 2003-11-13
  • 打赏
  • 举报
回复
你查一下有没有网络连接方面的api(就是系统也是调用它得到网络的状况),如果有你hook掉,以求都解决了,如果没有只有看看有没有系统消息了
aiirii 2003-11-13
  • 打赏
  • 举报
回复
dll???亂說???
在msdn上有一篇文章說到, 應該是解決方法!我昨晚花了一個小時, 想改成delphi的, 有點問題, 還改不成, 但可先看看, 如果你滿足于VC的解決方法, 那已經有了!

ISensNetwork

The ISensNetwork interface handles network events fired by the System Event Notification Service (SENS).


When To Implement
Implement this interface on your sink object if you subscribe to any of the SENS network events. Each event corresponds to a method in this interface. This interface is an outgoing interface defined by SENS and implemented by the subscriber application as a dispatch interface.

When To Use
SENS and the COM Event System call the ISensNetwork methods on your sink object to fire the corresponding event.

Methods in Vtable Order
The ISensNetwork interface inherits the methods of the standard COM interface IUnknown.

In addition, ISensNetwork defines the following methods.

Method Description
GetTypeInfoCount Retrieves the number of type descriptions.
GetTypeInfo Retrieves a description of the object's programmable interface.
GetIDsOfNames Maps name of method or property to DISPID.
Invoke Calls one of the object's methods, or gets/sets one of its properties.
ConnectionMade Specified connection has been established.
ConnectionMadeNoQOCInfo Specified connection has been established with no Quality of Connection information available.
ConnectionLost Specified connection has been dropped.
DestinationReachable Specified connection can be reached.
DestinationReachableNoQOCInfo Specified connection can be reached with no Quality of Connection information.

Requirements
Client: Included in Windows XP, Windows 2000 Professional, and Windows Me.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Internet Explorer 5 or later on Windows NT 4.0 and Windows 95/98.
Header: Declared in Sensevts.h.
Library: Use Sensevts.tlb.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/syncmgr/syncmgr/isensnetwork.asp


yansea 2003-11-13
  • 打赏
  • 举报
回复
多谢各位咯,不过e文看的是在费力……这次不看也不成了。
若能有好办法一定告诉大家。
yansea 2003-11-12
  • 打赏
  • 举报
回复
dll怎么讲?自己顶。
yansea 2003-11-11
  • 打赏
  • 举报
回复
有结果了一定要告诉我啊~~~
wqtc1016 2003-11-11
  • 打赏
  • 举报
回复
dll可以吗?
aiirii 2003-11-11
  • 打赏
  • 举报
回复
繼續關注....
aiirii 2003-11-11
  • 打赏
  • 举报
回复
繼續關注, 我也在新聞組關注中!!
aiirii 2003-11-10
  • 打赏
  • 举报
回复
>>我希望断网/上网的时候能截获系统的通知。
有的, 但如何得到, 我在探索中!!
winder_008 2003-11-10
  • 打赏
  • 举报
回复
关注中...
yansea 2003-11-10
  • 打赏
  • 举报
回复
但是我不能一直判断啊,我希望断网/上网的时候能截获系统的通知。
应该有这个通知吧,比如网络问题,供应商问题等,只要不能连接internet的都要处理,有什么好办法?
wqtc1016 2003-11-08
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
begin
//SM_NETWORK标志值为1,则表示计算机连上了网络;值为0,则表示计算机沿未连接网络
if GetSystemMetrics(SM_NETWORK) AND $01=$01 then
showmessage('连上了网络')
else
showmessage('尚未连上网络');
end;
lxhong1980 2003-11-08
  • 打赏
  • 举报
回复
关注
aiirii 2003-11-07
  • 打赏
  • 举报
回复
關注此問題很久!!! 等待答案中...

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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