Hi all,
I have to write a simple program that will retrieve information about
the System Battery, So I was able to find this WinAPI function:
CallNtPowerInfo rmation
NTSTATUS CallNtPowerInfo rmation(
POWER_INFORMATI ON_LEVEL InformationLeve l,
PVOID lpInputBuffer,
ULONG nInputBufferSiz e,
PVOID lpOutputBuffer,
ULONG nOutputBufferSi ze
);
By setting Informationleve l to SystemBatterySt ate, The lpOutputBuffer
buffer receives a SYSTEM_BATTERY_ STATE structure containing information
about the current system battery.
I was to compile the program and link it successfully; however when i
output all the members of the SYSTEM_BATTERY_ STATE structure I am not
getting anything. Here is
the code:
#include <windows.h>
#include <powrprof.h>
#include <WinDef.h>
void main()
{
NTSTATUS power_informati on;
SYSTEM_BATTERY_ STATE sys_bat_state;
power_informati on = CallNtPowerInfo rmation(SystemB atteryState, NULL, 0,
&sys_bat_sta te, sizeof(sys_bat_ state));
printf("Battery Present: \n", sys_bat_state.B atteryPresent);
printf("Chargin g: \n", sys_bat_state.C harging);
printf("Dischar ging: \n", sys_bat_state.D ischarging);
printf("Maxcapa city: \n", sys_bat_state.M axCapacity);
printf("Remaini ngCapacity: \n", sys_bat_state.R emainingCapacit y);
printf("Rate: \n", sys_bat_state.R ate);
system("PAUSE") ;
}
I did add the libpowrprof.a already and the program is linking
successfully.
Any ideas?
Thanks
I have to write a simple program that will retrieve information about
the System Battery, So I was able to find this WinAPI function:
CallNtPowerInfo rmation
NTSTATUS CallNtPowerInfo rmation(
POWER_INFORMATI ON_LEVEL InformationLeve l,
PVOID lpInputBuffer,
ULONG nInputBufferSiz e,
PVOID lpOutputBuffer,
ULONG nOutputBufferSi ze
);
By setting Informationleve l to SystemBatterySt ate, The lpOutputBuffer
buffer receives a SYSTEM_BATTERY_ STATE structure containing information
about the current system battery.
I was to compile the program and link it successfully; however when i
output all the members of the SYSTEM_BATTERY_ STATE structure I am not
getting anything. Here is
the code:
#include <windows.h>
#include <powrprof.h>
#include <WinDef.h>
void main()
{
NTSTATUS power_informati on;
SYSTEM_BATTERY_ STATE sys_bat_state;
power_informati on = CallNtPowerInfo rmation(SystemB atteryState, NULL, 0,
&sys_bat_sta te, sizeof(sys_bat_ state));
printf("Battery Present: \n", sys_bat_state.B atteryPresent);
printf("Chargin g: \n", sys_bat_state.C harging);
printf("Dischar ging: \n", sys_bat_state.D ischarging);
printf("Maxcapa city: \n", sys_bat_state.M axCapacity);
printf("Remaini ngCapacity: \n", sys_bat_state.R emainingCapacit y);
printf("Rate: \n", sys_bat_state.R ate);
system("PAUSE") ;
}
I did add the libpowrprof.a already and the program is linking
successfully.
Any ideas?
Thanks
Comment