Module

WinSCard

Path

C:\CPRS\CPRS30\XuDigSig\WinSCard.pas

Last Modified

7/15/2014 3:26:44 PM

Comments

Borland Delphi Runtime Library                                   
 PCSC interface unit                                              
                                                                  
 Portions created by Microsoft are                                
 Copyright (C) 1996 Microsoft Corporation.                        
 All Rights Reserved.                                             
                                                                  
 The original file is: WinSCard.h                                 
 The original Pascal code is: WinSCard.pas                        
 The initial developer of the Pascal code is Chris Dickerson      
 (chrisd@tsc.com).                                                
                                                                  
 Obtained through:                                                
                                                                  
 Joint Endeavour of Delphi Innovators (Project JEDI)              
                                                                  
 You may retrieve the latest version of this file at the Project  
 JEDI home page, located at http://delphi-jedi.org                
                                                                  
 The contents of this file are used with permission, subject to   
 the Mozilla Public License Version 1.1 (the "License"); you may  
 not use this file except in compliance with the License. You may 
 obtain a copy of the License at                                  
 http://www.mozilla.org/MPL/MPL-1.1.html                          
                                                                  
 Software distributed under the License is distributed on an      
 "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   
 implied. See the License for the specific language governing     
 rights and limitations under the License.

Functions

