home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / scardmgr.idl < prev    next >
Text File  |  1998-04-25  |  15KB  |  465 lines

  1. /*++
  2.  
  3. Copyright (c) 1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     SCardMgr
  8.  
  9. Abstract:
  10.  
  11.     IDL source for SCardMgr.DLL. This in-process server (DLL)
  12.     encapsulates the hardware oriented COM interfaces for the
  13.     Smart Card Service Provider (SSP) Manager.
  14.     
  15. Author:
  16.  
  17.     Michael Gallagher (a-mgalla) 10/21/1996
  18.  
  19. Environment:
  20.  
  21.     Win32
  22.  
  23. Revision History:
  24.  
  25.     Michael Gallagher (a-mgalla) 1/23/1997
  26.     Chris Dudley (cdudley) 1/24/1997
  27.     Chris Dudley (cdudley) 3/13/1997
  28.  
  29. Notes:
  30.  
  31.     This file will be processed by the MIDL tool to produce
  32.     the type library (SCardMgr.tlb) and marshalling code. A
  33.     header file named SCardMgr.h will be generated by the
  34.     MIDL compiler for the ATL CPP code to use.
  35.  
  36. --*/
  37.  
  38.  
  39. cpp_quote("//+-------------------------------------------------------------------------")
  40. cpp_quote("//")
  41. cpp_quote("//  Microsoft Smart Card Support")
  42. cpp_quote("//  Copyright (C) Microsoft Corporation, 1996.")
  43. cpp_quote("//")
  44. cpp_quote("// File: SCardMgr.h")
  45. cpp_quote("//")
  46. cpp_quote("//--------------------------------------------------------------------------")
  47.  
  48.  
  49. cpp_quote("")
  50. cpp_quote("//////////////////////////////////////////////////////////////////")
  51. cpp_quote("//")
  52. cpp_quote("// Imports")
  53. cpp_quote("//")
  54.  
  55. #ifndef DO_NO_IMPORTS
  56.     import "SspsIdl.idl";
  57. #endif
  58.  
  59. interface ISCard;
  60. interface ISCardDatabase;
  61. interface ISCardLocate;
  62.  
  63.  
  64. cpp_quote("")
  65. cpp_quote("//////////////////////////////////////////////////////////////////")
  66. cpp_quote("//")
  67. cpp_quote("// Types and Constants")
  68. cpp_quote("//")
  69.  
  70. cpp_quote("#ifndef _NULL_DEFINED")
  71.     cpp_quote("#define _NULL_DEFINED")
  72.     #define NULL    0
  73. cpp_quote("#endif // !_NULL_DEFINED")
  74.  
  75. cpp_quote("#ifndef _HSCARD_DEFINED")
  76.     cpp_quote("#define _HSCARD_DEFINED")
  77.     typedef [public] LONG HSCARD;
  78. cpp_quote("#endif // !_HSCARD_DEFINED")
  79.  
  80. cpp_quote("#ifndef _LPHSCARD_DEFINED")
  81.     cpp_quote("#define _LPHSCARD_DEFINED")
  82.     typedef [unique] HSCARD *PHSCARD;
  83.     typedef [unique] HSCARD *LPHSCARD;
  84. cpp_quote("#endif // !_LPHSCARD_DEFINED")
  85.  
  86. cpp_quote("#ifndef _HSCARDCONTEXT_DEFINED")
  87.     cpp_quote("#define _HSCARDCONTEXT_DEFINED")
  88.     typedef [public] LONG HSCARDCONTEXT;
  89. cpp_quote("#endif // !_HSCARDCONTEXT_DEFINED")
  90.  
  91. cpp_quote("#ifndef _LPHSCARDCONTEXT_DEFINED")
  92.     cpp_quote("#define _LPHSCARDCONTEXT_DEFINED")
  93.     typedef [unique] SHCARDCONTEXT *PHSCARDCONTEXT;
  94.     typedef [unique] SHCARDCONTEXT *LPHSCARDCONTEXT;
  95. cpp_quote("#endif // !_LPHSCARDCONTEXT_DEFINED")
  96.  
  97. cpp_quote("#ifndef _SCARD_SHARE_MODES_DEFINED")
  98.     cpp_quote("#define _SCARD_SHARE_MODES_DEFINED")
  99.     typedef [helpstring("SCard Share Modes"),
  100.              //uuid(),
  101.              //helpcontext(),
  102.              v1_enum,   // force 32-bit transmission over RPC, if in use...
  103.              version(1.0)]
  104.     enum tagSCARD_SHARE_MODES {
  105.         EXCLUSIVE = 1,
  106.         SHARED = 2
  107.      } SCARD_SHARE_MODES;
  108. cpp_quote("#endif // !_SCARD_SHARE_MODES_DEFINED")
  109.  
  110. cpp_quote("#ifndef _SCARD_DISPOSITIONS_DEFINED")
  111.     cpp_quote("#define _SCARD_DISPOSITIONS_DEFINED")
  112.     typedef [helpstring("SCard Dispositions"),
  113.              //uuid(),
  114.              //helpcontext(),
  115.              v1_enum,   // force 32-bit transmission over RPC, if in use...
  116.              version(1.0)]
  117.     enum tagSCARD_DISPOSITIONS {
  118.         LEAVE = 0,
  119.         RESET = 1,
  120.         UNPOWER = 2,
  121.         EJECT = 3
  122.      } SCARD_DISPOSITIONS;
  123. cpp_quote("#endif // !_SCARD_DISPOSITIONS_DEFINED")
  124.  
  125. cpp_quote("#ifndef _SCARD_STATES_DEFINED")
  126.     cpp_quote("#define _SCARD_STATES_DEFINED")
  127.     typedef [helpstring("SCard States"),
  128.              //uuid(),
  129.              //helpcontext(),
  130.              v1_enum,   // force 32-bit transmission over RPC, if in use...
  131.              version(1.0)]
  132.     enum tagSCARD_STATES {
  133.         ABSENT = 1,
  134.         PRESENT = 2,
  135.         SWALLOWED = 3,
  136.         POWERED = 4,
  137.         NEGOTIABLEMODE = 5,
  138.         SPECIFICMODE = 6
  139.      } SCARD_STATES;
  140. cpp_quote("#endif // !_SCARD_STATES_DEFINED")
  141.  
  142. cpp_quote("#ifndef _SCARD_PROTOCOLS_DEFINED")
  143.     cpp_quote("#define _SCARD_PROTOCOLS_DEFINED")
  144.     typedef [helpstring("SCard Protocols"),
  145.              //uuid(),
  146.              //helpcontext(),
  147.              v1_enum,   // force 32-bit transmission over RPC, if in use...
  148.              version(1.0)]
  149.     enum tagSCARD_PROTOCOLS {
  150.         T0 = 0x01,  // T=0 is the active protocol.
  151.         T1 = 0x02,  // T=1 is the active protocol.
  152.         RAW = 0xff  // Raw is the active protocol.
  153.      } SCARD_PROTOCOLS;
  154. cpp_quote("#endif // !_SCARD_PROTOCOLS_DEFINED")
  155.  
  156.  
  157. cpp_quote("#ifndef _SCARD_INFO")
  158.     cpp_quote("#define _SCARD_INFO")
  159.     typedef [helpstring("FindCard returned information structure."),
  160.              //uuid(),
  161.              //helpcontext(),
  162.              version(1.0)]
  163.     struct tagSCARDINFO {
  164.         HSCARD  hCard;
  165.         HSCARDCONTEXT hContext;
  166.         SCARD_PROTOCOLS ActiveProtocol;
  167.         SCARD_SHARE_MODES ShareMode;
  168.         LONG hwndOwner;
  169.         LONG lpfnConnectProc;
  170.         LONG lpfnCheckProc;
  171.         LONG lpfnDisconnectProc;
  172.         //
  173.         // Do we want to include any of the following???
  174.         //
  175.         //   1. card state (i.e., disposition)
  176.         //   2. process ID, thread ID (...a DWORD)
  177.         //   3. card GUID
  178.         //   4. GUID of class factory
  179.         //
  180.       } SCARDINFO;
  181.  
  182.     cpp_quote ("#define _LPSCARDINFO")      
  183.     typedef [unique] SCARDINFO *PSCARDINFO, *LPSCARDINFO;
  184.  
  185. cpp_quote ("#endif //_SCARD_INFO")
  186.  
  187. cpp_quote("")
  188. cpp_quote("//////////////////////////////////////////////////////////////////")
  189. cpp_quote("//")
  190. cpp_quote("// ISCard Interface")
  191. cpp_quote("//")
  192.  
  193. cpp_quote("#ifndef _LPSCARD_DEFINED")
  194. cpp_quote("#define _LPSCARD_DEFINED")
  195.     [
  196.         object,
  197.         uuid(1461AAC3-6810-11D0-918F-00AA00C18068),
  198.         dual,
  199.         helpstring("ISCard Interface"),
  200.         //hidden,
  201.         //restricted,       // prevent macro programming?
  202.         version(1.0),
  203.         pointer_default(unique)
  204.     ]
  205.     interface ISCard : IDispatch
  206.     {
  207.         // Includes -
  208.  
  209.         import "SspsIdl.idl";
  210.         
  211.         // Pointer(s) -
  212.  
  213.         typedef [unique] ISCard* LPSCARD;
  214.         typedef [unique] LPSCARD LPSMARTCARD;
  215.  
  216.         // Properties -
  217.  
  218.         [id(0), propget,
  219.          helpstring("Retrieve the ATR string for the Smart Card")]
  220.         HRESULT Atr([out,retval] LPBYTEBUFFER *ppAtr);
  221.  
  222.         [id(1), propget,
  223.          helpstring("Retrieve the current card handle.")]
  224.         HRESULT CardHandle([out,retval] HSCARD *pHandle);
  225.  
  226.         [id(2), propget,
  227.          helpstring("Retrieve the current context handle.")]
  228.         HRESULT Context([out,retval] HSCARDCONTEXT *pContext);
  229.  
  230.         [id(3), propget,
  231.          helpstring("Retrieve the protocol in use on the Smart Card")]
  232.         HRESULT Protocol([out,retval] SCARD_PROTOCOLS *pProtocol);
  233.  
  234.         [id(4), propget,
  235.          helpstring("Retrieve the current state that the Smart Card is in")]
  236.         HRESULT Status([out,retval] SCARD_STATES *pStatus);
  237.  
  238.         // Methods -
  239.  
  240.         [id(5),
  241.          helpstring("Attach an open SCard handle to this object")]
  242.         HRESULT AttachByHandle([in] HSCARD hCard);
  243.  
  244.         [id(6),
  245.          helpstring("Open a connection to a card in the named reader")]
  246.         HRESULT AttachByReader([in] BSTR bstrReaderName,
  247.                                [in,defaultvalue(EXCLUSIVE)]
  248.                                     SCARD_SHARE_MODES ShareMode,
  249.                                [in,defaultvalue(T0)]
  250.                                     SCARD_PROTOCOLS PrefProtocol);
  251.         
  252.         [id(7),
  253.          helpstring("Close a connection to an open card")]
  254.         HRESULT Detach([in,defaultvalue(LEAVE)]
  255.                             SCARD_DISPOSITIONS Disposition);
  256.         
  257.         [id(8),
  258.          helpstring("Acquire exclusive access and use of the open Smart Card")]
  259.         HRESULT LockSCard(void);
  260.  
  261.         [id(9),
  262.          helpstring("Reattach an existing connection to an in use Smart Card ")]
  263.         HRESULT ReAttach([in,defaultvalue(EXCLUSIVE)]
  264.                                 SCARD_SHARE_MODES ShareMode,
  265.                          [in,defaultvalue(LEAVE)]
  266.                                 SCARD_DISPOSITIONS InitState);
  267.         
  268.         [id(10),
  269.          helpstring("Execute a card transaction with a card command interface")]
  270.         HRESULT Transaction([in,out] LPSCARDCMD *ppCmd);
  271.  
  272.         [id(11),
  273.          helpstring("Release the exclusive access lock on the Smart Card")]
  274.         HRESULT UnlockSCard([in,defaultvalue(LEAVE)]
  275.                             SCARD_DISPOSITIONS Disposition);
  276.     };
  277. cpp_quote("#endif // !_LPSCARD_DEFINED")
  278.  
  279.  
  280. cpp_quote("")
  281. cpp_quote("//////////////////////////////////////////////////////////////////")
  282. cpp_quote("//")
  283. cpp_quote("// ISCardDatabase Interface")
  284. cpp_quote("//")
  285.  
  286. cpp_quote("#ifndef _LPSCARDDATABASE_DEFINED")
  287. cpp_quote("#define _LPSCARDDATABASE_DEFINED")
  288.     [
  289.         object,
  290.         uuid(1461AAC8-6810-11D0-918F-00AA00C18068),
  291.         dual,
  292.         helpstring("ISCardDatabase Interface"),
  293.         //hidden,
  294.         //restricted,       // prevent macro programming?
  295.         version(1.0),
  296.         pointer_default(unique)
  297.     ]
  298.     interface ISCardDatabase : IDispatch
  299.     {
  300.         // Includes -
  301.  
  302.         import "SspsIdl.idl";
  303.  
  304.         // Pointer(s) -
  305.  
  306.         typedef [unique] ISCardDatabase* LPSCARDDATABASE;
  307.  
  308.         // Methods -
  309.  
  310.         [id(0),
  311.          helpstring("Retrieve the provider ID for the named card")]
  312.         HRESULT GetProviderCardId([in] BSTR bstrCardName,
  313.                                   [out,retval] LPGUID *ppguidProviderId);
  314.  
  315.         [id(1),
  316.          helpstring("Retrieve a list of the interfaces (GUIDs) for the named card")]
  317.         HRESULT ListCardInterfaces([in] BSTR bstrCardName,
  318.                                    [out,retval] LPSAFEARRAY *ppInterfaceGuids); // BSTR
  319.  
  320.         [id(2),
  321.          helpstring("Retrieve a list of the names of the defined cards")]
  322.         HRESULT ListCards([in,defaultvalue(NULL)] LPBYTEBUFFER pAtr,
  323.                           [in,defaultvalue(NULL)] LPSAFEARRAY pInterfaceGuids,  // BSTR
  324.                           [in,lcid,defaultvalue(0x0409)] long localeId,
  325.                           [out,retval] LPSAFEARRAY *ppCardNames);                       // BSTR
  326.  
  327.         [id(3),
  328.          helpstring("Retrieve a list of the names of the defined card reader groups")]
  329.         HRESULT ListReaderGroups([in,lcid,defaultvalue(0x0409)] long localeId,
  330.                                  [out,retval] LPSAFEARRAY *ppReaderGroups);     // BSTR
  331.                         
  332.         [id(4),
  333.          helpstring("Retrieve a list of the names of the defined card readers")]
  334.         HRESULT ListReaders([in,lcid,defaultvalue(0x0409)] long localeId,
  335.                             [out,retval] LPSAFEARRAY *ppReaders);       // BSTR
  336.     };
  337. cpp_quote("#endif // !_LPSCARDDATABASE_DEFINED")
  338.  
  339.  
  340. cpp_quote("")
  341. cpp_quote("//////////////////////////////////////////////////////////////////")
  342. cpp_quote("//")
  343. cpp_quote("// ISCardLocate Interface")
  344. cpp_quote("//")
  345.  
  346. cpp_quote("#ifndef _LPSCARDLOCATE_DEFINED")
  347. cpp_quote("#define _LPSCARDLOCATE_DEFINED")
  348.  
  349.     [
  350.         object,
  351.         uuid(1461AACD-6810-11D0-918F-00AA00C18068),
  352.         dual,
  353.         helpstring("ISCardLocate Interface"),
  354.         //hidden,
  355.         //restricted,       // prevent macro programming?
  356.         version(1.0),
  357.         pointer_default(unique)
  358.     ]
  359.     interface ISCardLocate : IDispatch
  360.     {
  361.         // Includes -
  362.  
  363.         import "SspsIdl.idl";
  364.  
  365.         // Pointer(s) -
  366.  
  367.         typedef [unique] ISCardLocate* LPSCARDLOCATE;
  368.         typedef [unique] LPSCARDLOCATE LPSCARDLOC;
  369.  
  370.         // Type(s) -
  371.  
  372.         // Methods -
  373.  
  374.         [id(0),
  375.          helpstring("Configure the search based on the card GUIDs")]
  376.         HRESULT ConfigureCardGuidSearch(
  377.                         [in] LPSAFEARRAY pCardGuids,                        // BSTR
  378.                         [in,defaultvalue(NULL)] LPSAFEARRAY pGroupNames,    // BSTR
  379.                         [in,defaultvalue("")] BSTR bstrTitle,
  380.                         [in,defaultvalue(1)] LONG lFlags);
  381.  
  382.         [id(1),
  383.          helpstring("Configure the search based on card names")]
  384.         HRESULT ConfigureCardNameSearch(
  385.                         [in] LPSAFEARRAY pCardNames,                        // BSTR
  386.                         [in,defaultvalue(NULL)] LPSAFEARRAY pGroupNames,    // BSTR
  387.                         [in,defaultvalue("")] BSTR bstrTitle,
  388.                         [in,defaultvalue(1)] LONG lFlags);
  389.  
  390.         [id(2),
  391.          helpstring("Find and open a connection to the named Smart Card")]
  392.         HRESULT FindCard([in,defaultvalue(EXCLUSIVE)]
  393.                             SCARD_SHARE_MODES ShareMode,
  394.                          [in,defaultvalue(T0)]
  395.                             SCARD_PROTOCOLS Protocols,
  396.                          [in,defaultvalue(1)] LONG lFlags,
  397.                          [out,retval] LPSCARDINFO *ppCardInfo);
  398.     };
  399.  
  400.     cpp_quote("#define CB_SCARDINFO     (sizeof(SCARDINFO))")
  401. cpp_quote("#endif // !_LPSCARDLOCATE_DEFINED")
  402.  
  403.  
  404. cpp_quote("")
  405. cpp_quote("//////////////////////////////////////////////////////////////////")
  406. cpp_quote("//")
  407. cpp_quote("// SCardMgr Type Library")
  408. cpp_quote("//")
  409.  
  410. [
  411.     uuid(1461AAC1-6810-11D0-918F-00AA00C18068),
  412.     version(1.0),
  413.     //hidden,
  414.     //lcid(0x0409),     // general language
  415.     helpstring("SCardMgr 1.0 Type Library")
  416. ]
  417. library SCardMgrLib
  418. {
  419.     // NOTE: must include stdole2.tlb due to problems with the Alpha stdole32.tlb.
  420.     // This will generate warnings during build, but compile is successful.
  421.     #ifdef _ALPHA_
  422.     importlib("stdole2.tlb");
  423.     #else
  424.     importlib("stdole32.tlb");
  425.     #endif
  426.     importlib("SCardDat.tlb");
  427.  
  428.     [
  429.         uuid(1461AAC7-6810-11D0-918F-00AA00C18068),
  430.         helpstring("SCard Class"),
  431.         //hidden,
  432.         //licensed,
  433.         aggregatable
  434.     ]
  435.     coclass CSCard
  436.     {
  437.         [default] interface ISCard;
  438.     };
  439.  
  440.     [
  441.         uuid(1461AACC-6810-11D0-918F-00AA00C18068),
  442.         helpstring("SCardDatabase Class"),
  443.         //hidden,
  444.         //licensed,
  445.         aggregatable
  446.     ]
  447.     coclass CSCardDatabase
  448.     {
  449.         [default] interface ISCardDatabase;
  450.     };
  451.  
  452.     [
  453.         uuid(1461AAD1-6810-11D0-918F-00AA00C18068),
  454.         helpstring("SCardLocate Class"),
  455.         //hidden,
  456.         //licensed,
  457.         aggregatable
  458.     ]
  459.     coclass CSCardLocate
  460.     {
  461.         [default] interface ISCardLocate;
  462.     };
  463.  
  464. };
  465.