public void DeleteHibernationFile() { IntPtr inbool = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Int32))); Marshal.WriteInt32(inbool, 0); NativePowrProfInterop.CallNtPowerInformation( (int)InformationLevel.SystemReserveHiberFile, inbool, 0, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(SystemPowerInformation)) ); }
public SystemPowerInformation GetSystemPowerInformation() { IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(SystemPowerInformation))); NativePowrProfInterop.CallNtPowerInformation( (int)InformationLevel.SystemPowerInformation, IntPtr.Zero, 0, status, (uint)Marshal.SizeOf(typeof(SystemPowerInformation)) ); var spi = (SystemPowerInformation)Marshal.PtrToStructure(status, typeof(SystemPowerInformation)); return(spi); }
public SystemBatteryState GetSystemBatteryState() { IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(SystemBatteryState))); NativePowrProfInterop.CallNtPowerInformation( (int)InformationLevel.SystemBatteryState, (IntPtr)null, 0, status, (uint)Marshal.SizeOf(typeof(SystemBatteryState)) ); SystemBatteryState sbs = (SystemBatteryState)Marshal.PtrToStructure(status, typeof(SystemBatteryState)); return(sbs); }
public ulong GetLastWakeTime() { IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(ulong))); NativePowrProfInterop.CallNtPowerInformation( (int)InformationLevel.LastWakeTime, (IntPtr)null, 0, status, (uint)Marshal.SizeOf(typeof(SystemBatteryState)) ); ulong lwt = (ulong)Marshal.PtrToStructure(status, typeof(ulong)); return(lwt); }