Hello!
I've been trying to write code that would retrieve the GUIDs of all of the power schemes available on the system. I figured the best (only?) way to do this would be to get the information straight from the registry (HKLM\\SYSTEM\\ControlSet001\\Control\\Power\\User\\PowerSchemes). However, I'm running into the small snag of the keys I get from the registry being strings and not GUIDs. So I can't plug them into functions such as PowerSetActiveScheme, which would require a GUID argument.
What I have right now is...
TCHAR lszValue[100];
LONG lRet, lEnumRet;
HKEY hKey;
DWORD dwLength=100;
int i=0;
lRet = RegOpenKeyEx (HKEY_LOCAL_MACHINE, _T("SYSTEM\\ControlSet001\\Control\\Power\\User\\PowerSchemes"), 0L, KEY_READ , &hKey);
if(lRet == ERROR_SUCCESS)
{
lEnumRet = RegEnumKey (hKey, i, lszValue, dwLength);
SetDlgItemText(hWnd, IDC_OUTPUT, lszValue);
}
That's just a temporary thing to show me what I'm getting from the registry. It looks like a GUID to me! (Or at least it matches what I see when I do "powercfg /list" to view my available power schemes.) So my question is, how might I go about converting the value currently stored in lszValue into a GUID that I can use in the Windows power functions (the one I'm eyeing is PowerSetActiveScheme)?
Or am I taking completely the wrong approach? If anybody has any hints on how I might get a complete list, including GUIDs, of all power schemes, that would be great.
Thank you!