Determining if a laptop has AC power

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey guys... we are preparing remote installations of Windows XP SP2 for 15k+
laptops... at issue is the AC power... we have been using the key:

HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\SysTray\Services

Historically, for us, a value of 30 means on AC, 31 means not on AC.

However, all of a sudden, as we reach final stages of development, we find
some machines aren't adhering to this... and multiple types of laptops.

Is there a BETTER key/method?

Thanks in advance.

(Long time listener, first time caller)
 
plug in & boot off a knoppix CD and it magically knows without lookin in
the hard drive or in windows registry if you're on battery or not.

windows somewhere tells me my laptops state of dock is unknown,
and wants me to tell it if its running on battery or not.
It's the only 'I don't know' checkbox I've ever seen auto configured.
 
Thanks for the reply. Unfortunately, that doesn't help me. If I was there
to place a CD in 15k+ drives, I'd be able to see if it was plugged in. I
need to have a registry key to be able to determine (scriptomatically) if it
has AC power or not. This will be an automated rollout. The end user just
puts the DVD in the drive, and off go all the updates...
 
Platform SDK: Hardware

GetSystemPowerStatus
The GetSystemPowerStatus function retrieves the power status of the system. The status indicates whether the system is running on AC or DC power, whether the battery is currently charging, and how much battery life remains.

BOOL GetSystemPowerStatus(
LPSYSTEM_POWER_STATUS lpSystemPowerStatus
);Parameters
lpSystemPowerStatus
[out] Pointer to a SYSTEM_POWER_STATUS structure that receives status information.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

See Also
Power Management Overview, Power Management Functions, SYSTEM_POWER_STATUS


Platform SDK Release: August 2001 What did you think of this topic?
Let us know. Order a Platform SDK CD Online
(U.S/Canada) (International)



Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

See Also
Power Management Overview, Power Management Functions, SYSTEM_POWER_STATUS
 
I was looking for a much simpler way... nothing as simple as a status in the
registry somewhere? I would hate to have to add more code to make this work.
Might have to just give a warning that it "should be plugged in", and hope
it is.

David Candy said:
Platform SDK: Hardware

GetSystemPowerStatus
The GetSystemPowerStatus function retrieves the power status of the system. The status indicates whether the system is running on AC or DC power, whether the battery is currently charging, and how much battery life remains.

BOOL GetSystemPowerStatus(
LPSYSTEM_POWER_STATUS lpSystemPowerStatus
);Parameters
lpSystemPowerStatus
[out] Pointer to a SYSTEM_POWER_STATUS structure that receives status information.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

See Also
Power Management Overview, Power Management Functions, SYSTEM_POWER_STATUS


Platform SDK Release: August 2001 What did you think of this topic?
Let us know. Order a Platform SDK CD Online
(U.S/Canada) (International)



Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

See Also
Power Management Overview, Power Management Functions, SYSTEM_POWER_STATUS


--
----------------------------------------------------------

Legacy said:
Thanks for the reply. Unfortunately, that doesn't help me. If I was there
to place a CD in 15k+ drives, I'd be able to see if it was plugged in. I
need to have a registry key to be able to determine (scriptomatically) if it
has AC power or not. This will be an automated rollout. The end user just
puts the DVD in the drive, and off go all the updates...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top