예제 #1
0
 /// <summary>
 /// Commits or decommits depending on <value>isReseving</value> the storage required to hold the hibernation image on the boot volume.
 /// </summary>
 /// <param name="isReseving">A value that indecates if the hibernate file should be removed or reserved.</param>
 private static void HandleHibernationFile(bool isReseving)
 {
     InteropPowerManagment.CallNtPowerInformationForWrite <byte>(PowerInformationLevel.SystemReserveHiberFile, buffer =>
     {
         Marshal.WriteByte(buffer, Convert.ToByte(isReseving));
     });
 }
예제 #2
0
        /// <summary>
        /// Gets System Power Information by PowerInformation level.
        /// </summary>
        /// <typeparam name="T">An output buffer type.</typeparam>
        /// <param name="powerLevel">Indicates power level information.</param>
        /// <returns>The output buffer result.</returns>
        private static T GetPowerInformation <T>(PowerInformationLevel powerLevel)
        {
            T powerInformation = default(T);

            InteropPowerManagment.CallNtPowerInformationForRead <SystemBatteryState>(
                powerLevel,
                buffer => powerInformation = Marshal.PtrToStructure <T>(buffer));

            return(powerInformation);
        }