Export (0) Print
Expand All

CryptSetProviderEx (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function specifies the default cryptographic service provider (CSP) for the current user or the local device.

If a current user's default provider is set, that default provider is acquired by any call by that user to the CryptAcquireContext function specifying a dwProvType provider type but not a CSP name.

If a local computer default is set, calls to the CryptAcquireContext function by a user not having a current user default set and not specifying a CSP result in the use of the local computer's default CSP.

Typical applications do not use this function. It is intended for use solely by administrative applications.

BOOL WINAPI CryptSetProviderEx( 
  LPCTSTR pszProvName, 
  DWORD dwProvType, 
  DWORD* pdwReserved, 
  DWORD dwFlags
);

Parameters

pszProvName
[in] Pointer to the null-terminated string that contains the name of the new default CSP. This must be a CSP installed on the computer.
dwProvType
[in] Specifies the provider type of the CSP specified by the pszProvName parameter.
pdwReserved
[in] Reserved for future use and must be set to NULL.
dwFlags
[in] Bitmask of flags. The following table shows defined values for this parameter.
ValueDescription
CRYPT_MACHINE_DEFAULTSets the machine default CSP of the given type.
CRYPT_USER_DEFAULTSets the user default CSP of the given type.
CRYPT_DELETE_DEFAULTCan be used in conjunction with CRYPT_MACHINE_DEFAULT or CRYPT_USER_DEFAULT to delete the default.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call the GetLastError function.

The following table shows the common values for the GetLastError function. The error values prefaced by NTE are generated by the particular CSP you are using.

ValueDescription
ERROR_INVALID_PARAMETEROne of the parameters contains an invalid value. This is most often an illegal pointer.
ERROR_NOT_ENOUGH_MEMORYThe operating system ran out of memory.

Remarks

Most applications do not specify a CSP name when calling the CryptAcquireContext function; however, an application has the option of selecting a specific CSP. This gives the user the freedom to select a CSP with an appropriate level of security.

Because calling CryptSetProviderEx determines the CSP of a specified type used by all applications that run from that point on, this function must not be called without the consent of the user.

Windows CE does not support the ANSI version of this function.

Example Code

HCRYPTPROV hProv = 0;

// Specify the default PROV_RSA_SIG provider for the machine. Note that this assumes that a
// CSP with a type of PROV_RSA_SIG and named "Joe's Provider" has already been installed.
if (!CryptSetProviderEx(TEXT("Joe's Provider"), PROV_RSA_SIG, NULL,
 CRYPT_MACHINE_DEFAULT)) 
 {printf("Error %x during CryptSetProviderEx!\n", GetLastError);
 return;
 }

// Get a handle to the provider you just made default using CryptAcquireContext
// For sample code, see CryptAcquireContext.
...
...

// Free the provider handle.
if (!CryptReleaseContext(hProv, 0)) 
 {printf("Error %x during CryptReleaseContext!\n", GetLastError);
 return;
 }

Requirements

OS Versions: Windows CE 2.10 and later.
Header: Wincrypt.h.
Link Library: Coredll.lib.

See Also

CryptAcquireContext | CryptSetProvider


Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft