Microsoft Docs

Windows API Reference

Security Functions and Structures

The Windows Registry stores configuration data and uses security descriptors to control access. This article describes the primary security‑related functions, structures, and best practices for managing registry permissions.

Key Security Functions

LONG RegGetKeySecurity(
    HKEY hKey,
    SECURITY_INFORMATION SecurityInformation,
    PSECURITY_DESCRIPTOR pSecurityDescriptor,
    LPDWORD lpcbSecurityDescriptor
);
LONG RegSetKeySecurity(
    HKEY hKey,
    SECURITY_INFORMATION SecurityInformation,
    PSECURITY_DESCRIPTOR pSecurityDescriptor
);
LONG RegGetValueW(
    HKEY hkey,
    LPCWSTR lpSubKey,
    LPCWSTR lpValue,
    RRF_RT_REG_NONE | RRF_RT_ANY,
    LPDWORD pdwType,
    PVOID pvData,
    LPDWORD pcbData
);

Security Descriptor Structure

typedef struct _SECURITY_DESCRIPTOR {
    BYTE  Revision;
    BYTE  Sbz1;
    SECURITY_DESCRIPTOR_CONTROL Control;
    PSID  Owner;
    PSID  Group;
    PACL  Sacl;
    PACL  Dacl;
} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;

Common Access Rights

RightValueDescription
KEY_QUERY_VALUE0x0001Read a registry value.
KEY_SET_VALUE0x0002Write a registry value.
KEY_CREATE_SUB_KEY0x0004Create subkeys.
KEY_ENUMERATE_SUB_KEYS0x0008Enumerate subkeys.
KEY_NOTIFY0x0010Receive change notifications.
KEY_CREATE_LINK0x0020Create symbolic links.
KEY_WOW64_32KEY0x0200Access 32‑bit registry view.
KEY_WOW64_64KEY0x0100Access 64‑bit registry view.

Best Practices

Related Topics