private bool HibernateFile(HibernateFileActions action)
        {
            var    boolSize = Marshal.SizeOf <bool>();
            IntPtr intPtr   = Marshal.AllocCoTaskMem(boolSize);

            Marshal.WriteByte(intPtr, (byte)action);

            var result = PowerManagementConfiguration.CallNtPowerInformation(PowerInformationLevel.SystemReserveHiberFile,
                                                                             intPtr,
                                                                             boolSize,
                                                                             IntPtr.Zero,
                                                                             0);

            return(result == PowerInformationStatus.Success);
        }
        private bool HibernateFileAction(HibernateFileActions fileActions)
        {
            var    intSize = Marshal.SizeOf <bool>();
            IntPtr intPtr  = Marshal.AllocCoTaskMem(intSize);

            Marshal.WriteByte(intPtr, (byte)fileActions);

            var retval = PowerManagementConfiguration.CallNtPowerInformation(
                InformationLevelConstants.SYSTEM_RESERVE_HIBER_FILE,
                fileActions == HibernateFileActions.Reserve,
                Marshal.SizeOf <bool>(),
                IntPtr.Zero,
                0);

            return(retval == InformationLevelConstants.STATUS_SUCCESS);
        }