如何在 win32 上检测数据卡连接和断开事件?

发布于 2024-07-26 02:34:44 字数 374 浏览 3 评论 0原文

我有一个数据卡,只要插入数据卡,我就会使用 wm_device_change 事件获取事件。

但我也想在我的数据连接实际连接到外部世界时获取事件。

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

数据卡是沃达电话数据卡,我正在尝试使用该数据卡进行浏览。 无论 SDK 是什么,操作系统应该在某个地方获取网络连接和断开事件,是否有任何方法可以访问操作系统正在获取的事件。 正如我在通知中看到的那样,Vodaphone 连接和 LAN 连接发生了变化。

数据卡是一种内置SIM卡的USB设备,可以通过GPRS上网。

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

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.

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.

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠魁 2024-08-02 02:34:44

要检测网络更改,您可以使用 NotifyAddrChange(0,0); 由于这是阻塞的,因此您将需要一个线程。 线程函数可以像“

while(true) {
  NotifyAddrChange(0,0);
  PostMessage(gHWnd, WM_APP,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.

帅气称霸 2024-08-02 02:34:44

当然,这取决于您的“数据卡”sdk 或驱动程序以及它们是否支持此类事件。

否则,我建议当您在 SDK 中调用“Connect”或“Disconnect”方法时,使用指示成功或以其他方式引发您自己的事件的任何返回值。

如果不知道这个数据卡是什么以及它连接到什么,那么我不知道如何更全面地回答您的问题。

Surely this would depend on your "Data Card" sdk or drivers and whether they support such an event.

Otherwise what I would suggest is that when you call the "Connect" or "Disconnect" methods within the SDK that you use any return value indicating suuccess or otherwise to raise your own event.

Without knowing what this data card is and what it is connecting to then I don't see how we can answer your question more fully.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文