I'm trying to create a windows service to disable unwanted usb-devices and enable if it's allowed. To do so I need to monitor connect and disconnect events even for disabled devices.
Now I have the solution using wmi-events like this: Select * from __InstanceCreationEvent within 2 where TargetISA 'Win32_PnPDevice'
. However it uses CPU a lot and in my opinion will bother users on weak PCs.
I heard about WndProc but as far as I understood it works only for programs with gui (window), not for services.
All in all I need the event system that will not be such resource-intensive as wmi to avoid permanent CPU overload. I need only connect / disconnect events. It is not a problem to get full info about new / removed device.