Reputation: 25938
I am attempting to set the Discretionary Access Control List(DACL) for a Registry Key using the function SetNamedSecurityInfo().
I'm not sure what the first parameter pObjectName
should be for this function if I am setting a Registry Key? What I am also not sure about is the format of this string, ie, for current user do I use HKEY_CURRENT_USER\
or CURRENT_USER
?
For a registry key is the object name just the path to the registry key or something else?
For example:
LPTSTR pObjectName = _T("HKEY_CURRENT_USER\\Software\\MyAppName");
// or should it be...
LPTSTR pObjectName = _T("CURRENT_USER\\Software\\MyAppName");
Upvotes: 0
Views: 833
Reputation: 598039
Read the documentation for SetNamedSecurityInfo()
:
For descriptions of the string formats for the different object types, see SE_OBJECT_TYPE.
.
SE_REGISTRY_KEY Indicates a registry key. A registry key object can be in the local registry, such as CLASSES_ROOT\SomePath or in a remote registry, such as \ComputerName\CLASSES_ROOT\SomePath.
The names of registry keys must use the following literal strings to identify the predefined registry keys: "CLASSES_ROOT", "CURRENT_USER", "MACHINE", and "USERS".
So the answer to your question is this:
LPTSTR pObjectName = _T("CURRENT_USER\\Software\\MyAppName");
Upvotes: 2