Click to See Complete Forum and Search --> : How to make registry key accessible to all users?


jwspring
April 17th, 2009, 03:17 PM
Hi,
this is my code:

LONG ret;
HKEY keyHandle;
String msg;

ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\myKey",
0, KEY_ALL_ACCESS, &keyHandle);

if (ret != ERROR_SUCCESS)
{
msg = "Open key failed.";
ret = Application->MessageBoxA(msg.c_str(),"Error",MB_OK);
if (ret == ID_OK)
{};
exit(0);
}

CHAR value[80];
value[0] = '\0';
DWORD valueSize;
char valueName[64];
DWORD valueNameSize;
DWORD n=0;

for (n=0; n<2;n++) {
valueSize=64;
valueNameSize = 64;
ret=RegEnumValue(keyHandle, n, valueName, &valueNameSize,NULL, NULL, value, &valueSize);
if (ret == ERROR_NO_MORE_ITEMS) break;
msg = (String)valueName + "=" +(String)value;
Application->MessageBoxA(msg.c_str(),"Read Value",MB_OK);
}
ret=RegCloseKey(keyHandle);


I have admi rights and i created myKey manually in my account. The code worked. I could get
values from myKey.
However, RegOpenKeyEx fails when someone who login without admi rights. What can I do
to let myKey can be accessed by all the users no matter what privilege they have?
Thanks for help

lok.vikram
April 18th, 2009, 01:07 PM
what is the error code.

lok.vikram
April 18th, 2009, 01:08 PM
use KEY_READ and try

jwspring
April 21st, 2009, 12:55 PM
Thanks, lok.vikram,
The error code is 5. KEY_READ worked for some computers but not all the cases. Any other suggestion?