Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

LONG SCardEstablishContext ( DWORD  dwScope,
LPCVOID  pvReserved1,
LPCVOID  pvReserved2,
LPSCARDCONTEXT  phContext 
)

Creates an Application Context to the PC/SC Resource Manager.

Creates an Application Context for a client.

This must be the first WinSCard function called in a PC/SC application. Each thread of an application shall use its own SCARDCONTEXT.

Parameters:
[in] dwScope Scope of the establishment. This can either be a local or remote connection.
[in] pvReserved1 Reserved for future use.
[in] pvReserved2 Reserved for future use.
[out] phContext Returned Application Context.
Returns:
Connection status.
Return values:
SCARD_S_SUCCESS Successful (SCARD_S_SUCCESS)
SCARD_E_INVALID_PARAMETER phContext is null (SCARD_E_INVALID_PARAMETER)
SCARD_E_INVALID_VALUE Invalid scope type passed (SCARD_E_INVALID_VALUE )
SCARD_E_NO_MEMORY There is no free slot to store hContext (SCARD_E_NO_MEMORY)
SCARD_E_NO_SERVICE The server is not runing (SCARD_E_NO_SERVICE)
SCARD_F_COMM_ERROR An internal communications error has been detected (SCARD_F_COMM_ERROR)
SCARD_F_INTERNAL_ERROR An internal consistency check failed (SCARD_F_INTERNAL_ERROR)
 SCARDCONTEXT hContext;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);

Definition at line 305 of file winscard_clnt.c.

References SCARD_E_INVALID_HANDLE, SCARD_S_SUCCESS, SCardCheckDaemonAvailability(), SCardEstablishContextTH(), SCardLockThread(), and SCardUnlockThread().

{
      LONG rv;

      PROFILE_START

      /* Check if the server is running */
      rv = SCardCheckDaemonAvailability();
      if (SCARD_E_INVALID_HANDLE == rv)
            /* we reconnected to a daemon or we got called from a forked child */
            rv = SCardCheckDaemonAvailability();

      if (rv != SCARD_S_SUCCESS)
            return rv;

      (void)SCardLockThread();
      rv = SCardEstablishContextTH(dwScope, pvReserved1,
            pvReserved2, phContext);
      (void)SCardUnlockThread();

      PROFILE_END(rv)

      return rv;
}


Generated by  Doxygen 1.6.0   Back to index