I've been playing with this and I can't understand why the RegDeleteKey function is resulting to a file not found error..
I created this test key and it exists. HKLM\Software\test I am also the administrator of this computer. OS is Vista 32 bit.
int main()
{
HKEY hReg;
LONG oresult;
LONG dresult;
oresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\test", 0, KEY_ALL_ACCESS, &hReg);
if(oresult == ERROR_SUCCESS)
{
cout << "Key opened successfully." << endl;
}
dresult = RegDeleteKey(hReg, L"SOFTWARE\\test");
if(dresult == ERROR_SUCCESS)
{
cout << "Key deleted succssfully." << endl;
}
else
{
if(dresult == ERROR_FILE_NOT_FOUND)
{
cout << "Delete failed. Key not found." << endl;
cout << "\n";
}
}
RegCloseKey(hReg);
return 0;
}
The output is:
key opened successfully delete failed. key not found.