Is there any documented way to programmatically change the power state of a
device (i.e. power off or power on) from usermode? (I'm not particularly
knowledgeable about programmatically controlling power management...)

In particular, I'm looking to be able to power on or power off an arbitrary
USB or 1394 device (i.e. not a device I wrote the driver for). For example,
I might have an externally powered USB or 1394 device that is attached to a
battery backup system that is separate from the battery backup system the
computer is on. I can determine whether the battery backup system that the
external device is on is low on power or not, but I need a way to gracefully
shutdown the appropriate device before an impending power loss. Because the
computer itself is on a different battery system (say for the sake of
argument that it is a higher capacity battery system), I don't want (or
need) to shut down the computer entirely, just the affected devices.

Assume for the moment that I have control over any applications that might
be using said devices and can make sure that they relinquish usage before I
try to shutdown the device.

One option I see is to request a graceful device removal (e.g.
CM_Request_Device_Eject_Ex), since the devices are going to be on a
hotpluggable bus, but this seems suboptimal for what I'm looking for.

Re: Programmatically power up or down a particular device [on a hotplug bus] by Maxim

Maxim
Fri Apr 07 19:50:02 CDT 2006

Normally, only the device power policy owner decides when to change the
device's power state. The sources from which the PPO deduces its decisions are
usually a) global system power state change notifications via a system power
IRP b) idle time detection c) all children powered down.

You can add a filter driver to the stack which will only do some more PPO
work (like powering down the device is some battery is low) and not influence
any other stuff, but I envision some sync issues in 2 PPOs operating on the
same stack.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Skywing" <skywing_NO_SPAM_@valhallalegends.com> wrote in message
news:e6JwmypWGHA.4620@TK2MSFTNGP04.phx.gbl...
> Is there any documented way to programmatically change the power state of a
> device (i.e. power off or power on) from usermode? (I'm not particularly
> knowledgeable about programmatically controlling power management...)
>
> In particular, I'm looking to be able to power on or power off an arbitrary
> USB or 1394 device (i.e. not a device I wrote the driver for). For example,
> I might have an externally powered USB or 1394 device that is attached to a
> battery backup system that is separate from the battery backup system the
> computer is on. I can determine whether the battery backup system that the
> external device is on is low on power or not, but I need a way to gracefully
> shutdown the appropriate device before an impending power loss. Because the
> computer itself is on a different battery system (say for the sake of
> argument that it is a higher capacity battery system), I don't want (or
> need) to shut down the computer entirely, just the affected devices.
>
> Assume for the moment that I have control over any applications that might
> be using said devices and can make sure that they relinquish usage before I
> try to shutdown the device.
>
> One option I see is to request a graceful device removal (e.g.
> CM_Request_Device_Eject_Ex), since the devices are going to be on a
> hotpluggable bus, but this seems suboptimal for what I'm looking for.
>
>


Re: Programmatically power up or down a particular device [on a hotplug by Ray

Ray
Mon Apr 10 12:00:14 CDT 2006

Another problem is that I don't think there's any general way to turn
off power to a particular USB device. Host controllers and hubs
generally don't have that functionality to the best of my knowledge.

And "removing" the device just uninstalls the driver and makes the
device unavailable to Windows. It doesn't power it off.

Now if the OP has devices of their own design that can be commanded to
power themselves off, that's a different matter, but it doesn't sound
like that's the case.

Maxim S. Shatskih wrote:
> Normally, only the device power policy owner decides when to change the
> device's power state. The sources from which the PPO deduces its decisions are
> usually a) global system power state change notifications via a system power
> IRP b) idle time detection c) all children powered down.
>
> You can add a filter driver to the stack which will only do some more PPO
> work (like powering down the device is some battery is low) and not influence
> any other stuff, but I envision some sync issues in 2 PPOs operating on the
> same stack.
>


--
Ray