如何检测Win32上的数据卡连接和断开事件? [英] How to detect datacard connect and disconnect event on win32?

查看:60
本文介绍了如何检测Win32上的数据卡连接和断开事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据卡,一旦插入数据卡,我就会通过使用wm_device_change事件来获取事件.

I have a data card, as soon as I insert the data card, I am getting the events by using wm_device_change event.

但是当我的数据连接实际上连接到外部世界时,我也想获取事件.

But I also want to get event, when my data connect actually connects to the outside world.

我的意思是说,当我们单击数据卡的连接/断开按钮时,我想获取该事件.换句话说,我想知道何时建立和断开连接.

I mean to say, as soon as we click on connect/disconnect button of data card, I want to get the event. In other words, I want to know when connection is established and disconnected.

数据卡是Vodaphone数据卡,我正在尝试使用该数据卡进行浏览.无论使用哪种SDK,OS都应该在某个地方发生连接和网络断开事件,因此可以通过任何方法来访问该OS正在获得的事件.正如我在通知中看到的,Vodaphone连接和LAN连接的更改.

The data card is a Vodaphone data card and I am trying to browse using that data card. Whatever is the SDK, somewhere the OS should get the event of connection and disconnection to network is there any way to access that event which OS is getting. As I can see in notification the changes of Vodaphone connection and LAN connection.

数据卡是其中装有SIM卡的USB设备,可用于通过GPRS访问互联网.

Data card is a USB device having SIM within it, and can be used to access internet through GPRS.

如何在Win32 C/C ++程序中执行此操作?

How can I do this in a Win32 C/C++ program?

推荐答案

要检测网络更改,可以使用NotifyAddrChange(0,0);,因为这已阻止,因此需要一个线程.线程函数可以像

To detect a network change, you can use NotifyAddrChange(0,0); Since this is blocking, you will need a thread. The thread function can be as simple as

while(true) {
  NotifyAddrChange(0,0);
  PostMessage(gHWnd, WM_APP,0,0);
}

不要打扰已记录的异步行为.那根本行不通.

Don't bother with the documented asynchronous behavior. That simply doesn't work.

这篇关于如何检测Win32上的数据卡连接和断开事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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