NCryptEnumKeys function (ncrypt.h)
The NCryptEnumKeys function obtains the names of the keys that are stored by the provider.
Syntax
SECURITY_STATUS NCryptEnumKeys(
[in] NCRYPT_PROV_HANDLE hProvider,
[in, optional] LPCWSTR pszScope,
[out] NCryptKeyName **ppKeyName,
[in, out] PVOID *ppEnumState,
[in] DWORD dwFlags
);
Parameters
[in] hProvider
The handle of the key storage provider to enumerate the keys for. This handle is obtained with the NCryptOpenStorageProvider function.
[in, optional] pszScope
This parameter is not currently used and must be NULL.
[out] ppKeyName
The address of a pointer to an NCryptKeyName structure that receives the name of the retrieved key. When the application has finished using this memory, free it by calling the NCryptFreeBuffer function.
[in, out] ppEnumState
The address of a VOID pointer that receives enumeration state information that is used in subsequent calls to this function. This information only has meaning to the key storage provider and is opaque to the caller. The key storage provider uses this information to determine which item is next in the enumeration. If the variable pointed to by this parameter contains NULL, the enumeration is started from the beginning.
When this memory is no longer needed, it must be freed by passing this pointer to the NCryptFreeBuffer function.
[in] dwFlags
Flags that modify function behavior. This can be zero or a combination of one or more of the following values.
Return value
Returns a status code that indicates the success or failure of the function.
Possible return codes include, but are not limited to, the following.
Return code | Description |
---|---|
|
The function was successful. |
|
The dwFlags parameter contains a value that is not valid. |
|
The hProvider parameter is not valid. |
|
One or more parameters are not valid. |
|
A memory allocation failure occurred. |
|
The end of the enumeration has been reached. |
|
The dwFlags parameter contains the NCRYPT_SILENT_FLAG flag, but the key being enumerated requires user interaction. |
Remarks
This function retrieves only one item each time it is called. The state of the enumeration is stored in the variable pointed to by the ppEnumState parameter, so this must be preserved between calls to this function. When the last key stored by the provider has been retrieved, this function will return NTE_NO_MORE_ITEMS the next time it is called. To start the enumeration over, set the variable pointed to by the ppEnumState parameter to NULL, free the memory pointed to by the ppKeyName parameter, if it is not NULL, and call this function again.
A service must not call this function from its StartService Function. If a service calls this function from its StartService function, a deadlock can occur, and the service may stop responding.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | ncrypt.h |
Library | Ncrypt.lib |
DLL | Ncrypt.dll |