SCardGetCardTypeProviderName function
Applies to: desktop apps only
The SCardGetCardTypeProviderName function returns the name of the module (dynamic link library) that contains the provider for a given card name and provider type.
Syntax
LONG WINAPI SCardGetCardTypeProviderName( __in SCARDCONTEXT hContext, __in LPCTSTR szCardName, __in DWORD dwProviderId, __out LPTSTR szProvider, __inout LPDWORD *pcchProvider );
Parameters
- hContext [in]
-
Handle that identifies the resource manager context. The resource manager context can be set by a previous call to SCardEstablishContext. This value can be NULL if the call to SCardGetCardTypeProviderName is not directed to a specific context.
- szCardName [in]
-
Name of the card type with which this provider name is associated.
- dwProviderId [in]
-
Identifier for the provider associated with this card type.
Value Meaning - SCARD_PROVIDER_PRIMARY
- 1
The function retrieves the name of the smart card's primary service provider as a GUID string.
- SCARD_PROVIDER_CSP
- 2
The function retrieves the name of the cryptographic service provider.
- SCARD_PROVIDER_KSP
- 3
The function retrieves the name of the smart card key storage provider (KSP).
- SCARD_PROVIDER_CARD_MODULE
- 0x80000001
The function retrieves the name of the card module.
- szProvider [out]
-
String variable to receive the provider name upon successful completion of this function.
- pcchProvider [in, out]
-
Pointer to DWORD value. On input, pcchProvider supplies the length of the szProvider buffer in characters. If this value is SCARD_AUTOALLOCATE, then szProvider is converted to a pointer to a byte pointer and receives the address of a block of memory containing the string. This block of memory must be deallocated by calling SCardFreeMemory.
On output, this value represents the actual number of characters, including the null terminator, in the szProvider variable.
Return value
This function returns different values depending on whether it succeeds or fails.
| Return code | Description |
|---|---|
|
SCARD_S_SUCCESS. |
|
An error code. For more information, see Smart Card Return Values. |
Remarks
This function is not redirected. Calling the function SCardGetCardTypeProviderName when attempting a Remote Desktop session fails with the SCARD_E_READER_UNAVAILABLE error code.
Upon successful completion of this function, the value in szProvider can be used as the third parameter in a call to CryptAcquireContext.
Examples
The following example shows how to retrieve the provider name for the specified reader context. The example assumes that hContext is a valid handle obtained from a previous call to the SCardEstablishContext function.
LPTSTR szProvider = NULL; LPTSTR szCardName = _T("WindowsCard"); DWORD chProvider = SCARD_AUTOALLOCATE; LONG lReturn = SCARD_S_SUCCESS; // Retrieve the provider name. // hContext was set by SCardEstablishContext. lReturn = SCardGetCardTypeProviderName(hContext, szCardName, SCARD_PROVIDER_CSP, (LPTSTR)&szProvider, &chProvider); if (SCARD_S_SUCCESS == lReturn) { BOOL fSts = TRUE; HCRYPTPROV hProv = NULL; // Acquire a Cryptographic operation context. fSts = CryptAcquireContext(&hProv, NULL, szProvider, PROV_RSA_FULL, 0); // Perform Cryptographic operations with smart card // ... // Free memory allocated by SCardGetCardTypeProviderName. lReturn = SCardFreeMemory(hContext, szProvider); }
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | SCardGetCardTypeProviderNameW (Unicode) and SCardGetCardTypeProviderNameA (ANSI) |
See also
Send comments about this topic to Microsoft
Build date: 3/13/2012