I have a Windows service that needs to be notified when a particular
device has been enabled or disabled. When either of those actions
happen, I have noticed that Windows broadcasts WM_DEVICECHANGE with a
wParam of DBT_DEVNODES_CHANGED.

Since services don't receive Windows messages, I understand that I
should be using RegisterDeviceNotification along with HandlerEx to
receive device notifications. However, the documentation for
RegisterDeviceNotification says that it only supports the
DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events, which doesn't
help me.

So my primary question is: How can my service be notified when a
device has been disabled or enabled?

Related questions:

1. I've heard that some people create a hidden window to receive
broadcast messages in cases like this. This sounds kind of weird to
me. What are the possible problems with this approach?

2. Also, can what I'm asking about be done from a Windows service with
WMI? If so, is there any sample code of WMI being used for this
purpose (in a service or otherwise)?

Much thanks,
-j