Detecting USB insertion/Removal in C++ non-GUI application

前端 未结 5 1539
独厮守ぢ
独厮守ぢ 2020-12-14 20:25

I want to detect insertion/removal of a specific (Custom) USB device through a C++ application which runs in background and has no GUI.

I have seen lot of questions

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 21:13

    Create a service first and in RegisterDeviceNotification, give the handle of that service instead of a window handle.

    Also adjust the third parameter of RegisterDeviceNotification accordingly.

提交回复
热议问题