using System.Collections.Generic;
namespace Vanara.PInvoke;
public static partial class PowrProf
{
/// An application's DeviceNotifyCallbackRoutine callback function is used for receiving power notifications.
/// The context provided when registering for the power notification.
/// The type of power event that caused this notification.
/// The value of this parameter depends on the type of notification subscribed to.
/// This function returns a Windows error code.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nc-powrprof-device_notify_callback_routine
// DEVICE_NOTIFY_CALLBACK_ROUTINE DeviceNotifyCallbackRoutine; ULONG DeviceNotifyCallbackRoutine( PVOID Context, ULONG Type, PVOID
// Setting ) {...}
[PInvokeData("powrprof.h", MSDNShortId = "5734FDEE-E330-4115-AFA5-725114023A5A")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate Win32Error DeviceNotifyCallbackRoutine(IntPtr Context, uint Type, IntPtr Setting);
/// A callback function to be called for each power scheme enumerated in .
///
///
///
///
///
/// The power policy scheme.
///
///
/// To continue until all power schemes have been enumerated, the callback function must return TRUE. To stop the enumeration, the
/// callback function must return FALSE.
///
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.U1)]
public delegate bool PWRSCHEMESENUMPROC(uint uiIndex, uint dwName, string sName, uint dwDesc, string sDesc, in POWER_POLICY pp, IntPtr lParam);
private delegate Win32Error PwrReadMemFunc(HKEY h, IntPtr a, IntPtr b, IntPtr c, IntPtr d, ref uint e);
/// The global flags constants are used to enable or disable user power policy options.
[PInvokeData("powrprof.h", MSDNShortId = "0e89ae66-a889-4929-b028-125fcef5c89c")]
[Flags]
public enum GlobalFlags : uint
{
/// Enables or disables multiple battery display in the system Power Meter.
EnableMultiBatteryDisplay = 0x02,
/// Enables or disables requiring password logon when the system resumes from standby or hibernate.
EnablePasswordLogon = 0x04,
///
/// Enables or disables the battery meter icon in the system tray. When this flag is cleared, the battery meter icon is not displayed.
///
EnableSysTrayBatteryMeter = 0x01,
///
/// Enables or disables support for dimming the video display when the system changes from running on AC power to running on
/// battery power.
///
EnableVideoDimDisplay = 0x10,
/// Enables or disables wake on ring support.
EnableWakeOnRing = 0x08,
}
///
/// These flags tell us how to interpret a query of device power. Use these (or a combination of these) for the
/// QueryInterpretationFlags parameter sent into DevicePowerEnumDevices().
///
[PInvokeData("powrprof.h", MSDNShortId = "bb67634c-69d9-4194-ac27-4f9740d73a1a")]
[Flags]
public enum PDQUERY : uint
{
/// Return a hardware ID string rather than friendly device name.
DEVICEPOWER_HARDWAREID = 0x80000000,
/// Ignore devices not currently present in the system.
DEVICEPOWER_FILTER_DEVICES_PRESENT = 0x20000000,
/// Perform an AND operation on QueryFlags.
DEVICEPOWER_AND_OPERATION = 0x40000000,
/// Check whether the device is currently enabled to wake the system from a sleep state.
DEVICEPOWER_FILTER_WAKEENABLED = 0x08000000,
/// Find a device whose name matches the string passed in pReturnBuffer and check its capabilities against QueryFlags.
DEVICEPOWER_FILTER_ON_NAME = 0x02000000,
/// Only preform the query on devices that are actual hardware.
DEVICEPOWER_FILTER_HARDWARE = 0x10000000,
/// Only preform the query on devices that are capable of being programmed to wake the system from a sleep state.
DEVICEPOWER_FILTER_WAKEPROGRAMMABLE = 0x04000000,
}
/// Flags for .
[PInvokeData("powrprof.h", MSDNShortId = "300842ae-d7d4-42c2-959c-e1713f466d32")]
[Flags]
public enum PDSET
{
/// Enables the specified device to wake the system.
DEVICEPOWER_SET_WAKEENABLED = 0x00000001,
/// Stops the specified device from being able to wake the system.
DEVICEPOWER_CLEAR_WAKEENABLED = 0x00000002,
}
/// Power attributes.
[PInvokeData("powrprof.h", MSDNShortId = "9f430da2-7c8d-43e2-ab8a-d9af1bb7538f")]
[Flags]
public enum POWER_ATTR
{
/// Hide this power setting.
POWER_ATTRIBUTE_HIDE = 0x00000001,
/// Undocumented.
POWER_ATTRIBUTE_SHOW_AOAC = 0x00000002
}
/// Enumeration values used by PowerEnumerate and PowerSettingAccessCheck.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ne-powrprof-_power_data_accessor typedef enum _POWER_DATA_ACCESSOR {
// ACCESS_AC_POWER_SETTING_INDEX, ACCESS_DC_POWER_SETTING_INDEX, ACCESS_FRIENDLY_NAME, ACCESS_DESCRIPTION,
// ACCESS_POSSIBLE_POWER_SETTING, ACCESS_POSSIBLE_POWER_SETTING_FRIENDLY_NAME, ACCESS_POSSIBLE_POWER_SETTING_DESCRIPTION,
// ACCESS_DEFAULT_AC_POWER_SETTING, ACCESS_DEFAULT_DC_POWER_SETTING, ACCESS_POSSIBLE_VALUE_MIN, ACCESS_POSSIBLE_VALUE_MAX,
// ACCESS_POSSIBLE_VALUE_INCREMENT, ACCESS_POSSIBLE_VALUE_UNITS, ACCESS_ICON_RESOURCE, ACCESS_DEFAULT_SECURITY_DESCRIPTOR,
// ACCESS_ATTRIBUTES, ACCESS_SCHEME, ACCESS_SUBGROUP, ACCESS_INDIVIDUAL_SETTING, ACCESS_ACTIVE_SCHEME, ACCESS_CREATE_SCHEME,
// ACCESS_AC_POWER_SETTING_MAX, ACCESS_DC_POWER_SETTING_MAX, ACCESS_AC_POWER_SETTING_MIN, ACCESS_DC_POWER_SETTING_MIN,
// ACCESS_PROFILE, ACCESS_OVERLAY_SCHEME, ACCESS_ACTIVE_OVERLAY_SCHEME } POWER_DATA_ACCESSOR, *PPOWER_DATA_ACCESSOR;
[PInvokeData("powrprof.h", MSDNShortId = "4b3f8f89-2ade-4594-b055-b1873e74cda6")]
public enum POWER_DATA_ACCESSOR
{
/// Used with PowerSettingAccessCheck to check for group policy overrides for AC power settings.
ACCESS_AC_POWER_SETTING_INDEX,
/// Used with PowerSettingAccessCheck to check for group policy overrides for DC power settings.
ACCESS_DC_POWER_SETTING_INDEX,
///
ACCESS_FRIENDLY_NAME,
///
ACCESS_DESCRIPTION,
///
ACCESS_POSSIBLE_POWER_SETTING,
///
ACCESS_POSSIBLE_POWER_SETTING_FRIENDLY_NAME,
///
ACCESS_POSSIBLE_POWER_SETTING_DESCRIPTION,
///
ACCESS_DEFAULT_AC_POWER_SETTING,
///
ACCESS_DEFAULT_DC_POWER_SETTING,
///
ACCESS_POSSIBLE_VALUE_MIN,
///
ACCESS_POSSIBLE_VALUE_MAX,
///
ACCESS_POSSIBLE_VALUE_INCREMENT,
///
ACCESS_POSSIBLE_VALUE_UNITS,
///
ACCESS_ICON_RESOURCE,
///
ACCESS_DEFAULT_SECURITY_DESCRIPTOR,
///
ACCESS_ATTRIBUTES,
///
/// Used to enumerate power schemes with PowerEnumerate and with PowerSettingAccessCheck to check for restricted access to
/// specific power schemes.
///
ACCESS_SCHEME,
/// Used to enumerate subgroups with PowerEnumerate.
ACCESS_SUBGROUP,
/// Used to enumerate individual power settings with PowerEnumerate.
ACCESS_INDIVIDUAL_SETTING,
/// Used with PowerSettingAccessCheck to check for group policy overrides for active power schemes.
ACCESS_ACTIVE_SCHEME,
/// Used with PowerSettingAccessCheck to check for restricted access for creating power schemes.
ACCESS_CREATE_SCHEME,
///
ACCESS_AC_POWER_SETTING_MAX,
///
ACCESS_DC_POWER_SETTING_MAX,
///
ACCESS_AC_POWER_SETTING_MIN,
///
ACCESS_DC_POWER_SETTING_MIN,
///
ACCESS_PROFILE,
///
ACCESS_OVERLAY_SCHEME,
///
ACCESS_ACTIVE_OVERLAY_SCHEME,
}
///
///
/// [ CanUserWritePwrScheme is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. Applications written for Windows Vista and later should use
/// PowerSettingAccessCheck instead.]
///
/// Determines whether the current user has sufficient privilege to write a power scheme.
///
///
/// If the current user has sufficient privilege to write a power scheme, the function returns TRUE.
///
/// If the function fails, the return value is zero. To get extended error information, call GetLastError. Possible error values
/// include the following.
///
///
///
/// Error
/// Meaning
///
/// -
/// ERROR_ACCESS_DENIED
/// The current user does not have sufficient privilege to write a power scheme.
///
///
///
///
/// This function is useful if your application is impersonating a user.
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-canuserwritepwrscheme BOOLEAN CanUserWritePwrScheme( );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "3989da98-aa01-4c63-a74c-ce7ba18278c1")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool CanUserWritePwrScheme();
///
///
/// [ DeletePwrScheme is available for use in the operating systems specified in the Requirements section. It may be altered
/// or unavailable in subsequent versions. Applications written for Windows Vista and later should use PowerDeleteScheme instead.]
///
/// Deletes the specified power scheme.
///
/// The index of the power scheme to be deleted.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// Applications can call DeletePwrScheme to permanently delete a power scheme. An attempt to delete the currently active
/// power scheme fails with the last error set to ERROR_ACCESS_DENIED.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-deletepwrscheme BOOLEAN DeletePwrScheme( UINT uiID );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "c9513835-00c4-4260-a8b6-d947539c9dd1")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool DeletePwrScheme(uint uiID);
/// Frees all nodes in the device list and destroys the device list.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-devicepowerclose BOOLEAN DevicePowerClose( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "60f871bc-08b7-41d1-ba37-688ab68fb9b3")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool DevicePowerClose();
/// Enumerates devices on the system that meet the specified criteria.
/// The index of the requested device. For initial calls, this value should be zero.
///
/// The criteria applied to the search results.
///
///
/// Value
/// Meaning
///
/// -
/// DEVICEPOWER_HARDWAREID 0x80000000
/// Return a hardware ID string rather than friendly device name.
///
/// -
/// DEVICEPOWER_FILTER_DEVICES_PRESENT 0x20000000
/// Ignore devices not currently present in the system.
///
/// -
/// DEVICEPOWER_AND_OPERATION 0x40000000
/// Perform an AND operation on QueryFlags.
///
/// -
/// DEVICEPOWER_FILTER_WAKEENABLED 0x08000000
/// Check whether the device is currently enabled to wake the system from a sleep state.
///
/// -
/// DEVICEPOWER_FILTER_ON_NAME 0x02000000
/// Find a device whose name matches the string passed in pReturnBuffer and check its capabilities against QueryFlags.
///
///
///
///
/// The query criteria.
///
///
/// Value
/// Meaning
///
/// -
/// PDCAP_D0_SUPPORTED 0x00000001
/// The device supports system power state D0.
///
/// -
/// PDCAP_D1_SUPPORTED 0x00000002
/// The device supports system power state D1.
///
/// -
/// PDCAP_D2_SUPPORTED 0x00000004
/// The device supports system power state D2.
///
/// -
/// PDCAP_D3_SUPPORTED 0x00000008
/// The device supports system power state D3.
///
/// -
/// PDCAP_S0_SUPPORTED 0x00010000
/// The device supports system sleep state S0.
///
/// -
/// PDCAP_S1_SUPPORTED 0x00020000
/// The device supports system sleep state S1.
///
/// -
/// PDCAP_S2_SUPPORTED 0x00040000
/// The device supports system sleep state S2.
///
/// -
/// PDCAP_S3_SUPPORTED 0x00080000
/// The device supports system sleep state S3.
///
/// -
/// PDCAP_S4_SUPPORTED 0x01000000
/// The device supports system sleep state S4.
///
/// -
/// PDCAP_S5_SUPPORTED 0x02000000
/// The device supports system sleep state S5.
///
/// -
/// PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
/// The device supports waking from system power state D0.
///
/// -
/// PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
/// The device supports waking from system power state D1.
///
/// -
/// PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
/// The device supports waking from system power state D2.
///
/// -
/// PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
/// The device supports waking from system power state D3.
///
/// -
/// PDCAP_WAKE_FROM_S0_SUPPORTED 0x00100000
/// The device supports waking from system sleep state S0.
///
/// -
/// PDCAP_WAKE_FROM_S1_SUPPORTED 0x00200000
/// The device supports waking from system sleep state S1.
///
/// -
/// PDCAP_WAKE_FROM_S2_SUPPORTED 0x00400000
/// The device supports waking from system sleep state S2.
///
/// -
/// PDCAP_WAKE_FROM_S3_SUPPORTED 0x00800000
/// The device supports waking from system sleep state S3.
///
/// -
/// PDCAP_WARM_EJECT_SUPPORTED 0x00000100
/// The device supports warm eject.
///
///
///
/// Pointer to a buffer that receives the requested information.
///
/// The size, in bytes, of the return buffer.
/// Note If pReturnBuffer is NULL, pBufferSize will be filled with the size needed to return the data.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
///
///
/// The values of the QueryFlags parameter may be combined to query for devices that support two or more criteria. For example; if
/// PDCAP_D3_SUPPORTED | PDCAP_D1_SUPPORTED is passed as the QueryFlags parameter, the function will query for devices
/// that support either D3 or D1.
///
///
/// QueryFlags also may be combined with QueryInterpretationFlags set to DEVICEPOWER_AND_OPERATION to produce a query of
/// devices that support all of the requested criteria. For example; if PDCAP_D3_SUPPORTED | PDCAP_D1_SUPPORTED is
/// passed as the QueryFlags parameter and DEVICEPOWER_AND_OPERATION is passed as the QueryInterpretationFlags parameter, the
/// function will query devices that support both D3 and D1.
///
/// Examples
/// For an example that uses this function, see Using the Device Power API.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-devicepowerenumdevices BOOLEAN DevicePowerEnumDevices(
// ULONG QueryIndex, ULONG QueryInterpretationFlags, ULONG QueryFlags, PBYTE pReturnBuffer, PULONG pBufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "bb67634c-69d9-4194-ac27-4f9740d73a1a")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool DevicePowerEnumDevices(uint QueryIndex, PDQUERY QueryInterpretationFlags, PDCAP QueryFlags, StringBuilder pReturnBuffer, ref uint pBufferSize);
/// Initializes a device list by querying all the devices.
/// Reserved; must be 0.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-devicepoweropen BOOLEAN DevicePowerOpen( ULONG DebugMask );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "1f0e8ee6-cd9e-468a-ba9a-f11e17852f89")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool DevicePowerOpen(uint DebugMask = 0);
/// Modifies the specified data on the specified device.
/// The name or hardware identifier string of the device to be modified.
///
/// The properties of the device that are to be modified.
///
///
/// Value
/// Meaning
///
/// -
/// DEVICEPOWER_SET_WAKEENABLED 0x00000001
/// Enables the specified device to wake the system.
///
/// -
/// DEVICEPOWER_CLEAR_WAKEENABLED 0x00000002
/// Stops the specified device from being able to wake the system.
///
///
///
/// Reserved, must be NULL.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-devicepowersetdevicestate DWORD
// DevicePowerSetDeviceState( LPCWSTR DeviceDescription, ULONG SetFlags, PVOID SetData );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "300842ae-d7d4-42c2-959c-e1713f466d32")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DevicePowerSetDeviceState([MarshalAs(UnmanagedType.LPWStr)] string DeviceDescription, PDSET SetFlags, IntPtr SetData = default);
///
///
/// [ EnumPwrSchemes is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions. Applications written for Windows Vista and later should use PowerEnumerate instead.]
///
///
/// Enumerates all power schemes. For each power scheme enumerated, the function calls a callback function with information about the
/// power scheme.
///
///
///
/// A pointer to a callback function to be called for each power scheme enumerated. For more information, see Remarks.
///
///
/// A user-defined value to be passed to the callback function.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// For each power scheme enumerated, the callback function is called with the following parameters:
///
/// The sName and sDesc parameters are null-terminated Unicode strings. The pp parameter is a pointer to a POWER_POLICY structure
/// containing the power policy scheme. To continue until all power schemes have been enumerated, the callback function must return
/// TRUE. To stop the enumeration, the callback function must return FALSE.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-enumpwrschemes BOOLEAN EnumPwrSchemes(
// PWRSCHEMESENUMPROC lpfn, LPARAM lParam );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "5e9e10b4-84c3-40ec-8de9-220d13795403")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool EnumPwrSchemes(PWRSCHEMESENUMPROC lpfn, [Optional] IntPtr lParam);
///
///
/// [ GetActivePwrScheme is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. Applications written for Windows Vista and later should use PowerGetActiveScheme instead.]
///
/// Retrieves the index of the active power scheme.
///
/// A pointer to a variable that receives the index of the active power scheme.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The active power scheme remains active until either the user sets a new power scheme using the Power Options control panel
/// program, or an application calls the SetActivePwrScheme function.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-getactivepwrscheme BOOLEAN GetActivePwrScheme( PUINT
// puiID );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "2a321372-40ff-4292-8b66-db3f794e5f53")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool GetActivePwrScheme(out uint puiID);
/// Retrieves the current system power policy settings.
///
/// A pointer to a GLOBAL_POWER_POLICY structure that receives the current global power policy settings.
///
///
/// A pointer to a POWER_POLICY structure that receives the power policy settings that are unique to the active power scheme.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// To update the current power policy settings, call the WriteGlobalPwrPolicy or WritePwrScheme functions.
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-getcurrentpowerpolicies BOOLEAN GetCurrentPowerPolicies(
// PGLOBAL_POWER_POLICY pGlobalPowerPolicy, PPOWER_POLICY pPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "9a834fb6-35ae-4d36-885c-0d81cd39e9a6")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool GetCurrentPowerPolicies(out GLOBAL_POWER_POLICY pGlobalPowerPolicy, out POWER_POLICY pPowerPolicy);
///
///
/// [ GetPwrDiskSpindownRange is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. See Remarks.]
///
/// Retrieves the disk spin-down range.
///
/// The maximum disk spin-down time, in seconds.
/// The minimum disk spin-down time, in seconds.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// Starting with Windows Vista, power management configuration of the system's hard disk drives is controlled through the
/// GUID_DISK_SUBGROUP power settings subgroup. Use the PowerEnumerate function to enumerate individual settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-getpwrdiskspindownrange BOOLEAN GetPwrDiskSpindownRange(
// PUINT puiMax, PUINT puiMin );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "c56f679d-512a-4bf9-89dc-8905bba8c6ce")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool GetPwrDiskSpindownRange(out uint puiMax, out uint puiMin);
///
///
/// [ IsPwrHibernateAllowed is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. Applications written for Windows Vista and later should use GetPwrCapabilities instead.]
///
/// Determines whether the computer supports hibernation.
///
///
/// If the computer supports hibernation (power state S4) and the file Hiberfil.sys is present on the system, the function returns
/// TRUE. Otherwise, the function returns FALSE.
///
///
///
/// This information is also available through the CallNtPowerInformation function. The value is returned in the SystemS4
/// member of the SYSTEM_POWER_CAPABILITIES structure.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-ispwrhibernateallowed BOOLEAN IsPwrHibernateAllowed( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "fe9d06a8-c021-4cf4-9782-04519f370c5b")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool IsPwrHibernateAllowed();
///
///
/// [ IsPwrShutdownAllowed is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. See Remarks.]
///
/// Determines whether the computer supports the soft off power state.
///
///
/// If the computer supports soft off (power state S5), the function returns TRUE. Otherwise, the function returns FALSE.
///
///
///
/// This information is also available through the CallNtPowerInformation function. The value is returned in the SystemS5
/// member of the SYSTEM_POWER_CAPABILITIES structure.
///
///
/// Starting with Windows Vista, computers must support the soft off power state. Therefore, this function is relevant only to
/// Windows Server 2003 and earlier operating systems.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-ispwrshutdownallowed BOOLEAN IsPwrShutdownAllowed( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "e48d6f67-225b-40f7-902b-0e65112303b9")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool IsPwrShutdownAllowed();
///
///
/// [ IsPwrSuspendAllowed is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. Applications written for Windows Vista and later should use GetPwrCapabilities instead.]
///
/// Determines whether the computer supports the sleep states.
///
///
/// If the computer supports the sleep states (S1, S2, and S3), the function returns TRUE. Otherwise, the function returns FALSE.
///
///
///
/// This information is also available through the CallNtPowerInformation function. Check the SystemS1, SystemS2, and
/// SystemS3 members of the SYSTEM_POWER_CAPABILITIES structure.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-ispwrsuspendallowed BOOLEAN IsPwrSuspendAllowed( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "66ef2402-b1b8-432e-b47d-240d255fc907")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool IsPwrSuspendAllowed();
///
/// Determines if the current user has access to the data for the specified power scheme so that it could be restored if necessary.
///
/// The identifier of the power scheme.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powercanrestoreindividualdefaultpowerscheme DWORD
// PowerCanRestoreIndividualDefaultPowerScheme( const GUID *SchemeGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "8f29c993-b237-4302-a48b-05368ead9a44")]
public static extern Win32Error PowerCanRestoreIndividualDefaultPowerScheme(in Guid SchemeGuid);
/// Creates a possible setting value for a specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h.
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being created.
/// The zero-based index for the possible setting being created.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powercreatepossiblesetting DWORD
// PowerCreatePossibleSetting( HKEY RootSystemPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, ULONG
// PossibleSettingIndex );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "a7297dbe-8ea5-4097-a0b3-2740f99acbaf")]
public static extern Win32Error PowerCreatePossibleSetting([Optional] HKEY RootSystemPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint PossibleSettingIndex);
/// Creates a setting value for a specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h.
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being created.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powercreatesetting DWORD PowerCreateSetting( HKEY
// RootSystemPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "84b46096-a83b-4041-8ecb-e95c6189480b")]
public static extern Win32Error PowerCreateSetting([Optional] HKEY RootSystemPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid);
/// Deletes the specified power scheme from the database.
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerdeletescheme DWORD PowerDeleteScheme( HKEY
// RootPowerKey, const GUID *SchemeGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "5f9969a1-e598-4ca8-a5b8-f8bb3410223d")]
public static extern Win32Error PowerDeleteScheme([Optional] HKEY RootPowerKey, in Guid SchemeGuid);
///
///
/// Determines the computer role for Windows 7, Windows Server 2008 R2, Windows Vista or Windows Server 2008. To specify a different
/// platform, use the PowerDeterminePlatformRoleEx function.
///
/// To query additional power platform roles defined after Windows 7 and Windows Server 2008 R2, use PowerDeterminePlatformRoleEx.
///
///
/// The return value is one of the values from the POWER_PLATFORM_ROLE enumeration.
///
///
///
/// This function reads the ACPI Fixed ACPI Description Table (FADT) to determine the OEM preferred computer role. If that
/// information is not available, the function looks for a battery. If at least one battery is available, the function returns
/// PlatformRoleMobile. If no batteries are available, the function returns PlatformRoleDesktop.
///
///
/// Note This API has a newer version. To query additional power platform roles defined after Windows 7 and Windows Server
/// 2008 R2, use PowerDeterminePlatformRoleEx.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerdetermineplatformrole POWER_PLATFORM_ROLE
// PowerDeterminePlatformRole( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "a0311454-3908-49a6-95c0-c118dca259ac")]
public static extern POWER_PLATFORM_ROLE PowerDeterminePlatformRole();
/// Duplicates an existing power scheme.
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme that is to be duplicated.
///
/// The address of a pointer to a GUID. If the pointer contains NULL, the function allocates memory for a new
/// GUID and puts the address of this memory in the pointer. The caller can free this memory using LocalFree.
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// Return code/value
/// Description
///
/// -
/// ERROR_SUCCESS 0 (0x0)
/// The power scheme was successfully duplicated.
///
/// -
/// ERROR_INVALID_PARAMETER 87 (0x57)
/// One of the parameters is not valid.
///
/// -
/// ERROR_ALREADY_EXISTS 183 (0xB7)
/// The DestinationSchemeGuid parameter refers to an existing power scheme. PowerDeleteScheme can be used to delete this scheme.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerduplicatescheme DWORD PowerDuplicateScheme( HKEY
// RootPowerKey, const GUID *SourceSchemeGuid, GUID **DestinationSchemeGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "e58dee69-309c-4b52-bf28-f54b300801b9")]
public static extern Win32Error PowerDuplicateScheme([Optional] HKEY RootPowerKey, in Guid SourceSchemeGuid, out SafeLocalHandle DestinationSchemeGuid);
///
/// Enumerates the specified elements in a power scheme. This function is normally called in a loop incrementing the Index parameter
/// to retrieve subkeys until they've all been enumerated.
///
/// This parameter is reserved for future use and must be set to NULL.
///
/// The identifier of the power scheme. If this parameter is NULL, an enumeration of the power policies is returned.
///
///
///
/// The subgroup of power settings. If this parameter is NULL, an enumeration of settings under the PolicyGuid key is returned.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup will be part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
///
/// A set of flags that specifies what will be enumerated
///
///
/// Value
/// Meaning
///
/// -
/// ACCESS_SCHEME 16
/// Enumerate power schemes. The SchemeGuid and SubgroupOfPowerSettingsGuid parameters will be ignored.
///
/// -
/// ACCESS_SUBGROUP 17
/// Enumerate subgroups under SchemeGuid. The SubgroupOfPowerSettingsGuid parameter will be ignored.
///
/// -
/// ACCESS_INDIVIDUAL_SETTING 18
///
/// Enumerate individual power settings under SchemeGuid\SubgroupOfPowerSettingsGuid. To enumerate power settings directly under the
/// SchemeGuid key, use NO_SUBGROUP_GUID as the SubgroupOfPowerSettingsGuid parameter.
///
///
///
///
/// The zero-based index of the scheme, subgroup, or setting that is being enumerated.
///
/// A pointer to a variable to receive the elements. If this parameter is NULL, the function retrieves the size of the buffer required.
///
///
/// A pointer to a variable that on input contains the size of the buffer pointed to by the Buffer parameter. If the Buffer parameter
/// is NULL or if the BufferSize is not large enough, the function will return ERROR_MORE_DATA and the variable
/// receives the required buffer size.
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size passed
/// in the BufferSize parameter is too small, or if the Buffer parameter is NULL, ERROR_MORE_DATA will be returned and
/// the DWORD pointed to by the BufferSize parameter will be filled in with the required buffer size.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerenumerate DWORD PowerEnumerate( HKEY RootPowerKey,
// const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, POWER_DATA_ACCESSOR AccessFlags, ULONG Index, UCHAR *Buffer,
// DWORD *BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "5b2c8263-d916-4909-be56-ec784537bdc3")]
public static extern Win32Error PowerEnumerate([Optional] HKEY RootPowerKey, [Optional, In] IntPtr SchemeGuid, [Optional, In] IntPtr SubGroupOfPowerSettingsGuid, POWER_DATA_ACCESSOR AccessFlags, uint Index, IntPtr Buffer, ref uint BufferSize);
///
/// Enumerates the specified elements in a power scheme. This function is normally called in a loop incrementing the Index parameter
/// to retrieve subkeys until they've all been enumerated.
///
///
/// The identifier of the power scheme. If this parameter is NULL, an enumeration of the power policies is returned.
///
///
///
/// The subgroup of power settings. If this parameter is NULL, an enumeration of settings under the PolicyGuid key is returned.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup will be part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
///
/// A set of flags that specifies what will be enumerated
///
///
/// Value
/// Meaning
///
/// -
/// ACCESS_SCHEME 16
/// Enumerate power schemes. The SchemeGuid and SubgroupOfPowerSettingsGuid parameters will be ignored.
///
/// -
/// ACCESS_SUBGROUP 17
/// Enumerate subgroups under SchemeGuid. The SubgroupOfPowerSettingsGuid parameter will be ignored.
///
/// -
/// ACCESS_INDIVIDUAL_SETTING 18
///
/// Enumerate individual power settings under SchemeGuid\SubgroupOfPowerSettingsGuid. To enumerate power settings directly under the
/// SchemeGuid key, use NO_SUBGROUP_GUID as the SubgroupOfPowerSettingsGuid parameter.
///
///
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size passed
/// in the BufferSize parameter is too small, or if the Buffer parameter is NULL, ERROR_MORE_DATA will be returned and
/// the DWORD pointed to by the BufferSize parameter will be filled in with the required buffer size.
///
public static IEnumerable PowerEnumerate(Guid? SchemeGuid, Guid? SubGroupOfPowerSettingsGuid, POWER_DATA_ACCESSOR AccessFlags = (POWER_DATA_ACCESSOR)(-1)) where T : struct
{
if (AccessFlags == (POWER_DATA_ACCESSOR)(-1))
AccessFlags = SchemeGuid is null ? POWER_DATA_ACCESSOR.ACCESS_SCHEME : (SubGroupOfPowerSettingsGuid is null ? POWER_DATA_ACCESSOR.ACCESS_SUBGROUP : POWER_DATA_ACCESSOR.ACCESS_INDIVIDUAL_SETTING);
var l = new List();
PwrGuidTsl(SchemeGuid, SubGroupOfPowerSettingsGuid, null, (p1, p2, p3) => {
var checkSize = true;
for (var i = 0U; ; i++)
{
var sz = 0U;
var err = PowerEnumerate(default, p1, p2, AccessFlags, i, IntPtr.Zero, ref sz);
if (err == Win32Error.ERROR_NO_MORE_ITEMS)
break;
if (err != Win32Error.ERROR_MORE_DATA)
return err;
if (checkSize && sz < Marshal.SizeOf(typeof(T))) throw new ArgumentException("Size mismatch between returned value and size of T.", nameof(T));
checkSize = false;
using (var mem = new SafeHGlobalHandle((int)sz))
{
err = PowerEnumerate(default, p1, p2, AccessFlags, i, (IntPtr)mem, ref sz);
if (err.Failed) return err;
l.Add(mem.ToStructure());
}
}
return Win32Error.ERROR_SUCCESS;
}).ThrowIfFailed();
return l;
}
/// Imports a power scheme from a file.
/// This parameter is reserved for future use and must be set to NULL.
/// The path to a power scheme backup file created by PowerCfg.Exe /Export.
///
/// A pointer to a pointer to a GUID. If the pointer contains NULL, the function allocates memory for a new GUID
/// and puts the address of this memory in the pointer. The caller can free this memory using LocalFree.
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerimportpowerscheme DWORD PowerImportPowerScheme(
// HKEY RootPowerKey, LPCWSTR ImportFileNamePath, GUID **DestinationSchemeGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "84ba8cb6-13ad-459b-b154-c495aaeb67f3")]
public static extern Win32Error PowerImportPowerScheme([Optional] HKEY RootPowerKey, [MarshalAs(UnmanagedType.LPWStr)] string ImportFileNamePath, out SafeLocalHandle DestinationSchemeGuid);
/// Queries whether the specified power setting represents a range of possible values.
/// The identifier of the subkey to search.
/// The identifier of the power setting to query.
///
/// TRUE if the registry key specified by SubKeyGuid represents a single power setting.
/// If the registry key specified by SubKeyGuid represents a range, this function returns FALSE.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerissettingrangedefined BOOLEAN
// PowerIsSettingRangeDefined( const GUID *SubKeyGuid, const GUID *SettingGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "7babaf7b-ecb3-4b29-917e-2ed63bad4a38")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool PowerIsSettingRangeDefined(in Guid SubKeyGuid, in Guid SettingGuid);
/// Retrieves the default AC index of the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
/// The identifier for the scheme personality for this power setting. A power setting can have different default values depending on
/// the power scheme personality.
///
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to retrieve the setting for the default power scheme.
///
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUIDfea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUPe73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
///
/// The identifier for the single power setting.
/// A pointer to a variable that receives the default AC index.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// DWORD WINAPI PowerReadACDefaultIndex( _In_opt_ HKEY RootPowerKey, _In_ const GUID *SchemePersonalityGuid, _In_opt_ const GUID
// *SubGroupOfPowerSettingsGuid, _In_ const GUID *PowerSettingGuid, _Out_ LPDWORD AcDefaultIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/aa372733(v=vs.85).aspx
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("PowrProf.h", MSDNShortId = "aa372733")]
public static extern Win32Error PowerReadACDefaultIndex([Optional] HKEY RootPowerKey, in Guid SchemePersonalityGuid, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint AcDefaultIndex);
/// Retrieves the AC index of the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// A pointer to a variable that receives the AC value index.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadacvalueindex DWORD PowerReadACValueIndex( HKEY
// RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, LPDWORD AcValueIndex );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "e8760e78-78cd-4652-94b1-f42a72df5db2")]
public static extern Win32Error PowerReadACValueIndex([Optional] HKEY RootPowerKey, in Guid SchemeGuid, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint AcValueIndex);
/// Retrieves the default DC index of the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
/// The identifier of the scheme personality for this power setting. A power setting can have different default values depending on
/// the power scheme personality.
///
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to retrieve the setting for the default power scheme.
///
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUIDfea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUPe73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
///
/// The identifier of the power setting.
/// A pointer to a variable that receives the default DC index.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// DWORD WINAPI PowerReadDCDefaultIndex( _In_opt_ HKEY RootPowerKey, _In_ const GUID *SchemePersonalityGuid, _In_opt_ const GUID
// *SubGroupOfPowerSettingsGuid, _In_ const GUID *PowerSettingGuid, _Out_ LPDWORD DcDefaultIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/aa372736(v=vs.85).aspx
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("PowrProf.h", MSDNShortId = "aa372736")]
public static extern Win32Error PowerReadDCDefaultIndex([Optional] HKEY RootPowerKey, in Guid SchemePersonalityGuid, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint DcDefaultIndex);
/// Retrieves the DC value index of the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
/// The identifier of the subgroup of power settings. Use NO_SUBGROUP_GUID to refer to the default power scheme.
/// These values are the subgroup values included with Windows.
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// A pointer to a variable that receives the DC value index.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreaddcvalueindex DWORD PowerReadDCValueIndex( HKEY
// RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, LPDWORD DcValueIndex );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "91ba83bd-3e28-4933-a1ad-0cd8414fee37")]
public static extern Win32Error PowerReadDCValueIndex([Optional] HKEY RootPowerKey, in Guid SchemeGuid, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint DcValueIndex);
///
/// Retrieves the description for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL
/// but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the description of the power scheme
/// will be returned. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid
/// parameter is NULL, the description of the subgroup will be returned. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and
/// PowerSettingGuid parameters are not NULL, the description of the power setting will be returned.
///
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
///
/// A pointer to a buffer that receives the description. If this parameter is NULL, the BufferSize parameter receives the
/// required buffer size. The strings returned are all wide (Unicode) strings.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small, the function returns ERROR_SUCCESS and the DWORD pointed to by
/// the BufferSize parameter is filled in with the required buffer size.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreaddescription
// DWORD PowerReadDescription( HKEY RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, PUCHAR Buffer, LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "3c264f4f-fd1b-466b-ba76-fe78593a3628")]
public static extern Win32Error PowerReadDescription([Optional] HKEY RootPowerKey, [In] IntPtr SchemeGuid, [In] IntPtr SubGroupOfPowerSettingsGuid, [In] IntPtr PowerSettingGuid, IntPtr Buffer, ref uint BufferSize);
///
/// Retrieves the description for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL
/// but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the description of the power scheme
/// will be returned. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid
/// parameter is NULL, the description of the subgroup will be returned. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and
/// PowerSettingGuid parameters are not NULL, the description of the power setting will be returned.
///
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
///
/// The description.
///
[PInvokeData("powrprof.h", MSDNShortId = "3c264f4f-fd1b-466b-ba76-fe78593a3628")]
public static string PowerReadDescription([In] Guid? SchemeGuid = null, [In] Guid? SubGroupOfPowerSettingsGuid = null, [In] Guid? PowerSettingGuid = null) =>
PwrReadMem(PowerReadDescription, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid)?.ToString(-1) ?? string.Empty;
///
/// Retrieves the friendly name for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL
/// but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the friendly name of the power scheme
/// will be returned. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid
/// parameter is NULL, the friendly name of the subgroup will be returned. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and
/// PowerSettingGuid parameters are not NULL, the friendly name of the power setting will be returned.
///
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
/// The subgroup of power settings. Use NO_SUBGROUP_GUID to refer to the default power scheme.
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
///
/// A pointer to a buffer that receives the friendly name. If this parameter is NULL, the BufferSize parameter receives the
/// required buffer size. The strings returned are all wide (Unicode) strings.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small, ERROR_MORE_DATA will be returned and the DWORD pointed to by
/// the BufferSize parameter will be filled in with the required buffer size.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadfriendlyname DWORD PowerReadFriendlyName( HKEY
// RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, PUCHAR Buffer,
// LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "e6e46bbf-f9be-4dee-8976-df48bb1ccdf4")]
public static extern Win32Error PowerReadFriendlyName([Optional] HKEY RootPowerKey, [In] IntPtr SchemeGuid, [In] IntPtr SubGroupOfPowerSettingsGuid, [In] IntPtr PowerSettingGuid, IntPtr Buffer, ref uint BufferSize);
///
/// Retrieves the friendly name for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL
/// but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the friendly name of the power scheme
/// will be returned. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid
/// parameter is NULL, the friendly name of the subgroup will be returned. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and
/// PowerSettingGuid parameters are not NULL, the friendly name of the power setting will be returned.
///
/// The identifier of the power scheme.
/// The subgroup of power settings. Use NO_SUBGROUP_GUID to refer to the default power scheme.
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
/// The identifier of the power setting that is being used.
/// The friendly name.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadfriendlyname DWORD PowerReadFriendlyName( HKEY
// RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, PUCHAR Buffer,
// LPDWORD BufferSize );
[PInvokeData("powrprof.h", MSDNShortId = "e6e46bbf-f9be-4dee-8976-df48bb1ccdf4")]
public static string PowerReadFriendlyName([In] Guid? SchemeGuid = null, [In] Guid? SubGroupOfPowerSettingsGuid = null, [In] Guid? PowerSettingGuid = null) =>
PwrReadMem(PowerReadFriendlyName, SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid)?.ToString(-1) ?? string.Empty;
///
/// Retrieves the icon resource for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL
/// but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the friendly name of the power scheme
/// will be returned. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid
/// parameter is NULL, the friendly name of the subgroup will be returned. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and
/// PowerSettingGuid parameters are not NULL, the friendly name of the power setting will be returned.
///
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
///
/// A pointer to a buffer that receives the icon resource. If this parameter is NULL, the BufferSize parameter receives the
/// required buffer size.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small, ERROR_MORE_DATA will be returned and the DWORD pointed to by
/// the BufferSize parameter will be filled in with the required buffer size.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadiconresourcespecifier DWORD
// PowerReadIconResourceSpecifier( HKEY RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID
// *PowerSettingGuid, PUCHAR Buffer, LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "d9454acd-7a4a-4f54-b614-beee8763f1ef")]
public static extern Win32Error PowerReadIconResourceSpecifier([Optional] HKEY RootPowerKey, [In] IntPtr SchemeGuid, [In] IntPtr SubGroupOfPowerSettingsGuid, [In] IntPtr PowerSettingGuid, IntPtr Buffer, ref uint BufferSize);
/// Retrieves the description for one of the possible choices of a power setting value.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
/// The zero-based index for the possible setting.
///
/// A pointer to a buffer that receives the description. If this parameter is NULL, the BufferSize parameter receives the
/// required buffer size. The strings returned are all wide (Unicode) strings.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small,
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadpossibledescription DWORD
// PowerReadPossibleDescription( HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, ULONG
// PossibleSettingIndex, PUCHAR Buffer, LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "e803dc6b-706a-49fc-8c8d-ba9b0ccf8491")]
public static extern Win32Error PowerReadPossibleDescription([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint PossibleSettingIndex, StringBuilder? Buffer, ref uint BufferSize);
/// Retrieves the friendly name for one of the possible choices of a power setting value.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The zero-based index for the possible setting.
///
/// A pointer to a buffer that receives the friendly name. If this parameter is NULL, the BufferSize parameter receives the
/// required buffer size. The strings returned are all wide (Unicode) strings.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small,
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadpossiblefriendlyname DWORD
// PowerReadPossibleFriendlyName( HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, ULONG
// PossibleSettingIndex, PUCHAR Buffer, LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "38f3c5f4-ec65-47f0-b15c-36cd2b1e2813")]
public static extern Win32Error PowerReadPossibleFriendlyName([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint PossibleSettingIndex, StringBuilder? Buffer, ref uint BufferSize);
/// Retrieves the value for a possible value of a power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
///
/// A pointer to a variable that receives the type of data for the value. The possible values are listed in Registry Value Types.
/// This parameter can be NULL and the type of data is not returned.
///
/// The zero-based index of the possible setting.
///
/// A pointer to a buffer that receives the value. If this parameter is NULL, the BufferSize parameter receives the required
/// buffer size.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small,
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadpossiblevalue DWORD PowerReadPossibleValue(
// HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, PULONG Type, ULONG PossibleSettingIndex,
// PUCHAR Buffer, LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "453f3db0-537d-4f24-a62c-d12b44b5e019")]
public static extern Win32Error PowerReadPossibleValue([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out REG_VALUE_TYPE Type, uint PossibleSettingIndex, IntPtr Buffer, ref uint BufferSize);
///
/// Returns the current attribute of the specified power setting. If the SubGroupGuid parameter is NULL then the attribute for
/// PowerSettingGuid is returned. If the PowerSettingGuid parameter is NULL then the attribute for SubGroupGuid is returned.
/// If both the SubGroupGuid and PowerSettingGuid parameters are valid then the return value is the combination (bitwise OR) of the
/// attributes of the subgroup and the power setting.
///
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
/// These values are the subgroup values included with Windows.
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
///
///
/// Returns the current power setting attributes of the specified power setting. The attribute is a combination of the attributes of
/// the power setting and the attributes of its subgroup.
///
///
///
/// Return code/value
/// Description
///
/// -
/// POWER_ATTRIBUTE_HIDE 1
/// Hide this power setting.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadsettingattributes DWORD
// PowerReadSettingAttributes( const GUID *SubGroupGuid, const GUID *PowerSettingGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "9f430da2-7c8d-43e2-ab8a-d9af1bb7538f")]
public static extern POWER_ATTR PowerReadSettingAttributes(in Guid SubGroupGuid, in Guid PowerSettingGuid);
///
/// Retrieves the increment for valid values between the power settings minimum and maximum. If the power setting is not defined with
/// a range of possible values then this function will return an error.
///
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
/// A pointer to a variable that receives the increment for the specified power setting.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadvalueincrement DWORD PowerReadValueIncrement(
// HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, LPDWORD ValueIncrement );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "f5aa19c5-67ea-4a87-be87-b3bf3d9dd5a4")]
public static extern Win32Error PowerReadValueIncrement([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint ValueIncrement);
/// Retrieves the maximum value for the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
/// A pointer to a variable that receives the maximum for the specified power setting.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadvaluemax DWORD PowerReadValueMax( HKEY
// RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, LPDWORD ValueMaximum );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "577c7726-cba5-492b-9c9b-bbd815a70ddf")]
public static extern Win32Error PowerReadValueMax([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint ValueMaximum);
/// Retrieves the minimum value for the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
/// A pointer to a variable that receives the minimum value for the specified power setting.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadvaluemin DWORD PowerReadValueMin( HKEY
// RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, LPDWORD ValueMinimum );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "4a28cc2e-359b-45b3-8d2f-2f88baebb9c1")]
public static extern Win32Error PowerReadValueMin([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, out uint ValueMinimum);
///
/// Reads the string used to describe the units of a power setting that supports a range of values. For example "minutes" may be used
/// to describe a timeout setting.
///
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
///
/// A pointer to a buffer that receives the string. If this parameter is NULL, the BufferSize parameter receives the required
/// buffer size. The strings returned are all wide (Unicode) strings.
///
///
/// A pointer to a variable that contains the size of the buffer pointed to by the Buffer parameter.
///
/// If the Buffer parameter is NULL, the function returns ERROR_SUCCESS and the variable receives the required buffer size.
///
///
/// If the specified buffer size is not large enough to hold the requested data, the function returns ERROR_MORE_DATA and the
/// variable receives the required buffer size.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed. If the buffer size
/// specified by the BufferSize parameter is too small,
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreadvalueunitsspecifier DWORD
// PowerReadValueUnitsSpecifier( HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, UCHAR
// *Buffer, LPDWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "48ad80b7-f89a-4dad-a991-056ce41d6975")]
public static extern Win32Error PowerReadValueUnitsSpecifier([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, StringBuilder? Buffer, ref uint BufferSize);
/// Deletes the specified power setting.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting to be deleted.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerremovepowersetting DWORD PowerRemovePowerSetting(
// const GUID *PowerSettingSubKeyGuid, const GUID *PowerSettingGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "f78e3dfa-549c-4536-a486-cafc43717ee9")]
public static extern Win32Error PowerRemovePowerSetting(in Guid PowerSettingSubKeyGuid, in Guid PowerSettingGuid);
///
/// Replaces the default power schemes with the current user's power schemes. This allows an administrator to change the default
/// power schemes for the system. Replacing the default schemes enables users to use the Restore Defaults option in the
/// Control Panel Power Options application to restore customized power scheme defaults instead of the original Windows power
/// scheme defaults.
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// The caller must be a member of the local Administrators group.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreplacedefaultpowerschemes DWORD
// PowerReplaceDefaultPowerSchemes( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "0d028ed9-3505-4f08-b064-14cbc8172ce0")]
public static extern Win32Error PowerReplaceDefaultPowerSchemes();
/// Notifies the operating system of thermal events.
/// The thermal event structure, THERMAL_EVENT.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// Thermal managers call the PowerReportThermalEvent routine to notify the operating system of a thermal event so that the
/// event can be recorded in the system event log.
///
///
/// Before calling PowerReportThermalEvent, the thermal manager sets the members of the THERMAL_EVENT structure to describe
/// the thermal event.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerreportthermalevent DWORD PowerReportThermalEvent(
// PTHERMAL_EVENT Event );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "DD3DE1B2-17C1-4FF8-9DF8-BEF35933D913")]
public static extern Win32Error PowerReportThermalEvent(in THERMAL_EVENT Event);
///
/// Replaces the power schemes for the system with default power schemes. All current power schemes and settings are deleted and
/// replaced with the default system power schemes.
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// The caller must be a member of the local Administrators group.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerrestoredefaultpowerschemes DWORD
// PowerRestoreDefaultPowerSchemes( );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "6d0a6167-34de-439b-afb4-2536c715905c")]
public static extern Win32Error PowerRestoreDefaultPowerSchemes();
/// Replaces a specific power scheme for the current user with one from the default user (stored in HKEY_USERS<b>.Default)
/// The identifier of the power scheme.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerrestoreindividualdefaultpowerscheme DWORD
// PowerRestoreIndividualDefaultPowerScheme( const GUID *SchemeGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "f1a9cfb1-1b56-4873-994b-7fe929fdc86c")]
public static extern Win32Error PowerRestoreIndividualDefaultPowerScheme(in Guid SchemeGuid);
/// Queries for a group policy override for specified power settings.
///
/// The type of access to check for group policy overrides.
///
///
/// Value
/// Meaning
///
/// -
/// ACCESS_AC_POWER_SETTING_INDEX 0 (0x0)
/// Check for overrides on AC power settings.
///
/// -
/// ACCESS_DC_POWER_SETTING_INDEX 1 (0x1)
/// Check for overrides on DC power settings.
///
/// -
/// ACCESS_SCHEME 16 (0x10)
/// Check for restrictions on specific power schemes.
///
/// -
/// ACCESS_ACTIVE_SCHEME 19 (0x13)
/// Check for restrictions on active power schemes.
///
/// -
/// ACCESS_CREATE_SCHEME 20 (0x14)
/// Check for restrictions on creating or restoring power schemes.
///
///
///
/// The identifier of the power setting.
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// Return code/value
/// Description
///
/// -
/// ERROR_SUCCESS 0 (0x0)
/// The specified power setting is not currently overridden by a group policy.
///
/// -
/// ERROR_ACCESS_DISABLED_BY_POLICY 1260 (0x4EC)
/// This program is blocked by group policy. For more information, contact your system administrator.
///
/// -
/// ERROR_INSTALL_REMOTE_DISALLOWED 1640 (0x668)
/// Only Administrators can remotely access power settings.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powersettingaccesscheck DWORD PowerSettingAccessCheck(
// POWER_DATA_ACCESSOR AccessFlags, const GUID *PowerGuid );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "0b89c189-b162-44d4-aa50-d78385e40c27")]
public static extern Win32Error PowerSettingAccessCheck(POWER_DATA_ACCESSOR AccessFlags, in Guid PowerGuid);
/// Queries for a group policy override for specified power settings and specifies the requested access for the setting.
///
/// The type of access to check for group policy overrides.
///
///
/// Value
/// Meaning
///
/// -
/// ACCESS_AC_POWER_SETTING_INDEX 0 (0x0)
/// Check for overrides on AC power settings.
///
/// -
/// ACCESS_DC_POWER_SETTING_INDEX 1 (0x1)
/// Check for overrides on DC power settings.
///
/// -
/// ACCESS_SCHEME 16 (0x10)
/// Check for restrictions on specific power schemes.
///
/// -
/// ACCESS_ACTIVE_SCHEME 19 (0x13)
/// Check for restrictions on active power schemes.
///
/// -
/// ACCESS_CREATE_SCHEME 20 (0x14)
/// Check for restrictions on creating or restoring power schemes.
///
///
///
/// The identifier of the power setting.
///
/// The type of security access for the setting. For more information, see Registry Key Security and Access Rights.
/// This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// KEY_READ
/// Combines the STANDARD_RIGHTS_READ, KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY values.
///
/// -
/// KEY_WRITE
/// Combines the STANDARD_RIGHTS_WRITE, KEY_SET_VALUE, and KEY_CREATE_SUB_KEY access rights.
///
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// Return code/value
/// Description
///
/// -
/// ERROR_SUCCESS 0 (0x0)
/// The specified power setting is not currently overridden by a group policy.
///
/// -
/// ERROR_ACCESS_DISABLED_BY_POLICY 1260 (0x4EC)
/// This program is blocked by group policy. For more information, contact your system administrator.
///
/// -
/// ERROR_INSTALL_REMOTE_DISALLOWED 1640 (0x668)
/// Only Administrators can remotely access power settings.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powersettingaccesscheckex DWORD
// PowerSettingAccessCheckEx( POWER_DATA_ACCESSOR AccessFlags, const GUID *PowerGuid, REGSAM AccessType );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "dad9cca9-5961-48b5-b7d0-4828eca3364b")]
public static extern Win32Error PowerSettingAccessCheckEx(POWER_DATA_ACCESSOR AccessFlags, in Guid PowerGuid, uint AccessType);
/// Sets the default AC index of the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
/// The identifier of the scheme personality for this power setting. A power setting can have different default values depending on
/// the power scheme personality.
///
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The default AC index.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwriteacdefaultindex DWORD PowerWriteACDefaultIndex(
// HKEY RootSystemPowerKey, const GUID *SchemePersonalityGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid,
// DWORD DefaultAcIndex );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "37fd6ddd-3b63-47c8-8ede-63d7e589523d")]
public static extern Win32Error PowerWriteACDefaultIndex([Optional] HKEY RootSystemPowerKey, in Guid SchemePersonalityGuid, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint DefaultAcIndex);
/// Sets the default DC index of the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
/// The identifier of the scheme personality for this power setting. A power setting can have different default values depending on
/// the power scheme personality.
///
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUIDfea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUPe73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
///
/// The identifier of the power setting.
/// The default DC index.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
// DWORD WINAPI PowerWriteDCDefaultIndex( _In_opt_ HKEY RootSystemPowerKey, _In_ const GUID *SchemePersonalityGuid, _In_opt_ const
// GUID *SubGroupOfPowerSettingsGuid, _In_ const GUID *PowerSettingGuid, _In_ DWORD DefaultDcIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/aa372767(v=vs.85).aspx
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("PowrProf.h", MSDNShortId = "aa372767")]
public static extern Win32Error PowerWriteDCDefaultIndex([Optional] HKEY RootSystemPowerKey, in Guid SchemePersonalityGuid, [Optional] in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, [In] uint DefaultDcIndex);
/// Sets the description for the specified power setting, subgroup, or scheme.
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The description, in wide (Unicode) characters.
/// The size of the buffer pointed to by the Buffer parameter.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// If the SchemeGuid parameter is not NULL but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are
/// NULL, the description of the power scheme will be set. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are
/// not NULL and the PowerSettingGuid parameter is NULL, the description of the subgroup will be set. If the
/// SchemeGuid, SubGroupOfPowerSettingsGuid, and PowerSettingGuid parameters are not NULL, the description of the power
/// setting will be set.
///
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritedescription DWORD PowerWriteDescription( HKEY
// RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, UCHAR *Buffer, DWORD
// BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "42ee26ac-1a9c-4390-92e8-879b401168c7")]
public static extern Win32Error PowerWriteDescription([Optional] HKEY RootPowerKey, [In] IntPtr SchemeGuid, [In] IntPtr SubGroupOfPowerSettingsGuid, [In] IntPtr PowerSettingGuid, string Buffer, uint BufferSize);
/// Sets the description for the specified power setting, subgroup, or scheme.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The description, in wide (Unicode) characters.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// If the SchemeGuid parameter is not NULL but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are
/// NULL, the description of the power scheme will be set. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are
/// not NULL and the PowerSettingGuid parameter is NULL, the description of the subgroup will be set. If the
/// SchemeGuid, SubGroupOfPowerSettingsGuid, and PowerSettingGuid parameters are not NULL, the description of the power
/// setting will be set.
///
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
///
[PInvokeData("powrprof.h", MSDNShortId = "42ee26ac-1a9c-4390-92e8-879b401168c7")]
public static Win32Error PowerWriteDescription([In] Guid? SchemeGuid, [In] Guid? SubGroupOfPowerSettingsGuid, [In] Guid? PowerSettingGuid, string Buffer) =>
PwrGuidTsl(SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, (p1, p2, p3) => PowerWriteDescription(default, p1, p2, p3, Buffer, (uint)(Buffer.Length + 1) * 2));
///
/// Sets the friendly name for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL but
/// both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the friendly name of the power scheme will
/// be set. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid parameter is
/// NULL, the friendly name of the subgroup will be set. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and PowerSettingGuid
/// parameters are not NULL, the friendly name of the power setting will be set.
///
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The friendly name, in wide (Unicode) characters.
///
/// The size of the friendly name specified by the Buffer parameter, including the terminating NULL character.
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritefriendlyname DWORD PowerWriteFriendlyName(
// HKEY RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, UCHAR *Buffer,
// DWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "3d81f634-8095-49c6-a5fe-6fe5e33bf0aa")]
public static extern Win32Error PowerWriteFriendlyName([Optional] HKEY RootPowerKey, [In] IntPtr SchemeGuid, [In] IntPtr SubGroupOfPowerSettingsGuid, [In] IntPtr PowerSettingGuid, string Buffer, uint BufferSize);
///
/// Sets the friendly name for the specified power setting, subgroup, or scheme. If the SchemeGuid parameter is not NULL but
/// both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are NULL, the friendly name of the power scheme will
/// be set. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are not NULL and the PowerSettingGuid parameter is
/// NULL, the friendly name of the subgroup will be set. If the SchemeGuid, SubGroupOfPowerSettingsGuid, and PowerSettingGuid
/// parameters are not NULL, the friendly name of the power setting will be set.
///
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The friendly name, in wide (Unicode) characters.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
[PInvokeData("powrprof.h", MSDNShortId = "3d81f634-8095-49c6-a5fe-6fe5e33bf0aa")]
public static Win32Error PowerWriteFriendlyName([In] Guid? SchemeGuid, [In] Guid? SubGroupOfPowerSettingsGuid, [In] Guid? PowerSettingGuid, string Buffer) =>
PwrGuidTsl(SchemeGuid, SubGroupOfPowerSettingsGuid, PowerSettingGuid, (p1, p2, p3) => PowerWriteFriendlyName(default, p1, p2, p3, Buffer, (uint)(Buffer.Length + 1) * 2));
/// Sets the icon resource for the specified power setting, subgroup, or scheme.
/// This parameter is reserved for future use and must be set to NULL.
/// The identifier of the power scheme.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The icon resource.
/// The size of the buffer pointed to by the Buffer parameter.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
///
///
/// If the SchemeGuid parameter is not NULL but both the SubGroupOfPowerSettingsGuid and PowerSettingGuid parameters are
/// NULL, the friendly name of the power scheme will be set. If the SchemeGuid and SubGroupOfPowerSettingsGuid parameters are
/// not NULL and the PowerSettingGuid parameter is NULL, the friendly name of the subgroup will be set. If the
/// SchemeGuid, SubGroupOfPowerSettingsGuid, and PowerSettingGuid parameters are not NULL, the friendly name of the power
/// setting will be set.
///
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwriteiconresourcespecifier DWORD
// PowerWriteIconResourceSpecifier( HKEY RootPowerKey, const GUID *SchemeGuid, const GUID *SubGroupOfPowerSettingsGuid, const GUID
// *PowerSettingGuid, UCHAR *Buffer, DWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "968b068a-f62a-4148-b96c-48f47218f368")]
public static extern Win32Error PowerWriteIconResourceSpecifier([Optional] HKEY RootPowerKey, in Guid SchemeGuid, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, IntPtr Buffer, uint BufferSize);
/// Sets the description for one of the possible choices of a power setting value.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting that is being used.
/// The zero-based index for the possible setting.
/// The description, in wide (Unicode) characters.
/// The size of the buffer pointed to by the Buffer parameter.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritepossibledescription DWORD
// PowerWritePossibleDescription( HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, ULONG
// PossibleSettingIndex, UCHAR *Buffer, DWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "5dce4dc1-d8af-41b8-bef0-8f11b246960f")]
public static extern Win32Error PowerWritePossibleDescription([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, [Optional] in Guid PowerSettingGuid, uint PossibleSettingIndex, string Buffer, uint BufferSize);
/// Sets the friendly name for the specified possible setting of a power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The zero-based index for the possible setting.
/// The friendly name, in wide (Unicode) characters.
/// The size of the buffer pointed to by the Buffer parameter.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritepossiblefriendlyname DWORD
// PowerWritePossibleFriendlyName( HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, ULONG
// PossibleSettingIndex, UCHAR *Buffer, DWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "981e813b-f3c8-44d2-ac1f-ca74f4795c85")]
public static extern Win32Error PowerWritePossibleFriendlyName([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, [Optional] in Guid PowerSettingGuid, uint PossibleSettingIndex, string Buffer, uint BufferSize);
/// Sets the value for a possible value of a power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The type of data for the value. The possible values are listed in Registry Value Types.
/// The zero-based index for the possible setting.
/// The value for the possible setting.
/// The size of the buffer pointed to by the Buffer parameter.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritepossiblevalue DWORD PowerWritePossibleValue(
// HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, ULONG Type, ULONG PossibleSettingIndex,
// UCHAR *Buffer, DWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "1c1e2707-fe5e-4199-85c9-c30deca917c5")]
public static extern Win32Error PowerWritePossibleValue([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, [Optional] in Guid PowerSettingGuid, REG_VALUE_TYPE Type, uint PossibleSettingIndex, IntPtr Buffer, uint BufferSize);
///
/// Sets the power attributes of a power key. If the PowerSettingGuid parameter is NULL then the attribute for SubGroupGuid is
/// set, otherwise the attribute for PowerSettingGuid is set.
///
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
///
/// The attributes to be associated with the specified power setting.
///
///
/// Value
/// Meaning
///
/// -
/// POWER_ATTRIBUTE_HIDE 1
/// Hide this power setting.
///
///
///
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritesettingattributes DWORD
// PowerWriteSettingAttributes( const GUID *SubGroupGuid, const GUID *PowerSettingGuid, DWORD Attributes );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "9c18f79a-809b-4e48-a749-5de061566362")]
public static extern Win32Error PowerWriteSettingAttributes(in Guid SubGroupGuid, in Guid PowerSettingGuid, POWER_ATTR Attributes);
/// Sets the increment for valid values between the power settings minimum and maximum.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The increment to be set.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritevalueincrement DWORD PowerWriteValueIncrement(
// HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, DWORD ValueIncrement );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "8de6b470-dc6c-4539-8766-3c07a2700cf8")]
public static extern Win32Error PowerWriteValueIncrement([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint ValueIncrement);
/// Sets the maximum value for the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The maximum value to be set.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritevaluemax DWORD PowerWriteValueMax( HKEY
// RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, DWORD ValueMaximum );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "5a633d49-0d25-4073-b7a7-d1bdef1b8697")]
public static extern Win32Error PowerWriteValueMax([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint ValueMaximum);
/// Sets the minimum value for the specified power setting.
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The minimum value to be set.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritevaluemin DWORD PowerWriteValueMin( HKEY
// RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, DWORD ValueMinimum );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "a50861f7-4236-4692-839a-071081e09ccf")]
public static extern Win32Error PowerWriteValueMin([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, uint ValueMinimum);
///
/// Writes the string used to describe the units of a power setting that supports a range of values. For example "minutes" may be
/// used to describe a timeout setting.
///
/// This parameter is reserved for future use and must be set to NULL.
///
///
/// The subgroup of power settings. This parameter can be one of the following values defined in WinNT.h. Use NO_SUBGROUP_GUID
/// to refer to the default power scheme.
///
///
///
/// Value
/// Meaning
///
/// -
/// NO_SUBGROUP_GUID fea3413e-7e05-4911-9a71-700331f1c294
/// Settings in this subgroup are part of the default power scheme.
///
/// -
/// GUID_DISK_SUBGROUP 0012ee47-9041-4b5d-9b77-535fba8b1442
/// Settings in this subgroup control power management configuration of the system's hard disk drives.
///
/// -
/// GUID_SYSTEM_BUTTON_SUBGROUP 4f971e89-eebd-4455-a8de-9e59040e7347
/// Settings in this subgroup control configuration of the system power buttons.
///
/// -
/// GUID_PROCESSOR_SETTINGS_SUBGROUP 54533251-82be-4824-96c1-47b60b740d00
/// Settings in this subgroup control configuration of processor power management features.
///
/// -
/// GUID_VIDEO_SUBGROUP 7516b95f-f776-4464-8c53-06167f40cc99
/// Settings in this subgroup control configuration of the video power management features.
///
/// -
/// GUID_BATTERY_SUBGROUP e73a048d-bf27-4f12-9731-8b2076e8891f
/// Settings in this subgroup control battery alarm trip points and actions.
///
/// -
/// GUID_SLEEP_SUBGROUP 238C9FA8-0AAD-41ED-83F4-97BE242C8F20
/// Settings in this subgroup control system sleep settings.
///
/// -
/// GUID_PCIEXPRESS_SETTINGS_SUBGROUP 501a4d13-42af-4429-9fd1-a8218c268e20
/// Settings in this subgroup control PCI Express settings.
///
///
///
/// The identifier of the power setting.
/// The units specifier, in wide (Unicode) characters.
/// The size of the buffer pointed to by the Buffer parameter.
/// Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.
/// Changes to the settings for the active power scheme do not take effect until you call the PowerSetActiveScheme function.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-powerwritevalueunitsspecifier DWORD
// PowerWriteValueUnitsSpecifier( HKEY RootPowerKey, const GUID *SubGroupOfPowerSettingsGuid, const GUID *PowerSettingGuid, UCHAR
// *Buffer, DWORD BufferSize );
[DllImport(Lib.PowrProf, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("powrprof.h", MSDNShortId = "d9a81077-23e8-4bae-8e70-ffaaaf1ecda3")]
public static extern Win32Error PowerWriteValueUnitsSpecifier([Optional] HKEY RootPowerKey, in Guid SubGroupOfPowerSettingsGuid, in Guid PowerSettingGuid, string? Buffer, uint BufferSize);
///
///
/// [ ReadGlobalPwrPolicy is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. See Remarks.]
///
/// Retrieves the current global power policy settings.
///
/// A pointer to a GLOBAL_POWER_POLICY structure that receives the information.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The GLOBAL_POWER_POLICY structure contains policy settings that are common to all power schemes. This structure contains both
/// user and computer policy settings.
///
///
/// Starting with Windows Vista, use the PowerEnumerate function to enumerate power settings for a specified scheme and the power
/// read functions to retrieve individual settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-readglobalpwrpolicy BOOLEAN ReadGlobalPwrPolicy(
// PGLOBAL_POWER_POLICY pGlobalPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "65da3d9f-b688-4d41-9da0-05159297d169")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ReadGlobalPwrPolicy(out GLOBAL_POWER_POLICY pGlobalPowerPolicy);
///
///
/// [ ReadProcessorPwrScheme is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. See Remarks.]
///
/// Retrieves the processor power policy settings for the specified power scheme.
///
/// The index of the power scheme to be read.
///
/// A pointer to a MACHINE_PROCESSOR_POWER_POLICY structure that receives the processor power policy settings.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The MACHINE_PROCESSOR_POWER_POLICY structure contains processor power policy settings for use while the system is running on AC
/// power or battery power.
///
///
/// Starting with Windows Vista, power management configuration of the system's processor is controlled through the
/// GUID_PROCESSOR_SETTINGS_SUBGROUP power settings subgroup. Use the PowerEnumerate function to enumerate individual settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-readprocessorpwrscheme BOOLEAN ReadProcessorPwrScheme(
// UINT uiID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "740095a7-9def-48a3-9cbb-1da91b052321")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ReadProcessorPwrScheme(uint uiID, out MACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy);
///
///
/// [ ReadPwrScheme is available for use in the operating systems specified in the Requirements section. It may be altered or
/// unavailable in subsequent versions. See Remarks.]
///
/// Retrieves the power policy settings that are unique to the specified power scheme.
///
/// The index of the power scheme to be read.
/// A pointer to a POWER_POLICY structure that receives the power policy settings.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// If the power scheme specified does not exist, the function returns FALSE.
///
/// To retrieve information about the power policy settings currently in use by the system, call the GetActivePwrScheme function. To
/// retrieve additional information about the current power policy settings, call the CallNtPowerInformation function.
///
///
/// Starting with Windows Vista, use the PowerEnumerate function to enumerate power settings for a specified scheme and the power
/// read functions to retrieve individual settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-readpwrscheme BOOLEAN ReadPwrScheme( UINT uiID,
// PPOWER_POLICY pPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "a8d93820-b652-4358-8039-8987fac95dca")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ReadPwrScheme(uint uiID, out POWER_POLICY pPowerPolicy);
///
///
/// [ SetActivePwrScheme is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. Applications written for Windows Vista and later should use PowerSetActiveScheme instead.]
///
/// Sets the active power scheme.
///
/// The index of the power scheme to be activated.
///
/// A pointer to an optional GLOBAL_POWER_POLICY structure, which provides global power policy settings to be merged with the power
/// scheme when it becomes active.
///
///
/// A pointer to an optional POWER_POLICY structure, which provides power policy settings to be merged with the power scheme when it
/// becomes active.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// Use this function to make long-term changes to the system configuration. To temporarily keep the system running while an
/// application is performing a task, use the SetThreadExecutionState function.
///
/// If the power scheme specified by uiID does not exist, the function returns zero.
///
/// If lpGlobalPowerPolicy is NULL, the function uses the current global power policy settings set by WriteGlobalPwrPolicy.
/// Otherwise, the settings in the specified structure replace the current global power policy settings.
///
///
/// If lpPowerPolicy is NULL, the function uses the current power policy settings for the power scheme. Otherwise, the
/// settings in the specified structure replace the current power policy settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-setactivepwrscheme BOOLEAN SetActivePwrScheme( UINT
// uiID, PGLOBAL_POWER_POLICY pGlobalPowerPolicy, PPOWER_POLICY pPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "f449ff0d-5c22-4c6d-8c88-dc18258a8c6d")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool SetActivePwrScheme(uint uiID, in GLOBAL_POWER_POLICY pGlobalPowerPolicy, in POWER_POLICY pPowerPolicy);
///
/// Suspends the system by shutting power down. Depending on the Hibernate parameter, the system either enters a suspend (sleep)
/// state or hibernation (S4).
///
///
/// If this parameter is TRUE, the system hibernates. If the parameter is FALSE, the system is suspended.
///
/// This parameter has no effect.
///
/// If this parameter is TRUE, the system disables all wake events. If the parameter is FALSE, any system wake events
/// remain enabled.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The calling process must have the SE_SHUTDOWN_NAME privilege. To enable the SE_SHUTDOWN_NAME privilege, use the
/// AdjustTokenPrivileges function. For more information, see Changing Privileges in a Token.
///
///
/// An application may use SetSuspendState to transition the system from the working state to the standby (sleep), or
/// optionally, hibernate (S4) state. This function is similar to the SetSystemPowerState function.
///
///
/// For more information on using PowrProf.h, see Power Schemes. For information about events that can wake the system, see System
/// Wake-up Events.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-setsuspendstate BOOLEAN SetSuspendState( BOOLEAN
// bHibernate, BOOLEAN bForce, BOOLEAN bWakeupEventsDisabled );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "63cb6574-8c0d-4bcb-832c-7088447a5c04")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool SetSuspendState([MarshalAs(UnmanagedType.U1)] bool bHibernate, [MarshalAs(UnmanagedType.U1)] bool bForce, [MarshalAs(UnmanagedType.U1)] bool bWakeupEventsDisabled);
///
///
/// [ WriteGlobalPwrPolicy is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. See Remarks.]
///
/// Writes global power policy settings.
///
///
/// A pointer to a GLOBAL_POWER_POLICY structure that contains the power policy settings to be written.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The function replaces any existing global power policy settings. Each user has a separate global power scheme, which contains
/// power policy settings that apply to all power schemes for that user.
///
///
/// Starting with Windows Vista, use the PowerEnumerate function to enumerate power settings for a specified scheme and the power
/// write functions to write individual settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-writeglobalpwrpolicy BOOLEAN WriteGlobalPwrPolicy(
// PGLOBAL_POWER_POLICY pGlobalPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "293dc3a5-5e6b-4709-8439-67d2339740e7")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool WriteGlobalPwrPolicy(in GLOBAL_POWER_POLICY pGlobalPowerPolicy);
///
///
/// [ WriteProcessorPwrScheme is available for use in the operating systems specified in the Requirements section. It may be
/// altered or unavailable in subsequent versions. See Remarks.]
///
/// Writes processor power policy settings for the specified power scheme.
///
/// The index of the power scheme to be written.
///
/// A pointer to a MACHINE_PROCESSOR_POWER_POLICY structure that contains the power policy settings to be written.
///
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// This change does not affect the current system power policy. To apply this change to the current system power policy, call the
/// SetActivePwrScheme function, using the index of this power scheme.
///
///
/// Starting with Windows Vista, power management configuration of the system's processor is controlled through the
/// GUID_PROCESSOR_SETTINGS_SUBGROUP power settings subgroup. Use the PowerEnumerate function to enumerate individual settings.
///
/// For more information on using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-writeprocessorpwrscheme BOOLEAN WriteProcessorPwrScheme(
// UINT uiID, PMACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "70e18f50-4774-4a7c-8fe0-7fd6a54aaa90")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool WriteProcessorPwrScheme(uint uiID, in MACHINE_PROCESSOR_POWER_POLICY pMachineProcessorPowerPolicy);
///
///
/// [ WritePwrScheme is no longer available for use as of Windows Vista. Instead, use the PowerEnumerate function to enumerate
/// power settings for a specified scheme, and the power write functions to write individual settings.]
///
/// Writes policy settings that are unique to the specified power scheme.
///
///
/// The index of the power scheme to be written. If a power scheme with the same index already exists, it is replaced. Otherwise, a
/// new power scheme is created.
///
/// The name of the power scheme.
/// The description of the power scheme.
/// A pointer to a POWER_POLICY structure that contains the power policy settings to be written.
///
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// This change does not affect the current system power policy. To apply this change to the current system power policy, call the
/// SetActivePwrScheme function with the index of this power scheme.
///
///
/// Power policy schemes written using WritePwrScheme are permanently stored in the system registry hives, and remain
/// available for use in the Power Options control panel program, or by subsequent calls to the power scheme API. To permanently
/// remove a power scheme from the system, call the DeletePwrScheme function.
///
/// For more information about using PowrProf.h, see Power Schemes.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/nf-powrprof-writepwrscheme BOOLEAN WritePwrScheme( PUINT puiID,
// LPCWSTR lpszSchemeName, LPCWSTR lpszDescription, PPOWER_POLICY lpScheme );
[DllImport(Lib.PowrProf, SetLastError = true, ExactSpelling = true)]
[PInvokeData("powrprof.h", MSDNShortId = "b9233601-6848-41c4-bb58-27decad60ba5")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool WritePwrScheme(ref uint puiID, [MarshalAs(UnmanagedType.LPWStr)] string lpszSchemeName, [MarshalAs(UnmanagedType.LPWStr)] string lpszDescription, in POWER_POLICY lpScheme);
private static unsafe TRet PwrGuidTsl(Guid? g1, Guid? g2, Guid? g3, Func f)
{
var guids = new Guid[] { g1.GetValueOrDefault(), g2.GetValueOrDefault(), g3.GetValueOrDefault() };
fixed (Guid* ptrs = guids)
return f(g1.HasValue ? (IntPtr)(void*)&ptrs[0] : IntPtr.Zero, g2.HasValue ? (IntPtr)(void*)&ptrs[1] : IntPtr.Zero, g3.HasValue ? (IntPtr)(void*)&ptrs[2] : IntPtr.Zero);
}
private static SafeHGlobalHandle PwrReadMem(PwrReadMemFunc f, Guid? g1, Guid? g2, Guid? g3) =>
PwrGuidTsl(g1, g2, g3, (p1, p2, p3) =>
{
var sz = 0U;
var err = f(HKEY.NULL, p1, p2, p3, IntPtr.Zero, ref sz);
if (err.Failed)
{
if (err == Win32Error.ERROR_FILE_NOT_FOUND) return SafeHGlobalHandle.Null;
if (err != Win32Error.ERROR_MORE_DATA) throw err.GetException()!;
}
var p = new SafeHGlobalHandle((int)sz);
f(HKEY.NULL, p1, p2, p3, (IntPtr)p, ref sz).ThrowIfFailed();
return p;
});
/// Contains parameters used when registering for a power notification.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-device_notify_subscribe_parameters typedef struct
// _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS { PDEVICE_NOTIFY_CALLBACK_ROUTINE Callback; PVOID Context; }
// DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS, *PDEVICE_NOTIFY_SUBSCRIBE_PARAMETERS;
[PInvokeData("powrprof.h", MSDNShortId = "749F7C6F-1A42-43DE-921E-C3654034570D")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS
{
/// Indicates the callback function that will be called when the application receives the notification.
[MarshalAs(UnmanagedType.FunctionPtr)]
public DeviceNotifyCallbackRoutine Callback;
/// The context of the application registering for the notification.
public IntPtr Context;
}
///
/// Contains global computer power policy settings that apply to all power schemes for all users. This structure is part of the
/// GLOBAL_POWER_POLICY structure.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_global_machine_power_policy typedef struct
// _GLOBAL_MACHINE_POWER_POLICY { ULONG Revision; SYSTEM_POWER_STATE LidOpenWakeAc; SYSTEM_POWER_STATE LidOpenWakeDc; ULONG
// BroadcastCapacityResolution; } GLOBAL_MACHINE_POWER_POLICY, *PGLOBAL_MACHINE_POWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "79b57da4-0125-427b-aec7-7ca4c9bfb870")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct GLOBAL_MACHINE_POWER_POLICY
{
///
/// The current structure revision level. Set this value by calling GetCurrentPowerPolicies or ReadGlobalPwrPolicy before using a
/// GLOBAL_MACHINE_POWER_POLICY structure to set power policy.
///
public uint Revision;
///
/// The maximum power state (highest Sx value) from which a lid-open event should wake the system when running on AC power. This
/// member must be one of the SYSTEM_POWER_STATE enumeration type values. A value of PowerSystemUnspecified indicates that
/// a lid-open event does not wake the system.
///
public SYSTEM_POWER_STATE LidOpenWakeAc;
///
/// The maximum power state (highest Sx value) from which a lid-open event should wake the system when running on battery. This
/// member must be one of the SYSTEM_POWER_STATE enumeration type values. A value of PowerSystemUnspecified indicates that
/// a lid-open event does not wake the system.
///
public SYSTEM_POWER_STATE LidOpenWakeDc;
///
/// The resolution of change in the current battery capacity that should cause the system to be notified of a system power state
/// changed event.
///
public uint BroadcastCapacityResolution;
}
/// Contains global power policy settings that apply to all power schemes.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_global_power_policy typedef struct _GLOBAL_POWER_POLICY
// { GLOBAL_USER_POWER_POLICY user; GLOBAL_MACHINE_POWER_POLICY mach; } GLOBAL_POWER_POLICY, *PGLOBAL_POWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "5c177093-0c16-4a84-9212-f2376de6965b")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct GLOBAL_POWER_POLICY
{
/// A GLOBAL_USER_POWER_POLICY structure that defines the global user power policy settings.
public GLOBAL_USER_POWER_POLICY user;
/// A GLOBAL_MACHINE_POWER_POLICY structure that defines the global computer power policy settings.
public GLOBAL_MACHINE_POWER_POLICY mach;
}
///
/// Contains global user power policy settings that apply to all power schemes for a user. This structure is part of the
/// GLOBAL_POWER_POLICY structure.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_global_user_power_policy typedef struct
// _GLOBAL_USER_POWER_POLICY { ULONG Revision; POWER_ACTION_POLICY PowerButtonAc; POWER_ACTION_POLICY PowerButtonDc;
// POWER_ACTION_POLICY SleepButtonAc; POWER_ACTION_POLICY SleepButtonDc; POWER_ACTION_POLICY LidCloseAc; POWER_ACTION_POLICY
// LidCloseDc; SYSTEM_POWER_LEVEL DischargePolicy[NUM_DISCHARGE_POLICIES]; ULONG GlobalFlags; } GLOBAL_USER_POWER_POLICY, *PGLOBAL_USER_POWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "0e89ae66-a889-4929-b028-125fcef5c89c")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct GLOBAL_USER_POWER_POLICY
{
///
/// The current structure revision level. Set this value by calling GetCurrentPowerPolicies or ReadGlobalPwrPolicy before using a
/// GLOBAL_USER_POWER_POLICY structure to set power policy.
///
public uint Revision;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when the power button is pressed and the system is running on
/// AC power.
///
public POWER_ACTION_POLICY PowerButtonAc;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when the power button is pressed and the system is running on
/// battery power.
///
public POWER_ACTION_POLICY PowerButtonDc;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when the sleep button is pressed and the system is running on
/// AC power.
///
public POWER_ACTION_POLICY SleepButtonAc;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when the sleep button is pressed and the system is running on
/// battery power.
///
public POWER_ACTION_POLICY SleepButtonDc;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when the lid is closed and the system is running on AC power.
///
public POWER_ACTION_POLICY LidCloseAc;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when the lid is closed and the system is running on battery power.
///
public POWER_ACTION_POLICY LidCloseDc;
/// An array of SYSTEM_POWER_LEVEL structures that defines the actions to take at system battery discharge events.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public SYSTEM_POWER_LEVEL[] DischargePolicy;
///
///
/// A flag that enables or disables miscellaneous user power policy settings. This member can be one or more of the values
/// described in Global Flags Constants.
///
///
public GlobalFlags GlobalFlags;
}
///
/// Contains computer power policy settings that are unique to each power scheme on the computer. This structure is part of the
/// POWER_POLICY structure.
///
///
/// DozeS4TimeoutAc and DozeS4TimeoutDc correspond to the DozeS4Timeout member of SYSTEM_POWER_POLICY. These
/// values are merged from the machine power policy to the system power policy when the SetActivePwrScheme function is called to
/// apply a power scheme.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_machine_power_policy typedef struct
// _MACHINE_POWER_POLICY { ULONG Revision; SYSTEM_POWER_STATE MinSleepAc; SYSTEM_POWER_STATE MinSleepDc; SYSTEM_POWER_STATE
// ReducedLatencySleepAc; SYSTEM_POWER_STATE ReducedLatencySleepDc; ULONG DozeTimeoutAc; ULONG DozeTimeoutDc; ULONG DozeS4TimeoutAc;
// ULONG DozeS4TimeoutDc; UCHAR MinThrottleAc; UCHAR MinThrottleDc; UCHAR pad1[2]; POWER_ACTION_POLICY OverThrottledAc;
// POWER_ACTION_POLICY OverThrottledDc; } MACHINE_POWER_POLICY, *PMACHINE_POWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "41dca573-a73d-430c-9bd3-083e72aecbdc")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MACHINE_POWER_POLICY
{
///
/// The current structure revision level. Set this value by calling GetCurrentPowerPolicies or ReadPwrScheme before using a
/// MACHINE_POWER_POLICY structure to set power policy.
///
public uint Revision;
///
/// The minimum system power state (lowest Sx value) to enter on a system sleep action when running on AC power. This member must
/// be one of the SYSTEM_POWER_STATE enumeration type values.
///
public SYSTEM_POWER_STATE MinSleepAc;
///
/// The minimum system power state (lowest Sx value) to enter on a system sleep action when running on battery power. This member
/// must be one of the SYSTEM_POWER_STATE enumeration type values.
///
public SYSTEM_POWER_STATE MinSleepDc;
///
/// The maximum system power state (highest Sx value) to enter on a system sleep action when running on AC power, and when there
/// are outstanding latency requirements. This member must be one of the SYSTEM_POWER_STATE enumeration type values. If an
/// application calls RequestWakeupLatency with LT_LOWEST_LATENCY, ReducedLatencySleepAc is used in place of MaxSleepAc.
///
public SYSTEM_POWER_STATE ReducedLatencySleepAc;
///
/// The maximum system power state (highest Sx value) to enter on a system sleep action when running on battery power, and when
/// there are outstanding latency requirements. This member must be one of the SYSTEM_POWER_STATE enumeration type values. If an
/// application calls RequestWakeupLatency with LT_LOWEST_LATENCY, ReducedLatencySleepAc is used in place of MaxSleepAc.
///
public SYSTEM_POWER_STATE ReducedLatencySleepDc;
/// This member is ignored.
public uint DozeTimeoutAc;
/// This member is ignored.
public uint DozeTimeoutDc;
///
/// Time to wait between entering the suspend state and entering the hibernate sleeping state when the system is running on AC
/// power, in seconds. A value of zero indicates never hibernate.
///
public uint DozeS4TimeoutAc;
///
/// Time to wait between entering the suspend state and entering the hibernate sleeping state when the system is running on
/// battery power, in seconds. A value of zero indicates never hibernate.
///
public uint DozeS4TimeoutDc;
///
/// The minimum throttle setting allowed before being over-throttled when the system is running on AC power. Thermal conditions
/// would be the only reason for going below the minimum setting. When the processor is over-throttled, the system will initiate
/// the OverThrottledAc policy. Note that the power policy manager has a hard-coded policy to initiate a
/// CriticalShutdownOff whenever any thermal zone indicates a critical thermal condition. Range: 0-100.
///
public byte MinThrottleAc;
///
/// The minimum throttle setting allowed before being over-throttled when the system is running on battery power. Thermal
/// conditions would be the only reason for going below the minimum setting. When the processor is over-throttled, the system
/// will initiate the OverThrottledDc policy. Note that the power policy manager has a hard-coded policy to initiate a
/// CriticalShutdownOff whenever any thermal zone indicates a critical thermal condition. Range: 0-100.
///
public byte MinThrottleDc;
/// Reserved.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
private readonly byte[] pad1;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when a processor has become over-throttled (as defined by the
/// MinThrottleAc member) when the system is running on AC power.
///
public POWER_ACTION_POLICY OverThrottledAc;
///
/// A POWER_ACTION_POLICY structure that defines the action to take when a processor has become over-throttled (as defined by the
/// MinThrottleDc member) when the system is running on battery power.
///
public POWER_ACTION_POLICY OverThrottledDc;
}
/// Contains processor power policy settings that apply while the system is running on AC power or battery power.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_machine_processor_power_policy typedef struct
// _MACHINE_PROCESSOR_POWER_POLICY { ULONG Revision; PROCESSOR_POWER_POLICY ProcessorPolicyAc; PROCESSOR_POWER_POLICY
// ProcessorPolicyDc; } MACHINE_PROCESSOR_POWER_POLICY, *PMACHINE_PROCESSOR_POWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "54403b81-97bc-4f2b-8721-48c9f69e2773")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MACHINE_PROCESSOR_POWER_POLICY
{
///
/// The current structure revision level. Set this value by calling ReadProcessorPwrScheme before using a
/// MACHINE_PROCESSOR_POWER_POLICY structure to set power policy.
///
public uint Revision;
///
/// A PROCESSOR_POWER_POLICY structure that defines the processor power policy settings used while the computer is running on AC power.
///
public PROCESSOR_POWER_POLICY ProcessorPolicyAc;
///
/// A PROCESSOR_POWER_POLICY structure that defines the processor power policy settings used while the computer is running on
/// battery power.
///
public PROCESSOR_POWER_POLICY ProcessorPolicyDc;
}
/// Contains power policy settings that are unique to each power scheme.
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_power_policy typedef struct _POWER_POLICY {
// USER_POWER_POLICY user; MACHINE_POWER_POLICY mach; } POWER_POLICY, *PPOWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "ba49fca6-04b6-4627-a653-07c3fc0dab22")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct POWER_POLICY
{
/// A USER_POWER_POLICY structure that defines user power policy settings.
public USER_POWER_POLICY user;
/// A MACHINE_POWER_POLICY structure that defines computer power policy settings.
public MACHINE_POWER_POLICY mach;
}
/// Contains a thermal event.
///
/// Drivers use the THERMAL_EVENT structure to specify a thermal event. By calling the PowerReportThermalEvent routine, the
/// operating system can record the thermal event in the system event log.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_thermal_event typedef struct _THERMAL_EVENT { ULONG
// Version; ULONG Size; ULONG Type; ULONG Temperature; ULONG TripPointTemperature; LPWSTR Initiator; } THERMAL_EVENT, *PTHERMAL_EVENT;
[PInvokeData("powrprof.h", MSDNShortId = "80B6A494-AED6-4EF0-8B69-4AA5DA6BCBB3")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct THERMAL_EVENT
{
/// The current structure version level, THERMAL_EVENT_VERSION.
public uint Version;
/// The size of the structure.
public uint Size;
///
/// One of the thermal event values from Ntpoapi.h: THERMAL_EVENT_SHUTDOWN, THERMAL_EVENT_HIBERNATE, or THERMAL_EVENT_UNSPECIFIED.
///
public uint Type;
///
/// The temperature, in tenths of a degree Kelvin, that the sensor was at after crossing the trip point (or zero if unknown).
///
public uint Temperature;
/// The temperature, in tenths of a degree Kelvin, of the trip point (or zero if unknown).
public uint TripPointTemperature;
/// A pointer to a NULL-terminated, wide-character string that identifies the sensor whose threshold was crossed.
public string Initiator;
}
///
/// Contains power policy settings that are unique to each power scheme for a user. This structure is part of the POWER_POLICY structure.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/powrprof/ns-powrprof-_user_power_policy typedef struct _USER_POWER_POLICY {
// ULONG Revision; POWER_ACTION_POLICY IdleAc; POWER_ACTION_POLICY IdleDc; ULONG IdleTimeoutAc; ULONG IdleTimeoutDc; UCHAR
// IdleSensitivityAc; UCHAR IdleSensitivityDc; UCHAR ThrottlePolicyAc; UCHAR ThrottlePolicyDc; SYSTEM_POWER_STATE MaxSleepAc;
// SYSTEM_POWER_STATE MaxSleepDc; ULONG Reserved[2]; ULONG VideoTimeoutAc; ULONG VideoTimeoutDc; ULONG SpindownTimeoutAc; ULONG
// SpindownTimeoutDc; BOOLEAN OptimizeForPowerAc; BOOLEAN OptimizeForPowerDc; UCHAR FanThrottleToleranceAc; UCHAR
// FanThrottleToleranceDc; UCHAR ForcedThrottleAc; UCHAR ForcedThrottleDc; } USER_POWER_POLICY, *PUSER_POWER_POLICY;
[PInvokeData("powrprof.h", MSDNShortId = "616c45f6-ec80-42d9-a485-e9e778f2b971")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USER_POWER_POLICY
{
///
/// The current structure revision level. Set this value by calling GetCurrentPowerPolicies or ReadPwrScheme before using a
/// USER_POWER_POLICY structure to set power policy.
///
public uint Revision;
///
/// A POWER_ACTION_POLICY structure that defines the system power action to initiate when the system is running on AC (utility)
/// power and the system idle timer expires.
///
public POWER_ACTION_POLICY IdleAc;
///
/// A POWER_ACTION_POLICY structure that defines the system power action to initiate when the system is running on battery power
/// and the system idle timer expires.
///
public POWER_ACTION_POLICY IdleDc;
///
///
/// The time that the level of system activity must remain below the idle detection threshold before the system idle timer
/// expires when running on AC (utility) power, in seconds.
///
///
/// This member is ignored if the system is performing an automated resume because there is no user present. To temporarily keep
/// the system running while an application is performing a task, use the SetThreadExecutionState function.
///
///
public uint IdleTimeoutAc;
///
///
/// The time that the level of system activity must remain below the idle detection threshold before the system idle timer
/// expires when running on battery power, in seconds.
///
///
/// This member is ignored if the system is performing an automated resume because there is no user present. To temporarily keep
/// the system running while an application is performing a task, use the SetThreadExecutionState function.
///
///
public uint IdleTimeoutDc;
///
/// The level of system activity that defines the threshold for idle detection when the system is running on AC (utility) power,
/// expressed as a percentage.
///
public byte IdleSensitivityAc;
///
/// The level of system activity that defines the threshold for idle detection when the system is running on battery power,
/// expressed as a percentage.
///
public byte IdleSensitivityDc;
/// The processor dynamic throttling policy to use when the system is running on AC (utility) power.
public byte ThrottlePolicyAc;
/// The processor dynamic throttling policy to use when the system is running on battery power.
public byte ThrottlePolicyDc;
///
/// The maximum system sleep state when the system is running on AC (utility) power. This member must be one of the
/// SYSTEM_POWER_STATE enumeration type values.
///
public SYSTEM_POWER_STATE MaxSleepAc;
///
/// The maximum system sleep state when the system is running on battery power. This member must be one of the SYSTEM_POWER_STATE
/// enumeration type values.
///
public SYSTEM_POWER_STATE MaxSleepDc;
/// Reserved.
/// The .
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
private readonly uint[] Reserved;
///
/// The time before the display is turned off when the system is running on AC (utility) power, in seconds.
///
public uint VideoTimeoutAc;
///
/// The time before the display is turned off when the system is running on battery power, in seconds.
///
public uint VideoTimeoutDc;
///
/// The time before power to fixed disk drives is turned off when the system is running on AC (utility) power, in seconds.
///
public uint SpindownTimeoutAc;
///
/// The time before power to fixed disk drives is turned off when the system is running on battery power, in seconds.
///
public uint SpindownTimeoutDc;
///
///
/// If this member is TRUE, the system will turn on cooling fans and run the processor at full speed when passive cooling
/// is specified and the system is running on AC (utility) power. This causes the operating system to be biased toward using the
/// fan and running the processor at full speed.
///
///
[MarshalAs(UnmanagedType.U1)] public bool OptimizeForPowerAc;
///
///
/// If this member is TRUE, the system will turn on cooling fans and run the processor at full speed when passive cooling
/// is specified and the system is running on battery power. This causes the operating system to be biased toward using the fan
/// and running the processor at full speed.
///
///
[MarshalAs(UnmanagedType.U1)] public bool OptimizeForPowerDc;
///
///
/// The lower limit that the processor may be throttled down to prior to turning on system fans in response to a thermal event
/// while the system is operating on AC (utility) power, expressed as a percentage.
///
///
public byte FanThrottleToleranceAc;
///
///
/// The lower limit that the processor may be throttled down to prior to turning on system fans in response to a thermal event
/// while the system is operating on battery power, expressed as a percentage.
///
///
public byte FanThrottleToleranceDc;
///
///
/// The processor throttle level to be imposed by the system while the computer is running on AC (utility) power, expressed as a percentage.
///
///
public byte ForcedThrottleAc;
///
///
/// The processor throttle level to be imposed by the system while the computer is running on battery power, expressed as a percentage.
///
///
public byte ForcedThrottleDc;
}
}