Share via


RegQueryInfoKey

This function retrieves information about a specified registry key.

LONG RegQueryInfoKey ( 
HKEY hKey, 
LPWSTR lpClass, 
LPDWORD lpcbClass, 
LPDWORD lpReserved, 
LPDWORDlpcSubKeys, 
LPDWORD lpcbMaxSubKeyLen, 
LPDWORD lpcbMaxClassLen, 
LPDWORD lpcValues, 
LPDWORD lpcbMaxValueNameLen, 
LPDWORD lpcbMaxValueLen, 
LPDWORD lpcbSecurityDescriptor, 
PFILETIME lpftLastWriteTime ); 

Parameters

  • hKey
    [in] Handle to a currently open key or any of the following predefined reserved handle values:

    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
  • lpClass
    [out] Pointer to a buffer that receives the keys class name. This parameter can be NULL.

    If the registry key does not have a class name and the application passes in a string and size to get the class name, the function fails and returns ERROR_INVALID_HANDLE.

  • lpcbClass
    [in/out] Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpClass parameter. This size should include the terminating null character. When the function returns, this variable contains the length of the class string stored in the buffer. The count returned does not include the terminating null character. If the buffer is not big enough, the function returns ERROR_MORE_DATA, and the variable contains the size of the string, in characters, without counting the null character.

    If lpClass is NULL, lpcbClass can be NULL.

    If the lpClass parameter is a valid address, but this parameter is not, the function returns ERROR_INVALID_PARAMETER.

  • lpReserved
    [in] Reserved; set to NULL.

  • lpcSubKeys
    [out] Pointer to a variable that receives the number of subkeys contained by the specified key. This parameter can be NULL.

  • lpcbMaxSubKeyLen
    [out] Pointer to a variable that receives the length, in characters, of the keys subkey with the longest name. The count returned does not include the terminating null character. This parameter can be NULL.

  • lpcbMaxClassLen
    [out] Pointer to a variable that receives the length, in characters, of the longest string specifying a subkey class. The count returned does not include the terminating null character. This parameter can be NULL.

  • lpcValues
    [out] Pointer to a variable that receives the number of values associated with the key. This parameter can be NULL.

  • lpcbMaxValueNameLen
    [out] Pointer to a variable that receives the length, in characters, of the keys longest value name. The count returned does not include the terminating null character. This parameter can be NULL.

  • lpcbMaxValueLen
    [out] Pointer to a variable that receives the length, in bytes, of the longest data component among the values of the key. This parameter can be NULL.  

  • lpcbSecurityDescriptor
    [in] Not used; set to NULL.

  • lpftLastWriteTime
    [in] Ignored; set to NULL.

Return Values

ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you call FormatMessage it could fail.

Remarks

The key identified by the hKey parameter must have been opened with KEY_QUERY_VALUE access (KEY_READ access includes KEY_QUERY_VALUE access).

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winreg.h   Coredll.lib, Fsreg.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

RegDeleteKey, RegEnumKeyEx, RegEnumValue, RegQueryValueEx

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.