fxRichard
February 19th, 2009, 10:51 AM
...haven't used C/C++ in quite a long time, the following code is what I threw together based off of what I found on the internet however it is not working. I have found limited info on writing to the registry via C++. I can now open the key but when I go to write to it I get error code 5 which I believe is access denied. I have tried running this as admin and still get the error code. The goal is this task is accomplished through a service I have running under the LOCAL_SYSTEM account. Oh and this is on Vista.
HKEY handle;
LONG iSuccess = RegOpenKeyEx (HKEY_LOCAL_MACHINE, WINLOGON_KEY, 0L, KEY_READ , &handle);
if(iSuccess == ERROR_SUCCESS)
{
LONG iSuc = RegSetValueEx (handle, "Shell", 0L, REG_SZ,(LPBYTE)&service, sizeof(service) + 1);
if(iSuc != ERROR_SUCCESS)
{
log("Could not write key to registry");
}
}
RegCloseKey(handle);
HKEY handle;
LONG iSuccess = RegOpenKeyEx (HKEY_LOCAL_MACHINE, WINLOGON_KEY, 0L, KEY_READ , &handle);
if(iSuccess == ERROR_SUCCESS)
{
LONG iSuc = RegSetValueEx (handle, "Shell", 0L, REG_SZ,(LPBYTE)&service, sizeof(service) + 1);
if(iSuc != ERROR_SUCCESS)
{
log("Could not write key to registry");
}
}
RegCloseKey(handle);