Registry reading under Windows 95
Posted on 1999-12-14
I want't to read some registry keys in C/C++, i have used the following code myself:
unsigned long size;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArchiServe\\ArchiShell\\File locations\\",0, KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE, &openKey)==ERROR_SUCCESS)
if (RegQueryValueEx(openKey, "ArchiStream", NULL, NULL, NULL, &size)==ERROR_SUCCESS)
keyValue = (char*) malloc (size);
if (RegQueryValueEx(openKey, "ArchiStream", NULL, NULL, (unsigned char*)keyValue, &size)==ERROR_SUCCESS)
This code seems to work, but not under windows 95, but it works on 98 and NT. The ShowLastError() function does a GetLastError() and FormatMessage() to produce some normal error string. But I get two different error while running the code, which one seems to be random, but both have got nothing to do with the registry. One says that the system has to run in win32 mode, and the other one i can't remember right now. (I haven't got a test platform right now.)
Anyone who can tell me what the problem with my code is, or can give me some other working C code, will get the points.
Thanks in advance, Elmar.