|
Did not see the problem.
Try me this:
// Rename the registry
int RegReName(TCHAR oldKey[], TCHAR newKey[])
{
static int i;
HKEY hk;
// backup old keys
if(EnablePrivilege(SE_BACKUP_NAME,TRUE) == 0)
{
if (RegOpenKey(HKEY_LOCAL_MACHINE, oldKey,&hk) == ERROR_SUCCESS)
{
if (RegSaveKey(hk, "bak", NULL) != ERROR_SUCCESS)
if (i == 0) i = 1;
}
}
// restore the old key to the new key
if(EnablePrivilege(SE_RESTORE_NAME,TRUE) == 0)
{
if (RegOpenKey(HKEY_LOCAL_MACHINE, newKey,&hk) != ERROR_SUCCESS)
{
RegCreateKey(HKEY_LOCAL_MACHINE, newKey,&hk);
}
if (RegRestoreKey(hk, "bak", 0x00000008L) != ERROR_SUCCESS)
if (i == 0) i = 2;
}
// delete old key
RegDelete(HKEY_LOCAL_MACHINE, oldKey);
DeleteFile("bak");
RegCloseKey(hk);
return i;
} |
|