I'm trying to access the "TimeRemaining" value for the power management idle counter. Google search indicates that lots of folks (including me) can get a value once, but every subsequent call gives the same results. No countdown, no change in CurIdle value...
Here's a short version of the code in question:
#include <windows.h>
#include <tchar.h>
#include <powrprof.h>
typedef struct _SYSTEM_POWER_INFORMATION {
ULONG MaxIdlenessAllowed;
ULONG Idleness;
ULONG TimeRemaining;
UCHAR CoolingMode;
}SYSTEM_POWER_INFORMATION, *PSYSTEM_POWER_INFORMATION;
int _tmain(int argc, _TCHAR* argv[])
{
SYSTEM_POWER_INFORMATION spin;
CallNtPowerInformation(SystemPowerInformation,NULL,0,&spin,sizeof(SYSTEM_POWER_INFORMATION));
_tprintf(_T("MaxIdleness\t%d\t"),spin.MaxIdlenessAllowed);
_tprintf(_T("CurIdle\t%d\t"),spin.Idleness);
_tprintf(_T("TimeRemaining\t%d\n"),spin.TimeRemaining);
return 0;
}
When I run this from the command line, I always get the same values for MaxIdleness (which is to be expected), CurIdle (which should change) and TimeRemaining (which is always at the maximum value...understandable since I'm executing from the command line, but I get the same result if I put it in a batch file with sleep.exe in between or in a program that iterates with a "sleep" between each call to CallNtPowerInformation).
Can anyone send me a copy of example code that does show varying TimeRemaining and CurIdle values?