system_tray to receive notifications of device removal

天大地大妈咪最大 提交于 2019-12-13 22:28:59

问题


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 here I'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?

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.


回答1:


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.



来源:https://stackoverflow.com/questions/11223562/system-tray-to-receive-notifications-of-device-removal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!