Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# : Switch between power plans

i am creating an API and i want to switch between power plans

[Balanced , High performance , Power saver]

, my problem isn`t on the code , coding is easy , but i want to know where can i find these power planes .exe files or even values in registry to modify it

like image 960
BOSS Avatar asked May 13 '11 11:05

BOSS


3 Answers

Separate from C#, in 2011 Raymond Chen recommended that users use the GUI, or for those who prefer a terminal:

If you are using Vista or above, from the command line, run :

powercfg -aliases

However, this doesn't work for me as -aliases is not a valid switch on Windows XP.

EDIT: Or, you can just use this list of helpful GUIDs!

like image 55
RB. Avatar answered Sep 22 '22 08:09

RB.


While you could certainly use an external tool like powercfg, you could just as well use the Power Management API

http://msdn.microsoft.com/en-us/library/aa372711%28v=VS.85%29.aspx

Or Windows Management Instrumenation (WMI)

http://msdn.microsoft.com/en-us/library/dd904518%28v=VS.85%29.aspx

like image 33
Till Avatar answered Sep 23 '22 08:09

Till


You'll find them in the winnt.h SDK header file. Stored in c:\program files\microsoft sdks\windows\v6.0a\include for VS2008, v7.0a for VS2010. Search for "GUID_MAX_POWER_SAVINGS" to find this:

// =========================================
// Define GUIDs which represent well-known power schemes
// =========================================
//

//
// Maximum Power Savings - indicates that very aggressive power savings measures will be used to help
//                         stretch battery life.
//
// {a1841308-3541-4fab-bc81-f71556f20b4a}
//
DEFINE_GUID( GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A );

//
// No Power Savings - indicates that almost no power savings measures will be used.
//
// {8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c}
//
DEFINE_GUID( GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C );

//
// Typical Power Savings - indicates that fairly aggressive power savings measures will be used.
//
// {381b4222-f694-41f0-9685-ff5bb260df2e}
//
DEFINE_GUID( GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E );
like image 45
Hans Passant Avatar answered Sep 22 '22 08:09

Hans Passant