SPRINGCARD SAS PRNHSP01 用户手册

下载
页码 118
PMD2271-BA
page 88 of 118
S
PRING
C
ARD
 PC/SC C
OUPLERS
 - H663 
GROUP
 - Developer's reference manual
6. D
IRECT
 
CONTROL
 
OF
 
THE
 H663
6.1. B
ASIS
In PC/SC architecture, the SCardControl function implements the dialogue between an application
and the coupler, even when there’s no card in the slot.
Access to the coupler must be gained using  SCardConnect, specifying SCARD_SHARE_DIRECT as
coupler sharing mode.
Not all PC/SC drivers allow the application to gain direct access to the coupler. If you're using
SpringCard SDD480 PC/SC driver  for Windows, there's nothing specific to do, but for other
drivers, a specific configuration of the driver has to be performed. Please refer to chapter 9: Annex
6.2. I
MPLEMENTATION
 
DETAILS
6.2.1.
Sample code
#include <winscard.h>
// dwControlCode for SpringCard SDD480 driver
#define IOCTL_SC_PCSC_ESCAPE       SCARD_CTL_CODE(2048)
// dwControlCode for Microsoft CCID drivers
#define IOCTL_MS_PCSC_ESCAPE       SCARD_CTL_CODE(3050)
// This function is a wrapper around SCardControl
// It creates its own PC/SC context for convenience, but you
// may remain into a previously open context
// Note: Use SCardListReaders to get reader_name
LONG reader_control(const char *reader_name,
                    const BYTE in_buffer[],
                    DWORD      in_length,
                    BYTE       out_buffer[],
                    DWORD      max_out_length,
                    DWORD      *got_out_length)
{
  SCARDCONTEXT hContext;
  SCARDHANDLE  hCard;
  LONG rc;
  DWORD dwProtocol;
  rc = SCardEstablishContext(SCARD_SCOPE_SYSTEM,
                             NULL,
                             NULL,
                             &hContext);
  if (rc != SCARD_S_SUCCESS)
    return rc;
SPRINGCARD, the SPRINGCARD logo, PRO ACTIVE and the PRO ACTIVE logo are registered trademarks of PRO ACTIVE SAS.
All other brand names, product names, or trademarks belong to their respective holders.
Information in this document is subject to change without notice. Reproduction without written permission of PRO ACTIVE is forbidden.