I'm using the code from this answer: Win32 API function to programmatically enable/disable device
The code works, but sort of. It only succesfully enables the device if it has previously been disabled by the same code. If the device is "disabled" before the program starts, it can not successfully enable it, but it doesn't throw any exceptions. The code runs normally, I see a "refresh" in my device manager, but it's still disabled.
Only when I manually enable the device first, the code can successfully disable and enable it. Is there any way to properly use this excellent piece of code in a way that starts with a disabled device?
It's probably something small, but I can't see it.