private static extern uint CallNtPowerInformation( PowerIinformationLevel InformationLevel, IntPtr lpInputBuffer, int nInputBufferSize, IntPtr result, int nOutputBufferSize );
private static T Wrapper <T>(PowerIinformationLevel informationLevel) { int size = Marshal.SizeOf <T>(); IntPtr typePtr = Marshal.AllocCoTaskMem(size); uint status = CallNtPowerInformation(informationLevel, IntPtr.Zero, 0, typePtr, size); if (status != STATUS_SUCCESS) { return(default(T)); } return(Marshal.PtrToStructure <T>(typePtr)); }