I want to be able to be able to read and change the value of a key from the registry. I have a fairly good idea of how to change it, but I am having trouble reading the value. I have looked at the msdn, but it has not helped. Here is the code:
Code:
case WM_CREATE:
{
RegOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE//Microsoft//Windows NT//CurrentVersion//Winlogon",&hKey);
char str[MAX_PATH];
LONG strc = MAX_PATH;
DWORD hi;
hi = RegQueryValue(hKey,"Shell",str,&strc);
if(hi!=ERROR_SUCCESS)
{
SetWindowText(hwnd,"Error");
wsprintf(str,"%d",hi);
MessageBox(NULL,str,"Hi",0);
}
else
{
SetWindowText(hwnd,str);
}
}
break;
I have declared hKey at the beginning of the file. What am I doing wrong?