CallNtPowerInformation (powrprof)
Last changed: -75.36.142.46

.
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:

<DllImport("powrprof.dll", SetLastError := True)> _
Private Shared Function CallNtPowerInformation(InformationLevel As Int32, lpInputBuffer As IntPtr, nInputBufferSize As UInt32, lpOutputBuffer As IntPtr, nOutputBufferSize As UInt32) As UInt32

End Function

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