How to determine whether the system is running on battery power?

I want to know that so that I can lower power consumption of my device
during that time. In Win32, there is GetSystemPowerStatus call that appears
to provide exactly what I need, but I can’t find an equivalent for WDM.

Thank you

You can register for a notification which tells you when it changes
between AC and battery, but there is no way to query the current state.
Look at the docs for ExCreateCallback, you want to register for
\Callback\PowerState.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Tuesday, November 23, 2004 12:35 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to determine whether the system is running on
battery power?

I want to know that so that I can lower power consumption of my device
during that time. In Win32, there is GetSystemPowerStatus call that
appears
to provide exactly what I need, but I can’t find an equivalent for WDM.

Thank you


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

What about ZwPowerInformation(SystemBatteryState, …)? Haven’t tried it but I guess GetSystemPowerStatus() has to have native counterpart. It’s a pity native API isn’t completely documented, yet.

BTW, PowerState callback is very useful tool when driver needs to be informed about power state changes.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Doron Holan[SMTP:xxxxx@windows.microsoft.com]
Reply To: Windows System Software Devs Interest List
Sent: Tuesday, November 23, 2004 10:12 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to determine whether the system is running on battery power?

You can register for a notification which tells you when it changes
between AC and battery, but there is no way to query the current state.
Look at the docs for ExCreateCallback, you want to register for
\Callback\PowerState.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Tuesday, November 23, 2004 12:35 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to determine whether the system is running on
battery power?

I want to know that so that I can lower power consumption of my device
during that time. In Win32, there is GetSystemPowerStatus call that
appears
to provide exactly what I need, but I can’t find an equivalent for WDM.

Thank you


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thank you. Based on keywords you provided I’ve found more information.
http://www.intel.com/mobile/resources/downloads/pdf/DDPower_Perf_Mngmnt.PDF
suggests to use undocumented ZwPowerInformation to get the current state.
Would it be a reasonable idea to use it, provided there is no alternative?

“Doron Holan” wrote in message
news:xxxxx@ntdev…
You can register for a notification which tells you when it changes
between AC and battery, but there is no way to query the current state.
Look at the docs for ExCreateCallback, you want to register for
\Callback\PowerState.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Tuesday, November 23, 2004 12:35 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to determine whether the system is running on
battery power?

I want to know that so that I can lower power consumption of my device
during that time. In Win32, there is GetSystemPowerStatus call that
appears
to provide exactly what I need, but I can’t find an equivalent for WDM.

Thank you


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The other thing you can do is to send an IRP to the Composite Battery
driver. You’ll get the current battery state back.


Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no rights.

“Ivan Bublikov” wrote in message
news:xxxxx@ntdev…
> Thank you. Based on keywords you provided I’ve found more information.
> http://www.intel.com/mobile/resources/downloads/pdf/DDPower_Perf_Mngmnt.PDF
> suggests to use undocumented ZwPowerInformation to get the current state.
> Would it be a reasonable idea to use it, provided there is no alternative?
>
>
> “Doron Holan” wrote in message
> news:xxxxx@ntdev…
> You can register for a notification which tells you when it changes
> between AC and battery, but there is no way to query the current state.
> Look at the docs for ExCreateCallback, you want to register for
> \Callback\PowerState.
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
> Sent: Tuesday, November 23, 2004 12:35 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] How to determine whether the system is running on
> battery power?
>
> I want to know that so that I can lower power consumption of my device
> during that time. In Win32, there is GetSystemPowerStatus call that
> appears
> to provide exactly what I need, but I can’t find an equivalent for WDM.
>
> Thank you
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

Do you mean sending IOCTL_BATTERY_QUERY_STATUS to compbatt.sys? If so, the
thing I’m missing is to how to open its device. Does it register a device
interface? I don’t seem to find it.

“Jake Oshins” wrote in message
news:xxxxx@ntdev…
> The other thing you can do is to send an IRP to the Composite Battery
> driver. You’ll get the current battery state back.
>
> –
> Jake Oshins
> Windows Kernel Group
>
> This posting is provided “AS IS” with no warranties, and confers no
rights.
>
>
> “Ivan Bublikov” wrote in message
> news:xxxxx@ntdev…
> > Thank you. Based on keywords you provided I’ve found more information.
> >
http://www.intel.com/mobile/resources/downloads/pdf/DDPower_Perf_Mngmnt.PDF
> > suggests to use undocumented ZwPowerInformation to get the current
state.
> > Would it be a reasonable idea to use it, provided there is no
alternative?
> >
> >
> > “Doron Holan” wrote in message
> > news:xxxxx@ntdev…
> > You can register for a notification which tells you when it changes
> > between AC and battery, but there is no way to query the current state.
> > Look at the docs for ExCreateCallback, you want to register for
> > \Callback\PowerState.
> >
> > d
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
> > Sent: Tuesday, November 23, 2004 12:35 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] How to determine whether the system is running on
> > battery power?
> >
> > I want to know that so that I can lower power consumption of my device
> > during that time. In Win32, there is GetSystemPowerStatus call that
> > appears
> > to provide exactly what I need, but I can’t find an equivalent for WDM.
> >
> > Thank you
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
>
>
>

