C++ Learning Community Forum
September 04, 2010, 04:37:45 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: GUID From the Registry And/Or Listing Power Schemes  (Read 583 times)
camilla
N00b!!1
*
Posts: 1


View Profile
« on: January 27, 2010, 09:37:45 AM »

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

Code:
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!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!