[DllImport("powrprof.dll", SetLastError=true)]
private static extern UInt32 CallNtPowerInformation(
Int32 InformationLevel,
IntPtr lpInputBuffer,
UInt32 nInputBufferSize,
IntPtr lpOutputBuffer,
UInt32 nOutputBufferSize
);
Declare Function CallNtPowerInformation Lib "powrprof.dll" (TODO) As TODO
None.
Do you know one? Please contribute it!
None.
Please add some!
IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(SYSTEM_BATTERY_STATE)));
uint retval = CallNtPowerInformation(
5, // SystemBatteryState
(IntPtr)null,
0,
status,
(UInt32)Marshal.SizeOf(typeof(SYSTEM_BATTERY_STATE))
);
SYSTEM_BATTERY_STATE batt_status = (SYSTEM_BATTERY_STATE)Marshal.PtrToStructure(status, typeof(SYSTEM_BATTERY_STATE));