Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 6c21d55247420ace69cad1d05267fc34 > files > 90

pcsc-lite-doc-1.7.2-4.fc15.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>pcsc-lite: API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">pcsc-lite&#160;<span id="projectnumber">1.7.2</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">API</div>  </div>
</div>
<div class="contents">

<p>Handles smartcard reader communications and forwarding requests over message queues.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">PCSC_API char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gab5c302876c4c8187143603837a41aa86">pcsc_stringify_error</a> (const LONG pcscError)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This function return a human readable text for the given PC/SC error code.  <a href="#gab5c302876c4c8187143603837a41aa86"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67">SCardEstablishContext</a> (DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates an Application Context to the PC/SC Resource Manager.  <a href="#gaa1b8970169fd4883a6dc4a8f43f19b67"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga6aabcba7744c5c9419fdd6404f73a934">SCardReleaseContext</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys a communication context to the PC/SC Resource Manager.  <a href="#ga6aabcba7744c5c9419fdd6404f73a934"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5">SCardConnect</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Establishes a connection to the reader specified in <code>*</code> szReader.  <a href="#ga4e515829752e0a8dbc4d630696a8d6a5"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gad5d4393ca8c470112ad9468c44ed8940">SCardReconnect</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reestablishes a connection to a reader that was previously connected to using <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>.  <a href="#gad5d4393ca8c470112ad9468c44ed8940"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga4be198045c73ec0deb79e66c0ca1738a">SCardDisconnect</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, DWORD dwDisposition)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Terminates a connection made through <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>.  <a href="#ga4be198045c73ec0deb79e66c0ca1738a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861">SCardBeginTransaction</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Establishes a temporary exclusive access mode for doing a serie of commands in a transaction.  <a href="#gaddb835dce01a0da1d6ca02d33ee7d861"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gae8742473b404363e5c587f570d7e2f3b">SCardEndTransaction</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, DWORD dwDisposition)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Ends a previously begun transaction.  <a href="#gae8742473b404363e5c587f570d7e2f3b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga18f33eebb45d9e0d2a091ca7a0511d26">SCardStatus</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the current status of the reader connected to by <code>hCard</code>.  <a href="#ga18f33eebb45d9e0d2a091ca7a0511d26"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga33247d5d1257d59e55647c3bb717db24">SCardGetStatusChange</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext, DWORD dwTimeout, <a class="el" href="structSCARD__READERSTATE.html">SCARD_READERSTATE</a> *rgReaderStates, DWORD cReaders)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Blocks execution until the current availability of the cards in a specific set of readers changes.  <a href="#ga33247d5d1257d59e55647c3bb717db24"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f">SCardControl</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sends a command directly to the IFD Handler (reader driver) to be processed by the reader.  <a href="#gac3454d4657110fd7f753b2d3d8f4e32f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gaacfec51917255b7a25b94c5104961602">SCardGetAttrib</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get an attribute from the IFD Handler (reader driver).  <a href="#gaacfec51917255b7a25b94c5104961602"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga060f0038a4ddfd5dd2b8fadf3c3a2e4f">SCardSetAttrib</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Set an attribute of the IFD Handler.  <a href="#ga060f0038a4ddfd5dd2b8fadf3c3a2e4f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga9a2d77242a271310269065e64633ab99">SCardTransmit</a> (<a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a> hCard, const <a class="el" href="structSCARD__IO__REQUEST.html">SCARD_IO_REQUEST</a> *pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, <a class="el" href="structSCARD__IO__REQUEST.html">SCARD_IO_REQUEST</a> *pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sends an APDU to the smart card contained in the reader connected to by <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>.  <a href="#ga9a2d77242a271310269065e64633ab99"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga93b07815789b3cf2629d439ecf20f0d9">SCardListReaders</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns a list of currently available readers on the system.  <a href="#ga93b07815789b3cf2629d439ecf20f0d9"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga0522241e3180cb05dfd166e28930e961">SCardFreeMemory</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext, LPCVOID pvMem)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Releases memory that has been returned from the resource manager using the <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> length designator.  <a href="#ga0522241e3180cb05dfd166e28930e961"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga9d970d086d5218e080d0079d63f9d496">SCardListReaderGroups</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext, LPSTR mszGroups, LPDWORD pcchGroups)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a list of currently available reader groups on the system.  <a href="#ga9d970d086d5218e080d0079d63f9d496"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6">SCardCancel</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This function cancels all pending blocking requests on the <a class="el" href="group__API.html#ga33247d5d1257d59e55647c3bb717db24" title="Blocks execution until the current availability of the cards in a specific set of readers changes...">SCardGetStatusChange()</a> function.  <a href="#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">LONG&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__API.html#ga722eb66bcc44d391f700ff9065cc080b">SCardIsValidContext</a> (<a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> hContext)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if a <a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> is valid.  <a href="#ga722eb66bcc44d391f700ff9065cc080b"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Handles smartcard reader communications and forwarding requests over message queues. </p>
<p>Here is exposed the API for client applications.</p>
<dl class="attention"><dt><b>Attention:</b></dt><dd>Known differences with Microsoft Windows WinSCard implementation:</dd></dl>
<ol type="1">
<li><a class="el" href="group__API.html#ga18f33eebb45d9e0d2a091ca7a0511d26" title="Returns the current status of the reader connected to by hCard.">SCardStatus()</a> <dl class="user"><dt><b></b></dt><dd><a class="el" href="group__API.html#ga18f33eebb45d9e0d2a091ca7a0511d26" title="Returns the current status of the reader connected to by hCard.">SCardStatus()</a> returns a bit field on pcsc-lite but a enumeration on Windows. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>This difference may be resolved in a future version of pcsc-lite. The bit-fields would then only contain one bit set. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>You can have a <b>portable</b> code using: <div class="fragment"><pre class="fragment">    <span class="keywordflow">if</span> (dwState &amp; <a class="code" href="pcsclite_8h.html#a4d99b1aacfcda4e1a36198f5668ae520" title="Card is present.">SCARD_PRESENT</a>)
    {
      <span class="comment">// card is present</span>
    }
