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

LONG SCardBeginTransaction ( SCARDHANDLE  hCard  ) 

This function establishes a temporary exclusive access mode for doing a series of commands or transaction.

You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in SCARD_SHARE_EXCLUSIVE there will be no action taken.

Parameters:
[in] hCard Connection made from SCardConnect.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_INVALID_HANDLE Invalid hCard handle.
SCARD_E_SHARING_VIOLATION Someone else has exclusive rights.
SCARD_E_READER_UNAVAILABLE The reader has been removed.
Test:
 SCARDCONTEXT hContext;
 SCARDHANDLE hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol);
 rv = SCardBeginTransaction(hCard);
 ...
 / * Do some transmit commands * /

Definition at line 478 of file winscard_scf.c.

References SCardLockThread(), and SCardUnlockThread().

Referenced by MSGFunctionDemarshall().

{
      LONG rv;

      SCF_Card_t SCF_hCard;
      SCF_Status_t status;
      /* Zero out everything   */
      rv = 0;

      SCardLockThread();
      if (SCARD_S_SUCCESS != isOCFServerRunning())
      {
            SCardUnlockThread();
            return SCARD_E_NO_SERVICE;
      }
      rv = getCardForHandle(hCard, &SCF_hCard);
      if (SCARD_S_SUCCESS != rv)
      {
            SCardUnlockThread();
            return rv;
      }
      SCardUnlockThread();

      status = SCF_Card_lock(SCF_hCard, SCF_TIMEOUT_MAX);

      if (SCF_STATUS_DOUBLELOCK == status)
            return SCARD_S_SUCCESS;

      rv = ConvertStatus(status);

      return rv;
}


Generated by  Doxygen 1.6.0   Back to index