The CPSetKeyParam function allows applications to customize various aspects of the operations of a key.
BOOL CPSetKeyParam(
  HCRYPTPROV hProv,  // in
  HCRYPTKEY hKey,    // in
  DWORD dwParam,     // in
  BYTE *pbData,      // in
  DWORD dwFlags      // in
);
 
These are described along with the CPGetKeyParam function.
Additional parameters can be added as needed. If these are general-purpose in nature, rather than applying to a single provider type, you should define these in coordination with Microsoft. This will promote cross-vendor standardization, and allow the new parameter numbers to be added to the standard Win32 header files.
If the function succeeds, TRUE should be returned; otherwise, return FALSE. When FALSE is returned, the appropriate error code (see the following table) must be set via SetLastError.
| Error | Description | 
|---|---|
| NTE_BAD_FLAGS | The dwFlags parameter is non-zero or the pbData buffer contains an invalid value. | 
| NTE_BAD_TYPE | The dwParam parameter specifies an unknown parameter. | 
| NTE_BAD_UID | The CSP context that was specified when the hKey key was created cannot now be found. | 
| NTE_FAIL | The function failed in some unexpected manner. | 
CPGenKey, CPGetKeyParam, CryptSetKeyParam