CryptSetProviderA function (wincrypt.h)
If a current user's default provider is set, that default provider is acquired by any call by that user to CryptAcquireContext specifying a dwProvType provider type but not a CSP name.
An enhanced version of this function, CryptSetProviderEx, is also available.
Syntax
BOOL CryptSetProviderA(
[in] LPCSTR pszProvName,
[in] DWORD dwProvType
);
Parameters
[in] pszProvName
Name of the new default CSP. The named CSP must be installed on the computer. For a list of available cryptographic providers, see Cryptographic Provider Names.
[in] dwProvType
Provider type of the CSP specified by pszProvName.
Return value
If the function succeeds, the return value is nonzero (TRUE).
If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError. Some possible error codes are listed in the following table.
Return code | Description |
---|---|
|
One of the parameters specifies a handle that is not valid. |
|
One of the parameters contains a value that is not valid. This is most often a pointer that is not valid. |
|
The operating system ran out of memory during the operation. |
Errors can also be propagated from internal calls to RegCreateKeyEx and RegSetValueEx.
Remarks
Typical applications do not specify a CSP name when calling CryptAcquireContext; however, an application does have the option of selecting a specific CSP. This gives a user the freedom to select a CSP with an appropriate level of security.
Since calling CryptSetProvider determines the CSP of a specified type used by all applications that run from that point on, this function must not be called without users' consent.
Note
The wincrypt.h header defines CryptSetProvider as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | wincrypt.h |
Library | Advapi32.lib |
DLL | Advapi32.dll |