Beispiel #1
0
        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))
                );
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public bool HIbernateSystem()
 {
     return(NativePowrProfInterop.SetSuspendState(false, false, false));
 }