SCardGetProviderIdA function (winscard.h)

The SCardGetProviderId function returns the identifier (GUID) of the primary service provider for a given card.

The caller supplies the name of a smart card (previously introduced to the system) and receives the registered identifier of the primary service provider GUID, if one exists.

Syntax

LONG SCardGetProviderIdA(
  [in]  SCARDCONTEXT hContext,
  [in]  LPCSTR       szCard,
  [out] LPGUID       pguidProviderId
);

Parameters

[in] hContext

Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext. This parameter cannot be NULL.

[in] szCard

Name of the card defined to the system.

[out] pguidProviderId

Identifier (GUID) of the primary service provider. This provider may be activated using COM, and will supply access to other services in the card.

Return value

This function returns different values depending on whether it succeeds or fails.

Return code Description
Success
SCARD_S_SUCCESS.
Failure
An error code. For more information, see Smart Card Return Values.

Remarks

This function is not redirected, but calling the function when inside a Remote Desktop session will not result in an error. It only means that the result will be from the remote computer instead of the local computer.

The SCardGetProviderId function is a database query function. For more information on other database query functions, see Smart Card Database Query Functions.

Examples

The following example shows how to get the provider ID for the specified card. The example assumes that hContext is a valid handle obtained from a previous call to the SCardEstablishContext function and that "MyCardName" was introduced by a previous call to the SCardIntroduceCardType function.

GUID    guidProv;
LONG    lReturn;

lReturn = SCardGetProviderId(hContext, 
                             L"MyCardName",
                             &guidProv);
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardGetProviderId - %x\n", lReturn);
else
{
    // Use the provider GUID as needed.
    // ...
}

Note

The winscard.h header defines SCardGetProviderId as an alias which 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 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 winscard.h
Library Winscard.lib
DLL Winscard.dll

See also

SCardEstablishContext

SCardListCards

SCardListInterfaces

SCardListReaderGroups

SCardListReaders