Thread: RegCreateKeyEx Returning ERROR_FILE_NOT_FOUND with REG_OPTION_BACKUP_RESTORE

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    88

    RegCreateKeyEx Returning ERROR_FILE_NOT_FOUND with REG_OPTION_BACKUP_RESTORE

    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.
    Joe

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    This may possibly be the source of your problem

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    88
    That was an excellent point that I had forgotten about. Unfortunately, I am not opening any other subkey first prior to opening the test key. As the code I posted before shows, I directly open the key using HKEY_LOCAL_MACHINE as the root key.

    Thank you for the suggestion though.

    Joe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stop GUI Application returning when run
    By DaveHope in forum Windows Programming
    Replies: 7
    Last Post: 06-29-2009, 08:57 PM
  2. importance of returning reference in operator overloading.
    By vaibhavs17 in forum C++ Programming
    Replies: 20
    Last Post: 05-13-2009, 12:28 PM
  3. Help with struct... not returning correct results.
    By drty2 in forum C Programming
    Replies: 7
    Last Post: 01-18-2009, 11:25 PM
  4. Recursion: base case returning 1, function returning 0
    By yougene in forum C Programming
    Replies: 5
    Last Post: 09-07-2007, 05:38 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM