IMSAdminBase::EnumKeys

The IMSAdminBase::EnumKeys method enumerates the subkeys of the specified key. A subkey can be enumerated once per call. Subkeys are numbered from 0 to (NumKeys - 1), with NumKeys equal to the number of subkeys below the key.

If dwMDEnumKeyIndex is greater than or equal to the number of subkeys, ERROR_NO_MORE_ITEMS is returned.

HRESULT EnumKeys(

  METADATA_HANDLE hMDHandle,  //metabase handle.

  LPCWSTR pszMDPath,    //path to the key.

  LPWSTR pszMDName,     //receives the name of the subkey.

  DWORD dwMDEnumKeyIndex  //index of the subkey.

);

 

Parameters
hMDHandle
Specifies a handle to a metabase key. This can be either METADATA_MASTER_ROOT_HANDLE, or a handle with read permissions returned by the IMSAdminBase::OpenKey method.
pszMDPath
Points to a string that contains the path of the key relative to the path of hMDHandle. For example, if the handle references the /LM key, you could specify the Web services subkey using the path /W3SVC. In this case the subkeys of /LM/W3SVC would be enumerated.
pszMDName
Points to a string buffer that receives the names of the metabase subkeys enumerated. This buffer must be at least METADATA_MAX_NAME_LEN characters long.
dwMDEnumKeyIndex
Specifies the index of the subkey to be retrieved. Set this to 0 before the first call and increment it by 1 on each successive call until ERROR_NO_MORE_ITEMS is returned.
Return Values

Returns an HRESULT that contains one of the following values:

Value Description
ERROR_ACCESS_DENIED Access is denied. Either the open handle does not have read or write permission as needed, or the user does not have sufficient permissions to perform the operation.
ERROR_INVALID_PARAMETER The parameter is incorrect.
ERROR_NO_MORE_ITEMS There are no more subkeys to enumerate.
ERROR_PATH_NOT_FOUND The specified path was not found in the metabase.
ERROR_SUCCESS The method succeeded.

Remarks

The handle, METADATA_MASTER_ROOT_HANDLE, provides no guarantee against multiple thread access. If your application requires a constant data state, use a handle returned by IMSAdminBase::OpenKey.