Windows provides the ability to disable certain peripheral devices, such as USB ports, to save power (this behavior can be enabled / disabled using the device manager). The power turns off under various conditions, such as when the lid of a laptop is closed. This causes me a problem, since I have a GUI that talks about connecting to the USB port of the equipment, and the connection is disconnected every time the laptop lid closes. Is there a way to programmatically detect this power off event (standby?) Before it occurs and more gracefully disconnect my USB device? Is there a way to programmatically configure each of the system's USB ports to disable this behavior?
Now I am looking at SystemEvents.PowerModeChanged , is this the right event to detect this?
source share