-
Reading registry
Hey guys, I was searching alot in google but I could not find a way that worked to read the data of a key. I used this to open the key
Code:
RegOpenKeyEx(HKEY_LOCAL_MACHINE , "Software\\Someapp\\Theapp" , 0 ,
KEY_READ , &location );
RegQueryValueEx(hkey , "Path" , NULL , &data_type ,
(BYTE*)&value , &size);
But how can I read the data inside? Lets say that "Path" is the directory of the application.
-
Shouldn't location be instead of hkey, and I think you got more than 2 erros there... read at msdn or google for more examples.
-
Okay well I redid the code and now its working.
Code:
int main ()
{
HKEY keyHandle;
char rgValue [1024];
char fnlRes [1024];
DWORD size1;
DWORD Type;
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"SOFTWARE\\somesoft\\app",0,
KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS)
{
size1=1023;
RegQueryValueEx( keyHandle, "Path", NULL, &Type,
(LPBYTE)rgValue,&size1);
printf( "Your path is %s\n", rgValue );
}
else strcpy(fnlRes,"Somesoft is not installed on your computer!");
RegCloseKey(keyHandle);
std::cin.get();
return 0;
}
But now I want to go to that directory I tryed using
And as I expected it didn't work any help?
EDIT: fixed every thing works