12-03-2012 12:31 PM
I had the two DWORDs defined as I32s - probably because of MS's notes about returning the flag value of (-1). I ultimately promote the data to double, and substitute NaN for (-1).
I'm looking at the problem from a different angle. The call to GetPowerStatus in kernel32.dll seems to work OK for me. But the .NET event registration for the PowerModeChanged event only seems to fire on plug/unplug events. It doesn't fire when the battery percentage/lifetime values change. And since I don't poll, I'll only call to GetPowerStatus to update the battery percentage if the AC line changes - not good.
So on my Dell laptop, W7 x64, LV2011, the PowerModeChanged event doesn't fire to alert me to battery status changes, only AC changes.
12-03-2012 07:00 PM
Maybe it has something to do with the .net version.
i noticed that there is a comment about a message pump if you are writing a service With later versions.
LabVIEW should be a UI, but maybe this is part of the problem.
can you select a different version of the powermodechanged event?
12-03-2012 10:16 PM
This may give us a clue. The events version works perfectly in LV2012 and Win7 (so far) for monitoring the laptop power. The LEDs, the tank, and the Estimated time all seem to be updating correctly (don't know about the Low, Critical, and No Battery yet). It does not work for the USB connection to the APC UPS. Remember that the AC/DC and Charging indicators do work correctly for the APC ups under WIN XP and LV 2011, and the Estimated Time sort of works.
Soon I will check with the computer we will be using for our product as it is not a laptop so it doesn't have a battery. Also, it has LV 2011 on it (but it is running under Win 7 32-bit). If it does work I may table my investigations until I have more time. I will keep you all updated.
Thanks for all the help.