H
HK
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:
CallNtPowerInformation
NTSTATUS CallNtPowerInformation(
POWER_INFORMATION_LEVEL InformationLevel,
PVOID lpInputBuffer,
ULONG nInputBufferSize,
PVOID lpOutputBuffer,
ULONG nOutputBufferSize
);
By setting Informationlevel to SystemBatteryState, 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_information;
SYSTEM_BATTERY_STATE sys_bat_state;
power_information = CallNtPowerInformation(SystemBatteryState, NULL, 0,
&sys_bat_state, sizeof(sys_bat_state));
printf("BatteryPresent: \n", sys_bat_state.BatteryPresent);
printf("Charging: \n", sys_bat_state.Charging);
printf("Discharging: \n", sys_bat_state.Discharging);
printf("Maxcapacity: \n", sys_bat_state.MaxCapacity);
printf("RemainingCapacity: \n", sys_bat_state.RemainingCapacity);
printf("Rate: \n", sys_bat_state.Rate);
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:
CallNtPowerInformation
NTSTATUS CallNtPowerInformation(
POWER_INFORMATION_LEVEL InformationLevel,
PVOID lpInputBuffer,
ULONG nInputBufferSize,
PVOID lpOutputBuffer,
ULONG nOutputBufferSize
);
By setting Informationlevel to SystemBatteryState, 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_information;
SYSTEM_BATTERY_STATE sys_bat_state;
power_information = CallNtPowerInformation(SystemBatteryState, NULL, 0,
&sys_bat_state, sizeof(sys_bat_state));
printf("BatteryPresent: \n", sys_bat_state.BatteryPresent);
printf("Charging: \n", sys_bat_state.Charging);
printf("Discharging: \n", sys_bat_state.Discharging);
printf("Maxcapacity: \n", sys_bat_state.MaxCapacity);
printf("RemainingCapacity: \n", sys_bat_state.RemainingCapacity);
printf("Rate: \n", sys_bat_state.Rate);
system("PAUSE");
}
I did add the libpowrprof.a already and the program is linking
successfully.
Any ideas?
Thanks