NCryptDeleteKey function (ncrypt.h)

The NCryptDeleteKey function deletes a CNG key.

Syntax

SECURITY_STATUS NCryptDeleteKey(
  [in] NCRYPT_KEY_HANDLE hKey,
  [in] DWORD             dwFlags
);

Parameters

[in] hKey

The handle of the key to delete. This handle is obtained by using the NCryptOpenKey function.

Note  The NCryptDeleteKey function deletes the key and frees the handle. Applications may use NCryptFreeObject function to free the handle if NCryptDeleteKey fails.
 

[in] dwFlags

Flags that modify function behavior. This can be zero or a combination of values that is specific to each key storage provider.

Value Meaning
NCRYPT_SILENT_FLAG
Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error.

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
ERROR_SUCCESS
The function was successful.
NTE_BAD_FLAGS
The dwFlags parameter contains a value that is not valid.
NTE_INVALID_HANDLE
The hKey parameter is not valid.

Remarks

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

See also

NCryptOpenKey