SCardIsValidContext function
The SCardIsValidContext function determines whether a smart card context handle is valid.
Syntax
LONG WINAPI SCardIsValidContext( _In_ SCARDCONTEXT hContext );
Parameters
- hContext [in]
-
Handle that identifies the resource manager context. The resource manager context can be set by a previous call to SCardEstablishContext.
Return value
This function returns one of the following values.
| Return code | Description |
|---|---|
|
The hContext parameter is valid. |
|
The hContext parameter is not valid. |
|
An error code. For more information, see Smart Card Return Values. |
Remarks
Call this function to determine whether a smart card context handle is still valid. After a smart card context handle has been set by SCardEstablishContext, it may become not valid if the resource manager service has been shut down.
Examples
The following example shows determining whether a smart card context handle is valid.
// 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 ( ERROR_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
|
Minimum supported client |
Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also