The CreateSubKey method creates a registry key that has the access control specified by the registrySecurity parameter. The RegistryKey object that is returned represents the registry key, but that object is not restricted by the access control specified in the registrySecurity parameter.
If permissionCheck is RegistryKeyPermissionCheck..::.ReadWriteSubTree, the key is opened for read/write access. If permissionCheck is RegistryKeyPermissionCheck..::.ReadSubTree, the key is opened for read access.
For backward compatibility, the key is opened for reading and writing if permissionCheck is RegistryKeyPermissionCheck..::.Default and the parent key also has RegistryKeyPermissionCheck..::.Default. If the parent key has any other setting, read/write status is controlled by the parent key's setting.
In order to perform this action, the user must have permissions at this level and below in the registry hierarchy.
Caution: |
|---|
Do not expose
RegistryKey objects in such a way that a malicious program could create thousands of meaningless subkeys or key/value pairs. For example, do not allow callers to enter arbitrary keys or values.
|
In order to use the OpenSubKey method, you must have an instance of the RegistryKey class. To get an instance of RegistryKey, use one of the static members of the Registry class.