-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathWinSCard.pas
More file actions
1404 lines (1243 loc) · 65.4 KB
/
WinSCard.pas
File metadata and controls
1404 lines (1243 loc) · 65.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{******************************************************************}
{ }
{ 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. }
{ }
{******************************************************************}
unit WinSCard;
interface
uses
Windows;
{$IFDEF WinSCard_LINKONREQUEST}
{$DEFINE WinSCard_DYNLINK}
{$ENDIF}
type
LPCGUID = ^GUID;
{$EXTERNALSYM LPCGUID}
GUID = record
Data1: LongInt;
Data2: Integer;
Data3: Integer;
Data4: array[0..7] of Byte;
end;
{$EXTERNALSYM GUID}
(*
Copyright (c) 1996 Microsoft Corporation
Module Name:
WinSCard
Abstract:
This header file provides the definitions and symbols necessary for an
Application or Smart Card Service Provider to access the Smartcard
Subsystem.
Environment:
Win32
Notes:
*)
var
LPCBYTE: PUChar;
{$EXTERNALSYM LPCBYTE}
LPCVOID: Pointer; { VOID *LPCVOID; }
{$EXTERNALSYM LPCVOID}
type
PSCARD_IO_REQUEST = ^SCARD_IO_REQUEST;
{$EXTERNALSYM PSCARD_IO_REQUEST}
SCARD_IO_REQUEST = record
dwProtocol: DWORD; { Protocol identifier }
dbPciLength: DWORD; { Protocol Control Information Length }
end;
{$EXTERNALSYM SCARD_IO_REQUEST}
//
////////////////////////////////////////////////////////////////////////////////
//
// Service Manager Access Services
//
// The following services are used to manage user and terminal contexts for
// Smart Cards.
//
type
SCARDCONTEXT = DWORD;
{$EXTERNALSYM SCARDCONTEXT}
SCARDHANDLE = DWORD;
{$EXTERNALSYM SCARDHANDLE}
var
PSCARDCONTEXT, LPSCARDCONTEXT: ^SCARDCONTEXT; { SCARDCONTEXT * }
{$EXTERNALSYM PSCARDCONTEXT}
{$EXTERNALSYM LPSCARDCONTEXT}
PSCARDHANDLE, LPSCARDHANDLE: ^SCARDHANDLE; { SCARDHANDLE * }
{$EXTERNALSYM PSCARDHANDLE}
{$EXTERNALSYM LPSCARDHANDLE}
const
SCARD_AUTOALLOCATE = DWORD(-1);
{$EXTERNALSYM SCARD_AUTOALLOCATE}
SCARD_SCOPE_USER = 0; // The context is a user context, and any
{$EXTERNALSYM SCARD_SCOPE_USER} // database operations are performed within the
// domain of the user.
SCARD_SCOPE_TERMINAL = 1; // The context is that of the current terminal,
{$EXTERNALSYM SCARD_SCOPE_TERMINAL} // and any database operations are performed
// within the domain of that terminal. (The
// calling application must have appropriate
// access permissions for any database actions.)
SCARD_SCOPE_SYSTEM = 2; // The context is the system context, and any
{$EXTERNALSYM SCARD_SCOPE_SYSTEM} // database operations are performed within the
// domain of the system. (The calling
// application must have appropriate access
// permissions for any database actions.)
{$IFDEF WinSCard_DYNLINK}
type
TSCardEstablishContext = function (dwScope: DWORD; pvReserved1: Pointer; pvReserved2: Pointer;
phContext: Pointer): LongInt; stdcall;
TSCardReleaseContext = function (hContext: LongInt): LongInt; stdcall;
TSCardIsValidContext = function (hContext: LongInt): LongInt; stdcall;
{$ELSE}
function SCardEstablishContext(dwScope: DWORD; pvReserved1: Pointer; pvReserved2: Pointer;
phContext: Pointer): LongInt; stdcall;
{$EXTERNALSYM SCardEstablishContext}
function SCardReleaseContext(hContext: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardReleaseContext}
function SCardIsValidContext(hContext: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardIsValidContext}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Smart Card Database Management Services
//
// The following services provide for managing the Smart Card Database.
//
const
SCARD_ALL_READERS = 'SCard$AllReaders' + Chr(0) + Chr(0);
{$EXTERNALSYM SCARD_ALL_READERS}
SCARD_DEFAULT_READERS = 'SCard$DefaultReaders' + Chr(0) + Chr(0);
{$EXTERNALSYM SCARD_DEFAULT_READERS}
SCARD_LOCAL_READERS = 'SCard$LocalReaders' + Chr(0) + Chr(0);
{$EXTERNALSYM SCARD_LOCAL_READERS}
SCARD_SYSTEM_READERS = 'SCard$SystemReaders' + Chr(0) + Chr(0);
{$EXTERNALSYM SCARD_SYSTEM_READERS}
SCARD_PROVIDER_PRIMARY = 1; // Primary Provider Id
{$EXTERNALSYM SCARD_PROVIDER_PRIMARY}
SCARD_PROVIDER_CSP = 2; // Crypto Service Provider Id
{$EXTERNALSYM SCARD_PROVIDER_CSP}
//
// Database Reader routines
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardListReaderGroupsA = function (hContext: LongInt; mszGroups: LPStr; var pcchGroups: LongInt): LongInt; stdcall;
TSCardListReaderGroupsW = function (hContext: LongInt; mszGroups: LPWStr; var pcchGroups: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardListReaderGroups = TSCardListReaderGroupsW;
{$ELSE}
TSCardListReaderGroups = TSCardListReaderGroupsA;
{$ENDIF}
TSCardListReadersA = function (SCARDCONTEXT: LongInt; mszGroups: LPStr; mszReaders: LPStr;
var pcchReaders: LongInt): LongInt; stdcall;
TSCardListReadersW = function (SCARDCONTEXT: LongInt; mszGroups: LPWStr; mszReaders: LPWStr;
var pcchReaders: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardListReaders = TSCardListReadersW;
{$ELSE}
TSCardListReaders = TSCardListReadersA;
{$ENDIF}
TSCardListCardsA = function (hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
cguidInterfaceCount: LongInt; mszCards: LPStr; var pcchCards: LongInt): LongInt; stdcall;
TSCardListCardsW = function (hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
cguidInterfaceCount: LongInt; mszCards: LPWStr; var pcchCards: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardListCards = TSCardListCardsW;
{$ELSE}
TSCardListCards = TSCardListCardsA;
{$ENDIF}
{$ELSE}
function SCardListReaderGroupsA(hContext: LongInt; mszGroups: LPStr; var pcchGroups: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListReaderGroupsA}
function SCardListReaderGroupsW(hContext: LongInt; mszGroups: LPWStr; var pcchGroups: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListReaderGroupsW}
function SCardListReadersA(SCARDCONTEXT: LongInt; mszGroups: LPStr; mszReaders: LPStr;
var pcchReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListReadersA}
function SCardListReadersW(SCARDCONTEXT: LongInt; mszGroups: LPWStr; mszReaders: LPWStr;
var pcchReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListReadersW}
function SCardListCardsA(hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
cguidInterfaceCount: LongInt; mszCards: LPStr; var pcchCards: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListCardsA}
function SCardListCardsW(hContext: LongInt; var pbAtr: Byte; var rgguidInterfaces: GUID;
cguidInterfaceCount: LongInt; mszCards: LPWStr; var pcchCards: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListCardsW}
{$ENDIF}
//
// NOTE: The routine SCardListCards name differs from the PC/SC definition.
// It should be:
//
// extern WINSCARDAPI LONG WINAPI
// SCardListCardTypes(
// IN SCARDCONTEXT hContext,
// IN LPCBYTE pbAtr,
// IN LPCGUID rgquidInterfaces,
// IN DWORD cguidInterfaceCount,
// OUT LPTSTR mszCards,
// IN OUT LPDWORD pcchCards);
//
// Here's a work-around MACRO:
//#define SCardListCardTypes SCardListCards
{$IFDEF WinSCard_DYNLINK}
type
TSCardListCardTypes = TSCardListCardsA;
TSCardListInterfacesA = function (hContext: LongInt; szCard: LPStr; var pguidInterfaces: GUID;
var pcguidInterfaces: LongInt): LongInt; stdcall;
TSCardListInterfacesW = function (hContext: LongInt; szCard: LPWStr; var pguidInterfaces: GUID;
var pcguidInterfaces: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardListInterfaces = TSCardListInterfacesW;
{$ELSE}
TSCardListInterfaces = TSCardListInterfacesA;
{$ENDIF}
TSCardGetProviderIdA = function (hContext: LongInt; szCard: LPStr; var pguidProviderId: GUID): LongInt; stdcall;
TSCardGetProviderIdW = function (hContext: LongInt; szCard: LPWStr; var pguidProviderId: GUID): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardGetProviderId = TSCardGetProviderIdW;
{$ELSE}
TSCardGetProviderId = TSCardGetProviderIdA;
{$ENDIF}
{$ELSE}
function SCardListInterfacesA(hContext: LongInt; szCard: LPStr; var pguidInterfaces: GUID;
var pcguidInterfaces: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListInterfacesA}
function SCardListInterfacesW(hContext: LongInt; szCard: LPWStr; var pguidInterfaces: GUID;
var pcguidInterfaces: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardListInterfacesW}
function SCardGetProviderIdA(hContext: LongInt; szCard: LPStr; var pguidProviderId: GUID): LongInt; stdcall;
{$EXTERNALSYM SCardGetProviderIdA}
function SCardGetProviderIdW(hContext: LongInt; szCard: LPWStr; var pguidProviderId: GUID): LongInt; stdcall;
{$EXTERNALSYM SCardGetProviderIdW}
{$ENDIF}
//
// NOTE: The routine SCardGetProviderId in this implementation uses GUIDs.
// The PC/SC definition uses BYTEs.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardGetCardTypeProviderNameA = function (hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
szProvider: LPStr; var pcchProvider: LongInt): LongInt; stdcall;
TSCardGetCardTypeProviderNameW = function (hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
szProvider: LPWStr; var pcchProvider: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardGetCardTypeProviderName = TSCardGetCardTypeProviderNameW;
{$ELSE}
TSCardGetCardTypeProviderName = TSCardGetCardTypeProviderNameA;
{$ENDIF}
{$ELSE}
function SCardGetCardTypeProviderNameA(hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
szProvider: LPStr; var pcchProvider: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardGetCardTypeProviderNameA}
function SCardGetCardTypeProviderNameW(hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
szProvider: LPWStr; var pcchProvider: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardGetCardTypeProviderNameW}
{$ENDIF}
//
// NOTE: This routine is an extension to the PC/SC definitions.
//
//
// Database Writer routines
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardIntroduceReaderGroupA = function (hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
TSCardIntroduceReaderGroupW = function (hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardIntroduceReaderGroup = TSCardIntroduceReaderGroupW;
{$ELSE}
TSCardIntroduceReaderGroup = TSCardIntroduceReaderGroupA;
{$ENDIF}
TSCardForgetReaderGroupA = function (hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
TSCardForgetReaderGroupW = function (hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardForgetReaderGroup = TSCardForgetReaderGroupW;
{$ELSE}
TSCardForgetReaderGroup = TSCardForgetReaderGroupA;
{$ENDIF}
TSCardIntroduceReaderA = function (hContext: LongInt; szReadeName: LPStr; szDeviceName: LPStr): LongInt; stdcall;
TSCardIntroduceReaderW = function (hContext: LongInt; szReadeName: LPWStr; szDeviceName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardIntroduceReader = TSCardIntroduceReaderW;
{$ELSE}
TSCardIntroduceReader = TSCardIntroduceReaderA;
{$ENDIF}
TSCardForgetReaderA = function (hContext: LongInt; szReaderName: LPStr): LongInt; stdcall;
TSCardForgetReaderW = function (hContext: LongInt; szReaderName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardForgetReader = TSCardForgetReaderW;
{$ELSE}
TSCardForgetReader = TSCardForgetReaderA;
{$ENDIF}
TSCardAddReaderToGroupA = function (hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
TSCardAddReaderToGroupW = function (hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardAddReaderToGroup = TSCardAddReaderToGroupW;
{$ELSE}
TSCardAddReaderToGroup = TSCardAddReaderToGroupA;
{$ENDIF}
TSCardRemoveReaderFromGroupA = function (hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
TSCardRemoveReaderFromGroupW = function (hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardRemoveReaderFromGroup = TSCardRemoveReaderFromGroupW;
{$ELSE}
TSCardRemoveReaderFromGroup = TSCardRemoveReaderFromGroupA;
{$ENDIF}
TSCardIntroduceCardTypeA = function (hContext: LongInt; szCardName: LPStr; var pguidPrimaryProvider: GUID;
var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPStr;
pbAtrMask: LPStr; cbAtrLen: LongInt): LongInt; stdcall;
TSCardIntroduceCardTypeW = function (hContext: LongInt; szCardName: LPWStr; var pguidPrimaryProvider: GUID;
var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPWStr;
pbAtrMask: LPWStr; cbAtrLen: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardIntroduceCardType = TSCardIntroduceCardTypeW;
{$ELSE}
TSCardIntroduceCardType = TSCardIntroduceCardTypeA;
{$ENDIF}
TSCardSetCardTypeProviderNameA = function (hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
szProvider: LPStr): LongInt; stdcall;
TSCardSetCardTypeProviderNameW = function (hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
szProvider: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardSetCardTypeProviderName = TSCardSetCardTypeProviderNameW;
{$ELSE}
TSCardSetCardTypeProviderName = TSCardSetCardTypeProviderNameA;
{$ENDIF}
{$ELSE}
function SCardIntroduceReaderGroupA(hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardIntroduceReaderGroupA}
function SCardIntroduceReaderGroupW(hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardIntroduceReaderGroupW}
function SCardForgetReaderGroupA(hContext: LongInt; szGroupName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardForgetReaderGroupA}
function SCardForgetReaderGroupW(hContext: LongInt; szGroupName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardForgetReaderGroupW}
function SCardIntroduceReaderA(hContext: LongInt; szReadeName: LPStr; szDeviceName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardIntroduceReaderA}
function SCardIntroduceReaderW(hContext: LongInt; szReadeName: LPWStr; szDeviceName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardIntroduceReaderW}
function SCardForgetReaderA(hContext: LongInt; szReaderName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardForgetReaderA}
function SCardForgetReaderW(hContext: LongInt; szReaderName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardForgetReaderW}
function SCardAddReaderToGroupA(hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardAddReaderToGroupA}
function SCardAddReaderToGroupW(hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardAddReaderToGroupW}
function SCardRemoveReaderFromGroupA(hContext: LongInt; szReaderName: LPStr; szGroupName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardRemoveReaderFromGroupA}
function SCardRemoveReaderFromGroupW(hContext: LongInt; szReaderName: LPWStr; szGroupName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardRemoveReaderFromGroupW}
function SCardIntroduceCardTypeA(hContext: LongInt; szCardName: LPStr; var pguidPrimaryProvider: GUID;
var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPStr;
pbAtrMask: LPStr; cbAtrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardIntroduceCardTypeA}
function SCardIntroduceCardTypeW(hContext: LongInt; szCardName: LPWStr; var pguidPrimaryProvider: GUID;
var pguidInterfaces: GUID; dwInterfaceCount: LongInt; pbAtr: LPWStr;
pbAtrMask: LPWStr; cbAtrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardIntroduceCardTypeW}
function SCardSetCardTypeProviderNameA(hContext: LongInt; szCardName: LPStr; dwProviderId: LongInt;
szProvider: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardSetCardTypeProviderNameA}
function SCardSetCardTypeProviderNameW(hContext: LongInt; szCardName: LPWStr; dwProviderId: LongInt;
szProvider: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardSetCardTypeProviderNameW}
{$ENDIF}
//
// NOTE: This routine is an extention to the PC/SC specifications.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardForgetCardTypeA = function (hContext: LongInt; szCardName: LPStr): LongInt; stdcall;
TSCardForgetCardTypeW = function (hContext: LongInt; szCardName: LPWStr): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardForgetCardType = TSCardForgetCardTypeW;
{$ELSE}
TSCardForgetCardType = TSCardForgetCardTypeA;
{$ENDIF}
{$ELSE}
function SCardForgetCardTypeA(hContext: LongInt; szCardName: LPStr): LongInt; stdcall;
{$EXTERNALSYM SCardForgetCardTypeA}
function SCardForgetCardTypeW(hContext: LongInt; szCardName: LPWStr): LongInt; stdcall;
{$EXTERNALSYM SCardForgetCardTypeW}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Service Manager Support Routines
//
// The following services are supplied to simplify the use of the Service
// Manager API.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardFreeMemory = function (hContext: LongInt; pvMem: LongInt): LongInt; stdcall;
TSCardAccessStartedEvent = function: LongInt; stdcall;
TSCardReleaseStartedEvent = function: LongInt; stdcall;
{$ELSE}
function SCardFreeMemory(hContext: LongInt; pvMem: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardFreeMemory}
function SCardAccessStartedEvent: LongInt; stdcall;
{$EXTERNALSYM SCardAccessStartedEvent}
function SCardReleaseStartedEvent: LongInt; stdcall;
{$EXTERNALSYM SCardReleaseStartedEvent}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Reader Services
//
// The following services supply means for tracking cards within readers.
//
type
LPSCARD_READERSTATEA = ^SCARD_READERSTATEA;
{$EXTERNALSYM LPSCARD_READERSTATEA}
PSCARD_READERSTATEA = ^SCARD_READERSTATEA;
{$EXTERNALSYM PSCARD_READERSTATEA}
SCARD_READERSTATEA = record
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
szReader: LPCSTR; { the reader name from SCardListReaders }
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
pvUserData: Pointer; { user defined data }
dwCurrentState: LongInt; { current state of reader at time of call }
dwEventState: LongInt; { state of reader after state change }
cbAtr: LongInt; { Number of bytes in the returned ATR }
rgbAtr: array[0..35] of Byte; { Atr of inserted card, (extra alignment bytes) }
end;
{$EXTERNALSYM SCARD_READERSTATEA}
LPSCARD_READERSTATEW = ^SCARD_READERSTATEW;
{$EXTERNALSYM LPSCARD_READERSTATEW}
PSCARD_READERSTATEW = ^SCARD_READERSTATEW;
{$EXTERNALSYM PSCARD_READERSTATEW}
SCARD_READERSTATEW = record
szReader: LPCWStr; { reader name }
pvUserData: Pointer; { user defined data }
dwCurrentState: LongInt; { current state of reader at time of call }
dwEventState: LongInt; { state of reader after state change }
cbAtr: LongInt; { Number of bytes in the returned ATR }
rgbAtr: array[0..35] of Byte; { Atr of inserted card, (extra alignment bytes) }
end;
{$EXTERNALSYM SCARD_READERSTATEW}
{$IFDEF UNICODE}
SCARD_READERSTATE = SCARD_READERSTATEW;
PSCARD_READERSTATE = PSCARD_READERSTATEW;
LPSCARD_READERSTATE = LPSCARD_READERSTATEW;
{$ELSE}
SCARD_READERSTATE = SCARD_READERSTATEA;
PSCARD_READERSTATE = PSCARD_READERSTATEA;
LPSCARD_READERSTATE = LPSCARD_READERSTATEA;
{$ENDIF}
{$EXTERNALSYM SCARD_READERSTATE}
{$EXTERNALSYM PSCARD_READERSTATE}
{$EXTERNALSYM LPSCARD_READERSTATE}
const
SCARD_STATE_UNAWARE = $0; // The application is unaware of the
{$EXTERNALSYM SCARD_STATE_UNAWARE} // 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.
SCARD_STATE_IGNORE = $1; // The application requested that
{$EXTERNALSYM SCARD_STATE_IGNORE} // this reader be ignored. No other
// bits will be set.
SCARD_STATE_CHANGED = $2; // This implies that there is a
{$EXTERNALSYM SCARD_STATE_CHANGED} // 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.
SCARD_STATE_UNKNOWN = $4; // This implies that the given
{$EXTERNALSYM SCARD_STATE_UNKNOWN} // 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.
SCARD_STATE_UNAVAILABLE = $8; // This implies that the actual
{$EXTERNALSYM SCARD_STATE_UNAVAILABLE} // state of this reader is not
// available. If this bit is set,
// then all the following bits are
// clear.
SCARD_STATE_EMPTY = $10; // This implies that there is not
{$EXTERNALSYM SCARD_STATE_EMPTY} // card in the reader. If this bit
// is set, all the following bits
// will be clear.
SCARD_STATE_PRESENT = $20; // This implies that there is a card
{$EXTERNALSYM SCARD_STATE_PRESENT} // in the reader.
SCARD_STATE_ATRMATCH = $40; // This implies that there is a card
{$EXTERNALSYM SCARD_STATE_ATRMATCH} // 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.
SCARD_STATE_EXCLUSIVE = $80; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_EXCLUSIVE} // reader is allocated for exclusive
// use by another application. If
// this bit is set,
// SCARD_STATE_PRESENT will also be
// set.
SCARD_STATE_INUSE = $100; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_INUSE} // 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.
SCARD_STATE_MUTE = $200; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_MUTE} // reader is unresponsive or not
// supported by the reader or
// software.
SCARD_STATE_UNPOWERED = $400; // This implies that the card in the
{$EXTERNALSYM SCARD_STATE_UNPOWERED} // reader has not been powered up.
{$IFDEF WinSCard_DYNLINK}
type
TSCardLocateCardsA = function (hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
TSCardLocateCardsW = function (hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardLocateCards = TSCardLocateCardsW;
{$ELSE}
TSCardLocateCards = TSCardLocateCardsA;
{$ENDIF}
{$ELSE}
function SCardLocateCardsA(hContext: LongInt; mszCards: LPStr; var rgReaderStates: PSCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsA}
function SCardLocateCardsW(hContext: LongInt; mszCards: LPWStr; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsW}
{$ENDIF}
type
PSCARD_ATRMASK = ^SCARD_ATRMASK;
{$EXTERNALSYM PSCARD_ATRMASK}
LPSCARD_ATRMASK = ^SCARD_ATRMASK;
{$EXTERNALSYM LPSCARD_ATRMASK}
SCARD_ATRMASK = record
cbArt: DWORD; // Number of bytes in the ATR and the mask.
rgbAtr: array[0..35] of Byte; // Atr of card (extra alignment bytes)
rgbMask: array[0..35] of Byte; // Mask for the Atr (extra alignment bytes)
end;
{$EXTERNALSYM SCARD_ATRMASK}
{$IFDEF WinSCard_DYNLINK}
type
TSCardLocateCardsByATRA = function (hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall;
TSCardLocateCardsByATRW = function (hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardLocateCardsByATR = TSCardLocateCardsByATRW;
{$ELSE}
TSCardLocateCardsByATR = TSCardLocateCardsByATRA;
{$ENDIF}
TSCardGetStatusChangeA = function (hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
TSCardGetStatusChangeW = function (hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardGetStatusChange = TSCardGetStatusChangeW;
{$ELSE}
TSCardGetStatusChange = TSCardGetStatusChangeA;
{$ENDIF}
TSCardCancel = function (hContext: LongInt): LongInt; stdcall;
{$ELSE}
function SCardLocateCardsByATRA(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEA; cReaders: DWORD): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsByATRA}
function SCardLocateCardsByATRW(hContext: LongInt; rgAtrMasks: LPSCARD_ATRMASK; cAtrs: DWORD;
var rgReaderStates: SCARD_READERSTATEW; cReaders: DWORD): LongInt; stdcall;
{$EXTERNALSYM SCardLocateCardsByATRW}
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
function SCardGetStatusChangeA( hContext: SCARDCONTEXT;
dwTimeout: LongInt;
var rgReaderStates: array of SCARD_READERSTATEA;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardGetStatusChangeA}
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
function SCardGetStatusChangeW(hContext: LongInt; dwTimeout: LongInt; var rgReaderStates: PSCARD_READERSTATEW;
cReaders: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardGetStatusChangeW}
function SCardCancel (hContext: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardCancel}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Card/Reader Communication Services
//
// The following services provide means for communication with the card.
//
const
SCARD_SHARE_EXCLUSIVE = 1; // This application is not willing to share this
{$EXTERNALSYM SCARD_SHARE_EXCLUSIVE} // card with other applications.
SCARD_SHARE_SHARED = 2; // This application is willing to share this
{$EXTERNALSYM SCARD_SHARE_SHARED} // card with other applications.
SCARD_SHARE_DIRECT = 3; // This application demands direct control of
{$EXTERNALSYM SCARD_SHARE_DIRECT} // the reader, so it is not available to other
// applications.
SCARD_LEAVE_CARD = 0; // Don't do anything special on close
{$EXTERNALSYM SCARD_LEAVE_CARD}
SCARD_RESET_CARD = 1; // Reset the card on close
{$EXTERNALSYM SCARD_RESET_CARD}
SCARD_UNPOWER_CARD = 2; // Power down the card on close
{$EXTERNALSYM SCARD_UNPOWER_CARD}
SCARD_EJECT_CARD = 3; // Eject the card on close
{$EXTERNALSYM SCARD_EJECT_CARD}
{$IFDEF WinSCard_DYNLINK}
type
TSCardConnectA = function (hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
TSCardConnectW = function (hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardConnect = TSCardConnectW;
{$ELSE}
TSCardConnect = TSCardConnectA;
{$ENDIF}
TSCardReconnect = function (hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall;
TSCardDisconnect = function (hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
TSCardBeginTransaction = function (hCard: LongInt): LongInt; stdcall;
TSCardEndTransaction = function (hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
{$ELSE}
function SCardConnectA(hContext: LongInt; szReader: LPStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
{$EXTERNALSYM SCardConnectA}
function SCardConnectW(hContext: LongInt; szReader: LPWStr; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
var phCard: LongInt; pdwActiveProtocol: PDword): LongInt; stdcall;
{$EXTERNALSYM SCardConnectW}
function SCardReconnect(hCard: LongInt; dwShareMode: LongInt; dwPreferredProtocols: LongInt;
dwInitialization: LongInt; var pdwActiveProtocol: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardReconnect}
function SCardDisconnect(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardDisconnect}
function SCardBeginTransaction(hCard: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardBeginTransaction}
function SCardEndTransaction(hCard: LongInt; dwDisposition: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardEndTransaction}
{$ENDIF}
//
// NOTE: This call corresponds to the PC/SC SCARDCOMM::Cancel routine,
// terminating a blocked SCardBeginTransaction service.
//
//
// NOTE: SCardState is an obsolete routine. PC/SC has replaced it with
// SCardStatus.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardStatusA = function (hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
TSCardStatusW = function (hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
{$IFDEF UNICODE}
TSCardStatus = TSCardStatusW;
{$ELSE}
TSCardStatus = TSCardStatusA;
{$ENDIF}
TSCardTransmit = function (hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte;
dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte;
pcbRecvLength: PDWord): LongInt; stdcall;
{$ELSE}
function SCardStatusA(hCard: LongInt; mszReaderNames: LPStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardStatusA}
function SCardStatusW(hCard: LongInt; mszReaderNames: LPWStr; var pcchReaderLen: LongInt; var pdwState: LongInt;
pdwProtocol: PDWord; pbAtr: PByte; var pcbAtrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardStatusW}
function SCardTransmit(hCard: LongInt; pioSendPci: Pointer; pbSendBuffer: PByte;
dwSendLength: DWORD; pioRecvPci: Pointer; pbRecvBuffer: PByte;
pcbRecvLength: PDWord): LongInt; stdcall;
{$EXTERNALSYM SCardTransmit}
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Reader Control Routines
//
// The following services provide for direct, low-level manipulation of the
// reader by the calling application allowing it control over the
// attributes of the communications with the card.
//
{$IFDEF WinSCard_DYNLINK}
type
TSCardControl = function (hCard: LongInt; dwControlCode: LongInt; var pvInBuffer: PByte; cbInBufferSize: LongInt;
var pvOutBuffer: PByte; cbOutBufferSize: LongInt;
var pcbBytesReturned: LongInt): LongInt; stdcall;
TSCardGetAttrib = function (hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; var pcbAttrLen: LongInt): LongInt; stdcall;
{$ELSE}
function SCardControl(hCard: LongInt; dwControlCode: LongInt; var pvInBuffer: PByte; cbInBufferSize: LongInt;
var pvOutBuffer: PByte; cbOutBufferSize: LongInt;
var pcbBytesReturned: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardControl}
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
function SCardGetAttrib(hCard: LongInt; dwAttrId: LongInt; pbAttr: PByte; pcbAttrLen: PDWord): LongInt; stdcall;
{$EXTERNALSYM SCardGetAttrib}
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
// CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED CHANGED
{$ENDIF}
//
// NOTE: The routine SCardGetAttrib's name differs from the PC/SC definition.
// It should be:
//
// extern WINSCARDAPI LONG WINAPI
// SCardGetReaderCapabilities(
// IN SCARDHANDLE hCard,
// IN DWORD dwTag,
// OUT LPBYTE pbAttr,
// IN OUT LPDWORD pcbAttrLen);
//
// Here's a work-around MACRO:
{$IFDEF WinSCard_DYNLINK}
type
TSCardGetReaderCapabilities = TSCardGetAttrib;
TSCardSetAttrib = function (hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; cbAttrLen: LongInt): LongInt; stdcall;
{$ELSE}
function SCardSetAttrib(hCard: LongInt; dwAttrId: LongInt; var pbAttr: PByte; cbAttrLen: LongInt): LongInt; stdcall;
{$EXTERNALSYM SCardSetAttrib}
{$ENDIF}
//
// NOTE: The routine SCardSetAttrib's name differs from the PC/SC definition.
// It should be:
//
// extern WINSCARDAPI LONG WINAPI
// SCardSetReaderCapabilities(
// IN SCARDHANDLE hCard,
// IN DWORD dwTag,
// OUT LPBYTE pbAttr,
// IN OUT LPDWORD pcbAttrLen);
//
// Here's a work-around MACRO:
{$IFDEF WinSCard_DYNLINK}
type
TSCardSetReaderCapabilities = TSCardSetAttrib;
{$ENDIF}
//
////////////////////////////////////////////////////////////////////////////////
//
// Smart Card Dialog definitions
//
// The following section contains structures and exported function
// declarations for the Smart Card Common Dialog dialog.
//
// Defined constants
// Flags
const
SC_DLG_MINIMAL_UI = $01;
{$EXTERNALSYM SC_DLG_MINIMAL_UI}
SC_DLG_NO_UI = $02;
{$EXTERNALSYM SC_DLG_NO_UI}
SC_DLG_FORCE_UI = $04;
{$EXTERNALSYM SC_DLG_FORCE_UI}
SCERR_NOCARDNAME = $4000;
{$EXTERNALSYM SCERR_NOCARDNAME}
SCERR_NOGUIDS = $8000;
{$EXTERNALSYM SCERR_NOGUIDS}
type
LPOCNCONNPROCA = function(hSCardContext: LongInt; hCard: LPStr; pvUserData: Pointer): DWORD; cdecl;
{$EXTERNALSYM LPOCNCONNPROCA}
LPOCNCONNPROCW = function(hSCardContext: LongInt; hCard: LPWStr; pvUserData: Pointer): DWORD; cdecl;
{$EXTERNALSYM LPOCNCONNPROCW}
{$IFDEF UNICODE}
LPOCNCONNPROC = LPOCNCONNPROCW;
{$ELSE}
LPOCNCONNPROC = LPOCNCONNPROCA;
{$ENDIF}
{$EXTERNALSYM LPOCNCONNPROC}
LPOCNCHKPROC = function(hContext: LongInt; hCard: LPStr; pvUserData: Pointer): Bool; cdecl;
{$EXTERNALSYM LPOCNCHKPROC}
LPOCNDSCPROC = procedure(hContext: LongInt; hCard: LPStr; pvUserData: Pointer); cdecl;
{$EXTERNALSYM LPOCNDSCPROC}
//
// OPENCARD_SEARCH_CRITERIA: In order to specify a user-extended search,
// lpfnCheck must not be NULL. Moreover, the connection to be made to the
// card before performing the callback must be indicated by either providing
// lpfnConnect and lpfnDisconnect OR by setting dwShareMode.
// If both the connection callbacks and dwShareMode are non-NULL, the callbacks
// will be used.
//
POPENCARD_SEARCH_CRITERIAA = ^OPENCARD_SEARCH_CRITERIAA;
{$EXTERNALSYM POPENCARD_SEARCH_CRITERIAA}
LPOPENCARD_SEARCH_CRITERIAA = ^OPENCARD_SEARCH_CRITERIAA;
{$EXTERNALSYM LPOPENCARD_SEARCH_CRITERIAA}
OPENCARD_SEARCH_CRITERIAA = record
dwStructSize: DWORD;
lpstrGroupNames: LPSTR; // OPTIONAL reader groups to include in
nMaxGroupNames: DWORD; // search. NULL defaults to
// SCard$DefaultReaders
rgguidInterfaces: LPCGUID; // OPTIONAL requested interfaces
cguidInterfaces: DWORD; // supported by card's SSP
lpstrCardNames: LPSTR; // OPTIONAL requested card names; all cards w/
nMaxCardNames: DWORD; // matching ATRs will be accepted
lpfnCheck: LPOCNCHKPROC; // OPTIONAL if NULL no user check will be performed.
lpfnConnect: LPOCNCONNPROCA; // OPTIONAL if lpfnConnect is provided,
lpfnDisconnect: LPOCNDSCPROC; // lpfnDisconnect must also be set.
pvUserData: Pointer; // OPTIONAL parameter to callbacks
dwShareMode: DWORD; // OPTIONAL must be set if lpfnCheck is not null
dwPreferredProtocols: DWORD; // OPTIONAL
end;
{$EXTERNALSYM OPENCARD_SEARCH_CRITERIAA}
POPENCARD_SEARCH_CRITERIAW = ^OPENCARD_SEARCH_CRITERIAW;
{$EXTERNALSYM POPENCARD_SEARCH_CRITERIAW}
LPOPENCARD_SEARCH_CRITERIAW = ^OPENCARD_SEARCH_CRITERIAW;
{$EXTERNALSYM LPOPENCARD_SEARCH_CRITERIAW}
OPENCARD_SEARCH_CRITERIAW = record
dwStructSize: DWORD;
lpstrGroupNames: LPWSTR; // OPTIONAL reader groups to include in
nMaxGroupNames: DWORD; // search. NULL defaults to
// SCard$DefaultReaders
rgguidInterfaces: LPCGUID; // OPTIONAL requested interfaces
cguidInterfaces: DWORD; // supported by card's SSP
lpstrCardNames: LPWSTR; // OPTIONAL requested card names; all cards w/
nMaxCardNames: DWORD; // matching ATRs will be accepted
lpfnCheck: LPOCNCHKPROC; // OPTIONAL if NULL no user check will be performed.
lpfnConnect: LPOCNCONNPROCA; // OPTIONAL if lpfnConnect is provided,
lpfnDisconnect: LPOCNDSCPROC; // lpfnDisconnect must also be set.
pvUserData: Pointer; // OPTIONAL parameter to callbacks
dwShareMode: DWORD; // OPTIONAL must be set if lpfnCheck is not null
dwPreferredProtocols: DWORD; // OPTIONAL
end;
{$EXTERNALSYM OPENCARD_SEARCH_CRITERIAW}
{$IFDEF UNICODE}
OPENCARD_SEARCH_CRITERIA = OPENCARD_SEARCH_CRITERIAW;
POPENCARD_SEARCH_CRITERIA = POPENCARD_SEARCH_CRITERIAW;
LPOPENCARD_SEARCH_CRITERIA = LPOPENCARD_SEARCH_CRITERIAW;
{$ELSE}
OPENCARD_SEARCH_CRITERIA = OPENCARD_SEARCH_CRITERIAA;
POPENCARD_SEARCH_CRITERIA = POPENCARD_SEARCH_CRITERIAA;
LPOPENCARD_SEARCH_CRITERIA = LPOPENCARD_SEARCH_CRITERIAA;
{$ENDIF}
{$EXTERNALSYM OPENCARD_SEARCH_CRITERIA}
{$EXTERNALSYM POPENCARD_SEARCH_CRITERIA}
{$EXTERNALSYM LPOPENCARD_SEARCH_CRITERIA}
//
// OPENCARDNAME_EX: used by SCardUIDlgSelectCard; replaces obsolete OPENCARDNAME
//
POPENCARDNAME_EXA = ^OPENCARDNAME_EXA;
{$EXTERNALSYM POPENCARDNAME_EXA}
LPOPENCARDNAME_EXA = ^OPENCARDNAME_EXA;
{$EXTERNALSYM LPOPENCARDNAME_EXA}
OPENCARDNAME_EXA = record
dwStructSize: DWORD; // REQUIRED
hSCardContext: SCARDCONTEXT; // REQUIRED
hwndOwner: HWND; // OPTIONAL
dwFlags: DWORD; // OPTIONAL -- default is SC_DLG_MINIMAL_UI
lpstrTitle: LPCSTR; // OPTIONAL
lpstrSearchDesc: LPCSTR; // OPTIONAL (eg. "Please insert your <brandname> smart card.")