EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.
9 sur 19 ont trouvé cela utile - Évaluez ce sujet

RegOpenKey function

Opens the specified registry key.

Note  This function is provided only for compatibility with 16-bit versions of Windows. Applications should use the RegOpenKeyEx function.

Syntax


LONG WINAPI RegOpenKey(
  _In_      HKEY hKey,
  _In_opt_  LPCTSTR lpSubKey,
  _Out_     PHKEY phkResult
);

Parameters

hKey [in]

A handle to an open registry key. This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys:

HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
lpSubKey [in, optional]

The name of the registry key to be opened. This key must be a subkey of the key identified by the hKey parameter.

Key names are not case sensitive.

If this parameter is NULL or a pointer to an empty string, the function returns the same handle that was passed in.

For more information, see Registry Element Size Limits.

phkResult [out]

A pointer to a variable that receives a handle to the opened key. If the key is not one of the predefined registry keys, call the RegCloseKey function after you have finished using the handle.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

Remarks

The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different access right, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation.

RegOpenKey does not create the specified key if the key does not exist in the database.

If your service or application impersonates different users, do not use this function with HKEY_CURRENT_USER. Instead, call the RegOpenCurrentUser function.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winreg.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

RegOpenKeyW (Unicode) and RegOpenKeyA (ANSI)

See also

RegCloseKey
RegDeleteKey
Registry Functions
Registry Overview
RegOpenKeyEx

 

 

Send comments about this topic to Microsoft

Build date: 10/26/2012

Cela vous a-t-il été utile ?
(1500 caractères restants)

Ajouts de la communauté

AJOUTER
Microsoft réalise une enquête en ligne pour recueillir votre opinion sur le site Web de MSDN. Si vous choisissez d’y participer, cette enquête en ligne vous sera présentée lorsque vous quitterez le site Web de MSDN.

Si vous souhaitez y participer,
© 2013 Microsoft. Tous droits réservés.