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 for a client.

This must be the first function called in a PC/SC application.

Parameters:
[in] dwScope Scope of the establishment. This can either be a local or remote connection.
  • SCARD_SCOPE_USER - Not used.
  • SCARD_SCOPE_TERMINAL - Not used.
  • SCARD_SCOPE_GLOBAL - Not used.
  • SCARD_SCOPE_SYSTEM - Services on the local machine.
[in] pvReserved1 Reserved for future use. Can be used for remote connection.
[in] pvReserved2 Reserved for future use.
[out] phContext Returned Application Context.
Returns:
Connection status.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_INVALID_VALUE Invalid scope type passed.
SCARD_E_INVALID_PARAMETER phContext is null.
Creates an Application Context for a client.

This must be the first function called in a PC/SC application. This is a thread-safe wrapper to the function SCardEstablishContextTH().

Parameters:
[in] dwScope Scope of the establishment. This can either be a local or remote connection.
  • SCARD_SCOPE_USER - Not used.
  • SCARD_SCOPE_TERMINAL - Not used.
  • SCARD_SCOPE_GLOBAL - Not used.
  • SCARD_SCOPE_SYSTEM - Services on the local machine.
[in] pvReserved1 Reserved for future use. Can be used for remote connection.
[in] pvReserved2 Reserved for future use.
[out] phContext Returned Application Context.
Returns:
Connection status.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_NO_SERVICE The server is not runing
SCARD_E_INVALID_VALUE Invalid scope type passed.
SCARD_E_INVALID_PARAMETER phContext is null.
Test:
 SCARDCONTEXT hContext;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);

Definition at line 136 of file winscard.c.

References SCardEstablishContextTH(), SCardLockThread(), and SCardUnlockThread().

Referenced by MSGFunctionDemarshall().

{
      /*
       * Check for NULL pointer
       */
      if (phContext == 0)
            return SCARD_E_INVALID_PARAMETER;

      if (dwScope != SCARD_SCOPE_USER && dwScope != SCARD_SCOPE_TERMINAL &&
            dwScope != SCARD_SCOPE_SYSTEM && dwScope != SCARD_SCOPE_GLOBAL)
      {

            *phContext = 0;
            return SCARD_E_INVALID_VALUE;
      }

      /*
       * Unique identifier for this server so that it can uniquely be
       * identified by clients and distinguished from others
       */

      *phContext = (PCSCLITE_SVC_IDENTITY + SYS_RandomInt(1, 65535));

      Log2(PCSC_LOG_DEBUG, "Establishing Context: %d", *phContext);

      return SCARD_S_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index