Share via


SCardIsValidContext (Windows Embedded CE 6.0)

1/6/2010

This function determines whether a smart card context handle is valid.

Syntax

LONG SCardIsValidContext(
  SCARDCONTEXT hContext 
);

Parameters

  • hContext
    [in] Supplies the handle that identifies the resource manager context. The resource manager context can be set by a previous call to SCardEstablishContext.

Return Value

Value Description

SCARD_S_SUCCESS

hContext is valid.

SCARD_E_INVALID_HANDLE

hContext is not valid.

An error value (see Smart Card Error Values for a list of all error values).

Fails

Remarks

Call this function to determine if a smart card context handle is still valid. Once a smart card context handle has been set by SCardEstablishContext, it may become invalid if the resource manager service has been shut down.

Example Code
// Check the smart card context handle.
// hContext was set previously by SCardEstablishContext.
LONG    lReturn;
lReturn = SCardIsValidContext(hContext);
if ( SCARD_S_SUCCESS != lReturn )
{
    // Function failed; check return value.
    if ( SCARD_E_INVALID_HANDLE == lReturn )
        printf("Handle is invalid\n");
    else
    {
        // Some unexpected error occurred; report and bail out.
        printf("Failed SCardIsValidContext - %x\n", lReturn);
        exit(1);  // Or other appropriate error action.
    }
}
else
{
    // Handle is valid; proceed as needed.
    // ...
}

Requirements

Header winscard.h
Library winscard.lib
Windows Embedded CE Windows CE .NET 4.1 and later

See Also

Reference

Smart Card Functions
SCardEstablishContext