SCardForgetCardTypeA function (winscard.h)

The SCardForgetCardType function removes an introduced smart card from the smart card subsystem.


LONG SCardForgetCardTypeA(
  [in] SCARDCONTEXT hContext,
  [in] LPCSTR       szCardName


[in] hContext

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

[in] szCardName

Display name of the card to be removed from the smart card database.

Return value

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

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


This function is not redirected, but calling the function SCardForgetCardType 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 SCardForgetCardType function is a database management function. For more information about other database management functions, see Smart Card Database Management Functions.


The following example removes the specified card type from the system. The example assumes that lReturn is a valid variable of type LONG, that hContext is a valid handle received from a previous call to the SCardEstablishContext function, and that "MyCardName" was previously introduced by a call to the SCardIntroduceCardType function.

lReturn = SCardForgetCardType(hContext, 
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardForgetCardType\n");


The winscard.h header defines SCardForgetCardType 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.


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