捕获网络状态更改事件 [英] Capturing network status change event

查看:196
本文介绍了捕获网络状态更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在互联网连接重新建立后丢失时获取事件。它是一个我正在开发的数据传输软件。如果在数据传输期间丢失网络,我希望在系统回来时收到通知,并自动继续传输。

I am trying to get events when the internet connection is reestablished after it is lost. It is for a data transfer software that I am developing. If I lose the network during data transfer, I would like to be notified when it is back and continue the transfer automatically.

我当然可以创建一个单独的线程和检查

I can of course create a separate thread and check the network once in a while with a timer, but maybe there is a better option out there.

我主要在C ++(不是.net)中开发Windows。

I am developing for windows mainly, in C++ (not .net).

我也可以使用wxwidgets(我使用它为GUI),但我怀疑它提供任何相关的功能。

I can also use wxwidgets (I use it for GUI) but I doubt it offers any related functionality.

推荐答案

您可能想查看系统事件通知服务器(SENS)API http://msdn.microsoft.com/en-us/library/cc185680(VS.85).aspx

You might want to check out the System Event Notification Server (SENS) API http://msdn.microsoft.com/en-us/library/cc185680(VS.85).aspx

我没有实际使用它,但它似乎提供您寻找的事件。

I have not actually used it, but it seems like it supplies the events your looking for.

编辑:

WMI似乎具有关于各种网络连接和状态更改所需的所有信息。它还有一个异步事件模型,可用于获取通知。诀窍是,我想,生成正确的WMI查询,以获得您想要的信息。此 blog 看起来像正确的查询类型,此 MSDN 说明如何异步处理事件。

WMI appears to have all the information you need about various network connectivity and state changes. It also has an asynchronous event model that can be used to get notifications. The trick is, i suppose, generating the proper WMI query to get the information you want. This blog looks like the right type of query, and this MSDN explains how to handle the events asynchronously.

这篇关于捕获网络状态更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