I am trying to open/create a key to modify its security descriptor. To ensure that I have access to it, I am opening the handle to the key using RegCreateKeyEx with the REG_OPTION_BACKUP_RESTORE option.
Everything works fine in XP. If the key exists, it is opened. If it does not exist, it is created and opened. However, in win2k, the code works properly if the key exists, but if it does not, the function returns ERROR_FILE_NOT_FOUND. The key I am trying to open/create is "HKEY_LOCAL_MACHINE\Software\Test Key". This means the parent key does exist(Software does obviously exist).
Does anyone know why it would be returning this value? Is there a quirk in 2k? The msdn documentation seems to suggest the key should be created regardless of whether or not REG_OPTION_BACKUP_RESTORE is specified. The line of code I am using is posted below.
long lngRetVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Test Key", 0, 0, REG_OPTION_BACKUP_RESTORE, 0, 0, &hKey, 0);
Thank you for any help you can give.