Ejemplo n.º 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))
                );
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }