RegUnLoadKey Fails with error code 1314 even with correct privs
Posted on 2009-04-05
I have a function that successfully grants me the SeRestorePrivilege and SeBackupPrivilege privileges.
I can successfully load an offline registry hive with the following code:
hiveLoaded = RegLoadKey(HKEY_LOCAL_MACHINE, L"ABOH_HIVE", L"H:\WINDOWS\system32\config\software");
and then I revoke the privileges, without errors.
Next, I grant myself the same privileges, and try to unload the registry hive, as follows:
hiveUnloaded = RegUnLoadKey(HKEY_LOCAL_MACHINE, L"ABOH_HIVE");
but it always fails with an error code of 1314, which says that I am lacking some privileges.
I have the same two privileges that I used to load. According to MS documentation, they
should be all I need, so I am at a loss as to what to try next and would really appreciate
The environment is VS2008 C++, Vista Ultimate 32-bit, and everything is current. I have a solution
that contains two projects: A CLR DLL and a VB.NET application for testing the DLL. Although it
sounds complex, the registry code is in an unmanaged class that I've created. I have another
managed class, which I am using in a VB.NET application to test this code. The final product
will be a CLR DLL. I have enabled adminstrator in the VB.NET manifest. I don't have a manifest
for the DLL, but I don't think that it needs one. I am running VS2008 as Administrator.
All of this stuff is working properly and is based
upon templates that I've created for mixing managed and unmanaged code. Help! :)