Search code examples
c++windowsusbconsole-applicationdetect

C++ Console Application Detect if a USB plugged in


Meanwhile I am working on some application with hardware interface connected over USB, so I would like to be notified if USB has been plugged in over some kind of event handler so I can connect to the device automatically.

Microsoft has an posted an Example about (Registering for Device Notification) https://msdn.microsoft.com/en-us/library/windows/desktop/aa363432%28v=vs.85%29.aspx

but according to the documentation. it does not work with Console Application. so which options are left?


Solution

  • Have a look at this thread

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/ef5a76cd-966b-4cf3-a05e-7b809918cedc/message-handling-in-a-console-app?forum=vcgeneral

    Problem is you have a messagequeue but it doesn't operate as within a windows app.