Original Post
I''ve got this class that has these two functions:
the first one should open a key and the other one should read a value from this key. The code for these functions:
and this is the way i call these functions:
This code compiles and I can run the program but queryvalueex returns 87 and doesn''t return the value of the key. The first function returns 0.
Mankind must put an end to war before war puts an end to mankind.
John F. Kennedy
OpenKey(HKEY Pred_Key,char *SubKey_Name,REGSAM Sam,HKEY &Key) QueryValueEx(HKEY hKey,char *SubKey_Name,DWORD &Type,DWORD &dwBufferLen,char *buffer)
LONG cRegistry::OpenKey(HKEY Pred_Key,char *SubKey_Name,REGSAM Sam,HKEY &Key)
{
m_Error=RegOpenKeyEx(Pred_Key,SubKey_Name,NULL,Sam,&Key);
return m_Error;
}
LONG cRegistry::QueryValueEx(HKEY hKey,char *SubKey_Name,DWORD &Type,DWORD &dwBufferLen,char *buffer)
{
m_Error=RegQueryValueEx(hKey,SubKey_Name,NULL,&Type,(BYTE*)&buffer,&dwBufferLen);
return m_Error;
}
HKEY Key; char *buffer3; DWORD Type=REG_SZ; DWORD dwBufferLen; cRegistry Registry; Registry.OpenKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",KEY_ALL_ACCESS,Key); Registry.QueryValueEx(Key,"kernel.dll",Type,dwBufferLen,buffer3);