No, it’s a static name:

L"\Device\CompositeBattery"


Jake Oshins
Windows Kernel Group

This posting is provided “AS IS” with no warranties, and confers no rights.

“Ivan Bublikov” wrote in message
news:xxxxx@ntdev…
> Do you mean sending IOCTL_BATTERY_QUERY_STATUS to compbatt.sys? If so, the
> thing I’m missing is to how to open its device. Does it register a device
> interface? I don’t seem to find it.
>
> “Jake Oshins” wrote in message
> news:xxxxx@ntdev…
>> The other thing you can do is to send an IRP to the Composite Battery
>> driver. You’ll get the current battery state back.
>>
>> –
>> Jake Oshins
>> Windows Kernel Group
>>
>> This posting is provided “AS IS” with no warranties, and confers no
> rights.
>>
>>
>> “Ivan Bublikov” wrote in message
>> news:xxxxx@ntdev…
>> > Thank you. Based on keywords you provided I’ve found more information.
>> >
> http://www.intel.com/mobile/resources/downloads/pdf/DDPower_Perf_Mngmnt.PDF
>> > suggests to use undocumented ZwPowerInformation to get the current
> state.
>> > Would it be a reasonable idea to use it, provided there is no
> alternative?
>> >
>> >
>> > “Doron Holan” wrote in message
>> > news:xxxxx@ntdev…
>> > You can register for a notification which tells you when it changes
>> > between AC and battery, but there is no way to query the current state.
>> > Look at the docs for ExCreateCallback, you want to register for
>> > \Callback\PowerState.
>> >
>> > d
>> >
>> > -----Original Message-----
>> > From: xxxxx@lists.osr.com
>> > [mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
>> > Sent: Tuesday, November 23, 2004 12:35 PM
>> > To: Windows System Software Devs Interest List
>> > Subject: [ntdev] How to determine whether the system is running on
>> > battery power?
>> >
>> > I want to know that so that I can lower power consumption of my device
>> > during that time. In Win32, there is GetSystemPowerStatus call that
>> > appears
>> > to provide exactly what I need, but I can’t find an equivalent for WDM.
>> >
>> > Thank you
>> >
>> >
>> > —
>> > Questions? First check the Kernel Driver FAQ at
>> > http://www.osronline.com/article.cfm?id=256
>> >
>> > You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
>> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>> >
>> >
>>
>>
>>
>
>

Thanks. But aren’t compbatt’s IOCTL interface and
“\Device\CompositeBattery” undocumented just like ZwPowerInformation? If
they are both undocumented, why would I choose to use compbatt instead of
ZwPowerInformation? Indeed, ZwPowerInformation looks more likely to stay,
since it appears to be a level of indirection on top of compbatt…

“Jake Oshins” wrote in message
news:xxxxx@ntdev…
> No, it’s a static name:
>
> L"\Device\CompositeBattery"
>
> –
> Jake Oshins
> Windows Kernel Group
>
> This posting is provided “AS IS” with no warranties, and confers no
rights.
>
>
> “Ivan Bublikov” wrote in message
> news:xxxxx@ntdev…
> > Do you mean sending IOCTL_BATTERY_QUERY_STATUS to compbatt.sys? If so,
the
> > thing I’m missing is to how to open its device. Does it register a
device
> > interface? I don’t seem to find it.
> >
> > “Jake Oshins” wrote in message
> > news:xxxxx@ntdev…
> >> The other thing you can do is to send an IRP to the Composite Battery
> >> driver. You’ll get the current battery state back.
> >>
> >> –
> >> Jake Oshins
> >> Windows Kernel Group
> >>
> >> This posting is provided “AS IS” with no warranties, and confers no
> > rights.
> >>
> >>
> >> “Ivan Bublikov” wrote in message
> >> news:xxxxx@ntdev…
> >> > Thank you. Based on keywords you provided I’ve found more
information.
> >> >
> >
http://www.intel.com/mobile/resources/downloads/pdf/DDPower_Perf_Mngmnt.PDF
> >> > suggests to use undocumented ZwPowerInformation to get the current
> > state.
> >> > Would it be a reasonable idea to use it, provided there is no
> > alternative?
> >> >
> >> >
> >> > “Doron Holan” wrote in message
> >> > news:xxxxx@ntdev…
> >> > You can register for a notification which tells you when it changes
> >> > between AC and battery, but there is no way to query the current
state.
> >> > Look at the docs for ExCreateCallback, you want to register for
> >> > \Callback\PowerState.
> >> >
> >> > d
> >> >
> >> > -----Original Message-----
> >> > From: xxxxx@lists.osr.com
> >> > [mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
> >> > Sent: Tuesday, November 23, 2004 12:35 PM
> >> > To: Windows System Software Devs Interest List
> >> > Subject: [ntdev] How to determine whether the system is running on
> >> > battery power?
> >> >
> >> > I want to know that so that I can lower power consumption of my
device
> >> > during that time. In Win32, there is GetSystemPowerStatus call that
> >> > appears
> >> > to provide exactly what I need, but I can’t find an equivalent for
WDM.
> >> >
> >> > Thank you
> >> >
> >> >
> >> > —
> >> > Questions? First check the Kernel Driver FAQ at
> >> > http://www.osronline.com/article.cfm?id=256
> >> >
> >> > You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com
> >> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >> >
> >> >
> >>
> >>
> >>
> >
> >
>
>
>

My final goal is to find out if there is reliable way to do what I need
without a risk that it will break with a next service pack or OS version.
I’m hoping that ZwPowerInformation (or any other method) is not documented
just by an oversight and is here to stay. If that is not so, then I’ll have
to tell my customer that it is not possible to do what they want.

“Ivan Bublikov” wrote in message news:…
> Thanks. But aren’t compbatt’s IOCTL interface and
> “\Device\CompositeBattery” undocumented just like ZwPowerInformation? If
> they are both undocumented, why would I choose to use compbatt instead of
> ZwPowerInformation? Indeed, ZwPowerInformation looks more likely to stay,
> since it appears to be a level of indirection on top of compbatt…
>
>
> “Jake Oshins” wrote in message
> news:xxxxx@ntdev…
> > No, it’s a static name:
> >
> > L"\Device\CompositeBattery"
> >
> > –
> > Jake Oshins
> > Windows Kernel Group
> >
> > This posting is provided “AS IS” with no warranties, and confers no
> rights.
> >
> >
> > “Ivan Bublikov” wrote in message
> > news:xxxxx@ntdev…
> > > Do you mean sending IOCTL_BATTERY_QUERY_STATUS to compbatt.sys? If so,
> the
> > > thing I’m missing is to how to open its device. Does it register a
> device
> > > interface? I don’t seem to find it.
> > >
> > > “Jake Oshins” wrote in message
> > > news:xxxxx@ntdev…
> > >> The other thing you can do is to send an IRP to the Composite Battery
> > >> driver. You’ll get the current battery state back.
> > >>
> > >> –
> > >> Jake Oshins
> > >> Windows Kernel Group
> > >>
> > >> This posting is provided “AS IS” with no warranties, and confers no
> > > rights.
> > >>
> > >>
> > >> “Ivan Bublikov” wrote in message
> > >> news:xxxxx@ntdev…
> > >> > Thank you. Based on keywords you provided I’ve found more
> information.
> > >> >
> > >
>
http://www.intel.com/mobile/resources/downloads/pdf/DDPower_Perf_Mngmnt.PDF
> > >> > suggests to use undocumented ZwPowerInformation to get the current
> > > state.
> > >> > Would it be a reasonable idea to use it, provided there is no
> > > alternative?
> > >> >
> > >> >
> > >> > “Doron Holan” wrote in message
> > >> > news:xxxxx@ntdev…
> > >> > You can register for a notification which tells you when it changes
> > >> > between AC and battery, but there is no way to query the current
> state.
> > >> > Look at the docs for ExCreateCallback, you want to register for
> > >> > \Callback\PowerState.
> > >> >
> > >> > d
> > >> >
> > >> > -----Original Message-----
> > >> > From: xxxxx@lists.osr.com
> > >> > [mailto:xxxxx@lists.osr.com] On Behalf Of Ivan
Bublikov
> > >> > Sent: Tuesday, November 23, 2004 12:35 PM
> > >> > To: Windows System Software Devs Interest List
> > >> > Subject: [ntdev] How to determine whether the system is running on
> > >> > battery power?
> > >> >
> > >> > I want to know that so that I can lower power consumption of my
> device
> > >> > during that time. In Win32, there is GetSystemPowerStatus call that
> > >> > appears
> > >> > to provide exactly what I need, but I can’t find an equivalent for
> WDM.
> > >> >
> > >> > Thank you
> > >> >
> > >> >
> > >> > —
> > >> > Questions? First check the Kernel Driver FAQ at
> > >> > http://www.osronline.com/article.cfm?id=256
> > >> >
> > >> > You are currently subscribed to ntdev as:
> xxxxx@windows.microsoft.com
> > >> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >
> > >
> >
> >
> >
>