lolik121999
asked on
registry
I'm using RegRestoreKey, and the function fails on
error number 1314. I use it as an administrator and
while writing to a key in which I have full control.
help ?
error number 1314. I use it as an administrator and
while writing to a key in which I have full control.
help ?
ASKER
I tried this, but it still doesn't work.
I even added my user to Backup Operators group and
it's still giving me error 1314.
I even added my user to Backup Operators group and
it's still giving me error 1314.
Hi,
Why dont you set and disable the previliges using the
1. SetPrivilege();
2. LookupPrivilegeValue();
3. AdjustTokenPrivileges();
functions???
See MSDN for further details.
Or shall i paste its conetnt here???
Just a hint,
Hope this is useful
Bye,
ABdij
Why dont you set and disable the previliges using the
1. SetPrivilege();
2. LookupPrivilegeValue();
3. AdjustTokenPrivileges();
functions???
See MSDN for further details.
Or shall i paste its conetnt here???
Just a hint,
Hope this is useful
Bye,
ABdij
Abdij is (almost) right, sometimes it is necessary to also *enable* that privilege, e.g.
BOOL EnablePriv ( BOOL bEnable)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
if ( !OpenProcessToken ( GetCurrentProcess (),
TOKEN_ADJUST_PRIVILEGES,
&hToken
)
) return ( FALSE);
tp.PrivilegeCount = 1;
LookupPrivilegeValue ( NULL,
SE_RESTORE_NAME,
&tp.Privileges [ 0].Luid
);
tp.Privileges [ 0].Attributes = bEnable
? SE_PRIVILEGE_ENABLED
: 0;
AdjustTokenPrivileges ( hToken,
FALSE,
&tp,
sizeof ( tp),
NULL,
NULL
);
return ( GetLastError() == ERROR_SUCCESS);
}
BOOL EnablePriv ( BOOL bEnable)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
if ( !OpenProcessToken ( GetCurrentProcess (),
TOKEN_ADJUST_PRIVILEGES,
&hToken
)
) return ( FALSE);
tp.PrivilegeCount = 1;
LookupPrivilegeValue ( NULL,
SE_RESTORE_NAME,
&tp.Privileges [ 0].Luid
);
tp.Privileges [ 0].Attributes = bEnable
? SE_PRIVILEGE_ENABLED
: 0;
AdjustTokenPrivileges ( hToken,
FALSE,
&tp,
sizeof ( tp),
NULL,
NULL
);
return ( GetLastError() == ERROR_SUCCESS);
}
ASKER
jkr, thank u for the code, it really helped.
just ask a question and u get the points.
abdij : thank u too.
just ask a question and u get the points.
abdij : thank u too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Feel free to ask if you need more information!