Name Owner Declaration Scope Comments
SCardAccessStartedEvent - function SCardAccessStartedEvent: LongInt; stdcall; Interfaced -
SCardAddReaderToGroupA - function SCardAddReaderToGroupA(hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall; Interfaced -
SCardAddReaderToGroupW - function SCardAddReaderToGroupW(hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall; Interfaced -
SCardBeginTransaction - function SCardBeginTransaction(hCard: LongInt): LongInt; stdcall; Interfaced -
SCardCancel - function SCardCancel (hContext: LongInt): LongInt; stdcall; Interfaced -
SCardConnectA - function SCardConnectA(hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt; var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall; Interfaced -
SCardConnectW - function SCardConnectW(hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt; var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall; Interfaced -
SCardControl - function SCardControl(hCard: LongInt; dwControlCode: LongInt; var pvInBuffer: PByte; cbInBufferSize: LongInt; var pvOutBuffer: PByte; cbOutBufferSize: LongInt; var pcbBytesReturned: LongInt): LongInt; stdcall; Interfaced -
SCardDisconnect - function SCardDisconnect(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall; Interfaced -
SCardEndTransaction - function SCardEndTransaction(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall; Interfaced -
SCardEstablishContext - function SCardEstablishContext(dwScope: DWORD; pvReserved1: Pointer; pvReserved2: Pointer; phContext: Pointer): LongInt; stdcall; Interfaced -
SCardForgetCardTypeA - function SCardForgetCardTypeA(hContext: LongInt; szCardName: LPStr): LongInt; stdcall; Interfaced -
SCardForgetCardTypeW - function SCardForgetCardTypeW(hContext: LongInt; szCardName: LPWStr): LongInt; stdcall; Interfaced -
SCardForgetReaderA - function SCardForgetReaderA(hContext: LongInt; szReaderName: LPStr): LongInt; stdcall; Interfaced -
SCardForgetReaderGroupA - function SCardForgetReaderGroupA(hContext: LongInt; szGroupName: LPStr): LongInt; stdcall; Interfaced -
SCardForgetReaderGroupW - function SCardForgetReaderGroupW(hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall; Interfaced -
SCardForgetReaderW - function SCardForgetReaderW(hContext: LongInt; szReaderName: LPWStr): LongInt; stdcall; Interfaced -
SCardFreeMemory - function SCardFreeMemory(hContext: LongInt; pvMem: LongInt): LongInt; stdcall; Interfaced -
SCardGetAttrib - function SCardGetAttrib(hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; var pcbAttrLen: LongInt): LongInt; stdcall; Interfaced -
SCardGetCardTypeProviderNameA - function SCardGetCardTypeProviderNameA(hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt; szProvider: LPStr; var pcchProvider: LongInt): LongInt; stdcall; Interfaced -
SCardGetCardTypeProviderNameW - function SCardGetCardTypeProviderNameW(hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt; szProvider: LPWStr; var pcchProvider: LongInt): LongInt; stdcall; Interfaced -
SCardGetProviderIdA - function SCardGetProviderIdA(hContext: LongInt; szCard: LPStr; var pguidProviderId: GUID): LongInt; stdcall; Interfaced -
SCardGetProviderIdW - function SCardGetProviderIdW(hContext: LongInt; szCard: LPWStr; var pguidProviderId: GUID): LongInt; stdcall; Interfaced -
SCardGetStatusChangeA - function SCardGetStatusChangeA(hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEA; cReaders: LongInt): LongInt; stdcall; Interfaced -
SCardGetStatusChangeW - function SCardGetStatusChangeW(hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW; cReaders: LongInt): LongInt; stdcall; Interfaced -
SCardIntroduceCardTypeA - function SCardIntroduceCardTypeA(hContext: LongInt; szCardName: LPStr; var pguidPrimaryProvider: GUID; var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPStr; pbAtrMask: LPStr; cbAtrLen: LongInt): LongInt; stdcall; Interfaced -
SCardIntroduceCardTypeW - function SCardIntroduceCardTypeW(hContext: LongInt; szCardName: LPWStr; var pguidPrimaryProvider: GUID; var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPWStr; pbAtrMask: LPWStr; cbAtrLen: LongInt): LongInt; stdcall; Interfaced -
SCardIntroduceReaderA - function SCardIntroduceReaderA(hContext: LongInt; szReadeName: LPStr; szDeviceName: LPStr): LongInt; stdcall; Interfaced -
SCardIntroduceReaderGroupA - function SCardIntroduceReaderGroupA(hContext: LongInt; szGroupName: LPStr): LongInt; stdcall; Interfaced -
SCardIntroduceReaderGroupW - function SCardIntroduceReaderGroupW(hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall; Interfaced -
SCardIntroduceReaderW - function SCardIntroduceReaderW(hContext: LongInt; szReadeName: LPWStr; szDeviceName: LPWStr): LongInt; stdcall; Interfaced -
SCardIsValidContext - function SCardIsValidContext(hContext: LongInt): LongInt; stdcall; Interfaced -
SCardListCardsA - function SCardListCardsA(hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID; cguidInterfaceCount: LongInt; mszCards: LPStr; var pcchCards: LongInt): LongInt; stdcall; Interfaced -
SCardListCardsW - function SCardListCardsW(hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID; cguidInterfaceCount: LongInt; mszCards: LPWStr; var pcchCards: LongInt): LongInt; stdcall; Interfaced -
SCardListInterfacesA - function SCardListInterfacesA(hContext: LongInt; szCard: LPStr; var pguidInterfaces: GUID; var pcguidInterfaces: LongInt): LongInt; stdcall; Interfaced -
SCardListInterfacesW - function SCardListInterfacesW(hContext: LongInt; szCard: LPWStr; var pguidInterfaces: GUID; var pcguidInterfaces: LongInt): LongInt; stdcall; Interfaced -
SCardListReaderGroupsA - function SCardListReaderGroupsA(hContext: LongInt; mszGroups: LPStr; var pcchGroups: LongInt): LongInt; stdcall; Interfaced -
SCardListReaderGroupsW - function SCardListReaderGroupsW(hContext: LongInt; mszGroups: LPWStr; var pcchGroups: LongInt): LongInt; stdcall; Interfaced -
SCardListReadersA - function SCardListReadersA(SCARDCONTEXT: LongInt; mszGroups: LPStr; mszReaders: LPStr; var pcchReaders: LongInt): LongInt; stdcall; Interfaced -
SCardListReadersW - function SCardListReadersW(SCARDCONTEXT: LongInt; mszGroups: LPWStr; mszReaders: LPWStr; var pcchReaders: LongInt): LongInt; stdcall; Interfaced -
SCardLocateCardsA - function SCardLocateCardsA(hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA; cReaders: LongInt): LongInt; stdcall; Interfaced -
SCardLocateCardsByATRA - function SCardLocateCardsByATRA(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD; var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall; Interfaced -
SCardLocateCardsByATRW - function SCardLocateCardsByATRW(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD; var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall; Interfaced -
SCardLocateCardsW - function SCardLocateCardsW(hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW; cReaders: LongInt): LongInt; stdcall; Interfaced -
SCardReconnect - function SCardReconnect(hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt; dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall; Interfaced -
SCardReleaseContext - function SCardReleaseContext(hContext: LongInt): LongInt; stdcall; Interfaced -
SCardReleaseStartedEvent - function SCardReleaseStartedEvent: LongInt; stdcall; Interfaced -
SCardRemoveReaderFromGroupA - function SCardRemoveReaderFromGroupA(hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall; Interfaced -
SCardRemoveReaderFromGroupW - function SCardRemoveReaderFromGroupW(hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall; Interfaced -
SCardSetAttrib - function SCardSetAttrib(hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; cbAttrLen: LongInt): LongInt; stdcall; Interfaced -
SCardSetCardTypeProviderNameA - function SCardSetCardTypeProviderNameA(hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt; szProvider: LPStr): LongInt; stdcall; Interfaced -
SCardSetCardTypeProviderNameW - function SCardSetCardTypeProviderNameW(hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt; szProvider: LPWStr): LongInt; stdcall; Interfaced -
SCardStatusA - function SCardStatusA(hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt; pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall; Interfaced -
SCardStatusW - function SCardStatusW(hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt; pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall; Interfaced -
SCardTransmit - function SCardTransmit(hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte; dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte; pcbRecvLength: PDWord): LongInt; stdcall; Interfaced -

Global Variables

Name Type Declaration Comments
LPCBYTE Simple (unknown) LPCBYTE: PUChar; -
LPCVOID Pointer LPCVOID: Pointer; { VOID *LPCVOID; } VOID *LPCVOID;
LPSCARDCONTEXT PLongInt PSCARDCONTEXT, LPSCARDCONTEXT: PLongInt; { SCARDCONTEXT * } SCARDCONTEXT *
LPSCARDHANDLE PLongInt PSCARDHANDLE, LPSCARDHANDLE: PLongInt; { SCARDHANDLE * } SCARDHANDLE *
PSCARDCONTEXT PLongInt PSCARDCONTEXT, LPSCARDCONTEXT: PLongInt; { SCARDCONTEXT * } SCARDCONTEXT *
PSCARDHANDLE PLongInt PSCARDHANDLE, LPSCARDHANDLE: PLongInt; { SCARDHANDLE * } SCARDHANDLE *

Constants

Name Declaration Scope Comments
SC_DLG_FORCE_UI $04 Interfaced -
SC_DLG_MINIMAL_UI $01 Interfaced -
SC_DLG_NO_UI $02 Interfaced -
SCARD_ALL_READERS 'SCard$AllReaders' + Chr(0) + Chr(0) Interfaced -
SCARD_AUTOALLOCATE DWORD(-1) Interfaced -
SCARD_DEFAULT_READERS 'SCard$DefaultReaders' + Chr(0) + Chr(0) Interfaced -
SCARD_EJECT_CARD 3 Interfaced Eject the card on close
SCARD_LEAVE_CARD 0 Interfaced
The reader, so it is not available to other
 applications.

 Don't do anything special on close
SCARD_LOCAL_READERS 'SCard$LocalReaders' + Chr(0) + Chr(0) Interfaced -
SCARD_PROVIDER_CSP 2 Interfaced Crypto Service Provider Id
SCARD_PROVIDER_PRIMARY 1 Interfaced Primary Provider Id
SCARD_RESET_CARD 1 Interfaced Reset the card on close
SCARD_SCOPE_SYSTEM 2 Interfaced
And any database operations are performed
 within the domain of that terminal.  (The
 calling application must have appropriate
 access permissions for any database actions.)

 The context is the system context, and any
SCARD_SCOPE_TERMINAL 1 Interfaced
Database operations are performed within the
 domain of the user.

 The context is that of the current terminal,
SCARD_SCOPE_USER 0 Interfaced The context is a user context, and any
SCARD_SHARE_DIRECT 3 Interfaced
Card with other applications.

 This application demands direct control of
SCARD_SHARE_EXCLUSIVE 1 Interfaced This application is not willing to share this
SCARD_SHARE_SHARED 2 Interfaced
Card with other applications.

 This application is willing to share this
SCARD_STATE_ATRMATCH $40 Interfaced
In the reader.

 This implies that there is a card
SCARD_STATE_CHANGED $2 Interfaced
This reader be ignored.  No other
 bits will be set.

 This implies that there is a
SCARD_STATE_EMPTY $10 Interfaced
State of this reader is not
 available.  If this bit is set,
 then all the following bits are
 clear.

 This implies that there is not
SCARD_STATE_EXCLUSIVE $80 Interfaced
In the reader with an ATR
 matching one of the target cards.
 If this bit is set,
 SCARD_STATE_PRESENT will also be
 set.  This bit is only returned
 on the SCardLocateCard() service.

 This implies that the card in the
SCARD_STATE_IGNORE $1 Interfaced
Current state, and would like to
 know.  The use of this value
 results in an immediate return
 from state transition monitoring
 services.  This is represented by
 all bits set to zero.

 The application requested that
SCARD_STATE_INUSE $100 Interfaced
Reader is allocated for exclusive
 use by another application.  If
 this bit is set,
 SCARD_STATE_PRESENT will also be
 set.

 This implies that the card in the
SCARD_STATE_MUTE $200 Interfaced
Reader is in use by one or more
 other applications, but may be
 connected to in shared mode.  If
 this bit is set,
 SCARD_STATE_PRESENT will also be
 set.

 This implies that the card in the
SCARD_STATE_PRESENT $20 Interfaced
Card in the reader.  If this bit
 is set, all the following bits
 will be clear.

 This implies that there is a card
SCARD_STATE_UNAVAILABLE $8 Interfaced
Reader name is not recognized by
 the Service Manager.  If this bit
 is set, then SCARD_STATE_CHANGED
 and SCARD_STATE_IGNORE will also
 be set.

 This implies that the actual
SCARD_STATE_UNAWARE $0 Interfaced The application is unaware of the
SCARD_STATE_UNKNOWN $4 Interfaced
Difference between the state
 believed by the application, and
 the state known by the Service
 Manager.  When this bit is set,
 the application may assume a
 significant state change has
 occurred on this reader.

 This implies that the given
SCARD_STATE_UNPOWERED $400 Interfaced
Reader is unresponsive or not
 supported by the reader or
 software.

 This implies that the card in the
SCARD_SYSTEM_READERS 'SCard$SystemReaders' + Chr(0) + Chr(0) Interfaced -
SCARD_UNPOWER_CARD 2 Interfaced Power down the card on close
SCERR_NOCARDNAME $4000 Interfaced -
SCERR_NOGUIDS $8000 Interfaced -
WinSCardDLL 'winscard.dll' Global -


Module Source

1     {******************************************************************}
2     {                                                                  }
3     { Borland Delphi Runtime Library                                   }
4     { PCSC interface unit                                              }
5     {                                                                  }
6     { Portions created by Microsoft are                                }
7     { Copyright (C) 1996 Microsoft Corporation.                        }
8     { All Rights Reserved.                                             }
9     {                                                                  }
10    { The original file is: WinSCard.h                                 }
11    { The original Pascal code is: WinSCard.pas                        }
12    { The initial developer of the Pascal code is Chris Dickerson      }
13    { (chrisd@tsc.com).                                                }
14    {                                                                  }
15    { Obtained through:                                                }
16    {                                                                  }
17    { Joint Endeavour of Delphi Innovators (Project JEDI)              }
18    {                                                                  }
19    { You may retrieve the latest version of this file at the Project  }
20    { JEDI home page, located at http://delphi-jedi.org                }
21    {                                                                  }
22    { The contents of this file are used with permission, subject to   }
23    { the Mozilla Public License Version 1.1 (the "License"); you may  }
24    { not use this file except in compliance with the License. You may }
25    { obtain a copy of the License at                                  }
26    { http://www.mozilla.org/MPL/MPL-1.1.html                          }
27    {                                                                  }
28    { Software distributed under the License is distributed on an      }
29    { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   }
30    { implied. See the License for the specific language governing     }
31    { rights and limitations under the License.                        }
32    {                                                                  }
33    {******************************************************************}
34    unit WinSCard;
35    
36    interface
37    
38    uses
39       Windows;
40    
41    {$IFDEF WinSCard_LINKONREQUEST}
42      {$DEFINE WinSCard_DYNLINK}
43    {$ENDIF}
44    
45    type
46       LPCGUID = ^GUID;
47       {$EXTERNALSYM LPCGUID}
48       GUID = record
49          Data1: LongInt;
50          Data2: Integer;
51          Data3: Integer;
52          Data4: array[0..7] of Byte;
53       end;
54       {$EXTERNALSYM GUID}
55    
56    (*
57    
58    Copyright (c) 1996  Microsoft Corporation
59    
60    Module Name:
61    
62        WinSCard
63    
64    Abstract:
65    
66        This header file provides the definitions and symbols necessary for an
67        Application or Smart Card Service Provider to access the Smartcard
68        Subsystem.
69    
70    Environment:
71    
72        Win32
73    
74    Notes:
75    
76    *)
77    
78    var
79       LPCBYTE: PUChar;
80       {$EXTERNALSYM LPCBYTE}
81    
82       LPCVOID: Pointer;  { VOID *LPCVOID; }
83       {$EXTERNALSYM LPCVOID}
84    
85    type
86       PSCARD_IO_REQUEST = ^SCARD_IO_REQUEST;
87       {$EXTERNALSYM PSCARD_IO_REQUEST}
88       SCARD_IO_REQUEST = record
89          dwProtocol: DWORD;    { Protocol identifier }
90          dbPciLength: DWORD;   { Protocol Control Information Length }
91       end;
92       {$EXTERNALSYM SCARD_IO_REQUEST}
93    
94    //
95    ////////////////////////////////////////////////////////////////////////////////
96    //
97    //  Service Manager Access Services
98    //
99    //      The following services are used to manage user and terminal contexts for
100   //      Smart Cards.
101   //
102   type
103      SCARDCONTEXT = DWORD;
104      {$EXTERNALSYM SCARDCONTEXT}
105      SCARDHANDLE = DWORD;
106      {$EXTERNALSYM SCARDHANDLE}
107   
108   var
109      PSCARDCONTEXT, LPSCARDCONTEXT: PLongInt; { SCARDCONTEXT * }
110      {$EXTERNALSYM PSCARDCONTEXT}
111      {$EXTERNALSYM LPSCARDCONTEXT}
112   
113      PSCARDHANDLE, LPSCARDHANDLE: PLongInt; { SCARDHANDLE * }
114      {$EXTERNALSYM PSCARDHANDLE}
115      {$EXTERNALSYM LPSCARDHANDLE}
116   
117   const
118      SCARD_AUTOALLOCATE  = DWORD(-1);
119      {$EXTERNALSYM SCARD_AUTOALLOCATE}
120   
121      SCARD_SCOPE_USER = 0;                 // The context is a user context, and any
122      {$EXTERNALSYM SCARD_SCOPE_USER}       // database operations are performed within the
123                                            // domain of the user.
124      SCARD_SCOPE_TERMINAL = 1;             // The context is that of the current terminal,
125      {$EXTERNALSYM SCARD_SCOPE_TERMINAL}   // and any database operations are performed
126                                            // within the domain of that terminal.  (The
127                                            // calling application must have appropriate
128                                            // access permissions for any database actions.)
129      SCARD_SCOPE_SYSTEM = 2;               // The context is the system context, and any
130      {$EXTERNALSYM SCARD_SCOPE_SYSTEM}     // database operations are performed within the
131                                            // domain of the system.  (The calling
132                                            // application must have appropriate access
133                                            // permissions for any database actions.)
134   
135   
136   
137   {$IFDEF WinSCard_DYNLINK}
138   type
139      TSCardEstablishContext = function (dwScope: DWORD; pvReserved1: Pointer; pvReserved2: Pointer;
140                                         phContext: Pointer): LongInt; stdcall;
141      TSCardReleaseContext = function (hContext: LongInt): LongInt; stdcall;
142      TSCardIsValidContext = function (hContext: LongInt): LongInt; stdcall;
143   {$ELSE}
144      function SCardEstablishContext(dwScope: DWORD; pvReserved1: Pointer; pvReserved2: Pointer;
145                                     phContext: Pointer): LongInt; stdcall;
146      {$EXTERNALSYM SCardEstablishContext}
147      function SCardReleaseContext(hContext: LongInt): LongInt; stdcall;
148      {$EXTERNALSYM SCardReleaseContext}
149      function SCardIsValidContext(hContext: LongInt): LongInt; stdcall;
150      {$EXTERNALSYM SCardIsValidContext}
151   {$ENDIF}
152   
153   
154   //
155   ////////////////////////////////////////////////////////////////////////////////
156   //
157   //  Smart Card Database Management Services
158   //
159   //      The following services provide for managing the Smart Card Database.
160   //
161   
162   const
163      SCARD_ALL_READERS     =  'SCard$AllReaders' + Chr(0) + Chr(0);
164      {$EXTERNALSYM SCARD_ALL_READERS}
165      SCARD_DEFAULT_READERS =  'SCard$DefaultReaders' + Chr(0) + Chr(0);
166      {$EXTERNALSYM SCARD_DEFAULT_READERS}
167      SCARD_LOCAL_READERS   =  'SCard$LocalReaders' + Chr(0) + Chr(0);
168      {$EXTERNALSYM SCARD_LOCAL_READERS}
169      SCARD_SYSTEM_READERS  =  'SCard$SystemReaders' + Chr(0) + Chr(0);
170      {$EXTERNALSYM SCARD_SYSTEM_READERS}
171   
172      SCARD_PROVIDER_PRIMARY = 1;   // Primary Provider Id
173      {$EXTERNALSYM SCARD_PROVIDER_PRIMARY}
174      SCARD_PROVIDER_CSP     = 2;   // Crypto Service Provider Id
175      {$EXTERNALSYM SCARD_PROVIDER_CSP}
176   
177   //
178   // Database Reader routines
179   //
180   
181   {$IFDEF WinSCard_DYNLINK}
182   type
183      TSCardListReaderGroupsA = function (hContext: LongInt; mszGroups: LPStr; var pcchGroups: LongInt): LongInt; stdcall;
184      TSCardListReaderGroupsW = function (hContext: LongInt; mszGroups: LPWStr; var pcchGroups: LongInt): LongInt; stdcall;
185   
186      {$IFDEF UNICODE}
187         TSCardListReaderGroups = TSCardListReaderGroupsW;
188      {$ELSE}
189         TSCardListReaderGroups = TSCardListReaderGroupsA;
190      {$ENDIF}
191   
192      TSCardListReadersA = function (SCARDCONTEXT: LongInt; mszGroups: LPStr; mszReaders: LPStr;
193                                     var pcchReaders: LongInt): LongInt; stdcall;
194      TSCardListReadersW = function (SCARDCONTEXT: LongInt; mszGroups: LPWStr; mszReaders: LPWStr;
195                                     var pcchReaders: LongInt): LongInt; stdcall;
196   
197      {$IFDEF UNICODE}
198         TSCardListReaders = TSCardListReadersW;
199      {$ELSE}
200         TSCardListReaders = TSCardListReadersA;
201      {$ENDIF}
202   
203      TSCardListCardsA = function (hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
204                                   cguidInterfaceCount: LongInt; mszCards: LPStr; var pcchCards: LongInt): LongInt; stdcall;
205      TSCardListCardsW = function (hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
206                                   cguidInterfaceCount: LongInt; mszCards: LPWStr; var pcchCards: LongInt): LongInt; stdcall;
207   
208      {$IFDEF UNICODE}
209         TSCardListCards = TSCardListCardsW;
210      {$ELSE}
211         TSCardListCards = TSCardListCardsA;
212      {$ENDIF}
213   
214   {$ELSE}
215      function SCardListReaderGroupsA(hContext: LongInt; mszGroups: LPStr; var pcchGroups: LongInt): LongInt; stdcall;
216      {$EXTERNALSYM SCardListReaderGroupsA}
217      function SCardListReaderGroupsW(hContext: LongInt; mszGroups: LPWStr; var pcchGroups: LongInt): LongInt; stdcall;
218      {$EXTERNALSYM SCardListReaderGroupsW}
219   
220      function SCardListReadersA(SCARDCONTEXT: LongInt; mszGroups: LPStr; mszReaders: LPStr;
221                                 var pcchReaders: LongInt): LongInt; stdcall;
222      {$EXTERNALSYM SCardListReadersA}
223      function SCardListReadersW(SCARDCONTEXT: LongInt; mszGroups: LPWStr; mszReaders: LPWStr;
224                                 var pcchReaders: LongInt): LongInt; stdcall;
225      {$EXTERNALSYM SCardListReadersW}
226   
227      function SCardListCardsA(hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
228                               cguidInterfaceCount: LongInt; mszCards: LPStr; var pcchCards: LongInt): LongInt; stdcall;
229      {$EXTERNALSYM SCardListCardsA}
230      function SCardListCardsW(hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
231                               cguidInterfaceCount: LongInt; mszCards: LPWStr; var pcchCards: LongInt): LongInt; stdcall;
232      {$EXTERNALSYM SCardListCardsW}
233   
234   {$ENDIF}
235   
236   //
237   // NOTE:    The routine SCardListCards name differs from the PC/SC definition.
238   //          It should be:
239   //
240   //              extern WINSCARDAPI LONG WINAPI
241   //              SCardListCardTypes(
242   //                  IN      SCARDCONTEXT hContext,
243   //                  IN      LPCBYTE pbAtr,
244   //                  IN      LPCGUID rgquidInterfaces,
245   //                  IN      DWORD cguidInterfaceCount,
246   //                  OUT     LPTSTR mszCards,
247   //                  IN OUT  LPDWORD pcchCards);
248   //
249   //          Here's a work-around MACRO:
250   //#define SCardListCardTypes SCardListCards
251   
252   {$IFDEF WinSCard_DYNLINK}
253   type
254      TSCardListCardTypes = TSCardListCardsA;
255   
256      TSCardListInterfacesA = function (hContext: LongInt; szCard: LPStr; var pguidInterfaces: GUID;
257                                        var pcguidInterfaces: LongInt): LongInt; stdcall;
258      TSCardListInterfacesW = function (hContext: LongInt; szCard: LPWStr; var pguidInterfaces: GUID;
259                                        var pcguidInterfaces: LongInt): LongInt; stdcall;
260   
261      {$IFDEF UNICODE}
262         TSCardListInterfaces = TSCardListInterfacesW;
263      {$ELSE}
264         TSCardListInterfaces = TSCardListInterfacesA;
265      {$ENDIF}
266   
267      TSCardGetProviderIdA = function (hContext: LongInt; szCard: LPStr; var pguidProviderId: GUID): LongInt; stdcall;
268      TSCardGetProviderIdW = function (hContext: LongInt; szCard: LPWStr; var pguidProviderId: GUID): LongInt; stdcall;
269   
270      {$IFDEF UNICODE}
271         TSCardGetProviderId = TSCardGetProviderIdW;
272      {$ELSE}
273         TSCardGetProviderId = TSCardGetProviderIdA;
274      {$ENDIF}
275   {$ELSE}
276      function SCardListInterfacesA(hContext: LongInt; szCard: LPStr; var pguidInterfaces: GUID;
277                                    var pcguidInterfaces: LongInt): LongInt; stdcall;
278      {$EXTERNALSYM SCardListInterfacesA}
279      function SCardListInterfacesW(hContext: LongInt; szCard: LPWStr; var pguidInterfaces: GUID;
280                                    var pcguidInterfaces: LongInt): LongInt; stdcall;
281      {$EXTERNALSYM SCardListInterfacesW}
282   
283      function SCardGetProviderIdA(hContext: LongInt; szCard: LPStr; var pguidProviderId: GUID): LongInt; stdcall;
284      {$EXTERNALSYM SCardGetProviderIdA}
285      function SCardGetProviderIdW(hContext: LongInt; szCard: LPWStr; var pguidProviderId: GUID): LongInt; stdcall;
286      {$EXTERNALSYM SCardGetProviderIdW}
287   
288   {$ENDIF}
289   
290   //
291   // NOTE:    The routine SCardGetProviderId in this implementation uses GUIDs.
292   //          The PC/SC definition uses BYTEs.
293   //
294   
295   {$IFDEF WinSCard_DYNLINK}
296   type
297      TSCardGetCardTypeProviderNameA = function (hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
298                                                 szProvider: LPStr; var pcchProvider: LongInt): LongInt; stdcall;
299      TSCardGetCardTypeProviderNameW = function (hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
300                                                 szProvider: LPWStr; var pcchProvider: LongInt): LongInt; stdcall;
301   
302      {$IFDEF UNICODE}
303         TSCardGetCardTypeProviderName = TSCardGetCardTypeProviderNameW;
304      {$ELSE}
305         TSCardGetCardTypeProviderName = TSCardGetCardTypeProviderNameA;
306      {$ENDIF}
307   {$ELSE}
308      function SCardGetCardTypeProviderNameA(hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
309                                             szProvider: LPStr; var pcchProvider: LongInt): LongInt; stdcall;
310      {$EXTERNALSYM SCardGetCardTypeProviderNameA}
311      function SCardGetCardTypeProviderNameW(hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
312                                             szProvider: LPWStr; var pcchProvider: LongInt): LongInt; stdcall;
313      {$EXTERNALSYM SCardGetCardTypeProviderNameW}
314   {$ENDIF}
315   
316   
317   //
318   // NOTE:    This routine is an extension to the PC/SC definitions.
319   //
320   
321   
322   //
323   // Database Writer routines
324   //
325   
326   {$IFDEF WinSCard_DYNLINK}
327   type
328      TSCardIntroduceReaderGroupA = function (hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
329      TSCardIntroduceReaderGroupW = function (hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
330   
331      {$IFDEF UNICODE}
332         TSCardIntroduceReaderGroup = TSCardIntroduceReaderGroupW;
333      {$ELSE}
334         TSCardIntroduceReaderGroup = TSCardIntroduceReaderGroupA;
335      {$ENDIF}
336   
337      TSCardForgetReaderGroupA = function (hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
338      TSCardForgetReaderGroupW = function (hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
339      {$IFDEF UNICODE}
340         TSCardForgetReaderGroup = TSCardForgetReaderGroupW;
341      {$ELSE}
342         TSCardForgetReaderGroup = TSCardForgetReaderGroupA;
343      {$ENDIF}
344   
345      TSCardIntroduceReaderA = function (hContext: LongInt; szReadeName: LPStr; szDeviceName: LPStr): LongInt; stdcall;
346      TSCardIntroduceReaderW = function (hContext: LongInt; szReadeName: LPWStr; szDeviceName: LPWStr): LongInt; stdcall;
347      {$IFDEF UNICODE}
348         TSCardIntroduceReader = TSCardIntroduceReaderW;
349      {$ELSE}
350         TSCardIntroduceReader = TSCardIntroduceReaderA;
351      {$ENDIF}
352   
353      TSCardForgetReaderA = function (hContext: LongInt; szReaderName: LPStr): LongInt; stdcall;
354      TSCardForgetReaderW = function (hContext: LongInt; szReaderName: LPWStr): LongInt; stdcall;
355      {$IFDEF UNICODE}
356         TSCardForgetReader = TSCardForgetReaderW;
357      {$ELSE}
358         TSCardForgetReader = TSCardForgetReaderA;
359      {$ENDIF}
360   
361      TSCardAddReaderToGroupA = function (hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
362      TSCardAddReaderToGroupW = function (hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
363      {$IFDEF UNICODE}
364         TSCardAddReaderToGroup = TSCardAddReaderToGroupW;
365      {$ELSE}
366         TSCardAddReaderToGroup = TSCardAddReaderToGroupA;
367      {$ENDIF}
368   
369      TSCardRemoveReaderFromGroupA = function (hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
370      TSCardRemoveReaderFromGroupW = function (hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
371      {$IFDEF UNICODE}
372         TSCardRemoveReaderFromGroup = TSCardRemoveReaderFromGroupW;
373      {$ELSE}
374         TSCardRemoveReaderFromGroup = TSCardRemoveReaderFromGroupA;
375      {$ENDIF}
376   
377      TSCardIntroduceCardTypeA = function (hContext: LongInt; szCardName: LPStr; var pguidPrimaryProvider: GUID;
378                                           var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPStr;
379                                           pbAtrMask: LPStr; cbAtrLen: LongInt): LongInt; stdcall;
380      TSCardIntroduceCardTypeW = function (hContext: LongInt; szCardName: LPWStr; var pguidPrimaryProvider: GUID;
381                                           var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPWStr;
382                                           pbAtrMask: LPWStr; cbAtrLen: LongInt): LongInt; stdcall;
383   
384      {$IFDEF UNICODE}
385         TSCardIntroduceCardType = TSCardIntroduceCardTypeW;
386      {$ELSE}
387         TSCardIntroduceCardType = TSCardIntroduceCardTypeA;
388      {$ENDIF}
389   
390      TSCardSetCardTypeProviderNameA = function (hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
391                                                 szProvider: LPStr): LongInt; stdcall;
392      TSCardSetCardTypeProviderNameW = function (hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
393                                                 szProvider: LPWStr): LongInt; stdcall;
394      {$IFDEF UNICODE}
395         TSCardSetCardTypeProviderName = TSCardSetCardTypeProviderNameW;
396      {$ELSE}
397         TSCardSetCardTypeProviderName = TSCardSetCardTypeProviderNameA;
398      {$ENDIF}
399   {$ELSE}
400      function SCardIntroduceReaderGroupA(hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
401      {$EXTERNALSYM SCardIntroduceReaderGroupA}
402      function SCardIntroduceReaderGroupW(hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
403      {$EXTERNALSYM SCardIntroduceReaderGroupW}
404   
405      function SCardForgetReaderGroupA(hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
406      {$EXTERNALSYM SCardForgetReaderGroupA}
407      function SCardForgetReaderGroupW(hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
408      {$EXTERNALSYM SCardForgetReaderGroupW}
409   
410      function SCardIntroduceReaderA(hContext: LongInt; szReadeName: LPStr; szDeviceName: LPStr): LongInt; stdcall;
411      {$EXTERNALSYM SCardIntroduceReaderA}
412      function SCardIntroduceReaderW(hContext: LongInt; szReadeName: LPWStr; szDeviceName: LPWStr): LongInt; stdcall;
413      {$EXTERNALSYM SCardIntroduceReaderW}
414   
415      function SCardForgetReaderA(hContext: LongInt; szReaderName: LPStr): LongInt; stdcall;
416      {$EXTERNALSYM SCardForgetReaderA}
417      function SCardForgetReaderW(hContext: LongInt; szReaderName: LPWStr): LongInt; stdcall;
418      {$EXTERNALSYM SCardForgetReaderW}
419   
420      function SCardAddReaderToGroupA(hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
421      {$EXTERNALSYM SCardAddReaderToGroupA}
422      function SCardAddReaderToGroupW(hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
423      {$EXTERNALSYM SCardAddReaderToGroupW}
424   
425      function SCardRemoveReaderFromGroupA(hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
426      {$EXTERNALSYM SCardRemoveReaderFromGroupA}
427      function SCardRemoveReaderFromGroupW(hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
428      {$EXTERNALSYM SCardRemoveReaderFromGroupW}
429   
430      function SCardIntroduceCardTypeA(hContext: LongInt; szCardName: LPStr; var pguidPrimaryProvider: GUID;
431                                       var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPStr;
432                                       pbAtrMask: LPStr; cbAtrLen: LongInt): LongInt; stdcall;
433      {$EXTERNALSYM SCardIntroduceCardTypeA}
434      function SCardIntroduceCardTypeW(hContext: LongInt; szCardName: LPWStr; var pguidPrimaryProvider: GUID;
435                                       var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPWStr;
436                                       pbAtrMask: LPWStr; cbAtrLen: LongInt): LongInt; stdcall;
437      {$EXTERNALSYM SCardIntroduceCardTypeW}
438   
439      function SCardSetCardTypeProviderNameA(hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
440                                             szProvider: LPStr): LongInt; stdcall;
441      {$EXTERNALSYM SCardSetCardTypeProviderNameA}
442      function SCardSetCardTypeProviderNameW(hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
443                                             szProvider: LPWStr): LongInt; stdcall;
444      {$EXTERNALSYM SCardSetCardTypeProviderNameW}
445   {$ENDIF}
446   
447   //
448   // NOTE:    This routine is an extention to the PC/SC specifications.
449   //
450   
451   {$IFDEF WinSCard_DYNLINK}
452   type
453      TSCardForgetCardTypeA = function (hContext: LongInt; szCardName: LPStr): LongInt; stdcall;
454      TSCardForgetCardTypeW = function (hContext: LongInt; szCardName: LPWStr): LongInt; stdcall;
455   
456      {$IFDEF UNICODE}
457         TSCardForgetCardType = TSCardForgetCardTypeW;
458      {$ELSE}
459         TSCardForgetCardType = TSCardForgetCardTypeA;
460      {$ENDIF}
461   {$ELSE}
462      function SCardForgetCardTypeA(hContext: LongInt; szCardName: LPStr): LongInt; stdcall;
463      {$EXTERNALSYM SCardForgetCardTypeA}
464      function SCardForgetCardTypeW(hContext: LongInt; szCardName: LPWStr): LongInt; stdcall;
465      {$EXTERNALSYM SCardForgetCardTypeW}
466   {$ENDIF}
467   
468   //
469   ////////////////////////////////////////////////////////////////////////////////
470   //
471   //  Service Manager Support Routines
472   //
473   //      The following services are supplied to simplify the use of the Service
474   //      Manager API.
475   //
476   
477   {$IFDEF WinSCard_DYNLINK}
478   type
479      TSCardFreeMemory = function (hContext: LongInt; pvMem: LongInt): LongInt; stdcall;
480   
481      TSCardAccessStartedEvent = function: LongInt; stdcall;
482   
483      TSCardReleaseStartedEvent = function: LongInt; stdcall;
484   {$ELSE}
485      function SCardFreeMemory(hContext: LongInt; pvMem: LongInt): LongInt; stdcall;
486      {$EXTERNALSYM SCardFreeMemory}
487   
488      function SCardAccessStartedEvent: LongInt; stdcall;
489      {$EXTERNALSYM SCardAccessStartedEvent}
490   
491      function SCardReleaseStartedEvent: LongInt; stdcall;
492      {$EXTERNALSYM SCardReleaseStartedEvent}
493   {$ENDIF}
494   
495   //
496   ////////////////////////////////////////////////////////////////////////////////
497   //
498   //  Reader Services
499   //
500   //      The following services supply means for tracking cards within readers.
501   //
502   
503   type
504      LPSCARD_READERSTATEA = ^SCARD_READERSTATEA;
505      {$EXTERNALSYM LPSCARD_READERSTATEA}
506      PSCARD_READERSTATEA = ^SCARD_READERSTATEA;
507      {$EXTERNALSYM PSCARD_READERSTATEA}
508      SCARD_READERSTATEA = record
509         szReader: array[0..120] of Char;  { reader name }
510         pvUserData: Pointer;              { user defined data }
511         dwCurrentState: LongInt;          { current state of reader at time of call }
512         dwEventState: LongInt;            { state of reader after state change }
513         cbAtr: LongInt;                   { Number of bytes in the returned ATR }
514         rgbAtr: array[0..35] of Byte;     { Atr of inserted card, (extra alignment bytes) }
515      end;
516      {$EXTERNALSYM SCARD_READERSTATEA}
517   
518      LPSCARD_READERSTATEW = ^SCARD_READERSTATEW;
519      {$EXTERNALSYM LPSCARD_READERSTATEW}
520      PSCARD_READERSTATEW = ^SCARD_READERSTATEW;
521      {$EXTERNALSYM PSCARD_READERSTATEW}
522      SCARD_READERSTATEW = record
523         szReader: LPCWStr;                { reader name }
524         pvUserData: Pointer;              { user defined data }
525         dwCurrentState: LongInt;          { current state of reader at time of call }
526         dwEventState: LongInt;            { state of reader after state change }
527         cbAtr: LongInt;                   { Number of bytes in the returned ATR }
528         rgbAtr: array[0..35] of Byte;     { Atr of inserted card, (extra alignment bytes) }
529      end;
530      {$EXTERNALSYM SCARD_READERSTATEW}
531   
532   {$IFDEF UNICODE}
533      SCARD_READERSTATE = SCARD_READERSTATEW;
534      PSCARD_READERSTATE = PSCARD_READERSTATEW;
535      LPSCARD_READERSTATE = LPSCARD_READERSTATEW;
536   {$ELSE}
537      SCARD_READERSTATE = SCARD_READERSTATEA;
538      PSCARD_READERSTATE = PSCARD_READERSTATEA;
539      LPSCARD_READERSTATE = LPSCARD_READERSTATEA;
540   {$ENDIF}
541   {$EXTERNALSYM SCARD_READERSTATE}
542   {$EXTERNALSYM PSCARD_READERSTATE}
543   {$EXTERNALSYM LPSCARD_READERSTATE}
544   
545   const
546      SCARD_STATE_UNAWARE = $0;                // The application is unaware of the
547      {$EXTERNALSYM SCARD_STATE_UNAWARE}       // current state, and would like to
548                                               // know.  The use of this value
549                                               // results in an immediate return
550                                               // from state transition monitoring
551                                               // services.  This is represented by
552                                               // all bits set to zero.
553      SCARD_STATE_IGNORE  = $1;                // The application requested that
554      {$EXTERNALSYM SCARD_STATE_IGNORE}        // this reader be ignored.  No other
555                                               // bits will be set.
556      SCARD_STATE_CHANGED = $2;                // This implies that there is a
557      {$EXTERNALSYM SCARD_STATE_CHANGED}       // difference between the state
558                                               // believed by the application, and
559                                               // the state known by the Service
560                                               // Manager.  When this bit is set,
561                                               // the application may assume a
562                                               // significant state change has
563                                               // occurred on this reader.
564      SCARD_STATE_UNKNOWN = $4;                // This implies that the given
565      {$EXTERNALSYM SCARD_STATE_UNKNOWN}       // reader name is not recognized by
566                                               // the Service Manager.  If this bit
567                                               // is set, then SCARD_STATE_CHANGED
568                                               // and SCARD_STATE_IGNORE will also
569                                               // be set.
570      SCARD_STATE_UNAVAILABLE = $8;            // This implies that the actual
571      {$EXTERNALSYM SCARD_STATE_UNAVAILABLE}   // state of this reader is not
572                                               // available.  If this bit is set,
573                                               // then all the following bits are
574                                               // clear.
575      SCARD_STATE_EMPTY = $10;                 // This implies that there is not
576      {$EXTERNALSYM SCARD_STATE_EMPTY}         // card in the reader.  If this bit
577                                               // is set, all the following bits
578                                               // will be clear.
579      SCARD_STATE_PRESENT = $20;               // This implies that there is a card
580      {$EXTERNALSYM SCARD_STATE_PRESENT}       // in the reader.
581      SCARD_STATE_ATRMATCH = $40;              // This implies that there is a card
582      {$EXTERNALSYM SCARD_STATE_ATRMATCH}      // in the reader with an ATR
583                                               // matching one of the target cards.
584                                               // If this bit is set,
585                                               // SCARD_STATE_PRESENT will also be
586                                               // set.  This bit is only returned
587                                               // on the SCardLocateCard() service.
588      SCARD_STATE_EXCLUSIVE = $80;             // This implies that the card in the
589      {$EXTERNALSYM SCARD_STATE_EXCLUSIVE}     // reader is allocated for exclusive
590                                               // use by another application.  If
591                                               // this bit is set,
592                                               // SCARD_STATE_PRESENT will also be
593                                               // set.
594      SCARD_STATE_INUSE = $100;                // This implies that the card in the
595      {$EXTERNALSYM SCARD_STATE_INUSE}         // reader is in use by one or more
596                                               // other applications, but may be
597                                               // connected to in shared mode.  If
598                                               // this bit is set,
599                                               // SCARD_STATE_PRESENT will also be
600                                               // set.
601      SCARD_STATE_MUTE = $200;                 // This implies that the card in the
602      {$EXTERNALSYM SCARD_STATE_MUTE}          // reader is unresponsive or not
603                                               // supported by the reader or
604                                               // software.
605      SCARD_STATE_UNPOWERED = $400;            // This implies that the card in the
606      {$EXTERNALSYM SCARD_STATE_UNPOWERED}     // reader has not been powered up.
607   
608   {$IFDEF WinSCard_DYNLINK}
609   type
610      TSCardLocateCardsA = function (hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA;
611                                     cReaders: LongInt): LongInt; stdcall;
612      TSCardLocateCardsW = function (hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW;
613                                     cReaders: LongInt): LongInt; stdcall;
614   
615      {$IFDEF UNICODE}
616         TSCardLocateCards = TSCardLocateCardsW;
617      {$ELSE}
618         TSCardLocateCards = TSCardLocateCardsA;
619      {$ENDIF}
620   {$ELSE}
621      function SCardLocateCardsA(hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA;
622                                 cReaders: LongInt): LongInt; stdcall;
623      {$EXTERNALSYM SCardLocateCardsA}
624      function SCardLocateCardsW(hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW;
625                                 cReaders: LongInt): LongInt; stdcall;
626      {$EXTERNALSYM SCardLocateCardsW}
627   {$ENDIF}
628   
629   type
630      PSCARD_ATRMASK = ^SCARD_ATRMASK;
631      {$EXTERNALSYM PSCARD_ATRMASK}
632      LPSCARD_ATRMASK = ^SCARD_ATRMASK;
633      {$EXTERNALSYM LPSCARD_ATRMASK}
634      SCARD_ATRMASK = record
635         cbArt: DWORD;                  // Number of bytes in the ATR and the mask.
636         rgbAtr: array[0..35] of Byte;  // Atr of card (extra alignment bytes)
637         rgbMask: array[0..35] of Byte; // Mask for the Atr (extra alignment bytes)
638      end;
639      {$EXTERNALSYM SCARD_ATRMASK}
640   
641   {$IFDEF WinSCard_DYNLINK}
642   type
643      TSCardLocateCardsByATRA = function (hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
644                                          var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall;
645      TSCardLocateCardsByATRW = function (hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
646                                          var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall;
647   
648      {$IFDEF UNICODE}
649         TSCardLocateCardsByATR = TSCardLocateCardsByATRW;
650      {$ELSE}
651         TSCardLocateCardsByATR = TSCardLocateCardsByATRA;
652      {$ENDIF}
653   
654      TSCardGetStatusChangeA = function (hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEA;
655                                         cReaders: LongInt): LongInt; stdcall;
656      TSCardGetStatusChangeW = function (hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW;
657                                         cReaders: LongInt): LongInt; stdcall;
658      {$IFDEF UNICODE}
659         TSCardGetStatusChange = TSCardGetStatusChangeW;
660      {$ELSE}
661         TSCardGetStatusChange = TSCardGetStatusChangeA;
662      {$ENDIF}
663   
664      TSCardCancel = function (hContext: LongInt): LongInt; stdcall;
665   {$ELSE}
666      function SCardLocateCardsByATRA(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
667                                      var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall;
668      {$EXTERNALSYM SCardLocateCardsByATRA}
669      function SCardLocateCardsByATRW(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
670                                      var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall;
671      {$EXTERNALSYM SCardLocateCardsByATRW}
672   
673      function SCardGetStatusChangeA(hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEA;
674                                     cReaders: LongInt): LongInt; stdcall;
675      {$EXTERNALSYM SCardGetStatusChangeA}
676      function SCardGetStatusChangeW(hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW;
677                                     cReaders: LongInt): LongInt; stdcall;
678      {$EXTERNALSYM SCardGetStatusChangeW}
679      function SCardCancel (hContext: LongInt): LongInt; stdcall;
680      {$EXTERNALSYM SCardCancel}
681   {$ENDIF}
682   
683   //
684   ////////////////////////////////////////////////////////////////////////////////
685   //
686   //  Card/Reader Communication Services
687   //
688   //      The following services provide means for communication with the card.
689   //
690   
691   const
692      SCARD_SHARE_EXCLUSIVE = 1;            // This application is not willing to share this
693      {$EXTERNALSYM SCARD_SHARE_EXCLUSIVE}  // card with other applications.
694      SCARD_SHARE_SHARED = 2;               // This application is willing to share this
695      {$EXTERNALSYM SCARD_SHARE_SHARED}     // card with other applications.
696      SCARD_SHARE_DIRECT = 3;               // This application demands direct control of
697      {$EXTERNALSYM SCARD_SHARE_DIRECT}     // the reader, so it is not available to other
698                                            // applications.
699   
700      SCARD_LEAVE_CARD = 0;                 // Don't do anything special on close
701      {$EXTERNALSYM SCARD_LEAVE_CARD}
702      SCARD_RESET_CARD = 1;                 // Reset the card on close
703      {$EXTERNALSYM SCARD_RESET_CARD}
704      SCARD_UNPOWER_CARD = 2;               // Power down the card on close
705      {$EXTERNALSYM SCARD_UNPOWER_CARD}
706      SCARD_EJECT_CARD = 3;                 // Eject the card on close
707      {$EXTERNALSYM SCARD_EJECT_CARD}
708   
709   {$IFDEF WinSCard_DYNLINK}
710   type
711      TSCardConnectA = function (hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
712                                 var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
713      TSCardConnectW = function (hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
714                                 var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
715      {$IFDEF UNICODE}
716         TSCardConnect = TSCardConnectW;
717      {$ELSE}
718         TSCardConnect = TSCardConnectA;
719      {$ENDIF}
720   
721      TSCardReconnect = function (hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
722                                  dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall;
723   
724      TSCardDisconnect = function (hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
725   
726      TSCardBeginTransaction = function (hCard: LongInt): LongInt; stdcall;
727   
728      TSCardEndTransaction = function (hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
729   {$ELSE}
730      function SCardConnectA(hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
731                             var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
732      {$EXTERNALSYM SCardConnectA}
733      function SCardConnectW(hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
734                             var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
735      {$EXTERNALSYM SCardConnectW}
736   
737      function SCardReconnect(hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
738                              dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall;
739      {$EXTERNALSYM SCardReconnect}
740   
741      function SCardDisconnect(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
742      {$EXTERNALSYM SCardDisconnect}
743   
744      function SCardBeginTransaction(hCard: LongInt): LongInt; stdcall;
745      {$EXTERNALSYM SCardBeginTransaction}
746   
747      function SCardEndTransaction(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
748      {$EXTERNALSYM SCardEndTransaction}
749   {$ENDIF}
750   
751   //
752   // NOTE:    This call corresponds to the PC/SC SCARDCOMM::Cancel routine,
753   //          terminating a blocked SCardBeginTransaction service.
754   //
755   
756   //
757   // NOTE:    SCardState is an obsolete routine.  PC/SC has replaced it with
758   //          SCardStatus.
759   //
760   
761   {$IFDEF WinSCard_DYNLINK}
762   type
763      TSCardStatusA = function (hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
764                                pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
765      TSCardStatusW = function (hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
766                                pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
767      {$IFDEF UNICODE}
768         TSCardStatus = TSCardStatusW;
769      {$ELSE}
770         TSCardStatus = TSCardStatusA;
771      {$ENDIF}
772   
773      TSCardTransmit = function (hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte;
774                                 dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte;
775                                 pcbRecvLength: PDWord): LongInt; stdcall;
776   {$ELSE}
777      function SCardStatusA(hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
778                            pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
779      {$EXTERNALSYM SCardStatusA}
780      function SCardStatusW(hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
781                            pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
782      {$EXTERNALSYM SCardStatusW}
783   
784      function SCardTransmit(hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte;
785                             dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte;
786                             pcbRecvLength: PDWord): LongInt; stdcall;
787      {$EXTERNALSYM SCardTransmit}
788   {$ENDIF}
789   
790   //
791   ////////////////////////////////////////////////////////////////////////////////
792   //
793   //  Reader Control Routines
794   //
795   //      The following services provide for direct, low-level manipulation of the
796   //      reader by the calling application allowing it control over the
797   //      attributes of the communications with the card.
798   //
799   {$IFDEF WinSCard_DYNLINK}
800   type
801      TSCardControl = function (hCard: LongInt; dwControlCode: LongInt; var pvInBuffer: PByte; cbInBufferSize: LongInt;
802                                var pvOutBuffer: PByte; cbOutBufferSize: LongInt;
803                                var pcbBytesReturned: LongInt): LongInt; stdcall;
804   
805      TSCardGetAttrib = function (hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; var pcbAttrLen: LongInt): LongInt; stdcall;
806   {$ELSE}
807      function SCardControl(hCard: LongInt; dwControlCode: LongInt; var pvInBuffer: PByte; cbInBufferSize: LongInt;
808                            var pvOutBuffer: PByte; cbOutBufferSize: LongInt;
809                            var pcbBytesReturned: LongInt): LongInt; stdcall;
810      {$EXTERNALSYM SCardControl}
811   
812      function SCardGetAttrib(hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; var pcbAttrLen: LongInt): LongInt; stdcall;
813      {$EXTERNALSYM SCardGetAttrib}
814   {$ENDIF}
815   
816   //
817   // NOTE:    The routine SCardGetAttrib's name differs from the PC/SC definition.
818   //          It should be:
819   //
820   //              extern WINSCARDAPI LONG WINAPI
821   //              SCardGetReaderCapabilities(
822   //                  IN SCARDHANDLE hCard,
823   //                  IN DWORD dwTag,
824   //                  OUT LPBYTE pbAttr,
825   //                  IN OUT LPDWORD pcbAttrLen);
826   //
827   //          Here's a work-around MACRO:
828   {$IFDEF WinSCard_DYNLINK}
829   type
830      TSCardGetReaderCapabilities = TSCardGetAttrib;
831   
832      TSCardSetAttrib = function (hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; cbAttrLen: LongInt): LongInt; stdcall;
833   {$ELSE}
834      function SCardSetAttrib(hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; cbAttrLen: LongInt): LongInt; stdcall;
835      {$EXTERNALSYM SCardSetAttrib}
836   {$ENDIF}
837   
838   //
839   // NOTE:    The routine SCardSetAttrib's name differs from the PC/SC definition.
840   //          It should be:
841   //
842   //              extern WINSCARDAPI LONG WINAPI
843   //              SCardSetReaderCapabilities(
844   //                  IN SCARDHANDLE hCard,
845   //                  IN DWORD dwTag,
846   //                  OUT LPBYTE pbAttr,
847   //                  IN OUT LPDWORD pcbAttrLen);
848   //
849   //          Here's a work-around MACRO:
850   {$IFDEF WinSCard_DYNLINK}
851   type
852      TSCardSetReaderCapabilities = TSCardSetAttrib;
853   {$ENDIF}
854   
855   //
856   ////////////////////////////////////////////////////////////////////////////////
857   //
858   //  Smart Card Dialog definitions
859   //
860   //      The following section contains structures and  exported function
861   //      declarations for the Smart Card Common Dialog dialog.
862   //
863   
864   // Defined constants
865   // Flags
866   const
867      SC_DLG_MINIMAL_UI = $01;
868      {$EXTERNALSYM SC_DLG_MINIMAL_UI}
869      SC_DLG_NO_UI = $02;
870      {$EXTERNALSYM SC_DLG_NO_UI}
871      SC_DLG_FORCE_UI = $04;
872      {$EXTERNALSYM SC_DLG_FORCE_UI}
873   
874      SCERR_NOCARDNAME = $4000;
875      {$EXTERNALSYM SCERR_NOCARDNAME}
876      SCERR_NOGUIDS = $8000;
877      {$EXTERNALSYM SCERR_NOGUIDS}
878   
879   type
880      LPOCNCONNPROCA = function(hSCardContext: LongInt; hCard: LPStr; pvUserData: Pointer): DWORD; cdecl;
881      {$EXTERNALSYM LPOCNCONNPROCA}
882      LPOCNCONNPROCW = function(hSCardContext: LongInt; hCard: LPWStr; pvUserData: Pointer): DWORD; cdecl;
883      {$EXTERNALSYM LPOCNCONNPROCW}
884      {$IFDEF UNICODE}
885         LPOCNCONNPROC = LPOCNCONNPROCW;
886      {$ELSE}
887         LPOCNCONNPROC = LPOCNCONNPROCA;
888      {$ENDIF}
889      {$EXTERNALSYM LPOCNCONNPROC}
890   
891      LPOCNCHKPROC = function(hContext: LongInt; hCard: LPStr; pvUserData: Pointer): Bool; cdecl;
892      {$EXTERNALSYM LPOCNCHKPROC}
893      LPOCNDSCPROC = procedure(hContext: LongInt; hCard: LPStr; pvUserData: Pointer); cdecl;
894      {$EXTERNALSYM LPOCNDSCPROC}
895   
896   //
897   // OPENCARD_SEARCH_CRITERIA: In order to specify a user-extended search,
898   // lpfnCheck must not be NULL.  Moreover, the connection to be made to the
899   // card before performing the callback must be indicated by either providing
900   // lpfnConnect and lpfnDisconnect OR by setting dwShareMode.
901   // If both the connection callbacks and dwShareMode are non-NULL, the callbacks
902   // will be used.
903   //
904   
905      POPENCARD_SEARCH_CRITERIAA = ^OPENCARD_SEARCH_CRITERIAA;
906      {$EXTERNALSYM POPENCARD_SEARCH_CRITERIAA}
907      LPOPENCARD_SEARCH_CRITERIAA = ^OPENCARD_SEARCH_CRITERIAA;
908      {$EXTERNALSYM LPOPENCARD_SEARCH_CRITERIAA}
909      OPENCARD_SEARCH_CRITERIAA = record
910         dwStructSize: DWORD;
911         lpstrGroupNames: LPSTR;        // OPTIONAL reader groups to include in
912         nMaxGroupNames: DWORD;         //          search.  NULL defaults to
913                                        //          SCard$DefaultReaders
914         rgguidInterfaces: LPCGUID;     // OPTIONAL requested interfaces
915         cguidInterfaces: DWORD;        //          supported by card's SSP
916         lpstrCardNames: LPSTR;         // OPTIONAL requested card names; all cards w/
917         nMaxCardNames: DWORD;          //          matching ATRs will be accepted
918         lpfnCheck: LPOCNCHKPROC;       // OPTIONAL if NULL no user check will be performed.
919         lpfnConnect: LPOCNCONNPROCA;   // OPTIONAL if lpfnConnect is provided,
920         lpfnDisconnect: LPOCNDSCPROC;  //          lpfnDisconnect must also be set.
921         pvUserData: Pointer;           // OPTIONAL parameter to callbacks
922         dwShareMode: DWORD;            // OPTIONAL must be set if lpfnCheck is not null
923         dwPreferredProtocols: DWORD;   // OPTIONAL
924      end;
925      {$EXTERNALSYM OPENCARD_SEARCH_CRITERIAA}
926   
927      POPENCARD_SEARCH_CRITERIAW = ^OPENCARD_SEARCH_CRITERIAW;
928      {$EXTERNALSYM POPENCARD_SEARCH_CRITERIAW}
929      LPOPENCARD_SEARCH_CRITERIAW = ^OPENCARD_SEARCH_CRITERIAW;
930      {$EXTERNALSYM LPOPENCARD_SEARCH_CRITERIAW}
931      OPENCARD_SEARCH_CRITERIAW = record
932         dwStructSize: DWORD;
933         lpstrGroupNames: LPWSTR;       // OPTIONAL reader groups to include in
934         nMaxGroupNames: DWORD;         //          search.  NULL defaults to
935                                        //          SCard$DefaultReaders
936         rgguidInterfaces: LPCGUID;     // OPTIONAL requested interfaces
937         cguidInterfaces: DWORD;        //          supported by card's SSP
938         lpstrCardNames: LPWSTR;        // OPTIONAL requested card names; all cards w/
939         nMaxCardNames: DWORD;          //          matching ATRs will be accepted
940         lpfnCheck: LPOCNCHKPROC;       // OPTIONAL if NULL no user check will be performed.
941         lpfnConnect: LPOCNCONNPROCA;   // OPTIONAL if lpfnConnect is provided,
942         lpfnDisconnect: LPOCNDSCPROC;  //          lpfnDisconnect must also be set.
943         pvUserData: Pointer;           // OPTIONAL parameter to callbacks
944         dwShareMode: DWORD;            // OPTIONAL must be set if lpfnCheck is not null
945         dwPreferredProtocols: DWORD;   // OPTIONAL
946      end;
947      {$EXTERNALSYM OPENCARD_SEARCH_CRITERIAW}
948   
949      {$IFDEF UNICODE}
950         OPENCARD_SEARCH_CRITERIA = OPENCARD_SEARCH_CRITERIAW;
951         POPENCARD_SEARCH_CRITERIA = POPENCARD_SEARCH_CRITERIAW;
952         LPOPENCARD_SEARCH_CRITERIA = LPOPENCARD_SEARCH_CRITERIAW;
953      {$ELSE}
954         OPENCARD_SEARCH_CRITERIA = OPENCARD_SEARCH_CRITERIAA;
955         POPENCARD_SEARCH_CRITERIA = POPENCARD_SEARCH_CRITERIAA;
956         LPOPENCARD_SEARCH_CRITERIA = LPOPENCARD_SEARCH_CRITERIAA;
957      {$ENDIF}
958      {$EXTERNALSYM OPENCARD_SEARCH_CRITERIA}
959      {$EXTERNALSYM POPENCARD_SEARCH_CRITERIA}
960      {$EXTERNALSYM LPOPENCARD_SEARCH_CRITERIA}
961   
962   //
963   // OPENCARDNAME_EX: used by SCardUIDlgSelectCard; replaces obsolete OPENCARDNAME
964   //
965      POPENCARDNAME_EXA = ^OPENCARDNAME_EXA;
966      {$EXTERNALSYM POPENCARDNAME_EXA}
967      LPOPENCARDNAME_EXA = ^OPENCARDNAME_EXA;
968      {$EXTERNALSYM LPOPENCARDNAME_EXA}
969      OPENCARDNAME_EXA = record
970         dwStructSize: DWORD;           // REQUIRED
971         hSCardContext: SCARDCONTEXT;   // REQUIRED
972         hwndOwner: HWND;               // OPTIONAL
973         dwFlags: DWORD;                // OPTIONAL -- default is SC_DLG_MINIMAL_UI
974         lpstrTitle: LPCSTR;            // OPTIONAL
975         lpstrSearchDesc: LPCSTR;       // OPTIONAL (eg. "Please insert your <brandname> smart card.")
976         hIcon: HICON;                  // OPTIONAL 32x32 icon for your brand insignia
977         pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAA ; // OPTIONAL
978         lpfnConnect: LPOCNCONNPROCA;   // OPTIONAL - performed on successful selection
979         pvUserData: Pointer;           // OPTIONAL parameter to lpfnConnect
980         dwShareMode: DWORD;            // OPTIONAL - if lpfnConnect is NULL, dwShareMode and
981         dwPreferredProtocols: DWORD;   // OPTIONAL dwPreferredProtocols will be used to
982                                        //          connect to the selected card
983         lpstrRdr: LPSTR;               // REQUIRED [IN|OUT] Name of selected reader
984         nMaxRdr: DWORD;                // REQUIRED [IN|OUT]
985         lpstrCard: LPSTR;              // REQUIRED [IN|OUT] Name of selected card
986         nMaxCard: DWORD;               // REQUIRED [IN|OUT]
987         dwActiveProtocol: DWORD;       // [OUT] set only if dwShareMode not NULL
988         hCardHandle: SCARDHANDLE;      // [OUT] set if a card connection was indicated
989      end;
990      {$EXTERNALSYM OPENCARDNAME_EXA}
991   
992      POPENCARDNAME_EXW = ^OPENCARDNAME_EXW;
993      {$EXTERNALSYM POPENCARDNAME_EXW}
994      LPOPENCARDNAME_EXW = ^OPENCARDNAME_EXW;
995      {$EXTERNALSYM LPOPENCARDNAME_EXW}
996      OPENCARDNAME_EXW = record
997         dwStructSize: DWORD;           // REQUIRED
998         hSCardContext: SCARDCONTEXT;   // REQUIRED
999         hwndOwner: HWND;               // OPTIONAL
1000        dwFlags: DWORD;                // OPTIONAL -- default is SC_DLG_MINIMAL_UI
1001        lpstrTitle: LPCWSTR;           // OPTIONAL
1002        lpstrSearchDesc: LPCWSTR;      // OPTIONAL (eg. "Please insert your <brandname> smart card.")
1003        hIcon: HICON;                  // OPTIONAL 32x32 icon for your brand insignia
1004        pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAW ; // OPTIONAL
1005        lpfnConnect: LPOCNCONNPROCW;   // OPTIONAL - performed on successful selection
1006        pvUserData: Pointer;           // OPTIONAL parameter to lpfnConnect
1007        dwShareMode: DWORD;            // OPTIONAL - if lpfnConnect is NULL, dwShareMode and
1008        dwPreferredProtocols: DWORD;   // OPTIONAL dwPreferredProtocols will be used to
1009                                       //          connect to the selected card
1010        lpstrRdr: LPWSTR;              // REQUIRED [IN|OUT] Name of selected reader
1011        nMaxRdr: DWORD;                // REQUIRED [IN|OUT]
1012        lpstrCard: LPWSTR;             // REQUIRED [IN|OUT] Name of selected card
1013        nMaxCard: DWORD;               // REQUIRED [IN|OUT]
1014        dwActiveProtocol: DWORD;       // [OUT] set only if dwShareMode not NULL
1015        hCardHandle: SCARDHANDLE;      // [OUT] set if a card connection was indicated
1016     end;
1017     {$EXTERNALSYM OPENCARDNAME_EXW}
1018  
1019     {$IFDEF UNICODE}
1020        OPENCARDNAME_EX = OPENCARDNAME_EXW;
1021        POPENCARDNAME_EX = POPENCARDNAME_EXW;
1022        LPOPENCARDNAME_EX = LPOPENCARDNAME_EXW;
1023     {$ELSE}
1024        OPENCARDNAME_EX = OPENCARDNAME_EXA;
1025        POPENCARDNAME_EX = POPENCARDNAME_EXA;
1026        LPOPENCARDNAME_EX = LPOPENCARDNAME_EXA;
1027     {$ENDIF}
1028     {$EXTERNALSYM OPENCARDNAME_EX}
1029     {$EXTERNALSYM POPENCARDNAME_EX}
1030     {$EXTERNALSYM LPOPENCARDNAME_EX}
1031  
1032  //
1033  // SCardUIDlgSelectCard replaces GetOpenCardName
1034  //
1035  {$IFDEF WinSCard_DYNLINK}
1036  type
1037     TSCardUIDlgSelectCardA = function(pDlgStruc: LPOPENCARDNAME_EXA): LongInt; stdcall;
1038     TSCardUIDlgSelectCardW = function(pDlgStruc: LPOPENCARDNAME_EXW): LongInt; stdcall;
1039     {$IFDEF UNICODE}
1040        TSCardUIDlgSelectCard = TSCardUIDlgSelectCardW;
1041     {$ELSE}
1042        TSCardUIDlgSelectCard = TSCardUIDlgSelectCardA;
1043     {$ENDIF}
1044  {$ELSE}
1045     // These are not exported by the DLL no point defining them and causing errors
1046     // function SCardUIDlgSelectCardA(pDlgStruc: LPOPENCARDNAME_EXA): LongInt; stdcall;
1047     // function SCardUIDlgSelectCardW(pDlgStruc: LPOPENCARDNAME_EXW): LongInt; stdcall;
1048  {$ENDIF}
1049  
1050  //
1051  // "Smart Card Common Dialog" definitions for backwards compatibility
1052  //  with the Smart Card Base Services SDK version 1.0
1053  //
1054  
1055  type
1056     POPENCARDNAMEA = ^OPENCARDNAMEA;
1057     {$EXTERNALSYM POPENCARDNAMEA}
1058     LPOPENCARDNAMEA = ^OPENCARDNAMEA;
1059     {$EXTERNALSYM LPOPENCARDNAMEA}
1060     OPENCARDNAMEA = record
1061        dwStructSize: DWORD;
1062        hwndOwner: HWND;
1063        hSCardContext: SCARDCONTEXT;
1064        lpstrGroupNames: LPSTR;
1065        nMaxGroupNames: DWORD;
1066        lpstrCardNames: LPSTR;
1067        nMaxCardNames: DWORD;
1068        rgguidInterfaces: LPCGUID;
1069        cguidInterfaces: DWORD;
1070        lpstrRdr: LPSTR;
1071        nMaxRdr: DWORD;
1072        lpstrCard: LPSTR;
1073        nMaxCard: DWORD;
1074        lpstrTitle: LPCSTR;
1075        dwFlags: DWORD;
1076        pvUserData: Pointer;
1077        dwShareMode: DWORD;
1078        dwPreferredProtocols: DWORD;
1079        dwActiveProtocol: DWORD;
1080        lpfnConnect: LPOCNCONNPROCA;
1081        lpfnCheck: LPOCNCHKPROC;
1082        lpfnDisconnect: LPOCNDSCPROC;
1083        hCardHandle: SCARDHANDLE;
1084     end;
1085     {$EXTERNALSYM OPENCARDNAMEA}
1086  
1087     POPENCARDNAMEW = ^OPENCARDNAMEW;
1088     {$EXTERNALSYM POPENCARDNAMEW}
1089     LPOPENCARDNAMEW = ^OPENCARDNAMEW;
1090     {$EXTERNALSYM LPOPENCARDNAMEW}
1091     OPENCARDNAMEW = record
1092        dwStructSize: DWORD;
1093        hwndOwner: HWND;
1094        hSCardContext: SCARDCONTEXT;
1095        lpstrGroupNames: LPWSTR;
1096        nMaxGroupNames: DWORD;
1097        lpstrCardNames: LPWSTR;
1098        nMaxCardNames: DWORD;
1099        rgguidInterfaces: LPCGUID;
1100        cguidInterfaces: DWORD;
1101        lpstrRdr: LPWSTR;
1102        nMaxRdr: DWORD;
1103        lpstrCard: LPWSTR;
1104        nMaxCard: DWORD;
1105        lpstrTitle: LPCWSTR;
1106        dwFlags: DWORD;
1107        pvUserData: Pointer;
1108        dwShareMode: DWORD;
1109        dwPreferredProtocols: DWORD;
1110        dwActiveProtocol: DWORD;
1111        lpfnConnect: LPOCNCONNPROCW;
1112        lpfnCheck: LPOCNCHKPROC;
1113        lpfnDisconnect: LPOCNDSCPROC;
1114        hCardHandle: SCARDHANDLE;
1115     end;
1116     {$EXTERNALSYM OPENCARDNAMEW}
1117  
1118     {$IFDEF UNICODE}
1119        OPENCARDNAME = OPENCARDNAMEW;
1120        POPENCARDNAME = POPENCARDNAMEW;
1121        LPOPENCARDNAME = LPOPENCARDNAMEW;
1122     {$ELSE}
1123        OPENCARDNAME = OPENCARDNAMEA;
1124        POPENCARDNAME = POPENCARDNAMEA;
1125        LPOPENCARDNAME = LPOPENCARDNAMEA;
1126     {$ENDIF}
1127     {$EXTERNALSYM OPENCARDNAME}
1128     {$EXTERNALSYM POPENCARDNAME}
1129     {$EXTERNALSYM LPOPENCARDNAME}
1130  
1131  {$IFDEF WinSCard_DYNLINK}
1132  var
1133     SCardEstablishContext:          TSCardEstablishContext = nil;
1134     SCardReleaseContext:            TSCardReleaseContext = nil;
1135     SCardListReaderGroups:          TSCardListReaderGroups = nil;
1136     SCardListReaders:               TSCardListReaders = nil;
1137     SCardListCards:                 TSCardListCards = nil;
1138     SCardListInterfaces:            TSCardListInterfaces = nil;
1139     SCardGetProviderId:             TSCardGetProviderId = nil;
1140     SCardGetCardTypeProviderName:   TSCardGetCardTypeProviderName = nil;
1141     SCardIntroduceReaderGroup:      TSCardIntroduceReaderGroup = nil;
1142     SCardForgetReaderGroup:         TSCardForgetReaderGroup = nil;
1143     SCardIntroduceReader:           TSCardIntroduceReader = nil;
1144     SCardForgetReader:              TSCardForgetReader = nil;
1145     SCardAddReaderToGroup:          TSCardAddReaderToGroup = nil;
1146     SCardRemoveReaderFromGroup:     TSCardRemoveReaderFromGroup = nil;
1147     SCardIntroduceCardType:         TSCardIntroduceCardType = nil;
1148     SCardSetCardTypeProviderName:   TSCardSetCardTypeProviderName = nil;
1149     SCardForgetCardType:            TSCardForgetCardType = nil;
1150     SCardFreeMemory:                TSCardFreeMemory = nil;
1151     SCardLocateCards:               TSCardLocateCards = nil;
1152     SCardGetStatusChange:           TSCardGetStatusChange = nil;
1153     SCardCancel:                    TSCardCancel = nil;
1154     SCardConnect:                   TSCardConnect = nil;
1155     SCardReconnect:                 TSCardReconnect = nil;
1156     SCardDisconnect:                TSCardDisconnect = nil;
1157     SCardBeginTransaction:          TSCardBeginTransaction = nil;
1158     SCardEndTransaction:            TSCardEndTransaction = nil;
1159     SCardStatus:                    TSCardStatus = nil;
1160     SCardTransmit:                  TSCardTransmit = nil;
1161     SCardControl:                   TSCardControl = nil;
1162     SCardGetAttrib:                 TSCardGetAttrib = nil;
1163     SCardSetAttrib:                 TSCardSetAttrib = nil;
1164     SCardIsValidContext:            TSCardIsValidContext = nil;
1165     SCardLocateCardsByATR:          TSCardLocateCardsByATR = nil;
1166     SCardAccessStartedEvent:        TSCardAccessStartedEvent = nil;
1167     SCardReleaseStartedEvent:       TSCardReleaseStartedEvent = nil;
1168     bPCSCLoaded: Boolean; 
1169     hWinscardDLL: THandle;
1170  
1171     { load PC/SC DLL, pass variable for handle to unload DLL later }
1172     function PCSCLoadDLL: Boolean;
1173     {$EXTERNALSYM PCSCLoadDLL}
1174     procedure PCSCUnloadDLL;
1175     {$EXTERNALSYM PCSCUnloadDLL}
1176  {$ENDIF}
1177  
1178  implementation
1179  
1180  {$IFDEF WinSCard_DYNLINK}
1181  procedure PCSCUnloadDLL;
1182  begin
1183     if hWinscardDLL <> 0 then
1184        FreeLibrary(hWinscardDLL);
1185  end;
1186  
1187  function PCSCLoadDLL: Boolean;
1188  begin
1189  
1190     if hWinscardDLL = 0 then
1191        hWinscardDLL := LoadLibrary('winscard.dll');
1192  
1193     if hWinscardDLL = 0 then
1194     begin
1195        Result := False;
1196        Exit;
1197     end;
1198  
1199  (* WindowsXP winscard.dll
1200     8/23/2001   0:00          93,184  winscard.dll
1201     Exports from WinSCard.dll
1202     63 exported name(s), 63 export addresse(s).  Ordinal base is 1.
1203      Ord. Hint Name
1204      ---- ---- ----
1205         1 0000 ClassInstall32
1206         2 0001 SCardAccessNewReaderEvent *New
1207         5 0002 SCardAccessStartedEvent
1208         6 0003 SCardAddReaderToGroupA
1209         7 0004 SCardAddReaderToGroupW
1210         8 0005 SCardBeginTransaction
1211         9 0006 SCardCancel
1212        10 0007 SCardConnectA
1213        11 0008 SCardConnectW
1214        12 0009 SCardControl
1215        13 000A SCardDisconnect
1216        14 000B SCardEndTransaction
1217        15 000C SCardEstablishContext
1218        16 000D SCardForgetCardTypeA
1219        17 000E SCardForgetCardTypeW
1220        18 000F SCardForgetReaderA
1221        19 0010 SCardForgetReaderGroupA
1222        20 0011 SCardForgetReaderGroupW
1223        21 0012 SCardForgetReaderW
1224        22 0013 SCardFreeMemory
1225        23 0014 SCardGetAttrib
1226        24 0015 SCardGetCardTypeProviderNameA
1227        25 0016 SCardGetCardTypeProviderNameW
1228        26 0017 SCardGetProviderIdA
1229        27 0018 SCardGetProviderIdW
1230        28 0019 SCardGetStatusChangeA
1231        29 001A SCardGetStatusChangeW
1232        30 001B SCardIntroduceCardTypeA
1233        31 001C SCardIntroduceCardTypeW
1234        32 001D SCardIntroduceReaderA
1235        33 001E SCardIntroduceReaderGroupA
1236        34 001F SCardIntroduceReaderGroupW
1237        35 0020 SCardIntroduceReaderW
1238        36 0021 SCardIsValidContext
1239        37 0022 SCardListCardsA
1240        38 0023 SCardListCardsW
1241        39 0024 SCardListInterfacesA
1242        40 0025 SCardListInterfacesW
1243        41 0026 SCardListReaderGroupsA
1244        42 0027 SCardListReaderGroupsW
1245        43 0028 SCardListReadersA
1246        44 0029 SCardListReadersW
1247        45 002A SCardLocateCardsA
1248        46 002B SCardLocateCardsByATRA
1249        47 002C SCardLocateCardsByATRW
1250        48 002D SCardLocateCardsW
1251        49 002E SCardReconnect
1252         3 002F SCardReleaseAllEvents *New
1253        50 0030 SCardReleaseContext
1254         4 0031 SCardReleaseNewReaderEvent *New
1255        51 0032 SCardReleaseStartedEvent 
1256        52 0033 SCardRemoveReaderFromGroupA
1257        53 0034 SCardRemoveReaderFromGroupW
1258        54 0035 SCardSetAttrib
1259        55 0036 SCardSetCardTypeProviderNameA
1260        56 0037 SCardSetCardTypeProviderNameW
1261        57 0038 SCardState *New
1262        58 0039 SCardStatusA
1263        59 003A SCardStatusW
1264        60 003B SCardTransmit
1265        61 003C g_rgSCardRawPci
1266        62 003D g_rgSCardT0Pci
1267        63 003E g_rgSCardT1Pci
1268      *)
1269                         
1270     @SCardEstablishContext        := GetProcAddress(hWinscardDLL, 'SCardEstablishContext');
1271     @SCardReleaseContext          := GetProcAddress(hWinscardDLL, 'SCardReleaseContext');
1272     @SCardListReaderGroups        := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardListReaderGroupsW'{$ELSE}'SCardListReaderGroupsA'{$ENDIF});
1273     @SCardListReaders             := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardListReadersW'{$ELSE}'SCardListReadersA'{$ENDIF});
1274     @SCardListCards               := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardListCardsW'{$ELSE}'SCardListCardsA'{$ENDIF});
1275     @SCardListInterfaces          := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardListInterfacesW'{$ELSE}'SCardListInterfacesALib'{$ENDIF}); {SCardListInterfacesALib - alib?}
1276     @SCardGetProviderId           := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardGetProviderIdW'{$ELSE}'SCardGetProviderIdA'{$ENDIF});
1277     @SCardGetCardTypeProviderName := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardGetCardTypeProviderNameW'{$ELSE}'SCardGetCardTypeProviderNameA'{$ENDIF});
1278     @SCardIntroduceReaderGroup    := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardIntroduceReaderGroupW'{$ELSE}'SCardIntroduceReaderGroupA'{$ENDIF});
1279     @SCardForgetReaderGroup       := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardForgetReaderGroupW'{$ELSE}'SCardForgetReaderGroupA'{$ENDIF});
1280     @SCardIntroduceReader         := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardIntroduceReaderW'{$ELSE}'SCardIntroduceReaderA'{$ENDIF});
1281     @SCardForgetReader            := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardForgetReaderW'{$ELSE}'SCardForgetReaderA'{$ENDIF});
1282     @SCardAddReaderToGroup        := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardAddReaderToGroupW'{$ELSE}'SCardAddReaderToGroupA'{$ENDIF});
1283     @SCardRemoveReaderFromGroup   := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardRemoveReaderFromGroupW'{$ELSE}'SCardRemoveReaderFromGroupA'{$ENDIF});
1284     @SCardIntroduceCardType       := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardIntroduceCardTypeW'{$ELSE}'SCardIntroduceCardTypeA'{$ENDIF});
1285     @SCardSetCardTypeProviderName := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardSetCardTypeProviderNameW'{$ELSE}'SCardSetCardTypeProviderNameA'{$ENDIF});
1286     @SCardForgetCardType          := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardForgetCardTypeW'{$ELSE}'SCardForgetCardTypeA'{$ENDIF});
1287     @SCardFreeMemory              := GetProcAddress(hWinscardDLL, 'SCardFreeMemory');
1288     @SCardLocateCards             := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardLocateCardsW'{$ELSE}'SCardLocateCardsA'{$ENDIF});
1289     @SCardGetStatusChange         := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardGetStatusChangeW'{$ELSE}'SCardGetStatusChangeA'{$ENDIF});
1290     @SCardCancel                  := GetProcAddress(hWinscardDLL, 'SCardCancel');
1291     @SCardConnect                 := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardConnectW'{$ELSE}'SCardConnectA'{$ENDIF});
1292     @SCardReconnect               := GetProcAddress(hWinscardDLL, 'SCardReconnect');
1293     @SCardDisconnect              := GetProcAddress(hWinscardDLL, 'SCardDisconnect');
1294     @SCardBeginTransaction        := GetProcAddress(hWinscardDLL, 'SCardBeginTransaction');
1295     @SCardEndTransaction          := GetProcAddress(hWinscardDLL, 'SCardEndTransaction');
1296     @SCardStatus                  := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardStatusW'{$ELSE}'SCardStatusA'{$ENDIF});
1297     @SCardTransmit                := GetProcAddress(hWinscardDLL, 'SCardTransmit');
1298     @SCardControl                 := GetProcAddress(hWinscardDLL, 'SCardControl');
1299     @SCardGetAttrib               := GetProcAddress(hWinscardDLL, 'SCardGetAttrib');
1300     @SCardSetAttrib               := GetProcAddress(hWinscardDLL, 'SCardSetAttrib');
1301     @SCardIsValidContext          := GetProcAddress(hWinscardDLL, 'SCardIsValidContext');
1302     @SCardLocateCardsByATR        := GetProcAddress(hWinscardDLL, {$IFDEF UNICODE}'SCardLocateCardsByATRW'{$ELSE}'SCardLocateCardsByATRA'{$ENDIF});
1303     @SCardAccessStartedEvent      := GetProcAddress(hWinscardDLL, 'SCardAccessStartedEvent');
1304     @SCardReleaseStartedEvent     := GetProcAddress(hWinscardDLL, 'SCardReleaseStartedEvent');
1305  
1306     Result := True;
1307  
1308  end;
1309  {$ELSE}
1310  const
1311     WinSCardDLL = 'winscard.dll';
1312  
1313     function SCardEstablishContext;           external WinSCardDLL name 'SCardEstablishContext';
1314     function SCardReleaseContext;             external WinSCardDLL name 'SCardReleaseContext';
1315     function SCardListReaderGroupsW;          external WinSCardDLL name 'SCardListReaderGroupsW';
1316     function SCardListReaderGroupsA;          external WinSCardDLL name 'SCardListReaderGroupsA';
1317     function SCardListReadersW;               external WinSCardDLL name 'SCardListReadersW';
1318     function SCardListReadersA;               external WinSCardDLL name 'SCardListReadersA';
1319     function SCardListCardsW;                 external WinSCardDLL name 'SCardListCardsW';
1320     function SCardListCardsA;                 external WinSCardDLL name 'SCardListCardsA';
1321     function SCardListInterfacesW;            external WinSCardDLL name 'SCardListInterfacesW';
1322     function SCardListInterfacesA;            external WinSCardDLL name 'SCardListInterfacesA';
1323     function SCardGetProviderIdW;             external WinSCardDLL name 'SCardGetProviderIdW';
1324     function SCardGetProviderIdA;             external WinSCardDLL name 'SCardGetProviderIdA';
1325     function SCardGetCardTypeProviderNameW;   external WinSCardDLL name 'SCardGetCardTypeProviderNameW';
1326     function SCardGetCardTypeProviderNameA;   external WinSCardDLL name 'SCardGetCardTypeProviderNameA';
1327     function SCardIntroduceReaderGroupW;      external WinSCardDLL name 'SCardIntroduceReaderGroupW';
1328     function SCardIntroduceReaderGroupA;      external WinSCardDLL name 'SCardIntroduceReaderGroupA';
1329     function SCardForgetReaderGroupW;         external WinSCardDLL name 'SCardForgetReaderGroupW';
1330     function SCardForgetReaderGroupA;         external WinSCardDLL name 'SCardForgetReaderGroupA';
1331     function SCardIntroduceReaderW;           external WinSCardDLL name 'SCardIntroduceReaderW';
1332     function SCardIntroduceReaderA;           external WinSCardDLL name 'SCardIntroduceReaderA';
1333     function SCardForgetReaderW;              external WinSCardDLL name 'SCardForgetReaderW';
1334     function SCardForgetReaderA;              external WinSCardDLL name 'SCardForgetReaderA';
1335     function SCardAddReaderToGroupW;          external WinSCardDLL name 'SCardAddReaderToGroupW';
1336     function SCardAddReaderToGroupA;          external WinSCardDLL name 'SCardAddReaderToGroupA';
1337     function SCardRemoveReaderFromGroupW;     external WinSCardDLL name 'SCardRemoveReaderFromGroupW';
1338     function SCardRemoveReaderFromGroupA;     external WinSCardDLL name 'SCardRemoveReaderFromGroupA';
1339     function SCardIntroduceCardTypeW;         external WinSCardDLL name 'SCardIntroduceCardTypeW';
1340     function SCardIntroduceCardTypeA;         external WinSCardDLL name 'SCardIntroduceCardTypeA';
1341     function SCardSetCardTypeProviderNameW;   external WinSCardDLL name 'SCardSetCardTypeProviderNameW';
1342     function SCardSetCardTypeProviderNameA;   external WinSCardDLL name 'SCardSetCardTypeProviderNameA';
1343     function SCardForgetCardTypeW;            external WinSCardDLL name 'SCardForgetCardTypeW';
1344     function SCardForgetCardTypeA;            external WinSCardDLL name 'SCardForgetCardTypeA';
1345     function SCardFreeMemory;                 external WinSCardDLL name 'SCardFreeMemory';
1346     function SCardLocateCardsW;               external WinSCardDLL name 'SCardLocateCardsW';
1347     function SCardLocateCardsA;               external WinSCardDLL name 'SCardLocateCardsA';
1348     function SCardGetStatusChangeW;           external WinSCardDLL name 'SCardGetStatusChangeW';
1349     function SCardGetStatusChangeA;           external WinSCardDLL name 'SCardGetStatusChangeA';
1350     function SCardCancel;                     external WinSCardDLL name 'SCardCancel';
1351     function SCardConnectW;                   external WinSCardDLL name 'SCardConnectW';
1352     function SCardConnectA;                   external WinSCardDLL name 'SCardConnectA';
1353     function SCardReconnect;                  external WinSCardDLL name 'SCardReconnect';
1354     function SCardDisconnect;                 external WinSCardDLL name 'SCardDisconnect';
1355     function SCardBeginTransaction;           external WinSCardDLL name 'SCardBeginTransaction';
1356     function SCardEndTransaction;             external WinSCardDLL name 'SCardEndTransaction';
1357     function SCardStatusW;                    external WinSCardDLL name 'SCardStatusW';
1358     function SCardStatusA;                    external WinSCardDLL name 'SCardStatusA';
1359     function SCardTransmit;                   external WinSCardDLL name 'SCardTransmit';
1360     function SCardControl;                    external WinSCardDLL name 'SCardControl';
1361     function SCardGetAttrib;                  external WinSCardDLL name 'SCardGetAttrib';
1362     function SCardSetAttrib;                  external WinSCardDLL name 'SCardSetAttrib';
1363     function SCardIsValidContext;             external WinSCardDLL name 'SCardIsValidContext';
1364     function SCardLocateCardsByATRW;          external WinSCardDLL name 'SCardLocateCardsByATRW';
1365     function SCardLocateCardsByATRA;          external WinSCardDLL name 'SCardLocateCardsByATRA';
1366     function SCardAccessStartedEvent;         external WinSCardDLL name 'SCardAccessStartedEvent';
1367     function SCardReleaseStartedEvent;        external WinSCardDLL name 'SCardReleaseStartedEvent';
1368  {$ENDIF}
1369  
1370  {$IFDEF WinSCard_DYNLINK}
1371  initialization
1372     bPCSCLoaded := PCSCLoadDLL;
1373  
1374  finalization
1375     PCSCUnloadDll;
1376  {$ENDIF}
1377  
1378  end.

Module Calls (2 levels)

-

Module Called-By (2 levels)


       WinSCard
      XuDsigS┘ 
    uOrders┤   
     fFrame┤   
fOrdersSign┤   
    fReview┘