大网数据广告活动
Windows 系统接口

OREnumKey function (Offreg.h)

· 52CE 我爱测

Enumerates the subkeys of the specified open registry key in an offline registry hive. The function retrieves information about one subkey each time it is called.

Enumerates the subkeys of the specified open registry key in an offline registry hive. The function retrieves information about one subkey each time it is called.

Syntax

DWORD OREnumKey(
  _In_        ORHKEY    Handle,
  _In_        DWORD     dwIndex,
  _Out_       PWSTR     lpName,
  _Inout_     PDWORD    lpcName,
  _Out_opt_   PWSTR     lpClass,
  _Inout_opt_ PDWORD    lpcClass,
  _Out_opt_   PFILETIME lpftLastWriteTime
);

Parameters

Handle [in]

A handle to an open registry key in an offline registry hive.

dwIndex [in]

The index of the subkey to retrieve. This parameter should be zero for the first call to the function and then incremented for subsequent calls.

Because subkeys are not ordered, any new subkey will have an arbitrary index. This means that the function may return subkeys in any order.

lpName [out]

A pointer to a buffer that receives the name of the subkey, including the terminating null character. The function copies only the name of the subkey, not the full key hierarchy, to the buffer. If the function fails, no information is copied to this buffer.

For more information, see Registry Element Size Limits.

lpcName [in, out]

A pointer to a variable that specifies the size of the buffer specified by the lpName parameter, in WCHARs. This size should include the terminating null character. If the function succeeds, the variable pointed to by lpcName contains the number of characters stored in the buffer, not including the terminating null character.

lpClass [out, optional]

A pointer to a buffer that receives the null-terminated class string of the enumerated subkey. This parameter can be NULL.

lpcClass [in, out, optional]

A pointer to a variable that specifies the size of the buffer specified by the lpClass parameter, in WCHARs. The size should include the terminating null character. If the function succeeds, lpcClass contains the number of characters stored in the buffer, not including the terminating null character. This parameter can be NULL only if lpClass is NULL.

lpftLastWriteTime [out, optional]

A pointer to FILETIME structure that receives the time at which the enumerated subkey was last written. This parameter can be NULL.

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. Possible error codes include the following:

  • If the lpName buffer is too small to receive the name of the key, the function returns ERROR_MORE_DATA.
  • If there are no more subkeys available, the function returns ERROR_NO_MORE_ITEMS.

Remarks

To enumerate subkeys, an application should initially call the OREnumKey function with the dwIndex parameter set to zero. The application should then increment the dwIndex parameter and call OREnumKey until there are no more subkeys (meaning the function returns ERROR_NO_MORE_ITEMS).

The application can also set dwIndex to the index of the last subkey on the first call to the function and decrement the index until the subkey with the index 0 is enumerated. To retrieve the index of the last subkey, use the ORQueryInfoKey function.

While an application is using the OREnumKey function, it should not make calls to any offline registry functions that might change the key being enumerated.

Requirements

Requirement Value
Redistributable Windows Offline Registry library version 1.0 or later
Header Offreg.h
DLL Offreg.dll

See also

ORCreateKey

ORDeleteKey

OROpenKey

ORQueryInfoKey

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。