问题描述
我正在写检查USB设备,如果设备是可用的编缉进行拨号连接的应用程序。我使用 RASDIAL
来建立连接。不幸的是,如果我拔下USB电缆连接是没有得到断开或通知给用户。所以在这里
我在一个情况检查设备移除
。
I'm writing an application which check for my usb device and if the device is avialable make a dial-up connection. I use Rasdial
to establish the connection. Unfortunately if I remove the USB cable the connection is not getting disconnected or notified to the user. So hereI'm in a situation to check for the device removal
.
我计划运行我在系统托盘中的应用,并等待设备移除。我说得对吗?
I Planned to run my application in system tray and wait for the device removal. Am I right here?
如果是正确的如何使应用程序等设备删除,目前我的控制台应用程序退出时,一旦拨号连接而成。如何在Winapi32实现这一目标?我编码在C
If am right how to make the application wait for device removal, currently my console application exits once the dial-up connection is made. How to achieve this in Winapi32? Am coding it in C.
推荐答案
您窗口都可以办理 WM_DEVICECHANGE
广播消息时,东西已经改变诉说。如果您需要更详细的信息,请使用 RegisterDeviceNotification()
。
Your window can handle the WM_DEVICECHANGE
broadcast message to tell when something has changed. If you need more detailed information, use RegisterDeviceNotification()
.
使用系统通知区域对你使用这些方法的能力没有影响。它们都需要一个窗口来发送通知,但它可以保持隐藏。
Using the system notification area has no bearing on your ability to use these methods. They all require a window to send the notifications to, but it can be kept hidden.
这篇关于system_tray接收设备删除通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!