Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

723 lines
26 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. WinSCard
  5. Abstract:
  6. This header file provides the definitions and symbols necessary for an
  7. Application or Smart Card Service Provider to access the Smartcard
  8. Subsystem.
  9. Environment:
  10. Win32
  11. Notes:
  12. --*/
  13. #ifndef _WINSCARD_H_
  14. #define _WINSCARD_H_
  15. #if defined (_MSC_VER) && (_MSC_VER >= 1020)
  16. #pragma once
  17. #endif
  18. #include <wtypes.h>
  19. #include <winioctl.h>
  20. #include "winsmcrd.h"
  21. #ifndef SCARD_S_SUCCESS
  22. #include "SCardErr.h"
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #ifndef _LPCBYTE_DEFINED
  28. #define _LPCBYTE_DEFINED
  29. typedef const BYTE *LPCBYTE;
  30. #endif
  31. #ifndef _LPCVOID_DEFINED
  32. #define _LPCVOID_DEFINED
  33. typedef const VOID *LPCVOID;
  34. #endif
  35. #ifndef WINSCARDAPI
  36. #define WINSCARDAPI
  37. #endif
  38. #ifndef WINSCARDDATA
  39. #define WINSCARDDATA __declspec(dllimport)
  40. #endif
  41. WINSCARDDATA extern const SCARD_IO_REQUEST
  42. g_rgSCardT0Pci,
  43. g_rgSCardT1Pci,
  44. g_rgSCardRawPci;
  45. #define SCARD_PCI_T0 (&g_rgSCardT0Pci)
  46. #define SCARD_PCI_T1 (&g_rgSCardT1Pci)
  47. #define SCARD_PCI_RAW (&g_rgSCardRawPci)
  48. //
  49. ////////////////////////////////////////////////////////////////////////////////
  50. //
  51. // Service Manager Access Services
  52. //
  53. // The following services are used to manage user and terminal contexts for
  54. // Smart Cards.
  55. //
  56. typedef ULONG_PTR SCARDCONTEXT;
  57. typedef SCARDCONTEXT *PSCARDCONTEXT, *LPSCARDCONTEXT;
  58. typedef ULONG_PTR SCARDHANDLE;
  59. typedef SCARDHANDLE *PSCARDHANDLE, *LPSCARDHANDLE;
  60. #define SCARD_AUTOALLOCATE (DWORD)(-1)
  61. #define SCARD_SCOPE_USER 0 // The context is a user context, and any
  62. // database operations are performed within the
  63. // domain of the user.
  64. #define SCARD_SCOPE_TERMINAL 1 // The context is that of the current terminal,
  65. // and any database operations are performed
  66. // within the domain of that terminal. (The
  67. // calling application must have appropriate
  68. // access permissions for any database actions.)
  69. #define SCARD_SCOPE_SYSTEM 2 // The context is the system context, and any
  70. // database operations are performed within the
  71. // domain of the system. (The calling
  72. // application must have appropriate access
  73. // permissions for any database actions.)
  74. extern WINSCARDAPI LONG WINAPI
  75. SCardEstablishContext(
  76. IN DWORD dwScope,
  77. IN LPCVOID pvReserved1,
  78. IN LPCVOID pvReserved2,
  79. OUT LPSCARDCONTEXT phContext);
  80. extern WINSCARDAPI LONG WINAPI
  81. SCardReleaseContext(
  82. IN SCARDCONTEXT hContext);
  83. extern WINSCARDAPI LONG WINAPI
  84. SCardIsValidContext(
  85. IN SCARDCONTEXT hContext);
  86. //
  87. ////////////////////////////////////////////////////////////////////////////////
  88. //
  89. // Smart Card Database Management Services
  90. //
  91. // The following services provide for managing the Smart Card Database.
  92. //
  93. #define SCARD_ALL_READERS TEXT("SCard$AllReaders\000")
  94. #define SCARD_DEFAULT_READERS TEXT("SCard$DefaultReaders\000")
  95. #define SCARD_LOCAL_READERS TEXT("SCard$LocalReaders\000")
  96. #define SCARD_SYSTEM_READERS TEXT("SCard$SystemReaders\000")
  97. #define SCARD_PROVIDER_PRIMARY 1 // Primary Provider Id
  98. #define SCARD_PROVIDER_CSP 2 // Crypto Service Provider Id
  99. //
  100. // Database Reader routines
  101. //
  102. extern WINSCARDAPI LONG WINAPI
  103. SCardListReaderGroups%(
  104. IN SCARDCONTEXT hContext,
  105. OUT LPTSTR% mszGroups,
  106. IN OUT LPDWORD pcchGroups);
  107. extern WINSCARDAPI LONG WINAPI
  108. SCardListReaders%(
  109. IN SCARDCONTEXT hContext,
  110. IN LPCTSTR% mszGroups,
  111. OUT LPTSTR% mszReaders,
  112. IN OUT LPDWORD pcchReaders);
  113. extern WINSCARDAPI LONG WINAPI
  114. SCardListCards%(
  115. IN SCARDCONTEXT hContext,
  116. IN LPCBYTE pbAtr,
  117. IN LPCGUID rgquidInterfaces,
  118. IN DWORD cguidInterfaceCount,
  119. OUT LPTSTR% mszCards,
  120. IN OUT LPDWORD pcchCards);
  121. //
  122. // NOTE: The routine SCardListCards name differs from the PC/SC definition.
  123. // It should be:
  124. //
  125. // extern WINSCARDAPI LONG WINAPI
  126. // SCardListCardTypes(
  127. // IN SCARDCONTEXT hContext,
  128. // IN LPCBYTE pbAtr,
  129. // IN LPCGUID rgquidInterfaces,
  130. // IN DWORD cguidInterfaceCount,
  131. // OUT LPTSTR mszCards,
  132. // IN OUT LPDWORD pcchCards);
  133. //
  134. // Here's a work-around MACRO:
  135. #define SCardListCardTypes SCardListCards
  136. extern WINSCARDAPI LONG WINAPI
  137. SCardListInterfaces%(
  138. IN SCARDCONTEXT hContext,
  139. IN LPCTSTR% szCard,
  140. OUT LPGUID pguidInterfaces,
  141. IN OUT LPDWORD pcguidInterfaces);
  142. extern WINSCARDAPI LONG WINAPI
  143. SCardGetProviderId%(
  144. IN SCARDCONTEXT hContext,
  145. IN LPCTSTR% szCard,
  146. OUT LPGUID pguidProviderId);
  147. //
  148. // NOTE: The routine SCardGetProviderId in this implementation uses GUIDs.
  149. // The PC/SC definition uses BYTEs.
  150. //
  151. extern WINSCARDAPI LONG WINAPI
  152. SCardGetCardTypeProviderName%(
  153. IN SCARDCONTEXT hContext,
  154. IN LPCTSTR% szCardName,
  155. IN DWORD dwProviderId,
  156. OUT LPTSTR% szProvider,
  157. IN OUT LPDWORD pcchProvider);
  158. //
  159. // NOTE: This routine is an extension to the PC/SC definitions.
  160. //
  161. //
  162. // Database Writer routines
  163. //
  164. extern WINSCARDAPI LONG WINAPI
  165. SCardIntroduceReaderGroup%(
  166. IN SCARDCONTEXT hContext,
  167. IN LPCTSTR% szGroupName);
  168. extern WINSCARDAPI LONG WINAPI
  169. SCardForgetReaderGroup%(
  170. IN SCARDCONTEXT hContext,
  171. IN LPCTSTR% szGroupName);
  172. extern WINSCARDAPI LONG WINAPI
  173. SCardIntroduceReader%(
  174. IN SCARDCONTEXT hContext,
  175. IN LPCTSTR% szReaderName,
  176. IN LPCTSTR% szDeviceName);
  177. extern WINSCARDAPI LONG WINAPI
  178. SCardForgetReader%(
  179. IN SCARDCONTEXT hContext,
  180. IN LPCTSTR% szReaderName);
  181. extern WINSCARDAPI LONG WINAPI
  182. SCardAddReaderToGroup%(
  183. IN SCARDCONTEXT hContext,
  184. IN LPCTSTR% szReaderName,
  185. IN LPCTSTR% szGroupName);
  186. extern WINSCARDAPI LONG WINAPI
  187. SCardRemoveReaderFromGroup%(
  188. IN SCARDCONTEXT hContext,
  189. IN LPCTSTR% szReaderName,
  190. IN LPCTSTR% szGroupName);
  191. extern WINSCARDAPI LONG WINAPI
  192. SCardIntroduceCardType%(
  193. IN SCARDCONTEXT hContext,
  194. IN LPCTSTR% szCardName,
  195. IN LPCGUID pguidPrimaryProvider,
  196. IN LPCGUID rgguidInterfaces,
  197. IN DWORD dwInterfaceCount,
  198. IN LPCBYTE pbAtr,
  199. IN LPCBYTE pbAtrMask,
  200. IN DWORD cbAtrLen);
  201. //
  202. // NOTE: The routine SCardIntroduceCardType's parameters' order differs from
  203. // the PC/SC definition. It should be:
  204. //
  205. // extern WINSCARDAPI LONG WINAPI
  206. // SCardIntroduceCardType(
  207. // IN SCARDCONTEXT hContext,
  208. // IN LPCTSTR szCardName,
  209. // IN LPCBYTE pbAtr,
  210. // IN LPCBYTE pbAtrMask,
  211. // IN DWORD cbAtrLen,
  212. // IN LPCGUID pguidPrimaryProvider,
  213. // IN LPCGUID rgguidInterfaces,
  214. // IN DWORD dwInterfaceCount);
  215. //
  216. // Here's a work-around MACRO:
  217. #define PCSCardIntroduceCardType(hContext, szCardName, pbAtr, pbAtrMask, cbAtrLen, pguidPrimaryProvider, rgguidInterfaces, dwInterfaceCount) \
  218. SCardIntroduceCardType(hContext, szCardName, pguidPrimaryProvider, rgguidInterfaces, dwInterfaceCount, pbAtr, pbAtrMask, cbAtrLen)
  219. extern WINSCARDAPI LONG WINAPI
  220. SCardSetCardTypeProviderName%(
  221. IN SCARDCONTEXT hContext,
  222. IN LPCTSTR% szCardName,
  223. IN DWORD dwProviderId,
  224. IN LPCTSTR% szProvider);
  225. //
  226. // NOTE: This routine is an extention to the PC/SC specifications.
  227. //
  228. extern WINSCARDAPI LONG WINAPI
  229. SCardForgetCardType%(
  230. IN SCARDCONTEXT hContext,
  231. IN LPCTSTR% szCardName);
  232. //
  233. ////////////////////////////////////////////////////////////////////////////////
  234. //
  235. // Service Manager Support Routines
  236. //
  237. // The following services are supplied to simplify the use of the Service
  238. // Manager API.
  239. //
  240. extern WINSCARDAPI LONG WINAPI
  241. SCardFreeMemory(
  242. IN SCARDCONTEXT hContext,
  243. IN LPCVOID pvMem);
  244. extern WINSCARDAPI HANDLE WINAPI
  245. SCardAccessStartedEvent(void);
  246. extern WINSCARDAPI void WINAPI
  247. SCardReleaseStartedEvent(void);
  248. //
  249. ////////////////////////////////////////////////////////////////////////////////
  250. //
  251. // Reader Services
  252. //
  253. // The following services supply means for tracking cards within readers.
  254. //
  255. typedef struct {
  256. LPCTSTR% szReader; // reader name
  257. LPVOID pvUserData; // user defined data
  258. DWORD dwCurrentState; // current state of reader at time of call
  259. DWORD dwEventState; // state of reader after state change
  260. DWORD cbAtr; // Number of bytes in the returned ATR.
  261. BYTE rgbAtr[36]; // Atr of inserted card, (extra alignment bytes)
  262. } SCARD_READERSTATE%, *PSCARD_READERSTATE%, *LPSCARD_READERSTATE%;
  263. // Backwards compatibility macros
  264. #define SCARD_READERSTATE_A SCARD_READERSTATEA
  265. #define SCARD_READERSTATE_W SCARD_READERSTATEW
  266. #define PSCARD_READERSTATE_A PSCARD_READERSTATEA
  267. #define PSCARD_READERSTATE_W PSCARD_READERSTATEW
  268. #define LPSCARD_READERSTATE_A LPSCARD_READERSTATEA
  269. #define LPSCARD_READERSTATE_W LPSCARD_READERSTATEW
  270. #define SCARD_STATE_UNAWARE 0x00000000 // The application is unaware of the
  271. // current state, and would like to
  272. // know. The use of this value
  273. // results in an immediate return
  274. // from state transition monitoring
  275. // services. This is represented by
  276. // all bits set to zero.
  277. #define SCARD_STATE_IGNORE 0x00000001 // The application requested that
  278. // this reader be ignored. No other
  279. // bits will be set.
  280. #define SCARD_STATE_CHANGED 0x00000002 // This implies that there is a
  281. // difference between the state
  282. // believed by the application, and
  283. // the state known by the Service
  284. // Manager. When this bit is set,
  285. // the application may assume a
  286. // significant state change has
  287. // occurred on this reader.
  288. #define SCARD_STATE_UNKNOWN 0x00000004 // This implies that the given
  289. // reader name is not recognized by
  290. // the Service Manager. If this bit
  291. // is set, then SCARD_STATE_CHANGED
  292. // and SCARD_STATE_IGNORE will also
  293. // be set.
  294. #define SCARD_STATE_UNAVAILABLE 0x00000008 // This implies that the actual
  295. // state of this reader is not
  296. // available. If this bit is set,
  297. // then all the following bits are
  298. // clear.
  299. #define SCARD_STATE_EMPTY 0x00000010 // This implies that there is not
  300. // card in the reader. If this bit
  301. // is set, all the following bits
  302. // will be clear.
  303. #define SCARD_STATE_PRESENT 0x00000020 // This implies that there is a card
  304. // in the reader.
  305. #define SCARD_STATE_ATRMATCH 0x00000040 // This implies that there is a card
  306. // in the reader with an ATR
  307. // matching one of the target cards.
  308. // If this bit is set,
  309. // SCARD_STATE_PRESENT will also be
  310. // set. This bit is only returned
  311. // on the SCardLocateCard() service.
  312. #define SCARD_STATE_EXCLUSIVE 0x00000080 // This implies that the card in the
  313. // reader is allocated for exclusive
  314. // use by another application. If
  315. // this bit is set,
  316. // SCARD_STATE_PRESENT will also be
  317. // set.
  318. #define SCARD_STATE_INUSE 0x00000100 // This implies that the card in the
  319. // reader is in use by one or more
  320. // other applications, but may be
  321. // connected to in shared mode. If
  322. // this bit is set,
  323. // SCARD_STATE_PRESENT will also be
  324. // set.
  325. #define SCARD_STATE_MUTE 0x00000200 // This implies that the card in the
  326. // reader is unresponsive or not
  327. // supported by the reader or
  328. // software.
  329. #define SCARD_STATE_UNPOWERED 0x00000400 // This implies that the card in the
  330. // reader has not been powered up.
  331. extern WINSCARDAPI LONG WINAPI
  332. SCardLocateCards%(
  333. IN SCARDCONTEXT hContext,
  334. IN LPCTSTR% mszCards,
  335. IN OUT LPSCARD_READERSTATE% rgReaderStates,
  336. IN DWORD cReaders);
  337. typedef struct _SCARD_ATRMASK {
  338. DWORD cbAtr; // Number of bytes in the ATR and the mask.
  339. BYTE rgbAtr[36]; // Atr of card (extra alignment bytes)
  340. BYTE rgbMask[36]; // Mask for the Atr (extra alignment bytes)
  341. } SCARD_ATRMASK, *PSCARD_ATRMASK, *LPSCARD_ATRMASK;
  342. extern WINSCARDAPI LONG WINAPI
  343. SCardLocateCardsByATR%(
  344. IN SCARDCONTEXT hContext,
  345. IN LPSCARD_ATRMASK rgAtrMasks,
  346. IN DWORD cAtrs,
  347. IN OUT LPSCARD_READERSTATE% rgReaderStates,
  348. IN DWORD cReaders);
  349. extern WINSCARDAPI LONG WINAPI
  350. SCardGetStatusChange%(
  351. IN SCARDCONTEXT hContext,
  352. IN DWORD dwTimeout,
  353. IN OUT LPSCARD_READERSTATE% rgReaderStates,
  354. IN DWORD cReaders);
  355. extern WINSCARDAPI LONG WINAPI
  356. SCardCancel(
  357. IN SCARDCONTEXT hContext);
  358. //
  359. ////////////////////////////////////////////////////////////////////////////////
  360. //
  361. // Card/Reader Communication Services
  362. //
  363. // The following services provide means for communication with the card.
  364. //
  365. #define SCARD_SHARE_EXCLUSIVE 1 // This application is not willing to share this
  366. // card with other applications.
  367. #define SCARD_SHARE_SHARED 2 // This application is willing to share this
  368. // card with other applications.
  369. #define SCARD_SHARE_DIRECT 3 // This application demands direct control of
  370. // the reader, so it is not available to other
  371. // applications.
  372. #define SCARD_LEAVE_CARD 0 // Don't do anything special on close
  373. #define SCARD_RESET_CARD 1 // Reset the card on close
  374. #define SCARD_UNPOWER_CARD 2 // Power down the card on close
  375. #define SCARD_EJECT_CARD 3 // Eject the card on close
  376. extern WINSCARDAPI LONG WINAPI
  377. SCardConnect%(
  378. IN SCARDCONTEXT hContext,
  379. IN LPCTSTR% szReader,
  380. IN DWORD dwShareMode,
  381. IN DWORD dwPreferredProtocols,
  382. OUT LPSCARDHANDLE phCard,
  383. OUT LPDWORD pdwActiveProtocol);
  384. extern WINSCARDAPI LONG WINAPI
  385. SCardReconnect(
  386. IN SCARDHANDLE hCard,
  387. IN DWORD dwShareMode,
  388. IN DWORD dwPreferredProtocols,
  389. IN DWORD dwInitialization,
  390. OUT LPDWORD pdwActiveProtocol);
  391. extern WINSCARDAPI LONG WINAPI
  392. SCardDisconnect(
  393. IN SCARDHANDLE hCard,
  394. IN DWORD dwDisposition);
  395. extern WINSCARDAPI LONG WINAPI
  396. SCardBeginTransaction(
  397. IN SCARDHANDLE hCard);
  398. extern WINSCARDAPI LONG WINAPI
  399. SCardEndTransaction(
  400. IN SCARDHANDLE hCard,
  401. IN DWORD dwDisposition);
  402. extern WINSCARDAPI LONG WINAPI
  403. SCardCancelTransaction(
  404. IN SCARDHANDLE hCard);
  405. //
  406. // NOTE: This call corresponds to the PC/SC SCARDCOMM::Cancel routine,
  407. // terminating a blocked SCardBeginTransaction service.
  408. //
  409. extern WINSCARDAPI LONG WINAPI
  410. SCardState(
  411. IN SCARDHANDLE hCard,
  412. OUT LPDWORD pdwState,
  413. OUT LPDWORD pdwProtocol,
  414. OUT LPBYTE pbAtr,
  415. IN OUT LPDWORD pcbAtrLen);
  416. //
  417. // NOTE: SCardState is an obsolete routine. PC/SC has replaced it with
  418. // SCardStatus.
  419. //
  420. extern WINSCARDAPI LONG WINAPI
  421. SCardStatus%(
  422. IN SCARDHANDLE hCard,
  423. OUT LPTSTR% szReaderName,
  424. IN OUT LPDWORD pcchReaderLen,
  425. OUT LPDWORD pdwState,
  426. OUT LPDWORD pdwProtocol,
  427. OUT LPBYTE pbAtr,
  428. IN OUT LPDWORD pcbAtrLen);
  429. extern WINSCARDAPI LONG WINAPI
  430. SCardTransmit(
  431. IN SCARDHANDLE hCard,
  432. IN LPCSCARD_IO_REQUEST pioSendPci,
  433. IN LPCBYTE pbSendBuffer,
  434. IN DWORD cbSendLength,
  435. IN OUT LPSCARD_IO_REQUEST pioRecvPci,
  436. OUT LPBYTE pbRecvBuffer,
  437. IN OUT LPDWORD pcbRecvLength);
  438. //
  439. ////////////////////////////////////////////////////////////////////////////////
  440. //
  441. // Reader Control Routines
  442. //
  443. // The following services provide for direct, low-level manipulation of the
  444. // reader by the calling application allowing it control over the
  445. // attributes of the communications with the card.
  446. //
  447. extern WINSCARDAPI LONG WINAPI
  448. SCardControl(
  449. IN SCARDHANDLE hCard,
  450. IN DWORD dwControlCode,
  451. IN LPCVOID lpInBuffer,
  452. IN DWORD nInBufferSize,
  453. OUT LPVOID lpOutBuffer,
  454. IN DWORD nOutBufferSize,
  455. OUT LPDWORD lpBytesReturned);
  456. extern WINSCARDAPI LONG WINAPI
  457. SCardGetAttrib(
  458. IN SCARDHANDLE hCard,
  459. IN DWORD dwAttrId,
  460. OUT LPBYTE pbAttr,
  461. IN OUT LPDWORD pcbAttrLen);
  462. //
  463. // NOTE: The routine SCardGetAttrib's name differs from the PC/SC definition.
  464. // It should be:
  465. //
  466. // extern WINSCARDAPI LONG WINAPI
  467. // SCardGetReaderCapabilities(
  468. // IN SCARDHANDLE hCard,
  469. // IN DWORD dwTag,
  470. // OUT LPBYTE pbAttr,
  471. // IN OUT LPDWORD pcbAttrLen);
  472. //
  473. // Here's a work-around MACRO:
  474. #define SCardGetReaderCapabilities SCardGetAttrib
  475. extern WINSCARDAPI LONG WINAPI
  476. SCardSetAttrib(
  477. IN SCARDHANDLE hCard,
  478. IN DWORD dwAttrId,
  479. IN LPCBYTE pbAttr,
  480. IN DWORD cbAttrLen);
  481. //
  482. // NOTE: The routine SCardSetAttrib's name differs from the PC/SC definition.
  483. // It should be:
  484. //
  485. // extern WINSCARDAPI LONG WINAPI
  486. // SCardSetReaderCapabilities(
  487. // IN SCARDHANDLE hCard,
  488. // IN DWORD dwTag,
  489. // OUT LPBYTE pbAttr,
  490. // IN OUT LPDWORD pcbAttrLen);
  491. //
  492. // Here's a work-around MACRO:
  493. #define SCardSetReaderCapabilities SCardSetAttrib
  494. //
  495. ////////////////////////////////////////////////////////////////////////////////
  496. //
  497. // Smart Card Dialog definitions
  498. //
  499. // The following section contains structures and exported function
  500. // declarations for the Smart Card Common Dialog dialog.
  501. //
  502. // Defined constants
  503. // Flags
  504. #define SC_DLG_MINIMAL_UI 0x01
  505. #define SC_DLG_NO_UI 0x02
  506. #define SC_DLG_FORCE_UI 0x04
  507. #define SCERR_NOCARDNAME 0x4000
  508. #define SCERR_NOGUIDS 0x8000
  509. typedef SCARDHANDLE (WINAPI *LPOCNCONNPROC%) (IN SCARDCONTEXT, IN LPTSTR%, IN LPTSTR%, IN PVOID);
  510. typedef BOOL (WINAPI *LPOCNCHKPROC) (IN SCARDCONTEXT, IN SCARDHANDLE, IN PVOID);
  511. typedef void (WINAPI *LPOCNDSCPROC) (IN SCARDCONTEXT, IN SCARDHANDLE, IN PVOID);
  512. //
  513. // OPENCARD_SEARCH_CRITERIA: In order to specify a user-extended search,
  514. // lpfnCheck must not be NULL. Moreover, the connection to be made to the
  515. // card before performing the callback must be indicated by either providing
  516. // lpfnConnect and lpfnDisconnect OR by setting dwShareMode.
  517. // If both the connection callbacks and dwShareMode are non-NULL, the callbacks
  518. // will be used.
  519. //
  520. typedef struct {
  521. DWORD dwStructSize;
  522. LPTSTR% lpstrGroupNames; // OPTIONAL reader groups to include in
  523. DWORD nMaxGroupNames; // search. NULL defaults to
  524. // SCard$DefaultReaders
  525. LPCGUID rgguidInterfaces; // OPTIONAL requested interfaces
  526. DWORD cguidInterfaces; // supported by card's SSP
  527. LPTSTR% lpstrCardNames; // OPTIONAL requested card names; all cards w/
  528. DWORD nMaxCardNames; // matching ATRs will be accepted
  529. LPOCNCHKPROC lpfnCheck; // OPTIONAL if NULL no user check will be performed.
  530. LPOCNCONNPROC% lpfnConnect; // OPTIONAL if lpfnConnect is provided,
  531. LPOCNDSCPROC lpfnDisconnect; // lpfnDisconnect must also be set.
  532. LPVOID pvUserData; // OPTIONAL parameter to callbacks
  533. DWORD dwShareMode; // OPTIONAL must be set if lpfnCheck is not null
  534. DWORD dwPreferredProtocols; // OPTIONAL
  535. } OPENCARD_SEARCH_CRITERIA%, *POPENCARD_SEARCH_CRITERIA%, *LPOPENCARD_SEARCH_CRITERIA%;
  536. //
  537. // OPENCARDNAME_EX: used by SCardUIDlgSelectCard; replaces obsolete OPENCARDNAME
  538. //
  539. typedef struct {
  540. DWORD dwStructSize; // REQUIRED
  541. SCARDCONTEXT hSCardContext; // REQUIRED
  542. HWND hwndOwner; // OPTIONAL
  543. DWORD dwFlags; // OPTIONAL -- default is SC_DLG_MINIMAL_UI
  544. LPCTSTR% lpstrTitle; // OPTIONAL
  545. LPCTSTR% lpstrSearchDesc; // OPTIONAL (eg. "Please insert your <brandname> smart card.")
  546. HICON hIcon; // OPTIONAL 32x32 icon for your brand insignia
  547. POPENCARD_SEARCH_CRITERIA% pOpenCardSearchCriteria; // OPTIONAL
  548. LPOCNCONNPROC% lpfnConnect; // OPTIONAL - performed on successful selection
  549. LPVOID pvUserData; // OPTIONAL parameter to lpfnConnect
  550. DWORD dwShareMode; // OPTIONAL - if lpfnConnect is NULL, dwShareMode and
  551. DWORD dwPreferredProtocols; // OPTIONAL dwPreferredProtocols will be used to
  552. // connect to the selected card
  553. LPTSTR% lpstrRdr; // REQUIRED [IN|OUT] Name of selected reader
  554. DWORD nMaxRdr; // REQUIRED [IN|OUT]
  555. LPTSTR% lpstrCard; // REQUIRED [IN|OUT] Name of selected card
  556. DWORD nMaxCard; // REQUIRED [IN|OUT]
  557. DWORD dwActiveProtocol; // [OUT] set only if dwShareMode not NULL
  558. SCARDHANDLE hCardHandle; // [OUT] set if a card connection was indicated
  559. } OPENCARDNAME_EX%, *POPENCARDNAME_EX%, *LPOPENCARDNAME_EX%;
  560. #define OPENCARDNAMEA_EX OPENCARDNAME_EXA
  561. #define OPENCARDNAMEW_EX OPENCARDNAME_EXW
  562. #define POPENCARDNAMEA_EX POPENCARDNAME_EXA
  563. #define POPENCARDNAMEW_EX POPENCARDNAME_EXW
  564. #define LPOPENCARDNAMEA_EX LPOPENCARDNAME_EXA
  565. #define LPOPENCARDNAMEW_EX LPOPENCARDNAME_EXW
  566. //
  567. // SCardUIDlgSelectCard replaces GetOpenCardName
  568. //
  569. extern WINSCARDAPI LONG WINAPI
  570. SCardUIDlgSelectCard%(
  571. LPOPENCARDNAME%_EX);
  572. //
  573. // "Smart Card Common Dialog" definitions for backwards compatibility
  574. // with the Smart Card Base Services SDK version 1.0
  575. //
  576. typedef struct {
  577. DWORD dwStructSize;
  578. HWND hwndOwner;
  579. SCARDCONTEXT hSCardContext;
  580. LPTSTR% lpstrGroupNames;
  581. DWORD nMaxGroupNames;
  582. LPTSTR% lpstrCardNames;
  583. DWORD nMaxCardNames;
  584. LPCGUID rgguidInterfaces;
  585. DWORD cguidInterfaces;
  586. LPTSTR% lpstrRdr;
  587. DWORD nMaxRdr;
  588. LPTSTR% lpstrCard;
  589. DWORD nMaxCard;
  590. LPCTSTR% lpstrTitle;
  591. DWORD dwFlags;
  592. LPVOID pvUserData;
  593. DWORD dwShareMode;
  594. DWORD dwPreferredProtocols;
  595. DWORD dwActiveProtocol;
  596. LPOCNCONNPROC% lpfnConnect;
  597. LPOCNCHKPROC lpfnCheck;
  598. LPOCNDSCPROC lpfnDisconnect;
  599. SCARDHANDLE hCardHandle;
  600. } OPENCARDNAME%, *POPENCARDNAME%, *LPOPENCARDNAME%;
  601. // Backwards compatibility macros
  602. #define OPENCARDNAME_A OPENCARDNAMEA
  603. #define OPENCARDNAME_W OPENCARDNAMEW
  604. #define POPENCARDNAME_A POPENCARDNAMEA
  605. #define POPENCARDNAME_W POPENCARDNAMEW
  606. #define LPOPENCARDNAME_A LPOPENCARDNAMEA
  607. #define LPOPENCARDNAME_W LPOPENCARDNAMEW
  608. extern WINSCARDAPI LONG WINAPI
  609. GetOpenCardName%(
  610. LPOPENCARDNAME%);
  611. extern WINSCARDAPI LONG WINAPI
  612. SCardDlgExtendedError (void);
  613. #ifdef __cplusplus
  614. }
  615. #endif
  616. #endif // _WINSCARD_H_