SetActivePwrScheme function (powrprof.h)

[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.

Syntax

BOOLEAN SetActivePwrScheme(
  [in]           UINT                 uiID,
  [in, optional] PGLOBAL_POWER_POLICY pGlobalPowerPolicy,
  [in, optional] PPOWER_POLICY        pPowerPolicy
);

Parameters

[in] uiID

The index of the power scheme to be activated.

[in, optional] pGlobalPowerPolicy

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.

[in, optional] pPowerPolicy

A pointer to an optional POWER_POLICY structure, which provides power policy settings to be merged with the power scheme when it becomes active.

Return value

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.

Remarks

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.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header powrprof.h
Library PowrProf.lib
DLL PowrProf.dll

See also

GLOBAL_POWER_POLICY

GetActivePwrScheme

POWER_POLICY

Power Management Functions

Power Schemes