Sergio Calderon
Sergio Calderon

Reputation: 867

How to use the RegLoadKey function to load the NTUSER.DAT file from the Default User?

I thought I could use the RegLoadKey to load the NTUSER.DAT file located in the C:\Users\Default folder by using this code:

HKEY hKey = HKEY_LOCAL_MACHINE;
    LPCTSTR lpSubKey = L"software\\Load";
    LPCTSTR lpFile = L"C:\\Users\\Default\\NTUSER";

    long R=RegLoadKey(hKey, lpSubKey, lpFile);

It did not work. Can anyone tell me how I have to use this function to load the NTUSER.DAT file into the HKLM\Software\Load sub-key?

Thanks!

Upvotes: 0

Views: 2484

Answers (1)

ST3
ST3

Reputation: 8946

As @Xearinox mentioned you need privilages (SE_BACKUP_NAME and SE_RESTORE_NAME)

Also you must load NTUSER.DAT, otherwise you create new registry hive. And lpSubKey only can be first level after hKey.

So you should set privilages and load it like this:

long ret = RegLoadKey(HKEY_LOCAL_MACHINE, L"LOAD", L"C:\\Users\\Default\\NTUSER.DAT");

Upvotes: 1

Related Questions