Insufficient privilage when call RegLoadKey

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I log in as a administrator, then compile and run the following code on a
computer:

#include "stdafx.h"
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
long l = ::RegLoadKey(HKEY_USERS,L"XXXX",L"D:\\NTUSER.DAT");
return 0;
}

I get a 1314(A required privilege is not held by the client ) error when
call RegLoadKey, but i am an administrator!!! What the hell?

Thanks in advance
-Joe
 
I log in as a administrator, then compile and run the following code on a
computer:

#include "stdafx.h"
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
long l = ::RegLoadKey(HKEY_USERS,L"XXXX",L"D:\\NTUSER.DAT");
return 0;
}

I get a 1314(A required privilege is not held by the client ) error when
call RegLoadKey, but i am an administrator!!! What the hell?

Joe,

The documentation notes:

"The calling process must have the SE_RESTORE_NAME and SE_BACKUP_NAME
privileges on the computer in which the registry resides. For more
information, see Running with Special Privileges. To load a hive
without requiring these special privileges, use the RegLoadAppKey
function.
"

Just because you're an admin account doesn't necessarily mean that you
have those privileges.

Dave
 
Back
Top