</pre></div></dd></dl>
</li>
<li><a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a> <dl class="user"><dt><b></b></dt><dd>Windows may return ERROR_NOT_SUPPORTED instead of <a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a> </dd></dl>
<dl class="user"><dt><b></b></dt><dd>This difference will not be corrected. pcsc-lite only uses SCARD_E_* error codes.</dd></dl>
</li>
<li><a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a> <dl class="user"><dt><b></b></dt><dd>For historical reasons the value of <a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a> is <code>0x8010001F</code> in pcsc-lite but <code>0x80100022</code> in Windows WinSCard. You should not have any problem if you always use the symbolic name. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>The value <code>0x8010001F</code> is also used by <a class="el" href="pcsclite_8h.html#a05c6d9b6f2bf618209d6d7237470865e">SCARD_E_UNEXPECTED</a> on pcsc-lite but <a class="el" href="pcsclite_8h.html#a05c6d9b6f2bf618209d6d7237470865e">SCARD_E_UNEXPECTED</a> is never returned by pcsc-lite. So <code>0x8010001F</code> does always means <a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a>. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>Applications like rdekstop that allow a Windows application to talk to pcsc-lite should take care of this difference and convert the value between the two worlds.</dd></dl>
</li>
<li><a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a> <dl class="user"><dt><b></b></dt><dd>If <a class="el" href="pcsclite_8h.html#a440c31d5b68fda7dfe8f87f5ffe47bef">SCARD_SHARE_DIRECT</a> is used the reader is accessed in shared mode (like with <a class="el" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f">SCARD_SHARE_SHARED</a>) and not in exclusive mode (like with <a class="el" href="pcsclite_8h.html#aedc5ddb6c12dd0e9f522d4c669ca9135">SCARD_SHARE_EXCLUSIVE</a>) as on Windows.</dd></dl>
</li>
<li><a class="el" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext()</a> <dl class="user"><dt><b></b></dt><dd>Each thread of an application shall use its own SCARDCONTEXT. <a class="el" href="group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6" title="This function cancels all pending blocking requests on the SCardGetStatusChange() function...">SCardCancel()</a> is the only exception to the rule. On Windows the same SCARDCONTEXT can be shared by different threads of same application.</dd></dl>
</li>
<li>CardConnect() &amp; <a class="el" href="group__API.html#gad5d4393ca8c470112ad9468c44ed8940" title="Reestablishes a connection to a reader that was previously connected to using SCardConnect().">SCardReconnect()</a> <dl class="user"><dt><b></b></dt><dd>pdwActiveProtocol is not set to SCARD_PROTOCOL_UNDEFINED if SCARD_SHARE_DIRECT is used but the card has already negociated its protocol </dd></dl>
</li>
</ol>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gab5c302876c4c8187143603837a41aa86"></a><!-- doxytag: member="error.c::pcsc_stringify_error" ref="gab5c302876c4c8187143603837a41aa86" args="(const LONG pcscError)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">PCSC_API char* pcsc_stringify_error </td>
          <td>(</td>
          <td class="paramtype">const LONG&#160;</td>
          <td class="paramname"><em>pcscError</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>This function return a human readable text for the given PC/SC error code. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">pcscError</td><td>Error code to be translated to text.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Text representing the error code passed.</dd></dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LONG rv;
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 <span class="keywordflow">if</span> (rv != <a class="code" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75" title="error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx">SCARD_S_SUCCESS</a>)
     printf(<span class="stringliteral">&quot;SCardReleaseContext: %s (0x%lX)\n&quot;</span>,
         <a class="code" href="group__API.html#gab5c302876c4c8187143603837a41aa86" title="This function return a human readable text for the given PC/SC error code.">pcsc_stringify_error</a>(rv), rv);
</pre></div> 
<p>Definition at line <a class="el" href="error_8c_source.html#l00057">57</a> of file <a class="el" href="error_8c_source.html">error.c</a>.</p>

<p>References <a class="el" href="pcsclite_8h_source.html#l00082">SCARD_E_CANCELLED</a>, <a class="el" href="pcsclite_8h_source.html#l00094">SCARD_E_CANT_DISPOSE</a>, <a class="el" href="pcsclite_8h_source.html#l00108">SCARD_E_CARD_UNSUPPORTED</a>, <a class="el" href="pcsclite_8h_source.html#l00107">SCARD_E_DUPLICATE_READER</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00101">SCARD_E_INVALID_ATR</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00085">SCARD_E_INVALID_TARGET</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00086">SCARD_E_NO_MEMORY</a>, <a class="el" href="pcsclite_8h_source.html#l00127">SCARD_E_NO_READERS_AVAILABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00109">SCARD_E_NO_SERVICE</a>, <a class="el" href="pcsclite_8h_source.html#l00092">SCARD_E_NO_SMARTCARD</a>, <a class="el" href="pcsclite_8h_source.html#l00096">SCARD_E_NOT_READY</a>, <a class="el" href="pcsclite_8h_source.html#l00102">SCARD_E_NOT_TRANSACTED</a>, <a class="el" href="pcsclite_8h_source.html#l00105">SCARD_E_PCI_TOO_SMALL</a>, <a class="el" href="pcsclite_8h_source.html#l00095">SCARD_E_PROTO_MISMATCH</a>, <a class="el" href="pcsclite_8h_source.html#l00103">SCARD_E_READER_UNAVAILABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00106">SCARD_E_READER_UNSUPPORTED</a>, <a class="el" href="pcsclite_8h_source.html#l00110">SCARD_E_SERVICE_STOPPED</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00098">SCARD_E_SYSTEM_CANCELLED</a>, <a class="el" href="pcsclite_8h_source.html#l00090">SCARD_E_TIMEOUT</a>, <a class="el" href="pcsclite_8h_source.html#l00093">SCARD_E_UNKNOWN_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00089">SCARD_E_UNKNOWN_READER</a>, <a class="el" href="pcsclite_8h_source.html#l00112">SCARD_E_UNSUPPORTED_FEATURE</a>, <a class="el" href="pcsclite_8h_source.html#l00099">SCARD_F_COMM_ERROR</a>, <a class="el" href="pcsclite_8h_source.html#l00081">SCARD_F_INTERNAL_ERROR</a>, <a class="el" href="pcsclite_8h_source.html#l00100">SCARD_F_UNKNOWN_ERROR</a>, <a class="el" href="pcsclite_8h_source.html#l00087">SCARD_F_WAITED_TOO_LONG</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcsclite_8h_source.html#l00136">SCARD_W_REMOVED_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00135">SCARD_W_RESET_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00134">SCARD_W_UNPOWERED_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00133">SCARD_W_UNRESPONSIVE_CARD</a>, and <a class="el" href="pcsclite_8h_source.html#l00132">SCARD_W_UNSUPPORTED_CARD</a>.</p>

</div>
</div>
<a class="anchor" id="gaddb835dce01a0da1d6ca02d33ee7d861"></a><!-- doxytag: member="winscard_clnt.c::SCardBeginTransaction" ref="gaddb835dce01a0da1d6ca02d33ee7d861" args="(SCARDHANDLE hCard)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardBeginTransaction </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Establishes a temporary exclusive access mode for doing a serie of commands in a transaction. </p>
<p>You might want to use this when you are selecting a few files and then writing a large file so you can make sure that another application will not change the current file. If another application has a lock on this reader or this application is in <a class="el" href="pcsclite_8h.html#aedc5ddb6c12dd0e9f522d4c669ca9135">SCARD_SHARE_EXCLUSIVE</a> there will be no action taken.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid hCard handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_SHARING_VIOLATION</td><td>Someone else has exclusive rights (<a class="el" href="pcsclite_8h.html#a81cd3fc9e7e84c66be2471294152235f">SCARD_E_SHARING_VIOLATION</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 rv = <a class="code" href="group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861" title="Establishes a temporary exclusive access mode for doing a serie of commands in a transaction.">SCardBeginTransaction</a>(hCard);
 ...
 / * Do some transmit commands * /
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l01158">1158</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="pcscd_8h_source.html#l00037">PCSCLITE_LOCK_POLL_RATE</a>, <a class="el" href="winscard__msg_8h_source.html#l00061">SCARD_BEGIN_TRANSACTION</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gaddb835dce01a0da1d6ca02d33ee7d861_cgraph.png" border="0" usemap="#group__API_gaddb835dce01a0da1d6ca02d33ee7d861_cgraph" alt=""/></div>
<map name="group__API_gaddb835dce01a0da1d6ca02d33ee7d861_cgraph" id="group__API_gaddb835dce01a0da1d6ca02d33ee7d861_cgraph">
<area shape="rect" id="node3" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="240,5,363,35"/><area shape="rect" id="node5" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="215,59,388,88"/><area shape="rect" id="node9" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="252,112,351,141"/><area shape="rect" id="node7" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="439,59,543,88"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6"></a><!-- doxytag: member="winscard_clnt.c::SCardCancel" ref="gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6" args="(SCARDCONTEXT hContext)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardCancel </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>This function cancels all pending blocking requests on the <a class="el" href="group__API.html#ga33247d5d1257d59e55647c3bb717db24" title="Blocks execution until the current availability of the cards in a specific set of readers changes...">SCardGetStatusChange()</a> function. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hContext</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>Server is not running (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 DWORD cReaders;
 <a class="code" href="structSCARD__READERSTATE.html">SCARD_READERSTATE</a> rgReaderStates;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rgReaderStates.szReader = strdup(<span class="stringliteral">&quot;Reader X&quot;</span>);
 rgReaderStates.dwCurrentState = <a class="code" href="pcsclite_8h.html#aadf7badda42d372c2bc56d95a7720535" title="Card removed.">SCARD_STATE_EMPTY</a>;
 ...
 / * Spawn off thread <span class="keywordflow">for</span> following function * /
 ...
 rv = <a class="code" href="group__API.html#ga33247d5d1257d59e55647c3bb717db24" title="Blocks execution until the current availability of the cards in a specific set of readers changes...">SCardGetStatusChange</a>(hContext, 0, rgReaderStates, cReaders);
 rv = <a class="code" href="group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6" title="This function cancels all pending blocking requests on the SCardGetStatusChange() function...">SCardCancel</a>(hContext);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l03174">3174</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="winscard__msg_8c_source.html#l00138">ClientCloseSession()</a>, <a class="el" href="winscard__msg_8c_source.html#l00090">ClientSetupSession()</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="winscard__msg_8h_source.html#l00067">SCARD_CANCEL</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00109">SCARD_E_NO_SERVICE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6_cgraph.png" border="0" usemap="#group__API_gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6_cgraph" alt=""/></div>
<map name="group__API_gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6_cgraph" id="group__API_gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6_cgraph">
<area shape="rect" id="node3" href="winscard__msg_8c.html#a43b3c0b77aeac885864df13a39b5d44f" title="Closes the socket used by the client to communicate with the server." alt="" coords="175,5,311,35"/><area shape="rect" id="node5" href="winscard__msg_8c.html#a616a7d779449d1dc6a8a5d925d8212b1" title="Prepares a communication channel for the client to talk to the server." alt="" coords="175,59,311,88"/><area shape="rect" id="node7" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="181,112,304,141"/><area shape="rect" id="node9" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="156,165,329,195"/><area shape="rect" id="node13" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="180,245,305,275"/><area shape="rect" id="node11" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="399,152,503,181"/><area shape="rect" id="node15" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="379,205,523,235"/><area shape="rect" id="node17" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="388,259,513,288"/><area shape="rect" id="node19" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="381,312,520,341"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga4e515829752e0a8dbc4d630696a8d6a5"></a><!-- doxytag: member="winscard_clnt.c::SCardConnect" ref="ga4e515829752e0a8dbc4d630696a8d6a5" args="(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardConnect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCSTR&#160;</td>
          <td class="paramname"><em>szReader</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwShareMode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwPreferredProtocols</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPSCARDHANDLE&#160;</td>
          <td class="paramname"><em>phCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pdwActiveProtocol</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Establishes a connection to the reader specified in <code>*</code> szReader. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">szReader</td><td>Reader name to connect to. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwShareMode</td><td>Mode of connection type: exclusive or shared.<ul>
<li><a class="el" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f">SCARD_SHARE_SHARED</a> - This application will allow others to share the reader.</li>
<li><a class="el" href="pcsclite_8h.html#aedc5ddb6c12dd0e9f522d4c669ca9135">SCARD_SHARE_EXCLUSIVE</a> - This application will NOT allow others to share the reader.</li>
<li><a class="el" href="pcsclite_8h.html#a440c31d5b68fda7dfe8f87f5ffe47bef">SCARD_SHARE_DIRECT</a> - Direct control of the reader, even without a card. <a class="el" href="pcsclite_8h.html#a440c31d5b68fda7dfe8f87f5ffe47bef">SCARD_SHARE_DIRECT</a> can be used before using <a class="el" href="group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f" title="Sends a command directly to the IFD Handler (reader driver) to be processed by the reader...">SCardControl()</a> to send control commands to the reader even if a card is not present in the reader. Contrary to Windows winscard behavior, the reader is accessed in shared mode and not exclusive mode. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwPreferredProtocols</td><td>Desired protocol use.<ul>
<li>0 - valid only if dwShareMode is SCARD_SHARE_DIRECT</li>
<li><a class="el" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c">SCARD_PROTOCOL_T0</a> - Use the T=0 protocol.</li>
<li><a class="el" href="pcsclite_8h.html#a3c09cd155e07044f857130c183d64f03">SCARD_PROTOCOL_T1</a> - Use the T=1 protocol.</li>
<li><a class="el" href="pcsclite_8h.html#ab58a85ece18f4217fe5372981231d195">SCARD_PROTOCOL_RAW</a> - Use with memory type cards. <code>dwPreferredProtocols</code> is a bit mask of acceptable protocols for the connection. You can use (<a class="el" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c">SCARD_PROTOCOL_T0</a> | <a class="el" href="pcsclite_8h.html#a3c09cd155e07044f857130c183d64f03">SCARD_PROTOCOL_T1</a>) if you do not have a preferred protocol. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">phCard</td><td>Handle to this connection. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pdwActiveProtocol</td><td>Established protocol to this connection.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hContext</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>phCard</code> or <code>pdwActiveProtocol</code> is NULL (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid sharing mode, requested protocol, or reader name (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SMARTCARD</td><td>No smart card present (<a class="el" href="pcsclite_8h.html#aaf69330d6d119872ef76ae81c6b826db">SCARD_E_NO_SMARTCARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NOT_READY</td><td>Could not allocate the desired port (<a class="el" href="pcsclite_8h.html#aad8800bcf34cd97d4a4b0c3fbd3d955e">SCARD_E_NOT_READY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_PROTO_MISMATCH</td><td>Requested protocol is unknown (<a class="el" href="pcsclite_8h.html#a36d821a0458f935ddbe345f10408a988">SCARD_E_PROTO_MISMATCH</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>Could not power up the reader or card (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_SHARING_VIOLATION</td><td>Someone else has exclusive rights (<a class="el" href="pcsclite_8h.html#a81cd3fc9e7e84c66be2471294152235f">SCARD_E_SHARING_VIOLATION</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_UNKNOWN_READER</td><td><code>szReader</code> is NULL (<a class="el" href="pcsclite_8h.html#a1bc24e84bfe33ef68be7251e2423190a">SCARD_E_UNKNOWN_READER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_UNSUPPORTED_FEATURE</td><td>Protocol not supported (<a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_INTERNAL_ERROR</td><td>An internal consistency check failed (<a class="el" href="pcsclite_8h.html#a081a564acaf166f74592906f7dff2d86">SCARD_F_INTERNAL_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_UNPOWERED_CARD</td><td>Card is not powered (<a class="el" href="pcsclite_8h.html#ad7d27393bc1ba813e6f9042fe8e9eca7">SCARD_W_UNPOWERED_CARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_UNRESPONSIVE_CARD</td><td>Card is mute (<a class="el" href="pcsclite_8h.html#a359a9e85e3b7c83c76507a096452b74f">SCARD_W_UNRESPONSIVE_CARD</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l00778">778</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00034">pubReaderStatesList::cardAtr</a>, <a class="el" href="eventhandler_8h_source.html#l00035">pubReaderStatesList::cardAtrLength</a>, <a class="el" href="eventhandler_8h_source.html#l00036">pubReaderStatesList::cardProtocol</a>, <a class="el" href="readerfactory_8h_source.html#l00108">ReaderContext::contexts</a>, <a class="el" href="readerfactory_8h_source.html#l00105">ReaderContext::hLockId</a>, <a class="el" href="ifdhandler_8h_source.html#l00320">IFD_POWER_UP</a>, <a class="el" href="ifdhandler_8h_source.html#l00328">IFD_SUCCESS</a>, <a class="el" href="ifdwrapper_8c_source.html#l00247">IFDPowerICC()</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="readerfactory_8h_source.html#l00091">ReaderContext::mMutex</a>, <a class="el" href="pcscd_8h_source.html#l00037">PCSCLITE_LOCK_POLL_RATE</a>, <a class="el" href="eventhandler_8h_source.html#l00053">PCSCLITE_SHARING_EXCLUSIVE_CONTEXT</a>, <a class="el" href="eventhandler_8h_source.html#l00051">PCSCLITE_SHARING_NO_CONTEXT</a>, <a class="el" href="prothandler_8c_source.html#l00054">PHGetAvailableProtocols()</a>, <a class="el" href="prothandler_8c_source.html#l00034">PHGetDefaultProtocol()</a>, <a class="el" href="prothandler_8c_source.html#l00079">PHSetProtocol()</a>, <a class="el" href="pcscd_8h_source.html#l00055">POWER_STATE_INUSE</a>, <a class="el" href="pcscd_8h_source.html#l00052">POWER_STATE_UNPOWERED</a>, <a class="el" href="readerfactory_8h_source.html#l00111">ReaderContext::powerState</a>, <a class="el" href="readerfactory_8h_source.html#l00112">ReaderContext::powerState_lock</a>, <a class="el" href="eventhandler_8h_source.html#l00032">pubReaderStatesList::readerSharing</a>, <a class="el" href="eventhandler_8h_source.html#l00031">pubReaderStatesList::readerState</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="winscard__msg_8h_source.html#l00058">SCARD_CONNECT</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00092">SCARD_E_NO_SMARTCARD</a>, <a class="el" href="pcsclite_8h_source.html#l00095">SCARD_E_PROTO_MISMATCH</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00089">SCARD_E_UNKNOWN_READER</a>, <a class="el" href="pcsclite_8h_source.html#l00081">SCARD_F_INTERNAL_ERROR</a>, <a class="el" href="pcsclite_8h_source.html#l00173">SCARD_NEGOTIABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00172">SCARD_POWERED</a>, <a class="el" href="pcsclite_8h_source.html#l00170">SCARD_PRESENT</a>, <a class="el" href="winscard_8c_source.html#l00171">SCARD_PROTOCOL_ANY_OLD</a>, <a class="el" href="pcsclite_8h_source.html#l00154">SCARD_PROTOCOL_RAW</a>, <a class="el" href="pcsclite_8h_source.html#l00152">SCARD_PROTOCOL_T0</a>, <a class="el" href="pcsclite_8h_source.html#l00153">SCARD_PROTOCOL_T1</a>, <a class="el" href="pcsclite_8h_source.html#l00150">SCARD_PROTOCOL_UNDEFINED</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcsclite_8h_source.html#l00161">SCARD_SHARE_DIRECT</a>, <a class="el" href="pcsclite_8h_source.html#l00159">SCARD_SHARE_EXCLUSIVE</a>, <a class="el" href="pcsclite_8h_source.html#l00160">SCARD_SHARE_SHARED</a>, <a class="el" href="pcsclite_8h_source.html#l00134">SCARD_W_UNPOWERED_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00133">SCARD_W_UNRESPONSIVE_CARD</a>, <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>, and <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga4e515829752e0a8dbc4d630696a8d6a5_cgraph.png" border="0" usemap="#group__API_ga4e515829752e0a8dbc4d630696a8d6a5_cgraph" alt=""/></div>
<map name="group__API_ga4e515829752e0a8dbc4d630696a8d6a5_cgraph" id="group__API_ga4e515829752e0a8dbc4d630696a8d6a5_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#a5a891c2a91b2cce4f950fe6d466ea9a2" title="Power up/down or reset&#39;s an ICC located in the IFD." alt="" coords="199,32,303,61"/><area shape="rect" id="node11" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="189,85,312,115"/><area shape="rect" id="node13" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="164,139,337,168"/><area shape="rect" id="node17" href="prothandler_8c.html#a028195440f572393f25e2daf6d4df05b" title="Get the protocols supported by the card." alt="" coords="165,192,336,221"/><area shape="rect" id="node21" href="prothandler_8c.html#a30e7c843c2a5a626a1df5abe4a116e99" title="Get the default protocol used immediately after reset." alt="" coords="175,245,327,275"/><area shape="rect" id="node24" href="prothandler_8c.html#a4522f0d45b2ab13cf3d264a605eec02d" title="Determine which protocol to use." alt="" coords="196,299,305,328"/><area shape="rect" id="node30" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="188,352,313,381"/><area shape="rect" id="node38" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="201,405,300,435"/><area shape="rect" id="node5" href="group__IFDHandler.html#gae6e70f53c76e9dab59164b2af8e9edfc" title="This function controls the power and reset signals of the smart card reader at the particular reader/..." alt="" coords="401,5,516,35"/><area shape="rect" id="node7" href="ifdwrapper_8c.html#a53f77b110a7765f683e0629aad54772e" title="Provide statistical information about the IFD and ICC including insertions, atr, powering status/etc..." alt="" coords="405,59,512,88"/><area shape="rect" id="node9" href="group__IFDHandler.html#gac0ef46f09df179c44a82259468bea174" title="This function returns the status of the card inserted in the reader/slot specified by Lun..." alt="" coords="607,59,740,88"/><area shape="rect" id="node15" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="407,139,511,168"/><area shape="rect" id="node19" href="atrhandler_8c.html#a76bf3383cc11cc95499325c987d6f193" title="Uncomment the following for ATR debugging or use ." alt="" coords="404,205,513,235"/><area shape="rect" id="node26" href="ifdwrapper_8c.html#ad794bea544918757cd2fbbae218fa458" title="Set the protocol type selection (PTS)." alt="" coords="413,285,504,315"/><area shape="rect" id="node28" href="group__IFDHandler.html#gaa6fc195cb450a147550f4671492257ad" title="This function should set the Protocol Type Selection (PTS) of a particular card/slot using the three ..." alt="" coords="579,285,768,315"/><area shape="rect" id="node32" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="387,339,531,368"/><area shape="rect" id="node34" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="396,392,521,421"/><area shape="rect" id="node36" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="389,445,528,475"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="gac3454d4657110fd7f753b2d3d8f4e32f"></a><!-- doxytag: member="winscard_clnt.c::SCardControl" ref="gac3454d4657110fd7f753b2d3d8f4e32f" args="(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardControl </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwControlCode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCVOID&#160;</td>
          <td class="paramname"><em>pbSendBuffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>cbSendLength</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPVOID&#160;</td>
          <td class="paramname"><em>pbRecvBuffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>cbRecvLength</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>lpBytesReturned</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Sends a command directly to the IFD Handler (reader driver) to be processed by the reader. </p>
<p>This is useful for creating client side reader drivers for functions like PIN pads, biometrics, or other extensions to the normal smart card reader that are not normally handled by PC/SC.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>the API of this function changed. In pcsc-lite 1.2.0 and before the API was not Windows(R) PC/SC compatible. This has been corrected.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwControlCode</td><td>Control code for the operation.<br/>
 <a href="http://pcsclite.alioth.debian.org/pcsc-lite/node28.html">Click here</a> for a list of supported commands by some drivers. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pbSendBuffer</td><td>Command to send to the reader. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cbSendLength</td><td>Length of the command. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pbRecvBuffer</td><td>Response from the reader. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cbRecvLength</td><td>Length of the response buffer. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">lpBytesReturned</td><td>Length of the response.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td><code>cbSendLength</code> or <code>cbRecvLength</code> are too big (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>pbSendBuffer</code> is NULL or <code>cbSendLength</code> is null and the IFDHandler is version 2.0 (without <code>dwControlCode</code>) (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid value was presented (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NOT_TRANSACTED</td><td>Data exchange not successful (<a class="el" href="pcsclite_8h.html#ab02a33c2ef61f12a851dfe85c575d7cc">SCARD_E_NOT_TRANSACTED</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed(<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_UNSUPPORTED_FEATURE</td><td>Driver does not support (<a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_REMOVED_CARD</td><td>The card has been removed from the reader(<a class="el" href="pcsclite_8h.html#aa2efd953946973972b1afc5d0343820c">SCARD_W_REMOVED_CARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_RESET_CARD</td><td>The card has been reset by another application (<a class="el" href="pcsclite_8h.html#a20fbb8319646f26c4ad7f237d1a64f0c">SCARD_W_RESET_CARD</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> LONG rv;
 <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol, dwSendLength, dwRecvLength;
 BYTE pbRecvBuffer[10];
 BYTE pbSendBuffer[] = { 0x06, 0x00, 0x0A, 0x01, 0x01, 0x10 0x00 };
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#ab58a85ece18f4217fe5372981231d195" title="Raw active protocol.">SCARD_PROTOCOL_RAW</a>, &amp;hCard, &amp;dwActiveProtocol);
 dwSendLength = <span class="keyword">sizeof</span>(pbSendBuffer);
 dwRecvLength = <span class="keyword">sizeof</span>(pbRecvBuffer);
 rv = <a class="code" href="group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f" title="Sends a command directly to the IFD Handler (reader driver) to be processed by the reader...">SCardControl</a>(hCard, 0x42000001, pbSendBuffer, dwSendLength,
          pbRecvBuffer, <span class="keyword">sizeof</span>(pbRecvBuffer), &amp;dwRecvLength);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l02251">2251</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="ifdwrapper_8c_source.html#l00424">IFDControl()</a>, <a class="el" href="pcsclite_8h_source.html#l00209">MAX_BUFFER_SIZE_EXTENDED</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00317">MessageSend()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="winscard__msg_8h_source.html#l00064">SCARD_CONTROL</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00112">SCARD_E_UNSUPPORTED_FEATURE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="readerfactory_8h_source.html#l00102">ReaderContext::version</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gac3454d4657110fd7f753b2d3d8f4e32f_cgraph.png" border="0" usemap="#group__API_gac3454d4657110fd7f753b2d3d8f4e32f_cgraph" alt=""/></div>
<map name="group__API_gac3454d4657110fd7f753b2d3d8f4e32f_cgraph" id="group__API_gac3454d4657110fd7f753b2d3d8f4e32f_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#a3a32c91bea8a53ae2b53f8ae821294c5" title="Provide a means for toggling a specific action on the reader such as swallow, eject, biometric." alt="" coords="200,5,285,35"/><area shape="rect" id="node7" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="181,59,304,88"/><area shape="rect" id="node9" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="380,136,484,165"/><area shape="rect" id="node11" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="156,163,329,192"/><area shape="rect" id="node5" href="group__IFDHandler.html#gabc775e84456eab0bac55df678a147dc9" title="This function performs a data exchange with the reader (not the card) specified by Lun..." alt="" coords="384,5,480,35"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga4be198045c73ec0deb79e66c0ca1738a"></a><!-- doxytag: member="winscard_clnt.c::SCardDisconnect" ref="ga4be198045c73ec0deb79e66c0ca1738a" args="(SCARDHANDLE hCard, DWORD dwDisposition)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardDisconnect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwDisposition</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Terminates a connection made through <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwDisposition</td><td>Reader function to execute.<ul>
<li><a class="el" href="pcsclite_8h.html#acf43bd7f99fbd970f331fc36ffbe8ca5">SCARD_LEAVE_CARD</a> - Do nothing.</li>
<li><a class="el" href="pcsclite_8h.html#a07feb710d597835d1afc5cfd2ef6ecef">SCARD_RESET_CARD</a> - Reset the card (warm reset).</li>
<li><a class="el" href="pcsclite_8h.html#a6f4f7f74e35ab4269f08381c967ee97b">SCARD_UNPOWER_CARD</a> - Unpower the card (cold reset).</li>
<li><a class="el" href="pcsclite_8h.html#a6d6346c6e1a1491965bb9ebe8ed02a95">SCARD_EJECT_CARD</a> - Eject the card.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful(<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid <code>dwDisposition</code> (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SMARTCARD</td><td>No smart card present (<a class="el" href="pcsclite_8h.html#aaf69330d6d119872ef76ae81c6b826db">SCARD_E_NO_SMARTCARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 rv = <a class="code" href="group__API.html#ga4be198045c73ec0deb79e66c0ca1738a" title="Terminates a connection made through SCardConnect().">SCardDisconnect</a>(hCard, <a class="code" href="pcsclite_8h.html#a6f4f7f74e35ab4269f08381c967ee97b" title="Power down on close.">SCARD_UNPOWER_CARD</a>);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l01053">1053</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00034">pubReaderStatesList::cardAtr</a>, <a class="el" href="eventhandler_8h_source.html#l00035">pubReaderStatesList::cardAtrLength</a>, <a class="el" href="eventhandler_8h_source.html#l00036">pubReaderStatesList::cardProtocol</a>, <a class="el" href="readerfactory_8h_source.html#l00108">ReaderContext::contexts</a>, <a class="el" href="readerfactory_8h_source.html#l00105">ReaderContext::hLockId</a>, <a class="el" href="ifdhandler_8h_source.html#l00321">IFD_POWER_DOWN</a>, <a class="el" href="ifdhandler_8h_source.html#l00320">IFD_POWER_UP</a>, <a class="el" href="ifdhandler_8h_source.html#l00322">IFD_RESET</a>, <a class="el" href="ifdhandler_8h_source.html#l00328">IFD_SUCCESS</a>, <a class="el" href="ifdwrapper_8c_source.html#l00217">IFDGetCapabilities()</a>, <a class="el" href="ifdwrapper_8c_source.html#l00247">IFDPowerICC()</a>, <a class="el" href="pcsclite_8h_source.html#l00208">MAX_BUFFER_SIZE</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="pcscd_8h_source.html#l00037">PCSCLITE_LOCK_POLL_RATE</a>, <a class="el" href="eventhandler_8h_source.html#l00053">PCSCLITE_SHARING_EXCLUSIVE_CONTEXT</a>, <a class="el" href="eventhandler_8h_source.html#l00051">PCSCLITE_SHARING_NO_CONTEXT</a>, <a class="el" href="pcscd_8h_source.html#l00054">POWER_STATE_GRACE_PERIOD</a>, <a class="el" href="pcscd_8h_source.html#l00052">POWER_STATE_UNPOWERED</a>, <a class="el" href="readerfactory_8h_source.html#l00111">ReaderContext::powerState</a>, <a class="el" href="readerfactory_8h_source.html#l00112">ReaderContext::powerState_lock</a>, <a class="el" href="eventhandler_8h_source.html#l00032">pubReaderStatesList::readerSharing</a>, <a class="el" href="eventhandler_8h_source.html#l00031">pubReaderStatesList::readerState</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="pcsclite_8h_source.html#l00169">SCARD_ABSENT</a>, <a class="el" href="winscard__msg_8h_source.html#l00060">SCARD_DISCONNECT</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00166">SCARD_EJECT_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00163">SCARD_LEAVE_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00173">SCARD_NEGOTIABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00172">SCARD_POWERED</a>, <a class="el" href="pcsclite_8h_source.html#l00170">SCARD_PRESENT</a>, <a class="el" href="pcsclite_8h_source.html#l00150">SCARD_PROTOCOL_UNDEFINED</a>, <a class="el" href="pcscd_8h_source.html#l00022">SCARD_RESET</a>, <a class="el" href="pcsclite_8h_source.html#l00164">SCARD_RESET_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcsclite_8h_source.html#l00171">SCARD_SWALLOWED</a>, <a class="el" href="pcsclite_8h_source.html#l00165">SCARD_UNPOWER_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00136">SCARD_W_REMOVED_CARD</a>, <a class="el" href="readerfactory_8h_source.html#l00104">ReaderContext::slot</a>, <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>, and <a class="el" href="ifdhandler_8h_source.html#l00307">TAG_IFD_STOP_POLLING_THREAD</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga4be198045c73ec0deb79e66c0ca1738a_cgraph.png" border="0" usemap="#group__API_ga4be198045c73ec0deb79e66c0ca1738a_cgraph" alt=""/></div>
<map name="group__API_ga4be198045c73ec0deb79e66c0ca1738a_cgraph" id="group__API_ga4be198045c73ec0deb79e66c0ca1738a_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#af9ec3bb9c077c400c6c0bc4b4e19155f" title="Get&#39;s capabilities in the reader." alt="" coords="200,5,333,35"/><area shape="rect" id="node7" href="ifdwrapper_8c.html#a5a891c2a91b2cce4f950fe6d466ea9a2" title="Power up/down or reset&#39;s an ICC located in the IFD." alt="" coords="215,59,319,88"/><area shape="rect" id="node15" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="205,112,328,141"/><area shape="rect" id="node17" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="180,165,353,195"/><area shape="rect" id="node21" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="217,219,316,248"/><area shape="rect" id="node5" href="group__IFDHandler.html#ga799aa26945bbd3f61aaa57107f63ae0b" title="This function should get the slot/card capabilities for a particular slot/card specified by Lun..." alt="" coords="404,5,545,35"/><area shape="rect" id="node9" href="group__IFDHandler.html#gae6e70f53c76e9dab59164b2af8e9edfc" title="This function controls the power and reset signals of the smart card reader at the particular reader/..." alt="" coords="417,59,532,88"/><area shape="rect" id="node11" href="ifdwrapper_8c.html#a53f77b110a7765f683e0629aad54772e" title="Provide statistical information about the IFD and ICC including insertions, atr, powering status/etc..." alt="" coords="421,112,528,141"/><area shape="rect" id="node13" href="group__IFDHandler.html#gac0ef46f09df179c44a82259468bea174" title="This function returns the status of the card inserted in the reader/slot specified by Lun..." alt="" coords="595,112,728,141"/><area shape="rect" id="node19" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="423,165,527,195"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="gae8742473b404363e5c587f570d7e2f3b"></a><!-- doxytag: member="winscard_clnt.c::SCardEndTransaction" ref="gae8742473b404363e5c587f570d7e2f3b" args="(SCARDHANDLE hCard, DWORD dwDisposition)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardEndTransaction </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwDisposition</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Ends a previously begun transaction. </p>
<p>The calling application must be the owner of the previously begun transaction or an error will occur.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwDisposition</td><td>Action to be taken on the reader. The disposition action is not currently used in this release.<ul>
<li><a class="el" href="pcsclite_8h.html#acf43bd7f99fbd970f331fc36ffbe8ca5">SCARD_LEAVE_CARD</a> - Do nothing.</li>
<li><a class="el" href="pcsclite_8h.html#a07feb710d597835d1afc5cfd2ef6ecef">SCARD_RESET_CARD</a> - Reset the card.</li>
<li><a class="el" href="pcsclite_8h.html#a6f4f7f74e35ab4269f08381c967ee97b">SCARD_UNPOWER_CARD</a> - Unpower the card.</li>
<li><a class="el" href="pcsclite_8h.html#a6d6346c6e1a1491965bb9ebe8ed02a95">SCARD_EJECT_CARD</a> - Eject the card.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid value for <code>dwDisposition</code> (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_SHARING_VIOLATION</td><td>Someone else has exclusive rights (<a class="el" href="pcsclite_8h.html#a81cd3fc9e7e84c66be2471294152235f">SCARD_E_SHARING_VIOLATION</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 rv = <a class="code" href="group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861" title="Establishes a temporary exclusive access mode for doing a serie of commands in a transaction.">SCardBeginTransaction</a>(hCard);
 ...
 / * Do some transmit commands * /
 ...
 rv = <a class="code" href="group__API.html#gae8742473b404363e5c587f570d7e2f3b" title="Ends a previously begun transaction.">SCardEndTransaction</a>(hCard, <a class="code" href="pcsclite_8h.html#acf43bd7f99fbd970f331fc36ffbe8ca5" title="Do nothing on close.">SCARD_LEAVE_CARD</a>);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l01267">1267</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00034">pubReaderStatesList::cardAtr</a>, <a class="el" href="eventhandler_8h_source.html#l00035">pubReaderStatesList::cardAtrLength</a>, <a class="el" href="eventhandler_8h_source.html#l00036">pubReaderStatesList::cardProtocol</a>, <a class="el" href="winscard__clnt_8c_source.html#l00301">_psContextMap::dwClientID</a>, <a class="el" href="ifdhandler_8h_source.html#l00321">IFD_POWER_DOWN</a>, <a class="el" href="ifdhandler_8h_source.html#l00320">IFD_POWER_UP</a>, <a class="el" href="ifdhandler_8h_source.html#l00322">IFD_RESET</a>, <a class="el" href="ifdwrapper_8c_source.html#l00247">IFDPowerICC()</a>, <a class="el" href="pcsclite_8h_source.html#l00208">MAX_BUFFER_SIZE</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="winscard__clnt_8c_source.html#l00303">_psContextMap::mMutex</a>, <a class="el" href="eventhandler_8h_source.html#l00031">pubReaderStatesList::readerState</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="pcsclite_8h_source.html#l00169">SCARD_ABSENT</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00166">SCARD_EJECT_CARD</a>, <a class="el" href="winscard__msg_8h_source.html#l00062">SCARD_END_TRANSACTION</a>, <a class="el" href="pcsclite_8h_source.html#l00163">SCARD_LEAVE_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00173">SCARD_NEGOTIABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00172">SCARD_POWERED</a>, <a class="el" href="pcsclite_8h_source.html#l00170">SCARD_PRESENT</a>, <a class="el" href="pcsclite_8h_source.html#l00150">SCARD_PROTOCOL_UNDEFINED</a>, <a class="el" href="pcscd_8h_source.html#l00022">SCARD_RESET</a>, <a class="el" href="pcsclite_8h_source.html#l00164">SCARD_RESET_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcsclite_8h_source.html#l00171">SCARD_SWALLOWED</a>, <a class="el" href="pcsclite_8h_source.html#l00165">SCARD_UNPOWER_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00136">SCARD_W_REMOVED_CARD</a>, <a class="el" href="readerfactory_8h_source.html#l00104">ReaderContext::slot</a>, and <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gae8742473b404363e5c587f570d7e2f3b_cgraph.png" border="0" usemap="#group__API_gae8742473b404363e5c587f570d7e2f3b_cgraph" alt=""/></div>
<map name="group__API_gae8742473b404363e5c587f570d7e2f3b_cgraph" id="group__API_gae8742473b404363e5c587f570d7e2f3b_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#a5a891c2a91b2cce4f950fe6d466ea9a2" title="Power up/down or reset&#39;s an ICC located in the IFD." alt="" coords="241,32,345,61"/><area shape="rect" id="node11" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="232,85,355,115"/><area shape="rect" id="node13" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="207,139,380,168"/><area shape="rect" id="node17" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="244,192,343,221"/><area shape="rect" id="node5" href="group__IFDHandler.html#gae6e70f53c76e9dab59164b2af8e9edfc" title="This function controls the power and reset signals of the smart card reader at the particular reader/..." alt="" coords="429,5,544,35"/><area shape="rect" id="node7" href="ifdwrapper_8c.html#a53f77b110a7765f683e0629aad54772e" title="Provide statistical information about the IFD and ICC including insertions, atr, powering status/etc..." alt="" coords="433,59,540,88"/><area shape="rect" id="node9" href="group__IFDHandler.html#gac0ef46f09df179c44a82259468bea174" title="This function returns the status of the card inserted in the reader/slot specified by Lun..." alt="" coords="592,59,725,88"/><area shape="rect" id="node15" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="435,139,539,168"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="gaa1b8970169fd4883a6dc4a8f43f19b67"></a><!-- doxytag: member="winscard_clnt.c::SCardEstablishContext" ref="gaa1b8970169fd4883a6dc4a8f43f19b67" args="(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardEstablishContext </td>
          <td>(</td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwScope</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCVOID&#160;</td>
          <td class="paramname"><em>pvReserved1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCVOID&#160;</td>
          <td class="paramname"><em>pvReserved2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPSCARDCONTEXT&#160;</td>
          <td class="paramname"><em>phContext</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Creates an Application Context to the PC/SC Resource Manager. </p>
<p>This must be the first WinSCard function called in a PC/SC application. Each thread of an application shall use its own SCARDCONTEXT.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">dwScope</td><td>Scope of the establishment. This can either be a local or remote connection.<ul>
<li><a class="el" href="pcsclite_8h.html#a4476ec1c5ae384961f0f059fa28fb1dc">SCARD_SCOPE_USER</a> - Not used.</li>
<li><a class="el" href="pcsclite_8h.html#a82f7392ae7f5e6702940d7fc64854dc2">SCARD_SCOPE_TERMINAL</a> - Not used.</li>
<li><a class="el" href="pcscd_8h.html#a44e87b3c0cca8a029dd654f0432f34e8">SCARD_SCOPE_GLOBAL</a> - Not used.</li>
<li><a class="el" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309">SCARD_SCOPE_SYSTEM</a> - Services on the local machine. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pvReserved1</td><td>Reserved for future use. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pvReserved2</td><td>Reserved for future use. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">phContext</td><td>Returned Application Context.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Connection status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>phContext</code> is null (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid scope type passed (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a> ) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_MEMORY</td><td>There is no free slot to store <code>hContext</code> (<a class="el" href="pcsclite_8h.html#a81694393a1494d5091145734a2f0b36c">SCARD_E_NO_MEMORY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_INTERNAL_ERROR</td><td>An internal consistency check failed (<a class="el" href="pcsclite_8h.html#a081a564acaf166f74592906f7dff2d86">SCARD_F_INTERNAL_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l00443">443</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="pcscd_8h_source.html#l00033">PCSCLITE_SVC_IDENTITY</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcscd_8h_source.html#l00020">SCARD_SCOPE_GLOBAL</a>, <a class="el" href="pcsclite_8h_source.html#l00148">SCARD_SCOPE_SYSTEM</a>, <a class="el" href="pcsclite_8h_source.html#l00147">SCARD_SCOPE_TERMINAL</a>, <a class="el" href="pcsclite_8h_source.html#l00146">SCARD_SCOPE_USER</a>, <a class="el" href="winscard__clnt_8c_source.html#l03584">SCardCheckDaemonAvailability()</a>, <a class="el" href="winscard__clnt_8c_source.html#l00498">SCardEstablishContextTH()</a>, <a class="el" href="winscard__clnt_8c_source.html#l00392">SCardLockThread()</a>, and <a class="el" href="winscard__clnt_8c_source.html#l00402">SCardUnlockThread()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gaa1b8970169fd4883a6dc4a8f43f19b67_cgraph.png" border="0" usemap="#group__API_gaa1b8970169fd4883a6dc4a8f43f19b67_cgraph" alt=""/></div>
<map name="group__API_gaa1b8970169fd4883a6dc4a8f43f19b67_cgraph" id="group__API_gaa1b8970169fd4883a6dc4a8f43f19b67_cgraph">
<area shape="rect" id="node3" href="winscard__clnt_8c.html#aaa02e1f70d68a502cd92ed066c44542f" title="Checks if the server is running." alt="" coords="215,59,423,88"/><area shape="rect" id="node5" href="winscard__clnt_8c.html#aa86f1a8ccfbdbe7c64eea5219c7639e6" title="Creates a communication context to the PC/SC Resource Manager." alt="" coords="231,112,407,141"/><area shape="rect" id="node19" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="256,165,381,195"/><area shape="rect" id="node21" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="249,219,388,248"/><area shape="rect" id="node7" href="winscard__msg_8c.html#a616a7d779449d1dc6a8a5d925d8212b1" title="Prepares a communication channel for the client to talk to the server." alt="" coords="492,5,628,35"/><area shape="rect" id="node9" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="499,59,621,88"/><area shape="rect" id="node11" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="473,112,647,141"/><area shape="rect" id="node15" href="winscard__clnt_8c.html#ac75190d70d571bca9915bef60491534a" title="Functions for managing instances of SCardEstablishContext() These functions keep track of Context han..." alt="" coords="496,165,624,195"/><area shape="rect" id="node17" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="488,219,632,248"/><area shape="rect" id="node13" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="697,112,801,141"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga0522241e3180cb05dfd166e28930e961"></a><!-- doxytag: member="winscard_clnt.c::SCardFreeMemory" ref="ga0522241e3180cb05dfd166e28930e961" args="(SCARDCONTEXT hContext, LPCVOID pvMem)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardFreeMemory </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCVOID&#160;</td>
          <td class="paramname"><em>pvMem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Releases memory that has been returned from the resource manager using the <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> length designator. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pvMem</td><td>pointer to allocated memory</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hContext</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l03000">3000</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga0522241e3180cb05dfd166e28930e961_cgraph.png" border="0" usemap="#group__API_ga0522241e3180cb05dfd166e28930e961_cgraph" alt=""/></div>
<map name="group__API_ga0522241e3180cb05dfd166e28930e961_cgraph" id="group__API_ga0522241e3180cb05dfd166e28930e961_cgraph">
<area shape="rect" id="node3" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="188,59,313,88"/><area shape="rect" id="node5" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="363,5,507,35"/><area shape="rect" id="node7" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="372,59,497,88"/><area shape="rect" id="node9" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="365,112,504,141"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="gaacfec51917255b7a25b94c5104961602"></a><!-- doxytag: member="winscard_clnt.c::SCardGetAttrib" ref="gaacfec51917255b7a25b94c5104961602" args="(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, LPDWORD pcbAttrLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardGetAttrib </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwAttrId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPBYTE&#160;</td>
          <td class="paramname"><em>pbAttr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pcbAttrLen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Get an attribute from the IFD Handler (reader driver). </p>
<p>The list of possible attributes is available in the file <code><a class="el" href="reader_8h.html" title="This keeps a list of defines shared between the driver and the application.">reader.h</a></code>.</p>
<p>If <code>*pcbAttrLen</code> is equal to <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> then the function will allocate itself the needed memory. Use <a class="el" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory()</a> to release it.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwAttrId</td><td>Identifier for the attribute to get.<br/>
 Not all the <code>dwAttrId</code> values listed above may be implemented in the IFD Handler you are using. And some <code>dwAttrId</code> values not listed here may be implemented.<ul>
<li><a class="el" href="reader_8h.html#a2e87e6925548b9fcca3fa0026b82500d">SCARD_ATTR_ASYNC_PROTOCOL_TYPES</a></li>
<li><a class="el" href="reader_8h.html#ae450bada1fa917057610dd0446983784">SCARD_ATTR_ATR_STRING</a></li>
<li><a class="el" href="reader_8h.html#a8c38e24b650a967fbd052bb2a376c492">SCARD_ATTR_CHANNEL_ID</a></li>
<li><a class="el" href="reader_8h.html#a1ae75dff994bb9cede8b48f3c122b048">SCARD_ATTR_CHARACTERISTICS</a></li>
<li><a class="el" href="reader_8h.html#a0684ca7b1180d2f3ed44297005c7f9d4">SCARD_ATTR_CURRENT_BWT</a></li>
<li><a class="el" href="reader_8h.html#a447488ba15bce3e75f62f2c65b052030">SCARD_ATTR_CURRENT_CLK</a></li>
<li><a class="el" href="reader_8h.html#af83058f4dcd2051b74c2e3fc6e02781c">SCARD_ATTR_CURRENT_CWT</a></li>
<li><a class="el" href="reader_8h.html#a7940c3ad5296495fad9aa5e04f58c83b">SCARD_ATTR_CURRENT_D</a></li>
<li><a class="el" href="reader_8h.html#ae6d0cc32ff645d19e9180244c4ef3c81">SCARD_ATTR_CURRENT_EBC_ENCODING</a></li>
<li><a class="el" href="reader_8h.html#aab6a1f84654ddb09d47feab98d2be554">SCARD_ATTR_CURRENT_F</a></li>
<li><a class="el" href="reader_8h.html#afc64b5592340e1cce3479b54dd7560e9">SCARD_ATTR_CURRENT_IFSC</a></li>
<li><a class="el" href="reader_8h.html#a1ec6dd8c482a91b0d0bd9e52e5a383f8">SCARD_ATTR_CURRENT_IFSD</a></li>
<li><a class="el" href="reader_8h.html#a9c6ee3dccc23e924907e3dc2e29a50f6">SCARD_ATTR_CURRENT_IO_STATE</a></li>
<li><a class="el" href="reader_8h.html#aedeec28fe350408eccf5b8c98328aaf8">SCARD_ATTR_CURRENT_N</a></li>
<li><a class="el" href="reader_8h.html#a76c1d362b156a01b284e8169eaabd4fd">SCARD_ATTR_CURRENT_PROTOCOL_TYPE</a></li>
<li><a class="el" href="reader_8h.html#ad50deb32988b5a8168d7a63ebcf463a6">SCARD_ATTR_CURRENT_W</a></li>
<li><a class="el" href="reader_8h.html#afb122c686777ecf51f106bcc88836270">SCARD_ATTR_DEFAULT_CLK</a></li>
<li><a class="el" href="reader_8h.html#aa4e83e4f0024961638da8c8608c1c50e">SCARD_ATTR_DEFAULT_DATA_RATE</a></li>
<li><a class="el" href="reader_8h.html#a362e5f163fda06e0aa6d2964d2a4bbae">SCARD_ATTR_DEVICE_FRIENDLY_NAME</a><br/>
 Implemented by pcsc-lite if the IFD Handler (driver) returns <a class="el" href="ifdhandler_8h.html#a1e29ead07807cd3c5f62844af4f3f6f7">IFD_ERROR_TAG</a>. pcsc-lite then returns the same reader name as returned by <a class="el" href="group__API.html#ga93b07815789b3cf2629d439ecf20f0d9">SCardListReaders</a>.</li>
<li><a class="el" href="reader_8h.html#a9ab15f1b788a302737415a13e1546eae">SCARD_ATTR_DEVICE_IN_USE</a></li>
<li><a class="el" href="reader_8h.html#abd1302e7451b1f101898b9bf7d079a6c">SCARD_ATTR_DEVICE_SYSTEM_NAME</a></li>
<li><a class="el" href="reader_8h.html#a529910b9e28448ee881a55125fc9916f">SCARD_ATTR_DEVICE_UNIT</a></li>
<li><a class="el" href="reader_8h.html#a1a1d31628ec9f49f79d2dda6651658d6">SCARD_ATTR_ESC_AUTHREQUEST</a></li>
<li><a class="el" href="reader_8h.html#a69d8dd84f5f433efbfa6e0fce2a95528">SCARD_ATTR_ESC_CANCEL</a></li>
<li><a class="el" href="reader_8h.html#a55df7896fb65a2a942780d383d815071">SCARD_ATTR_ESC_RESET</a></li>
<li><a class="el" href="reader_8h.html#a5fcd5c979018130c164a64c728f0716d">SCARD_ATTR_EXTENDED_BWT</a></li>
<li><a class="el" href="reader_8h.html#a222400e1955f63c956437e786197dd27">SCARD_ATTR_ICC_INTERFACE_STATUS</a></li>
<li><a class="el" href="reader_8h.html#ae9f8bb5f689263c35c0888bb37f2ca69">SCARD_ATTR_ICC_PRESENCE</a></li>
<li><a class="el" href="reader_8h.html#a2563696a9f7abd40684b46db714bfc8b">SCARD_ATTR_ICC_TYPE_PER_ATR</a></li>
<li><a class="el" href="reader_8h.html#a0a30cd55c56ceeb3f97d8c0c91e68d77">SCARD_ATTR_MAX_CLK</a></li>
<li><a class="el" href="reader_8h.html#a67cd46e2a022ae72ce6dde4b04c950ff">SCARD_ATTR_MAX_DATA_RATE</a></li>
<li><a class="el" href="reader_8h.html#a338aa843f02a567ea406b0c5bd488620">SCARD_ATTR_MAX_IFSD</a></li>
<li><a class="el" href="reader_8h.html#a42ea634deb1ec51e10722b661aa73d01">SCARD_ATTR_MAXINPUT</a></li>
<li><a class="el" href="reader_8h.html#a33c927bbe78a8eab44869c04783ea0d2">SCARD_ATTR_POWER_MGMT_SUPPORT</a></li>
<li><a class="el" href="reader_8h.html#a62d09db2a45663ea726239aeafaac747">SCARD_ATTR_SUPRESS_T1_IFS_REQUEST</a></li>
<li><a class="el" href="reader_8h.html#a2be4573e3c86834b1b35abf66d0053ad">SCARD_ATTR_SYNC_PROTOCOL_TYPES</a></li>
<li><a class="el" href="reader_8h.html#a86eb3bba6a8a463aa0eac4ada7704785">SCARD_ATTR_USER_AUTH_INPUT_DEVICE</a></li>
<li><a class="el" href="reader_8h.html#a60bf2dbb950d448099314aa86c14b2aa">SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE</a></li>
<li><a class="el" href="reader_8h.html#ae1143cec3f4ee0f37dee6cdaf8942e8b">SCARD_ATTR_VENDOR_IFD_SERIAL_NO</a></li>
<li><a class="el" href="reader_8h.html#a5667d6bcd2fb4b0aa5ea43f85a579518">SCARD_ATTR_VENDOR_IFD_TYPE</a></li>
<li><a class="el" href="reader_8h.html#a21105eef90f69895754548688e4b0721">SCARD_ATTR_VENDOR_IFD_VERSION</a></li>
<li><a class="el" href="reader_8h.html#a8c0b0539cf006d7bfef49db7136cda95">SCARD_ATTR_VENDOR_NAME</a> </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pbAttr</td><td>Pointer to a buffer that receives the attribute. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pcbAttrLen</td><td>Length of the <code>pbAttr</code> buffer in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td><code>cbAttrLen</code> is too big (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td>Reader buffer not large enough (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td>A parameter is NULL and should not (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_MEMORY</td><td>Memory allocation failed (<a class="el" href="pcsclite_8h.html#a81694393a1494d5091145734a2f0b36c">SCARD_E_NO_MEMORY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NOT_TRANSACTED</td><td>Data exchange not successful (<a class="el" href="pcsclite_8h.html#ab02a33c2ef61f12a851dfe85c575d7cc">SCARD_E_NOT_TRANSACTED</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> LONG rv;
 <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> pbAtr[<a class="code" href="pcsclite_8h.html#a7ac7915ff6f9baefa66886c98bdbb91e" title="Maximum ATR size.">MAX_ATR_SIZE</a>];
 DWORD dwAtrLen;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#ab58a85ece18f4217fe5372981231d195" title="Raw active protocol.">SCARD_PROTOCOL_RAW</a>, &amp;hCard, &amp;dwActiveProtocol);
 dwAtrLen = <span class="keyword">sizeof</span>(pbAtr);
 rv = <a class="code" href="group__API.html#gaacfec51917255b7a25b94c5104961602" title="Get an attribute from the IFD Handler (reader driver).">SCardGetAttrib</a>(hCard, <a class="code" href="reader_8h.html#ae450bada1fa917057610dd0446983784" title="Answer to reset (ATR) string.">SCARD_ATTR_ATR_STRING</a>, pbAtr, &amp;dwAtrLen);
</pre></div><div class="fragment"><pre class="fragment"> LONG rv;
 <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *pbAttr;
 DWORD dwAttrLen;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#ab58a85ece18f4217fe5372981231d195" title="Raw active protocol.">SCARD_PROTOCOL_RAW</a>, &amp;hCard, &amp;dwActiveProtocol);
 dwAttrLen = <a class="code" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0" title="see SCardFreeMemory()">SCARD_AUTOALLOCATE</a>;
 rv = <a class="code" href="group__API.html#gaacfec51917255b7a25b94c5104961602" title="Get an attribute from the IFD Handler (reader driver).">SCardGetAttrib</a>(hCard, <a class="code" href="reader_8h.html#ae450bada1fa917057610dd0446983784" title="Answer to reset (ATR) string.">SCARD_ATTR_ATR_STRING</a>, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)&amp;pbAttr, &amp;dwAttrLen);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l02454">2454</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="ifdhandler_8h_source.html#l00350">IFD_ERROR_INSUFFICIENT_BUFFER</a>, <a class="el" href="ifdhandler_8h_source.html#l00329">IFD_ERROR_TAG</a>, <a class="el" href="ifdhandler_8h_source.html#l00328">IFD_SUCCESS</a>, <a class="el" href="ifdwrapper_8c_source.html#l00217">IFDGetCapabilities()</a>, <a class="el" href="pcsclite_8h_source.html#l00208">MAX_BUFFER_SIZE</a>, <a class="el" href="eventhandler_8h_source.html#l00029">pubReaderStatesList::readerName</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="reader_8h_source.html#l00090">SCARD_ATTR_DEVICE_FRIENDLY_NAME</a>, <a class="el" href="pcsclite_8h_source.html#l00145">SCARD_AUTOALLOCATE</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00086">SCARD_E_NO_MEMORY</a>, <a class="el" href="pcsclite_8h_source.html#l00102">SCARD_E_NOT_TRANSACTED</a>, <a class="el" href="pcsclite_8h_source.html#l00112">SCARD_E_UNSUPPORTED_FEATURE</a>, <a class="el" href="winscard__msg_8h_source.html#l00069">SCARD_GET_ATTRIB</a>, and <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gaacfec51917255b7a25b94c5104961602_cgraph.png" border="0" usemap="#group__API_gaacfec51917255b7a25b94c5104961602_cgraph" alt=""/></div>
<map name="group__API_gaacfec51917255b7a25b94c5104961602_cgraph" id="group__API_gaacfec51917255b7a25b94c5104961602_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#af9ec3bb9c077c400c6c0bc4b4e19155f" title="Get&#39;s capabilities in the reader." alt="" coords="165,5,299,35"/><area shape="rect" id="node5" href="group__IFDHandler.html#ga799aa26945bbd3f61aaa57107f63ae0b" title="This function should get the slot/card capabilities for a particular slot/card specified by Lun..." alt="" coords="348,5,489,35"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga33247d5d1257d59e55647c3bb717db24"></a><!-- doxytag: member="winscard_clnt.c::SCardGetStatusChange" ref="ga33247d5d1257d59e55647c3bb717db24" args="(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE *rgReaderStates, DWORD cReaders)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardGetStatusChange </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwTimeout</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structSCARD__READERSTATE.html">SCARD_READERSTATE</a> *&#160;</td>
          <td class="paramname"><em>rgReaderStates</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>cReaders</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Blocks execution until the current availability of the cards in a specific set of readers changes. </p>
<p>This function receives a structure or list of structures containing reader names. It then blocks for a change in state to occur for a maximum blocking time of <code>dwTimeout</code> or forever if <a class="el" href="pcsclite_8h.html#aa84a29002ab81c719c0d07bb446296e0">INFINITE</a> is used.</p>
<p>The new event state will be contained in <code>dwEventState</code>. A status change might be a card insertion or removal event, a change in ATR, etc.</p>
<p><code>dwEventState</code> also contains a number of events in the upper 16 bits (<code>dwEventState</code> &amp; 0xFFFF0000). This number of events is incremented for each card insertion or removal in the specified reader. This can be used to detect a card removal/insertion between two calls to <a class="el" href="group__API.html#ga33247d5d1257d59e55647c3bb717db24" title="Blocks execution until the current availability of the cards in a specific set of readers changes...">SCardGetStatusChange()</a></p>
<p>To wait for a reader event (reader added or removed) you may use the special reader name <code>"\\?PnP?\Notification"</code>. If a reader event occurs the state of this reader will change and the bit <a class="el" href="pcsclite_8h.html#abd53085c631a1bade0fb5e974de90d48">SCARD_STATE_CHANGED</a> will be set.</p>
<div class="fragment"><pre class="fragment"> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
   LPCSTR szReader;          <span class="comment">// Reader name</span>
   LPVOID pvUserData;         <span class="comment">// User defined data</span>
   DWORD dwCurrentState;      <span class="comment">// Current state of reader</span>
   DWORD dwEventState;        <span class="comment">// Reader state after a state change</span>
   DWORD cbAtr;               <span class="comment">// ATR Length, usually MAX_ATR_SIZE</span>
   BYTE rgbAtr[<a class="code" href="pcsclite_8h.html#a7ac7915ff6f9baefa66886c98bdbb91e" title="Maximum ATR size.">MAX_ATR_SIZE</a>]; <span class="comment">// ATR Value</span>
 } <a class="code" href="structSCARD__READERSTATE.html">SCARD_READERSTATE</a>;
 ...
 <span class="keyword">typedef</span> <a class="code" href="structSCARD__READERSTATE.html">SCARD_READERSTATE</a> *PSCARD_READERSTATE, **<a class="code" href="structSCARD__READERSTATE.html">LPSCARD_READERSTATE</a>;
 ...
</pre></div><p>Value of <code>dwCurrentState</code> and <code>dwEventState:</code> </p>
<ul>
<li><a class="el" href="pcsclite_8h.html#ae73c6e4ff31781d4358b93bbde952cfe">SCARD_STATE_UNAWARE</a> The application is unaware of the 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.</li>
<li><a class="el" href="pcsclite_8h.html#a0bfdd63120b09223fd4fed4884cbfeec">SCARD_STATE_IGNORE</a> This reader should be ignored</li>
<li><a class="el" href="pcsclite_8h.html#abd53085c631a1bade0fb5e974de90d48">SCARD_STATE_CHANGED</a> There is a difference between the state believed by the application, and the state known by the resource manager. When this bit is set, the application may assume a significant state change has occurred on this reader.</li>
<li><a class="el" href="pcsclite_8h.html#a96ab0fac1bb56525c5f216428e7dd8e7">SCARD_STATE_UNKNOWN</a> The given reader name is not recognized by the resource manager. If this bit is set, then <a class="el" href="pcsclite_8h.html#abd53085c631a1bade0fb5e974de90d48">SCARD_STATE_CHANGED</a> and <a class="el" href="pcsclite_8h.html#a0bfdd63120b09223fd4fed4884cbfeec">SCARD_STATE_IGNORE</a> will also be set</li>
<li><a class="el" href="pcsclite_8h.html#a781e4a27c9512c19935e3addaeaa152f">SCARD_STATE_UNAVAILABLE</a> The actual state of this reader is not available. If this bit is set, then all the following bits are clear.</li>
<li><a class="el" href="pcsclite_8h.html#aadf7badda42d372c2bc56d95a7720535">SCARD_STATE_EMPTY</a> There is no card in the reader. If this bit is set, all the following bits will be clear</li>
<li><a class="el" href="pcsclite_8h.html#a78d2639a9716b6b27f4d516e43470f8f">SCARD_STATE_PRESENT</a> There is a card in the reader</li>
<li><a class="el" href="pcsclite_8h.html#ae371f8ad287d26aceb591537189f962a">SCARD_STATE_EXCLUSIVE</a> The card in the reader is allocated for exclusive use by another application. If this bit is set, <a class="el" href="pcsclite_8h.html#a78d2639a9716b6b27f4d516e43470f8f">SCARD_STATE_PRESENT</a> will also be set.</li>
<li><a class="el" href="pcsclite_8h.html#a56b01a133df54d0ca651b1541a7f11d5">SCARD_STATE_INUSE</a> The card in the reader is in use by one or more other applications, but may be connected to in shared mode. If this bit is set, <a class="el" href="pcsclite_8h.html#a78d2639a9716b6b27f4d516e43470f8f">SCARD_STATE_PRESENT</a> will also be set.</li>
<li><a class="el" href="pcsclite_8h.html#aba849aaf01b436d511218b18d96caf83">SCARD_STATE_MUTE</a> There is an unresponsive card in the reader.</li>
</ul>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwTimeout</td><td>Maximum waiting time (in milliseconds) for status change, zero (or <a class="el" href="pcsclite_8h.html#aa84a29002ab81c719c0d07bb446296e0">INFINITE</a>) for infinite. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">rgReaderStates</td><td>Structures of readers with current states. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cReaders</td><td>Number of structures.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>Server is not running (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>rgReaderStates</code> is NULL and <code>cReaders</code> &gt; 0 (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid States, reader name, etc (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid hContext handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader is unavailable (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_TIMEOUT</td><td>The user-specified timeout value has expired (<a class="el" href="pcsclite_8h.html#aa01265b3f55d4f18cdeb4f9cd736b508">SCARD_E_TIMEOUT</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="structSCARD__READERSTATE.html">SCARD_READERSTATE</a> rgReaderStates[2];
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 ...
 rgReaderStates[0].szReader = <span class="stringliteral">&quot;Reader X&quot;</span>;
 rgReaderStates[0].dwCurrentState = <a class="code" href="pcsclite_8h.html#ae73c6e4ff31781d4358b93bbde952cfe" title="App wants status.">SCARD_STATE_UNAWARE</a>;

 rgReaderStates[1].szReader = <span class="stringliteral">&quot;\\\\?PnP?\\Notification&quot;</span>;
 rgReaderStates[1].dwCurrentState = <a class="code" href="pcsclite_8h.html#ae73c6e4ff31781d4358b93bbde952cfe" title="App wants status.">SCARD_STATE_UNAWARE</a>;
 ...
 rv = <a class="code" href="group__API.html#ga33247d5d1257d59e55647c3bb717db24" title="Blocks execution until the current availability of the cards in a specific set of readers changes...">SCardGetStatusChange</a>(hContext, <a class="code" href="pcsclite_8h.html#aa84a29002ab81c719c0d07bb446296e0" title="Infinite timeout.">INFINITE</a>, rgReaderStates, 2);
 printf(<span class="stringliteral">&quot;reader state: 0x%04X\n&quot;</span>, rgReaderStates[0].dwEventState);
 printf(<span class="stringliteral">&quot;reader state: 0x%04X\n&quot;</span>, rgReaderStates[1].dwEventState);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l01716">1716</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00034">pubReaderStatesList::cardAtr</a>, <a class="el" href="eventhandler_8h_source.html#l00035">pubReaderStatesList::cardAtrLength</a>, <a class="el" href="winscard__msg_8h_source.html#l00074">CMD_STOP_WAITING_READER_STATE_CHANGE</a>, <a class="el" href="winscard__msg_8h_source.html#l00073">CMD_WAIT_READER_STATE_CHANGE</a>, <a class="el" href="eventhandler_8h_source.html#l00030">pubReaderStatesList::eventCounter</a>, <a class="el" href="pcsclite_8h_source.html#l00190">INFINITE</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00159">MessageReceiveTimeout()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="pcsclite_8h_source.html#l00195">PCSCLITE_MAX_READERS_CONTEXTS</a>, <a class="el" href="eventhandler_8h_source.html#l00053">PCSCLITE_SHARING_EXCLUSIVE_CONTEXT</a>, <a class="el" href="eventhandler_8h_source.html#l00049">PCSCLITE_SHARING_LAST_CONTEXT</a>, <a class="el" href="eventhandler_8h_source.html#l00051">PCSCLITE_SHARING_NO_CONTEXT</a>, <a class="el" href="pcscd_8h_source.html#l00036">PCSCLITE_STATUS_POLL_RATE</a>, <a class="el" href="eventhandler_8h_source.html#l00032">pubReaderStatesList::readerSharing</a>, <a class="el" href="eventhandler_8h_source.html#l00031">pubReaderStatesList::readerState</a>, <a class="el" href="pcsclite_8h_source.html#l00169">SCARD_ABSENT</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00090">SCARD_E_TIMEOUT</a>, <a class="el" href="pcsclite_8h_source.html#l00170">SCARD_PRESENT</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcsclite_8h_source.html#l00183">SCARD_STATE_ATRMATCH</a>, <a class="el" href="pcsclite_8h_source.html#l00178">SCARD_STATE_CHANGED</a>, <a class="el" href="pcsclite_8h_source.html#l00181">SCARD_STATE_EMPTY</a>, <a class="el" href="pcsclite_8h_source.html#l00184">SCARD_STATE_EXCLUSIVE</a>, <a class="el" href="pcsclite_8h_source.html#l00177">SCARD_STATE_IGNORE</a>, <a class="el" href="pcsclite_8h_source.html#l00185">SCARD_STATE_INUSE</a>, <a class="el" href="pcsclite_8h_source.html#l00186">SCARD_STATE_MUTE</a>, <a class="el" href="pcsclite_8h_source.html#l00182">SCARD_STATE_PRESENT</a>, <a class="el" href="pcsclite_8h_source.html#l00180">SCARD_STATE_UNAVAILABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00176">SCARD_STATE_UNAWARE</a>, <a class="el" href="pcsclite_8h_source.html#l00179">SCARD_STATE_UNKNOWN</a>, <a class="el" href="pcsclite_8h_source.html#l00171">SCARD_SWALLOWED</a>, <a class="el" href="pcsclite_8h_source.html#l00168">SCARD_UNKNOWN</a>, <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>, <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>, <a class="el" href="utils_8c_source.html#l00106">time_sub()</a>, and <a class="el" href="winscard__msg_8h_source.html#l00088">wait_reader_state_change::timeOut</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga33247d5d1257d59e55647c3bb717db24_cgraph.png" border="0" usemap="#group__API_ga33247d5d1257d59e55647c3bb717db24_cgraph" alt=""/></div>
<map name="group__API_ga33247d5d1257d59e55647c3bb717db24_cgraph" id="group__API_ga33247d5d1257d59e55647c3bb717db24_cgraph">
<area shape="rect" id="node3" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="243,5,365,35"/><area shape="rect" id="node5" href="winscard__msg_8c.html#a882edc5b2e3fe0d8a70a4ffd00d8455c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="219,59,389,88"/><area shape="rect" id="node9" href="utils_8c.html#a470f4ac4abe231a7b3346be4fe455912" title="return the difference (as long int) in µs between 2 struct timeval r = a &#45; b" alt="" coords="508,109,583,139"/><area shape="rect" id="node11" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="217,163,391,192"/><area shape="rect" id="node15" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="241,216,367,245"/><area shape="rect" id="node23" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="255,269,353,299"/><area shape="rect" id="node7" href="winscard__clnt_8c.html#aaa02e1f70d68a502cd92ed066c44542f" title="Checks if the server is running." alt="" coords="441,56,649,85"/><area shape="rect" id="node13" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="493,163,597,192"/><area shape="rect" id="node17" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="473,216,617,245"/><area shape="rect" id="node19" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="483,269,608,299"/><area shape="rect" id="node21" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="476,323,615,352"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga722eb66bcc44d391f700ff9065cc080b"></a><!-- doxytag: member="winscard_clnt.c::SCardIsValidContext" ref="ga722eb66bcc44d391f700ff9065cc080b" args="(SCARDCONTEXT hContext)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardIsValidContext </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Check if a <a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a> is valid. </p>
<p>Call this function to determine whether a smart card context handle is still valid. After a smart card context handle has been set by <a class="el" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext()</a>, it may become not valid if the resource manager service has been shut down.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid Handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga722eb66bcc44d391f700ff9065cc080b" title="Check if a SCARDCONTEXT is valid.">SCardIsValidContext</a>(hContext);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l03258">3258</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga722eb66bcc44d391f700ff9065cc080b_cgraph.png" border="0" usemap="#group__API_ga722eb66bcc44d391f700ff9065cc080b_cgraph" alt=""/></div>
<map name="group__API_ga722eb66bcc44d391f700ff9065cc080b_cgraph" id="group__API_ga722eb66bcc44d391f700ff9065cc080b_cgraph">
<area shape="rect" id="node3" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="201,59,327,88"/><area shape="rect" id="node5" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="376,5,520,35"/><area shape="rect" id="node7" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="385,59,511,88"/><area shape="rect" id="node9" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="379,112,517,141"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga9d970d086d5218e080d0079d63f9d496"></a><!-- doxytag: member="winscard_clnt.c::SCardListReaderGroups" ref="ga9d970d086d5218e080d0079d63f9d496" args="(SCARDCONTEXT hContext, LPSTR mszGroups, LPDWORD pcchGroups)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardListReaderGroups </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPSTR&#160;</td>
          <td class="paramname"><em>mszGroups</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pcchGroups</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a list of currently available reader groups on the system. </p>
<p><code>mszGroups</code> is a pointer to a character string that is allocated by the application. If the application sends <code>mszGroups</code> as NULL then this function will return the size of the buffer needed to allocate in <code>pcchGroups</code>.</p>
<p>The group names is a multi-string and separated by a nul character (<code>'\0'</code>) and ended by a double nul character like <code>"SCard$DefaultReaders\\0Group 2\\0\\0"</code>.</p>
<p>If <code>*pcchGroups</code> is equal to <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> then the function will allocate itself the needed memory. Use <a class="el" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory()</a> to release it.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">mszGroups</td><td>List of groups to list readers. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pcchGroups</td><td>Size of multi-string buffer including NUL's.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td>Reader buffer not large enough (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid Scope Handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>mszGroups</code> is NULL (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_MEMORY</td><td>Memory allocation failed (<a class="el" href="pcsclite_8h.html#a81694393a1494d5091145734a2f0b36c">SCARD_E_NO_MEMORY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LPSTR mszGroups;
 DWORD dwGroups;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga9d970d086d5218e080d0079d63f9d496" title="Returns a list of currently available reader groups on the system.">SCardListReaderGroups</a>(hContext, NULL, &amp;dwGroups);
 mszGroups = malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)*dwGroups);
 rv = <a class="code" href="group__API.html#ga9d970d086d5218e080d0079d63f9d496" title="Returns a list of currently available reader groups on the system.">SCardListReaderGroups</a>(hContext, mszGroups, &amp;dwGroups);
</pre></div><div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LPSTR mszGroups;
 DWORD dwGroups;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 dwGroups = <a class="code" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0" title="see SCardFreeMemory()">SCARD_AUTOALLOCATE</a>;
 rv = <a class="code" href="group__API.html#ga9d970d086d5218e080d0079d63f9d496" title="Returns a list of currently available reader groups on the system.">SCardListReaderGroups</a>(hContext, (LPSTR)&amp;mszGroups, &amp;dwGroups);
 rv = <a class="code" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory</a>(hContext, mszGroups);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l03074">3074</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="pcsclite_8h_source.html#l00145">SCARD_AUTOALLOCATE</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00086">SCARD_E_NO_MEMORY</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga9d970d086d5218e080d0079d63f9d496_cgraph.png" border="0" usemap="#group__API_ga9d970d086d5218e080d0079d63f9d496_cgraph" alt=""/></div>
<map name="group__API_ga9d970d086d5218e080d0079d63f9d496_cgraph" id="group__API_ga9d970d086d5218e080d0079d63f9d496_cgraph">
<area shape="rect" id="node3" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="220,59,345,88"/><area shape="rect" id="node5" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="395,5,539,35"/><area shape="rect" id="node7" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="404,59,529,88"/><area shape="rect" id="node9" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="397,112,536,141"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga93b07815789b3cf2629d439ecf20f0d9"></a><!-- doxytag: member="winscard_clnt.c::SCardListReaders" ref="ga93b07815789b3cf2629d439ecf20f0d9" args="(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, LPDWORD pcchReaders)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardListReaders </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCSTR&#160;</td>
          <td class="paramname"><em>mszGroups</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPSTR&#160;</td>
          <td class="paramname"><em>mszReaders</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pcchReaders</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>This function returns a list of currently available readers on the system. </p>
<p><code>mszReaders</code> is a pointer to a character string that is allocated by the application. If the application sends <code>mszGroups</code> and <code>mszReaders</code> as NULL then this function will return the size of the buffer needed to allocate in <code>pcchReaders</code>.</p>
<p>If <code>*pcchReaders</code> is equal to <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> then the function will allocate itself the needed memory. Use <a class="el" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory()</a> to release it.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to the PC/SC Resource Manager. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">mszGroups</td><td>List of groups to list readers (not used). </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">mszReaders</td><td>Multi-string with list of readers. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pcchReaders</td><td>Size of multi-string buffer including NULL's.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Connection status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td>Reader buffer not large enough (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid Scope Handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>pcchReaders</code> is NULL (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_MEMORY</td><td>Memory allocation failed (<a class="el" href="pcsclite_8h.html#a81694393a1494d5091145734a2f0b36c">SCARD_E_NO_MEMORY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_READERS_AVAILABLE</td><td>No readers available (<a class="el" href="pcsclite_8h.html#a81b59e9319d3fcd0d957d98781b3ebd2">SCARD_E_NO_READERS_AVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LPSTR mszReaders;
 DWORD dwReaders;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga93b07815789b3cf2629d439ecf20f0d9" title="This function returns a list of currently available readers on the system.">SCardListReaders</a>(hContext, NULL, NULL, &amp;dwReaders);
 mszReaders = malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)*dwReaders);
 rv = <a class="code" href="group__API.html#ga93b07815789b3cf2629d439ecf20f0d9" title="This function returns a list of currently available readers on the system.">SCardListReaders</a>(hContext, NULL, mszReaders, &amp;dwReaders);
</pre></div><div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LPSTR mszReaders;
 DWORD dwReaders;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 dwReaders = <a class="code" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0" title="see SCardFreeMemory()">SCARD_AUTOALLOCATE</a>
 rv = <a class="code" href="group__API.html#ga93b07815789b3cf2629d439ecf20f0d9" title="This function returns a list of currently available readers on the system.">SCardListReaders</a>(hContext, NULL, (LPSTR)&amp;mszReaders, &amp;dwReaders);
 rv = <a class="code" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory</a>(hContext, mszReaders);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l02872">2872</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="pcsclite_8h_source.html#l00195">PCSCLITE_MAX_READERS_CONTEXTS</a>, <a class="el" href="pcsclite_8h_source.html#l00145">SCARD_AUTOALLOCATE</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00086">SCARD_E_NO_MEMORY</a>, <a class="el" href="pcsclite_8h_source.html#l00127">SCARD_E_NO_READERS_AVAILABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga93b07815789b3cf2629d439ecf20f0d9_cgraph.png" border="0" usemap="#group__API_ga93b07815789b3cf2629d439ecf20f0d9_cgraph" alt=""/></div>
<map name="group__API_ga93b07815789b3cf2629d439ecf20f0d9_cgraph" id="group__API_ga93b07815789b3cf2629d439ecf20f0d9_cgraph">
<area shape="rect" id="node3" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="185,59,311,88"/><area shape="rect" id="node5" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="360,5,504,35"/><area shape="rect" id="node7" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="369,59,495,88"/><area shape="rect" id="node9" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="363,112,501,141"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="gad5d4393ca8c470112ad9468c44ed8940"></a><!-- doxytag: member="winscard_clnt.c::SCardReconnect" ref="gad5d4393ca8c470112ad9468c44ed8940" args="(SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardReconnect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwShareMode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwPreferredProtocols</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwInitialization</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pdwActiveProtocol</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reestablishes a connection to a reader that was previously connected to using <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </p>
<p>In a multi application environment it is possible for an application to reset the card in shared mode. When this occurs any other application trying to access certain commands will be returned the value <a class="el" href="pcsclite_8h.html#a20fbb8319646f26c4ad7f237d1a64f0c">SCARD_W_RESET_CARD</a>. When this occurs <a class="el" href="group__API.html#gad5d4393ca8c470112ad9468c44ed8940" title="Reestablishes a connection to a reader that was previously connected to using SCardConnect().">SCardReconnect()</a> must be called in order to acknowledge that the card was reset and allow it to change it's state accordingly.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Handle to a previous call to connect. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwShareMode</td><td>Mode of connection type: exclusive/shared.<ul>
<li><a class="el" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f">SCARD_SHARE_SHARED</a> - This application will allow others to share the reader.</li>
<li><a class="el" href="pcsclite_8h.html#aedc5ddb6c12dd0e9f522d4c669ca9135">SCARD_SHARE_EXCLUSIVE</a> - This application will NOT allow others to share the reader. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwPreferredProtocols</td><td>Desired protocol use.<ul>
<li><a class="el" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c">SCARD_PROTOCOL_T0</a> - Use the T=0 protocol.</li>
<li><a class="el" href="pcsclite_8h.html#a3c09cd155e07044f857130c183d64f03">SCARD_PROTOCOL_T1</a> - Use the T=1 protocol.</li>
<li><a class="el" href="pcsclite_8h.html#ab58a85ece18f4217fe5372981231d195">SCARD_PROTOCOL_RAW</a> - Use with memory type cards. <code>dwPreferredProtocols</code> is a bit mask of acceptable protocols for the connection. You can use (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) if you do not have a preferred protocol. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwInitialization</td><td>Desired action taken on the card/reader.<ul>
<li><a class="el" href="pcsclite_8h.html#acf43bd7f99fbd970f331fc36ffbe8ca5">SCARD_LEAVE_CARD</a> - Do nothing.</li>
<li><a class="el" href="pcsclite_8h.html#a07feb710d597835d1afc5cfd2ef6ecef">SCARD_RESET_CARD</a> - Reset the card (warm reset).</li>
<li><a class="el" href="pcsclite_8h.html#a6f4f7f74e35ab4269f08381c967ee97b">SCARD_UNPOWER_CARD</a> - Unpower the card (cold reset).</li>
<li><a class="el" href="pcsclite_8h.html#a6d6346c6e1a1491965bb9ebe8ed02a95">SCARD_EJECT_CARD</a> - Eject the card. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pdwActiveProtocol</td><td>Established protocol to this connection.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>phContext</code> is null. (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid sharing mode, requested protocol, or reader name (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SMARTCARD</td><td>No smart card present (<a class="el" href="pcsclite_8h.html#aaf69330d6d119872ef76ae81c6b826db">SCARD_E_NO_SMARTCARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NOT_READY</td><td>Could not allocate the desired port (<a class="el" href="pcsclite_8h.html#aad8800bcf34cd97d4a4b0c3fbd3d955e">SCARD_E_NOT_READY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_PROTO_MISMATCH</td><td>Requested protocol is unknown (<a class="el" href="pcsclite_8h.html#a36d821a0458f935ddbe345f10408a988">SCARD_E_PROTO_MISMATCH</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_SHARING_VIOLATION</td><td>Someone else has exclusive rights (<a class="el" href="pcsclite_8h.html#a81cd3fc9e7e84c66be2471294152235f">SCARD_E_SHARING_VIOLATION</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_UNSUPPORTED_FEATURE</td><td>Protocol not supported (<a class="el" href="pcsclite_8h.html#aef39984cd0dd3822088099fffd9d5f96">SCARD_E_UNSUPPORTED_FEATURE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_INTERNAL_ERROR</td><td>An internal consistency check failed (<a class="el" href="pcsclite_8h.html#a081a564acaf166f74592906f7dff2d86">SCARD_F_INTERNAL_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_REMOVED_CARD</td><td>The smart card has been removed (<a class="el" href="pcsclite_8h.html#aa2efd953946973972b1afc5d0343820c">SCARD_W_REMOVED_CARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_UNRESPONSIVE_CARD</td><td>Card is mute (<a class="el" href="pcsclite_8h.html#a359a9e85e3b7c83c76507a096452b74f">SCARD_W_UNRESPONSIVE_CARD</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol, dwSendLength, dwRecvLength;
 LONG rv;
 BYTE pbRecvBuffer[10];
 BYTE pbSendBuffer[] = {0xC0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00};
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 ...
 dwSendLength = <span class="keyword">sizeof</span>(pbSendBuffer);
 dwRecvLength = <span class="keyword">sizeof</span>(pbRecvBuffer);
 rv = <a class="code" href="group__API.html#ga9a2d77242a271310269065e64633ab99" title="Sends an APDU to the smart card contained in the reader connected to by SCardConnect().">SCardTransmit</a>(hCard, <a class="code" href="pcsclite_8h.html#afe9c9747a9359719e1094e2754580a9a" title="protocol control information (PCI) for T=0">SCARD_PCI_T0</a>, pbSendBuffer, dwSendLength,
          &amp;pioRecvPci, pbRecvBuffer, &amp;dwRecvLength);
 / * Card has been reset by another application * /
 <span class="keywordflow">if</span> (rv == <a class="code" href="pcsclite_8h.html#a20fbb8319646f26c4ad7f237d1a64f0c" title="The smart card has been reset, so any shared state information is invalid.">SCARD_W_RESET_CARD</a>)
 {
   rv = <a class="code" href="group__API.html#gad5d4393ca8c470112ad9468c44ed8940" title="Reestablishes a connection to a reader that was previously connected to using SCardConnect().">SCardReconnect</a>(hCard, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>, <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>,
            <a class="code" href="pcsclite_8h.html#a07feb710d597835d1afc5cfd2ef6ecef" title="Reset on close.">SCARD_RESET_CARD</a>, &amp;dwActiveProtocol);
 }
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l00944">944</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00034">pubReaderStatesList::cardAtr</a>, <a class="el" href="eventhandler_8h_source.html#l00035">pubReaderStatesList::cardAtrLength</a>, <a class="el" href="eventhandler_8h_source.html#l00036">pubReaderStatesList::cardProtocol</a>, <a class="el" href="readerfactory_8h_source.html#l00108">ReaderContext::contexts</a>, <a class="el" href="ifdhandler_8h_source.html#l00321">IFD_POWER_DOWN</a>, <a class="el" href="ifdhandler_8h_source.html#l00320">IFD_POWER_UP</a>, <a class="el" href="ifdhandler_8h_source.html#l00322">IFD_RESET</a>, <a class="el" href="ifdwrapper_8c_source.html#l00247">IFDPowerICC()</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="readerfactory_8h_source.html#l00091">ReaderContext::mMutex</a>, <a class="el" href="pcscd_8h_source.html#l00037">PCSCLITE_LOCK_POLL_RATE</a>, <a class="el" href="eventhandler_8h_source.html#l00053">PCSCLITE_SHARING_EXCLUSIVE_CONTEXT</a>, <a class="el" href="eventhandler_8h_source.html#l00049">PCSCLITE_SHARING_LAST_CONTEXT</a>, <a class="el" href="prothandler_8c_source.html#l00054">PHGetAvailableProtocols()</a>, <a class="el" href="prothandler_8c_source.html#l00034">PHGetDefaultProtocol()</a>, <a class="el" href="prothandler_8c_source.html#l00079">PHSetProtocol()</a>, <a class="el" href="eventhandler_8h_source.html#l00032">pubReaderStatesList::readerSharing</a>, <a class="el" href="eventhandler_8h_source.html#l00031">pubReaderStatesList::readerState</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="pcsclite_8h_source.html#l00169">SCARD_ABSENT</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00097">SCARD_E_INVALID_VALUE</a>, <a class="el" href="pcsclite_8h_source.html#l00092">SCARD_E_NO_SMARTCARD</a>, <a class="el" href="pcsclite_8h_source.html#l00095">SCARD_E_PROTO_MISMATCH</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00163">SCARD_LEAVE_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00173">SCARD_NEGOTIABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00172">SCARD_POWERED</a>, <a class="el" href="pcsclite_8h_source.html#l00170">SCARD_PRESENT</a>, <a class="el" href="winscard_8c_source.html#l00171">SCARD_PROTOCOL_ANY_OLD</a>, <a class="el" href="pcsclite_8h_source.html#l00154">SCARD_PROTOCOL_RAW</a>, <a class="el" href="pcsclite_8h_source.html#l00152">SCARD_PROTOCOL_T0</a>, <a class="el" href="pcsclite_8h_source.html#l00153">SCARD_PROTOCOL_T1</a>, <a class="el" href="pcsclite_8h_source.html#l00150">SCARD_PROTOCOL_UNDEFINED</a>, <a class="el" href="winscard__msg_8h_source.html#l00059">SCARD_RECONNECT</a>, <a class="el" href="pcscd_8h_source.html#l00022">SCARD_RESET</a>, <a class="el" href="pcsclite_8h_source.html#l00164">SCARD_RESET_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="pcsclite_8h_source.html#l00161">SCARD_SHARE_DIRECT</a>, <a class="el" href="pcsclite_8h_source.html#l00159">SCARD_SHARE_EXCLUSIVE</a>, <a class="el" href="pcsclite_8h_source.html#l00160">SCARD_SHARE_SHARED</a>, <a class="el" href="pcsclite_8h_source.html#l00171">SCARD_SWALLOWED</a>, <a class="el" href="pcsclite_8h_source.html#l00165">SCARD_UNPOWER_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00136">SCARD_W_REMOVED_CARD</a>, <a class="el" href="pcsclite_8h_source.html#l00133">SCARD_W_UNRESPONSIVE_CARD</a>, and <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_gad5d4393ca8c470112ad9468c44ed8940_cgraph.png" border="0" usemap="#group__API_gad5d4393ca8c470112ad9468c44ed8940_cgraph" alt=""/></div>
<map name="group__API_gad5d4393ca8c470112ad9468c44ed8940_cgraph" id="group__API_gad5d4393ca8c470112ad9468c44ed8940_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#a5a891c2a91b2cce4f950fe6d466ea9a2" title="Power up/down or reset&#39;s an ICC located in the IFD." alt="" coords="212,32,316,61"/><area shape="rect" id="node11" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="203,85,325,115"/><area shape="rect" id="node13" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="177,139,351,168"/><area shape="rect" id="node17" href="prothandler_8c.html#a028195440f572393f25e2daf6d4df05b" title="Get the protocols supported by the card." alt="" coords="179,192,349,221"/><area shape="rect" id="node21" href="prothandler_8c.html#a30e7c843c2a5a626a1df5abe4a116e99" title="Get the default protocol used immediately after reset." alt="" coords="188,245,340,275"/><area shape="rect" id="node24" href="prothandler_8c.html#a4522f0d45b2ab13cf3d264a605eec02d" title="Determine which protocol to use." alt="" coords="209,299,319,328"/><area shape="rect" id="node30" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="215,352,313,381"/><area shape="rect" id="node5" href="group__IFDHandler.html#gae6e70f53c76e9dab59164b2af8e9edfc" title="This function controls the power and reset signals of the smart card reader at the particular reader/..." alt="" coords="400,5,515,35"/><area shape="rect" id="node7" href="ifdwrapper_8c.html#a53f77b110a7765f683e0629aad54772e" title="Provide statistical information about the IFD and ICC including insertions, atr, powering status/etc..." alt="" coords="404,59,511,88"/><area shape="rect" id="node9" href="group__IFDHandler.html#gac0ef46f09df179c44a82259468bea174" title="This function returns the status of the card inserted in the reader/slot specified by Lun..." alt="" coords="591,59,724,88"/><area shape="rect" id="node15" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="405,139,509,168"/><area shape="rect" id="node19" href="atrhandler_8c.html#a76bf3383cc11cc95499325c987d6f193" title="Uncomment the following for ATR debugging or use ." alt="" coords="403,219,512,248"/><area shape="rect" id="node26" href="ifdwrapper_8c.html#ad794bea544918757cd2fbbae218fa458" title="Set the protocol type selection (PTS)." alt="" coords="412,299,503,328"/><area shape="rect" id="node28" href="group__IFDHandler.html#gaa6fc195cb450a147550f4671492257ad" title="This function should set the Protocol Type Selection (PTS) of a particular card/slot using the three ..." alt="" coords="563,299,752,328"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga6aabcba7744c5c9419fdd6404f73a934"></a><!-- doxytag: member="winscard_clnt.c::SCardReleaseContext" ref="ga6aabcba7744c5c9419fdd6404f73a934" args="(SCARDCONTEXT hContext)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardReleaseContext </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd">SCARDCONTEXT</a>&#160;</td>
          <td class="paramname"><em>hContext</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Destroys a communication context to the PC/SC Resource Manager. </p>
<p>This must be the last function called in a PC/SC application.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hContext</td><td>Connection context to be closed.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Connection status. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hContext</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 LONG rv;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga6aabcba7744c5c9419fdd6404f73a934" title="Destroys a communication context to the PC/SC Resource Manager.">SCardReleaseContext</a>(hContext);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l00650">650</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="winscard__msg_8h_source.html#l00056">SCARD_RELEASE_CONTEXT</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="winscard__clnt_8c_source.html#l03372">SCardGetContext()</a>, <a class="el" href="winscard__clnt_8c_source.html#l00392">SCardLockThread()</a>, <a class="el" href="winscard__clnt_8c_source.html#l03409">SCardRemoveContext()</a>, and <a class="el" href="winscard__clnt_8c_source.html#l00402">SCardUnlockThread()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga6aabcba7744c5c9419fdd6404f73a934_cgraph.png" border="0" usemap="#group__API_ga6aabcba7744c5c9419fdd6404f73a934_cgraph" alt=""/></div>
<map name="group__API_ga6aabcba7744c5c9419fdd6404f73a934_cgraph" id="group__API_ga6aabcba7744c5c9419fdd6404f73a934_cgraph">
<area shape="rect" id="node3" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="235,5,357,35"/><area shape="rect" id="node5" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="209,59,383,88"/><area shape="rect" id="node9" href="winscard__clnt_8c.html#a8a3c749483d20ff887797b0879244699" title="Get the index from the Application Context vector _psContextMap for the passed context." alt="" coords="233,165,359,195"/><area shape="rect" id="node13" href="winscard__clnt_8c.html#a1f7e1b05b30f1e5a5cd62b2f925222fe" title="Locks a mutex so another thread must wait to use this function." alt="" coords="441,184,567,213"/><area shape="rect" id="node15" href="winscard__clnt_8c.html#a5dc8cab71db796c9e91329c22f4ebfa1" title="Unlocks a mutex so another thread may use the client." alt="" coords="435,261,573,291"/><area shape="rect" id="node18" href="winscard__clnt_8c.html#a7e3dc878020f1e5ccdae1a6914abd3b0" title="Removes an Application Context from a control vector." alt="" coords="219,112,373,141"/><area shape="rect" id="node7" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="452,59,556,88"/><area shape="rect" id="node11" href="winscard__clnt_8c.html#aafd00ba256e4ba8a81491c970ee336ed" title="Get the address from the Application Context list _psContextMap for the passed context." alt="" coords="432,119,576,148"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga060f0038a4ddfd5dd2b8fadf3c3a2e4f"></a><!-- doxytag: member="winscard_clnt.c::SCardSetAttrib" ref="ga060f0038a4ddfd5dd2b8fadf3c3a2e4f" args="(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardSetAttrib </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>dwAttrId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCBYTE&#160;</td>
          <td class="paramname"><em>pbAttr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>cbAttrLen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set an attribute of the IFD Handler. </p>
<p>The list of attributes you can set is dependent on the IFD Handler you are using.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dwAttrId</td><td>Identifier for the attribute to set. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pbAttr</td><td>Pointer to a buffer that receives the attribute. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cbAttrLen</td><td>Length of the <code>pbAttr</code> buffer in bytes.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td><code>cbAttrLen</code> is too big (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td>A parameter is NULL and should not (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NOT_TRANSACTED</td><td>Data exchange not successful (<a class="el" href="pcsclite_8h.html#ab02a33c2ef61f12a851dfe85c575d7cc">SCARD_E_NOT_TRANSACTED</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> LONG rv;
 <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> pbAttr[] = { 0x12, 0x34, 0x56 };
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#ab58a85ece18f4217fe5372981231d195" title="Raw active protocol.">SCARD_PROTOCOL_RAW</a>, &amp;hCard, &amp;dwActiveProtocol);
 rv = <a class="code" href="group__API.html#ga060f0038a4ddfd5dd2b8fadf3c3a2e4f" title="Set an attribute of the IFD Handler.">SCardSetAttrib</a>(hCard, 0x42000001, pbAttr, <span class="keyword">sizeof</span>(pbAttr));
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l02537">2537</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="ifdhandler_8h_source.html#l00329">IFD_ERROR_TAG</a>, <a class="el" href="ifdhandler_8h_source.html#l00328">IFD_SUCCESS</a>, <a class="el" href="ifdwrapper_8c_source.html#l00186">IFDSetCapabilities()</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00102">SCARD_E_NOT_TRANSACTED</a>, <a class="el" href="pcsclite_8h_source.html#l00112">SCARD_E_UNSUPPORTED_FEATURE</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, and <a class="el" href="winscard__msg_8h_source.html#l00070">SCARD_SET_ATTRIB</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga060f0038a4ddfd5dd2b8fadf3c3a2e4f_cgraph.png" border="0" usemap="#group__API_ga060f0038a4ddfd5dd2b8fadf3c3a2e4f_cgraph" alt=""/></div>
<map name="group__API_ga060f0038a4ddfd5dd2b8fadf3c3a2e4f_cgraph" id="group__API_ga060f0038a4ddfd5dd2b8fadf3c3a2e4f_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#a8cdbfd360837b39967cec4c75834250c" title="Set capabilities in the reader." alt="" coords="167,5,297,35"/><area shape="rect" id="node5" href="group__IFDHandler.html#gab0ae04abb9850ccff194112bacd18fcb" title="This function should set the slot/card capabilities for a particular slot/card specified by Lun..." alt="" coords="348,5,489,35"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga18f33eebb45d9e0d2a091ca7a0511d26"></a><!-- doxytag: member="winscard_clnt.c::SCardStatus" ref="ga18f33eebb45d9e0d2a091ca7a0511d26" args="(SCARDHANDLE hCard, LPSTR mszReaderName, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardStatus </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPSTR&#160;</td>
          <td class="paramname"><em>mszReaderName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pcchReaderLen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pdwState</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pdwProtocol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPBYTE&#160;</td>
          <td class="paramname"><em>pbAtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pcbAtrLen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns the current status of the reader connected to by <code>hCard</code>. </p>
<p>It's friendly name will be stored in <code>szReaderName</code>. <code>pcchReaderLen</code> will be the size of the allocated buffer for <code>szReaderName</code>, while <code>pcbAtrLen</code> will be the size of the allocated buffer for <code>pbAtr</code>. If either of these is too small, the function will return with <a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a> and the necessary size in <code>pcchReaderLen</code> and <code>pcbAtrLen</code>. The current state, and protocol will be stored in pdwState and <code>pdwProtocol</code> respectively.</p>
<p>*pdwState also contains a number of events in the upper 16 bits (*pdwState &amp; 0xFFFF0000). This number of events is incremented for each card insertion or removal in the specified reader. This can be used to detect a card removal/insertion between two calls to <a class="el" href="group__API.html#ga18f33eebb45d9e0d2a091ca7a0511d26" title="Returns the current status of the reader connected to by hCard.">SCardStatus()</a></p>
<p>If <code>*pcchReaderLen</code> is equal to <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> then the function will allocate itself the needed memory for mszReaderName. Use <a class="el" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory()</a> to release it.</p>
<p>If <code>*pcbAtrLen</code> is equal to <a class="el" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0">SCARD_AUTOALLOCATE</a> then the function will allocate itself the needed memory for pbAtr. Use <a class="el" href="group__API.html#ga0522241e3180cb05dfd166e28930e961" title="Releases memory that has been returned from the resource manager using the SCARD_AUTOALLOCATE length ...">SCardFreeMemory()</a> to release it.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">mszReaderName</td><td>Friendly name of this reader. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pcchReaderLen</td><td>Size of the <code>szReaderName</code> multistring. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pdwState</td><td>Current state of this reader. <code>pdwState</code> is a DWORD possibly OR'd with the following values:<ul>
<li><a class="el" href="pcsclite_8h.html#a8108c39f71de4ea806b0a411eb9906ab">SCARD_ABSENT</a> - There is no card in the reader.</li>
<li><a class="el" href="pcsclite_8h.html#a4d99b1aacfcda4e1a36198f5668ae520">SCARD_PRESENT</a> - There is a card in the reader, but it has not been moved into position for use.</li>
<li><a class="el" href="pcsclite_8h.html#a0feed8b3b5ce43d1411359a9b0a3d78c">SCARD_SWALLOWED</a> - There is a card in the reader in position for use. The card is not powered.</li>
<li><a class="el" href="pcsclite_8h.html#a73c52c7df905c748f00b22c88827d65a">SCARD_POWERED</a> - Power is being provided to the card, but the reader driver is unaware of the mode of the card.</li>
<li><a class="el" href="pcsclite_8h.html#af261075b3c31cd33def0d5af9eaed921">SCARD_NEGOTIABLE</a> - The card has been reset and is awaiting PTS negotiation.</li>
<li><a class="el" href="pcsclite_8h.html#af4eb99171c14cab34222d4a4a5d2a5be">SCARD_SPECIFIC</a> - The card has been reset and specific communication protocols have been established. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pdwProtocol</td><td>Current protocol of this reader.<ul>
<li><a class="el" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c">SCARD_PROTOCOL_T0</a> Use the T=0 protocol.</li>
<li><a class="el" href="pcsclite_8h.html#a3c09cd155e07044f857130c183d64f03">SCARD_PROTOCOL_T1</a> Use the T=1 protocol. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pbAtr</td><td>Current ATR of a card in this reader. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pcbAtrLen</td><td>Length of ATR.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td>Not enough allocated memory for <code>szReaderName</code> or for <code>pbAtr</code> (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>pcchReaderLen</code> or <code>pcbAtrLen</code> is NULL (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_MEMORY</td><td>Memory allocation failed (<a class="el" href="pcsclite_8h.html#a81694393a1494d5091145734a2f0b36c">SCARD_E_NO_MEMORY</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_INTERNAL_ERROR</td><td>An internal consistency check failed (<a class="el" href="pcsclite_8h.html#a081a564acaf166f74592906f7dff2d86">SCARD_F_INTERNAL_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_REMOVED_CARD</td><td>The smart card has been removed (<a class="el" href="pcsclite_8h.html#aa2efd953946973972b1afc5d0343820c">SCARD_W_REMOVED_CARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_RESET_CARD</td><td>The smart card has been reset (<a class="el" href="pcsclite_8h.html#a20fbb8319646f26c4ad7f237d1a64f0c">SCARD_W_RESET_CARD</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 DWORD dwState, dwProtocol, dwAtrLen, dwReaderLen;
 BYTE pbAtr[<a class="code" href="pcsclite_8h.html#a7ac7915ff6f9baefa66886c98bdbb91e" title="Maximum ATR size.">MAX_ATR_SIZE</a>];
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 ...
 dwAtrLen = <span class="keyword">sizeof</span>(pbAtr);
 rv = <a class="code" href="group__API.html#ga18f33eebb45d9e0d2a091ca7a0511d26" title="Returns the current status of the reader connected to by hCard.">SCardStatus</a>(hCard, NULL, &amp;dwReaderLen, &amp;dwState, &amp;dwProtocol, pbAtr, &amp;dwAtrLen);
</pre></div><div class="fragment"><pre class="fragment"> <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol;
 DWORD dwState, dwProtocol, dwAtrLen, dwReaderLen;
 BYTE *pbAtr = NULL;
 <span class="keywordtype">char</span> *pcReader = NULL;
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 ...
 dwReaderLen = <a class="code" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0" title="see SCardFreeMemory()">SCARD_AUTOALLOCATE</a>;
 dwAtrLen = <a class="code" href="pcsclite_8h.html#a67db0943aeb13f9f468eaae39b5ff1b0" title="see SCardFreeMemory()">SCARD_AUTOALLOCATE</a>;
 rv = <a class="code" href="group__API.html#ga18f33eebb45d9e0d2a091ca7a0511d26" title="Returns the current status of the reader connected to by hCard.">SCardStatus</a>(hCard, (LPSTR)&amp;pcReader, &amp;dwReaderLen, &amp;dwState,
          &amp;dwProtocol, (LPBYTE)&amp;pbAtr, &amp;dwAtrLen);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l01428">1428</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00035">pubReaderStatesList::cardAtrLength</a>, <a class="el" href="eventhandler_8h_source.html#l00036">pubReaderStatesList::cardProtocol</a>, <a class="el" href="eventhandler_8h_source.html#l00030">pubReaderStatesList::eventCounter</a>, <a class="el" href="pcsclite_8h_source.html#l00038">MAX_ATR_SIZE</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="pcscd_8h_source.html#l00037">PCSCLITE_LOCK_POLL_RATE</a>, <a class="el" href="pcsclite_8h_source.html#l00195">PCSCLITE_MAX_READERS_CONTEXTS</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="pcsclite_8h_source.html#l00145">SCARD_AUTOALLOCATE</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00086">SCARD_E_NO_MEMORY</a>, <a class="el" href="pcsclite_8h_source.html#l00103">SCARD_E_READER_UNAVAILABLE</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00081">SCARD_F_INTERNAL_ERROR</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="winscard__msg_8h_source.html#l00065">SCARD_STATUS</a>, and <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga18f33eebb45d9e0d2a091ca7a0511d26_cgraph.png" border="0" usemap="#group__API_ga18f33eebb45d9e0d2a091ca7a0511d26_cgraph" alt=""/></div>
<map name="group__API_ga18f33eebb45d9e0d2a091ca7a0511d26_cgraph" id="group__API_ga18f33eebb45d9e0d2a091ca7a0511d26_cgraph">
<area shape="rect" id="node3" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="179,5,301,35"/><area shape="rect" id="node5" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="153,59,327,88"/><area shape="rect" id="node9" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="191,112,289,141"/><area shape="rect" id="node7" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="377,59,481,88"/></map>
</div>
</p>

</div>
</div>
<a class="anchor" id="ga9a2d77242a271310269065e64633ab99"></a><!-- doxytag: member="winscard_clnt.c::SCardTransmit" ref="ga9a2d77242a271310269065e64633ab99" args="(SCARDHANDLE hCard, const SCARD_IO_REQUEST *pioSendPci, LPCBYTE pbSendBuffer, DWORD cbSendLength, SCARD_IO_REQUEST *pioRecvPci, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LONG SCardTransmit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5">SCARDHANDLE</a>&#160;</td>
          <td class="paramname"><em>hCard</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structSCARD__IO__REQUEST.html">SCARD_IO_REQUEST</a> *&#160;</td>
          <td class="paramname"><em>pioSendPci</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPCBYTE&#160;</td>
          <td class="paramname"><em>pbSendBuffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">DWORD&#160;</td>
          <td class="paramname"><em>cbSendLength</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structSCARD__IO__REQUEST.html">SCARD_IO_REQUEST</a> *&#160;</td>
          <td class="paramname"><em>pioRecvPci</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPBYTE&#160;</td>
          <td class="paramname"><em>pbRecvBuffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">LPDWORD&#160;</td>
          <td class="paramname"><em>pcbRecvLength</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Sends an APDU to the smart card contained in the reader connected to by <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </p>
<p>The card responds from the APDU and stores this response in <code>pbRecvBuffer</code> and it's length in <code>pcbRecvLength</code>. <code>pioSendPci</code> and <code>pioRecvPci</code> are structures containing the following: </p>
<div class="fragment"><pre class="fragment"> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
    DWORD dwProtocol;    <span class="comment">// SCARD_PROTOCOL_T0 or SCARD_PROTOCOL_T1</span>
    DWORD cbPciLength;   <span class="comment">// Length of this structure - not used</span>
 } <a class="code" href="structSCARD__IO__REQUEST.html" title="Protocol Control Information (PCI)">SCARD_IO_REQUEST</a>;
</pre></div><dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">hCard</td><td>Connection made from <a class="el" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect()</a>. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pioSendPci</td><td>Structure of Protocol Control Information.<ul>
<li><a class="el" href="pcsclite_8h.html#afe9c9747a9359719e1094e2754580a9a">SCARD_PCI_T0</a> - Pre-defined T=0 PCI structure.</li>
<li><a class="el" href="pcsclite_8h.html#ae07c084592ce8e0ae24384d93bd026e7">SCARD_PCI_T1</a> - Pre-defined T=1 PCI structure.</li>
<li><a class="el" href="pcsclite_8h.html#a884ba9fa57faa3e2537b4dafc9fe8b11">SCARD_PCI_RAW</a> - Pre-defined RAW PCI structure. </li>
</ul>
</td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pbSendBuffer</td><td>APDU to send to the card. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cbSendLength</td><td>Length of the APDU. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pioRecvPci</td><td>Structure of protocol information. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">pbRecvBuffer</td><td>Response from the card. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">pcbRecvLength</td><td>Length of the response.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Error code. </dd></dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">SCARD_S_SUCCESS</td><td>Successful (<a class="el" href="pcsclite_8h.html#a4a3c56f69570971d366642a563b34a75">SCARD_S_SUCCESS</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INSUFFICIENT_BUFFER</td><td><code>cbSendLength</code> or <code>cbRecvLength</code> are too big (<a class="el" href="pcsclite_8h.html#aac3f8d945f8a0e667e0926daaa18dc57">SCARD_E_INSUFFICIENT_BUFFER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_HANDLE</td><td>Invalid <code>hCard</code> handle (<a class="el" href="pcsclite_8h.html#a05bdea2f2341e78d920885d1cc357676">SCARD_E_INVALID_HANDLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_PARAMETER</td><td><code>pbSendBuffer</code> or <code>pbRecvBuffer</code> or <code>pcbRecvLength</code> or <code>pioSendPci</code> is null (<a class="el" href="pcsclite_8h.html#a47a6da10ec4ea2cbebfcc4b2a93d786f">SCARD_E_INVALID_PARAMETER</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_INVALID_VALUE</td><td>Invalid Protocol, reader name, etc (<a class="el" href="pcsclite_8h.html#a9ece9fd9e68e4f802e16e951f8f2a642">SCARD_E_INVALID_VALUE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NO_SERVICE</td><td>The server is not runing (<a class="el" href="pcsclite_8h.html#ad4729ab109ff490285d2ad881c04bee8">SCARD_E_NO_SERVICE</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_NOT_TRANSACTED</td><td>APDU exchange not successful (<a class="el" href="pcsclite_8h.html#ab02a33c2ef61f12a851dfe85c575d7cc">SCARD_E_NOT_TRANSACTED</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_PROTO_MISMATCH</td><td>Connect protocol is different than desired (<a class="el" href="pcsclite_8h.html#a36d821a0458f935ddbe345f10408a988">SCARD_E_PROTO_MISMATCH</a>) </td></tr>
    <tr><td class="paramname">SCARD_E_READER_UNAVAILABLE</td><td>The reader has been removed (<a class="el" href="pcsclite_8h.html#ad70bc694ffdf40c3b494d9239160d69d">SCARD_E_READER_UNAVAILABLE</a>) </td></tr>
    <tr><td class="paramname">SCARD_F_COMM_ERROR</td><td>An internal communications error has been detected (<a class="el" href="pcsclite_8h.html#a93d3cf468d69423eab1d478a7a870408">SCARD_F_COMM_ERROR</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_RESET_CARD</td><td>The card has been reset by another application (<a class="el" href="pcsclite_8h.html#a20fbb8319646f26c4ad7f237d1a64f0c">SCARD_W_RESET_CARD</a>) </td></tr>
    <tr><td class="paramname">SCARD_W_REMOVED_CARD</td><td>The card has been removed from the reader (<a class="el" href="pcsclite_8h.html#aa2efd953946973972b1afc5d0343820c">SCARD_W_REMOVED_CARD</a>)</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> LONG rv;
 <a class="code" href="pcsclite_8h.html#a22530ffaff18b5d3e32260a5f1ce4abd" title="hContext returned by SCardEstablishContext()">SCARDCONTEXT</a> hContext;
 <a class="code" href="pcsclite_8h.html#af328aca3e11de737ecd771bcf1f75fb5" title="hCard returned by SCardConnect()">SCARDHANDLE</a> hCard;
 DWORD dwActiveProtocol, dwSendLength, dwRecvLength;
 <a class="code" href="structSCARD__IO__REQUEST.html" title="Protocol Control Information (PCI)">SCARD_IO_REQUEST</a> pioRecvPci;
 BYTE pbRecvBuffer[10];
 BYTE pbSendBuffer[] = { 0xC0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 };
 ...
 rv = <a class="code" href="group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67" title="Creates an Application Context to the PC/SC Resource Manager.">SCardEstablishContext</a>(<a class="code" href="pcsclite_8h.html#a01ffeed2d7fac470371c79fa86b1e309" title="Scope in system.">SCARD_SCOPE_SYSTEM</a>, NULL, NULL, &amp;hContext);
 rv = <a class="code" href="group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5" title="Establishes a connection to the reader specified in * szReader.">SCardConnect</a>(hContext, <span class="stringliteral">&quot;Reader X&quot;</span>, <a class="code" href="pcsclite_8h.html#a724a33782fe519553f1e05ee77940f6f" title="Shared mode only.">SCARD_SHARE_SHARED</a>,
          <a class="code" href="pcsclite_8h.html#a4fe95267c322c3bf35f30fab6b25526c" title="T=0 active protocol.">SCARD_PROTOCOL_T0</a>, &amp;hCard, &amp;dwActiveProtocol);
 dwSendLength = <span class="keyword">sizeof</span>(pbSendBuffer);
 dwRecvLength = <span class="keyword">sizeof</span>(pbRecvBuffer);
 rv = <a class="code" href="group__API.html#ga9a2d77242a271310269065e64633ab99" title="Sends an APDU to the smart card contained in the reader connected to by SCardConnect().">SCardTransmit</a>(hCard, <a class="code" href="pcsclite_8h.html#afe9c9747a9359719e1094e2754580a9a" title="protocol control information (PCI) for T=0">SCARD_PCI_T0</a>, pbSendBuffer, dwSendLength,
          &amp;pioRecvPci, pbRecvBuffer, &amp;dwRecvLength);
</pre></div> 
<p>Definition at line <a class="el" href="winscard__clnt_8c_source.html#l02697">2697</a> of file <a class="el" href="winscard__clnt_8c_source.html">winscard_clnt.c</a>.</p>

<p>References <a class="el" href="eventhandler_8h_source.html#l00036">pubReaderStatesList::cardProtocol</a>, <a class="el" href="pcsclite_8h_source.html#l00061">SCARD_IO_REQUEST::cbPciLength</a>, <a class="el" href="winscard__clnt_8c_source.html#l00301">_psContextMap::dwClientID</a>, <a class="el" href="pcsclite_8h_source.html#l00060">SCARD_IO_REQUEST::dwProtocol</a>, <a class="el" href="ifdwrapper_8c_source.html#l00484">IFDTransmit()</a>, <a class="el" href="pcsclite_8h_source.html#l00209">MAX_BUFFER_SIZE_EXTENDED</a>, <a class="el" href="winscard__msg_8c_source.html#l00415">MessageReceive()</a>, <a class="el" href="winscard__msg_8c_source.html#l00317">MessageSend()</a>, <a class="el" href="winscard__msg_8c_source.html#l00281">MessageSendWithHeader()</a>, <a class="el" href="winscard__clnt_8c_source.html#l00303">_psContextMap::mMutex</a>, <a class="el" href="pcscd_8h_source.html#l00037">PCSCLITE_LOCK_POLL_RATE</a>, <a class="el" href="eventhandler_8h_source.html#l00031">pubReaderStatesList::readerState</a>, <a class="el" href="readerfactory_8h_source.html#l00114">ReaderContext::readerState</a>, <a class="el" href="pcsclite_8h_source.html#l00169">SCARD_ABSENT</a>, <a class="el" href="pcsclite_8h_source.html#l00088">SCARD_E_INSUFFICIENT_BUFFER</a>, <a class="el" href="pcsclite_8h_source.html#l00083">SCARD_E_INVALID_HANDLE</a>, <a class="el" href="pcsclite_8h_source.html#l00084">SCARD_E_INVALID_PARAMETER</a>, <a class="el" href="pcsclite_8h_source.html#l00092">SCARD_E_NO_SMARTCARD</a>, <a class="el" href="pcsclite_8h_source.html#l00095">SCARD_E_PROTO_MISMATCH</a>, <a class="el" href="pcsclite_8h_source.html#l00091">SCARD_E_SHARING_VIOLATION</a>, <a class="el" href="pcsclite_8h_source.html#l00157">SCARD_PROTOCOL_ANY</a>, <a class="el" href="winscard_8c_source.html#l00171">SCARD_PROTOCOL_ANY_OLD</a>, <a class="el" href="pcsclite_8h_source.html#l00154">SCARD_PROTOCOL_RAW</a>, <a class="el" href="pcsclite_8h_source.html#l00153">SCARD_PROTOCOL_T1</a>, <a class="el" href="pcsclite_8h_source.html#l00080">SCARD_S_SUCCESS</a>, <a class="el" href="winscard__msg_8h_source.html#l00063">SCARD_TRANSMIT</a>, <a class="el" href="sys__unix_8c_source.html#l00062">SYS_USleep()</a>, and <a class="el" href="readerfactory_8h_source.html#l00102">ReaderContext::version</a>.</p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="group__API_ga9a2d77242a271310269065e64633ab99_cgraph.png" border="0" usemap="#group__API_ga9a2d77242a271310269065e64633ab99_cgraph" alt=""/></div>
<map name="group__API_ga9a2d77242a271310269065e64633ab99_cgraph" id="group__API_ga9a2d77242a271310269065e64633ab99_cgraph">
<area shape="rect" id="node3" href="ifdwrapper_8c.html#a5c09051f18604f829349702ed226257e" title="Transmit an APDU to the ICC." alt="" coords="207,5,300,35"/><area shape="rect" id="node7" href="winscard__msg_8c.html#adbb09969d5d410393ae441b9a18c7a0c" title="Called by the Client to get the reponse from the server or vice&#45;versa." alt="" coords="192,59,315,88"/><area shape="rect" id="node9" href="winscard__msg_8c.html#aacd09139ce5667d3b651de29c0d62057" title="Sends a menssage from client to server or vice&#45;versa." alt="" coords="409,136,513,165"/><area shape="rect" id="node11" href="winscard__msg_8c.html#a922f8b35802c2449f80a9bd02a25b05b" title="Wrapper for the MessageSend() function." alt="" coords="167,163,340,192"/><area shape="rect" id="node14" href="sys__generic_8h.html#a910a2c6f5b5a4eadf3213bdfdd0b9bb1" title="Makes the current process sleep for some microseconds." alt="" coords="204,216,303,245"/><area shape="rect" id="node5" href="group__IFDHandler.html#gac86e07f01d11accda93fb80d3935eeed" title="This function performs an APDU exchange with the card/slot specified by Lun." alt="" coords="389,5,533,35"/></map>
</div>
</p>

</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Thu Sep 15 2011 for pcsc-lite by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>