CallNtPowerInformation (powrprof)
Last changed: zkonstantin3@gmail.com-86.57.255.92

.
Summary
TODO - a short description

C# Signature:

[DllImport("powrprof.dll", SetLastError=true)]

private static extern UInt32 CallNtPowerInformation(
     Int32 InformationLevel,
     IntPtr lpInputBuffer,
     UInt32 nInputBufferSize,
     IntPtr lpOutputBuffer,
     UInt32 nOutputBufferSize
     );

VB Signature:

Declare Function CallNtPowerInformation Lib "powrprof.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

  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));

Documentation