PowerSetActiveScheme (powrprof)
Last changed: -179.97.153.215

.
Summary
Sets the active power scheme for the current user.

C# Signature:

[DllImport("powrprof.dll")]
static extern uint PowerSetActiveScheme (IntPtr userRootPowerKey, ref Guid schemeGuid);

VB Signature:

Declare Function PowerSetActiveScheme Lib "powrprof.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one?  Please contribute it!

Notes:

Returns ERROR_SUCCESS (zero) if the call was successful, and a nonzero value if the call failed.

Tips & Tricks:

Please add some!

Sample Code:

public static void PowerSetActiveScheme (Guid schemeGuid)
{
     uint result = PowerSetActiveScheme(IntPtr.Zero, ref schemeGuid);
     result (res != 0) throw new COMException($"Error occurred. Win32 error code: {res}");
}

Documentation