Windows Win32Registroadvapi32.dll
RegCreateKeyExW
Cria uma nova chave do Registro (ou abre uma existente).
Descrição
Se a chave já existir, comporta-se como RegOpenKeyExW — o parâmetro `lpdwDisposition` informa qual dos dois casos ocorreu.
Header:
winreg.hDLL: advapi32.dllNative API: NtCreateKeyAssinatura
LSTATUS RegCreateKeyExW(
HKEY hKey,
LPCWSTR lpSubKey,
DWORD Reserved,
LPWSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
PHKEY phkResult,
LPDWORD lpdwDisposition
);Parâmetros
| Parâmetro | Tipo | Descrição |
|---|---|---|
| hKey | HKEY | Chave pai. |
| lpSubKey | LPCWSTR | Caminho da subchave a criar/abrir. |
| Reserved | DWORD | Deve ser 0. |
| lpClass | LPWSTR | Classe da chave (raramente usada), ou NULL. |
| dwOptions | DWORD | REG_OPTION_NON_VOLATILE, REG_OPTION_VOLATILE. |
| samDesired | REGSAM | Direitos de acesso desejados. |
| lpSecurityAttributes | LPSECURITY_ATTRIBUTES | Atributos de segurança, ou NULL. |
| phkResult | PHKEY | Recebe o handle da chave. |
| lpdwDisposition | LPDWORD | Recebe REG_CREATED_NEW_KEY ou REG_OPENED_EXISTING_KEY. |
Valor de retorno
ERROR_SUCCESS em sucesso; um código de erro do Windows caso contrário.
Códigos de erro (GetLastError)
- ERROR_ACCESS_DENIED(5)
- Acesso negado.
- ERROR_INVALID_PARAMETER(87)
- Parâmetro incorreto.