/// Provides the definitions and symbols necessary for an Application or Smart Card Service Provider to access the Smartcard Subsystem from WinSCard.dll.
/// </summary>
publicstaticpartialclassWinSCard
{
/// <summary>
/// Group used when no group name is provided when listing readers. Returns a list of all readers, regardless of what group or groups the
/// <summary>Value used to indicate that memory for a return value should be allocated by the function and freed using <see cref="SCardFreeMemory"/>.</summary>
/// <summary>The <c>SCardAudit</c> function writes event messages to the Windows application log Microsoft-Windows-SmartCard-Audit/Authentication.</summary>
/// <param name="hContext">
/// Handle that identifies the resource manager context. The resource manager context can be set by a previous call to the
/// SCardEstablishContext function. This parameter cannot be <c>NULL</c>.
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This function is not redirected. An application calling the <c>SCardAudit</c> function from within a Remote Desktop session will log
/// the event on the remote system.
/// </para>
/// <para>Examples</para>
/// <para>
/// <code>// hContext was set by a previous call to SCardEstablishContext. lReturn = SCardAudit (hContext, SCARD_AUDIT_CHV_SUCCESS); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardAudit - %x\n", lReturn); // Take appropriate action }</code>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardaudit LONG SCardAudit( [in] SCARDCONTEXT hContext, [in]
/// The <c>SCardEstablishContext</c> function establishes the resource manager context (the scope) within which database operations are performed.
/// </summary>
/// <param name="dwScope">
/// <para>Scope of the resource manager context. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_SCOPE_USER</c></term>
/// <term>Database operations are performed within the domain of the user.</term>
/// </item>
/// <item>
/// <term><c>SCARD_SCOPE_SYSTEM</c></term>
/// <term>
/// Database operations are performed within the domain of the system. The calling application must have appropriate access permissions
/// for any database actions.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="pvReserved1">
/// Reserved for future use and must be <c>NULL</c>. This parameter will allow a suitably privileged management application to act on
/// behalf of another user.
/// </param>
/// <param name="pvReserved2">Reserved for future use and must be <c>NULL</c>.</param>
/// <param name="phContext">
/// A handle to the established resource manager context. This handle can now be supplied to other functions attempting to do work within
/// this context.
/// </param>
/// <returns>
/// <para>If the function succeeds, the function returns SCARD_S_SUCCESS.</para>
/// <para>If the function fails, it returns an error code. For more information, see Smart Card Return Values.</para>
/// </returns>
/// <remarks>
/// <para>
/// The context handle returned by <c>SCardEstablishContext</c> can be used by database query and management functions. For more
/// information, see Smart Card Database Query Functions and Smart Card Database Management Functions.
/// </para>
/// <para>To release an established resource manager context, use SCardReleaseContext.</para>
/// <para>
/// If the client attempts a smart card operation in a remote session, such as a client session running on a terminal server, and the
/// operating system in use does not support smart card redirection, this function returns ERROR_BROKEN_PIPE.
/// </para>
/// <para>Examples</para>
/// <para>The following example establishes a resource manager context.</para>
/// <para>
/// <code>SCARDCONTEXT hSC; LONG lReturn; // Establish the context. lReturn = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &hSC); if ( SCARD_S_SUCCESS != lReturn ) printf("Failed SCardEstablishContext\n"); else { // Use the context as needed. When done, // free the context by calling SCardReleaseContext. // ... }</code>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardestablishcontext LONG SCardEstablishContext( [in] DWORD
/// <para>The <c>SCardIntroduceReader</c> function introduces a new name for an existing smart card reader.</para>
/// <para>
/// <c>Note</c> Smart card readers are automatically introduced to the system; a smart card reader vendor's setup program can also
/// introduce a smart card reader to the system.
/// </para>
/// </summary>
/// <param name="hContext">
/// Handle that identifies the resource manager context. The resource manager context is set by a previous call to SCardEstablishContext.
/// This parameter cannot be <c>NULL</c>.
/// </param>
/// <param name="szReaderName">Display name to be assigned to the reader.</param>
/// <param name="szDeviceName">System name of the smart card reader, for example, "MyReader 01".</param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// All readers installed on the system are automatically introduced by their system name. Typically, <c>SCardIntroduceReader</c> is
/// called only to change the name of an existing reader.
/// </para>
/// <para>
/// The <c>SCardIntroduceReader</c> function is a database management function. For more information on other database management
/// functions, see Smart Card Database Management Functions.
/// </para>
/// <para>To remove a reader, use SCardForgetReader.</para>
/// <para>Examples</para>
/// <para>The following example shows introducing a smart card reader.</para>
/// <para>
/// <code>// This example renames the reader name. // This is a two-step process (first add the new // name, then forget the old name). LPBYTE pbAttr = NULL; DWORD cByte = SCARD_AUTOALLOCATE; LONG lReturn; // Step 1: Add the new reader name. // The device name attribute is a necessary value. // hCardHandle was set by a previous call to SCardConnect. lReturn = SCardGetAttrib(hCardHandle, SCARD_ATTR_DEVICE_SYSTEM_NAME, (LPBYTE)&pbAttr, &cByte); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardGetAttrib\n"); exit(1); // Or other error action } // Add the reader name. // hContext was set earlier by SCardEstablishContext. lReturn = SCardIntroduceReader(hContext, TEXT("My New Reader Name"), (LPCTSTR)pbAttr ); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardIntroduceReader\n"); exit(1); // Or other error action } // Step 2: Forget the old reader name. lReturn = SCardForgetReader(hContext, (LPCTSTR)pbAttr ); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardForgetReader\n"); exit(1); // Or other error action } // Free the memory when done. lReturn = SCardFreeMemory( hContext, pbAttr );</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardIntroduceReader as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardintroducereadera LONG SCardIntroduceReaderA( [in]
/// Unused legacy value. This is an internally managed group that cannot be modified by using any reader group APIs. It is intended to be
/// used for enumeration only.
/// </term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// The <c>SCardIntroduceReaderGroup</c> function is provided for PC/SC specification compatibility. Reader groups are not stored until a
/// reader is added to the group.
/// </para>
/// <para>
/// The <c>SCardIntroduceReaderGroup</c> function is a database management function. For a description of other database management
/// functions, see Smart Card Database Management Functions.
/// </para>
/// <para>To remove a reader group, use SCardForgetReaderGroup.</para>
/// <para>Examples</para>
/// <para>The following example shows introducing a smart card reader group.</para>
/// <para>
/// <code>// Introduce the reader group. // lReturn is of type LONG. // hContext was set by a previous call to SCardEstablishContext. lReturn = SCardIntroduceReaderGroup(hContext, L"MyReaderGroup"); if ( SCARD_S_SUCCESS != lReturn ) printf("Failed SCardIntroduceReaderGroup\n");</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardIntroduceReaderGroup as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardintroducereadergroupa LONG SCardIntroduceReaderGroupA(
/// The <c>SCardListCards</c> function searches the smart card database and provides a list of named cards previously introduced to the
/// system by the user.
/// </para>
/// <para>
/// The caller specifies an ATR string, a set of interface identifiers (GUIDs), or both. If both an ATR string and an identifier array
/// are supplied, the cards returned will match the ATR string supplied and support the interfaces specified.
/// </para>
/// </summary>
/// <param name="hContext">
/// <para>
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
/// </para>
/// <para>If this parameter is set to <c>NULL</c>, the search for cards is not limited to any context.</para>
/// </param>
/// <param name="pbAtr">Address of an ATR string to compare to known cards, or <c>NULL</c> if no ATR matching is to be performed.</param>
/// <param name="rgquidInterfaces">
/// Array of identifiers (GUIDs), or <c>NULL</c> if no interface matching is to be performed. When an array is supplied, a card name will
/// be returned only if all the specified identifiers are supported by the card.
/// </param>
/// <param name="cguidInterfaceCount">
/// Number of entries in the <c>rgguidInterfaces</c> array. If <c>rgguidInterfaces</c> is <c>NULL</c>, then this value is ignored.
/// </param>
/// <param name="mszCards">
/// Multi-string that lists the smart cards found. If this value is <c>NULL</c>, <c>SCardListCards</c> ignores the buffer length supplied
/// in <c>pcchCards</c>, returning the length of the buffer that would have been returned if this parameter had not been <c>NULL</c> to
/// <c>pcchCards</c> and a success code.
/// </param>
/// <param name="pcchCards">
/// Length of the <c>mszCards</c> buffer in characters. Receives the actual length of the multi-string structure, including all trailing
/// <c>null</c> characters. If the buffer length is specified as SCARD_AUTOALLOCATE, then <c>mszCards</c> is converted to a pointer to a
/// byte pointer, and receives the address of a block of memory containing the multi-string structure. This block of memory must be
/// deallocated with SCardFreeMemory.
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This function is not redirected, but calling the function when inside a Remote Desktop session will not result in an error. It only
/// means that the result will be from the remote computer instead of the local computer.
/// </para>
/// <para>To return all smart cards introduced to the subsystem, set <c>pbAtr</c> and <c>rgguidInterfaces</c> to <c>NULL</c>.</para>
/// <para>
/// The <c>SCardListCards</c> function is a database query function. For more information on other database query functions, see Smart
/// Card Database Query Functions.
/// </para>
/// <para>
/// Calling this function should be done outside of a transaction. If an application begins a transaction with the SCardBeginTransaction
/// function and then calls this function, it resets the <c>hCard</c> parameter (of type <c>SCARDHANDLE</c>) of the
/// <c>SCardBeginTransaction</c> function.
/// </para>
/// <para>
/// <c>Windows Server 2008 R2 and Windows 7:</c> Calling this function within a transaction could result in your computer becoming unresponsive.
/// </para>
/// <para><c>Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:</c> Not applicable.</para>
/// <para>Examples</para>
/// <para>The following example shows listing of the smart cards.</para>
/// <para>
/// <code>LPTSTR pmszCards = NULL; LPTSTR pCard; LONG lReturn; DWORD cch = SCARD_AUTOALLOCATE; // Retrieve the list of cards. lReturn = SCardListCards(NULL, NULL, NULL, NULL, (LPTSTR)&pmszCards, &cch ); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardListCards\n"); exit(1); // Or other appropriate error action } // Do something with the multi string of cards. // Output the values. // A double-null terminates the list of values. pCard = pmszCards; while ( '\0' != *pCard ) { // Display the value. printf("%S\n", pCard ); // Advance to the next value. pCard = pCard + wcslen(pCard) + 1; } // Remember to free pmszCards (by calling SCardFreeMemory). // ...</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardListCards as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistcardsa LONG SCardListCardsA( [in] SCARDCONTEXT
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
/// <para>The <c>SCardListInterfaces</c> function provides a list of interfaces supplied by a given card.</para>
/// <para>
/// The caller supplies the name of a smart card previously introduced to the subsystem, and receives the list of interfaces supported by
/// the card.
/// </para>
/// </summary>
/// <param name="hContext">
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to
/// SCardEstablishContext. This parameter cannot be <c>NULL</c>.
/// </param>
/// <param name="szCard">Name of the smart card already introduced to the smart card subsystem.</param>
/// <param name="pguidInterfaces">
/// Array of interface identifiers (GUIDs) that indicate the interfaces supported by the smart card. If this value is <c>NULL</c>,
/// <c>SCardListInterfaces</c> ignores the array length supplied in <c>pcguidInterfaces</c>, returning the size of the array that would
/// have been returned if this parameter had not been <c>NULL</c> to <c>pcguidInterfaces</c> and a success code.
/// </param>
/// <param name="pcguidInterfaces">
/// Size of the <c>pcguidInterfaces</c> array, and receives the actual size of the returned array. If the array size is specified as
/// SCARD_AUTOALLOCATE, then <c>pcguidInterfaces</c> is converted to a pointer to a GUID pointer, and receives the address of a block of
/// memory containing the array. This block of memory must be deallocated with SCardFreeMemory.
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This function is not redirected, but calling the function when attempting a Remote Desktop session will not result in an error. It
/// only means that the result will be from the remote computer instead of the local computer.
/// </para>
/// <para>
/// The <c>SCardListInterfaces</c> function is a database query function. For more information on other database query functions, see
/// Smart Card Database Query Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows listing the interfaces for a smart card.</para>
/// <para>
/// <code>LPGUID pGuids = NULL; LONG lReturn; DWORD cGuid = SCARD_AUTOALLOCATE; // Retrieve the list of interfaces. lReturn = SCardListInterfaces(NULL, (LPCSTR) "MyCard", (LPGUID)&pGuids, &cGuid ); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardListInterfaces\n"); exit(1); // Or other appropriate action } if ( 0 != cGuid ) { // Do something with the array of Guids. // Remember to free pGuids when done (by SCardFreeMemory). // ... }</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardListInterfaces as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistinterfacesa LONG SCardListInterfacesA( [in]
/// <para>The <c>SCardListInterfaces</c> function provides a list of interfaces supplied by a given card.</para>
/// <para>
/// The caller supplies the name of a smart card previously introduced to the subsystem, and receives the list of interfaces supported by
/// the card.
/// </para>
/// </summary>
/// <param name="hContext">
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to
/// SCardEstablishContext. This parameter cannot be <c>NULL</c>.
/// </param>
/// <param name="szCard">Name of the smart card already introduced to the smart card subsystem.</param>
/// <param name="pguidInterfaces">
/// Array of interface identifiers (GUIDs) that indicate the interfaces supported by the smart card. If this value is <c>NULL</c>,
/// <c>SCardListInterfaces</c> ignores the array length supplied in <c>pcguidInterfaces</c>, returning the size of the array that would
/// have been returned if this parameter had not been <c>NULL</c> to <c>pcguidInterfaces</c> and a success code.
/// </param>
/// <param name="pcguidInterfaces">
/// Size of the <c>pcguidInterfaces</c> array, and receives the actual size of the returned array. If the array size is specified as
/// SCARD_AUTOALLOCATE, then <c>pcguidInterfaces</c> is converted to a pointer to a GUID pointer, and receives the address of a block of
/// memory containing the array. This block of memory must be deallocated with SCardFreeMemory.
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This function is not redirected, but calling the function when attempting a Remote Desktop session will not result in an error. It
/// only means that the result will be from the remote computer instead of the local computer.
/// </para>
/// <para>
/// The <c>SCardListInterfaces</c> function is a database query function. For more information on other database query functions, see
/// Smart Card Database Query Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows listing the interfaces for a smart card.</para>
/// <para>
/// <code>LPGUID pGuids = NULL; LONG lReturn; DWORD cGuid = SCARD_AUTOALLOCATE; // Retrieve the list of interfaces. lReturn = SCardListInterfaces(NULL, (LPCSTR) "MyCard", (LPGUID)&pGuids, &cGuid ); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardListInterfaces\n"); exit(1); // Or other appropriate action } if ( 0 != cGuid ) { // Do something with the array of Guids. // Remember to free pGuids when done (by SCardFreeMemory). // ... }</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardListInterfaces as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistinterfacesa LONG SCardListInterfacesA( [in]
/// The <c>SCardListReaderGroups</c> function provides the list of reader groups that have previously been introduced to the system.
/// </summary>
/// <param name="hContext">
/// <para>
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
/// </para>
/// <para>If this parameter is set to <c>NULL</c>, the search for reader groups is not limited to any context.</para>
/// </param>
/// <param name="mszGroups">
/// <para>
/// Multi-string that lists the reader groups defined to the system and available to the current user on the current terminal. If this
/// value is <c>NULL</c>, <c>SCardListReaderGroups</c> ignores the buffer length supplied in <c>pcchGroups</c>, writes the length of the
/// buffer that would have been returned if this parameter had not been <c>NULL</c> to <c>pcchGroups</c>, and returns a success code.
/// Unused legacy value. This is an internally managed group that cannot be modified by using any reader group APIs. It is intended to be
/// used for enumeration only.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="pcchGroups">
/// Length of the <c>mszGroups</c> buffer in characters, and receives the actual length of the multi-string structure, including all
/// trailing <c>null</c> characters. If the buffer length is specified as SCARD_AUTOALLOCATE, then <c>mszGroups</c> is converted to a
/// pointer to a byte pointer, and receives the address of a block of memory containing the multi-string structure. This block of memory
/// must be deallocated with SCardFreeMemory.
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// A group is returned only if it contains at least one reader. This includes the group SCard$DefaultReaders. The group SCard$AllReaders
/// cannot be returned, since it only exists implicitly.
/// </para>
/// <para>
/// The <c>SCardListReaderGroups</c> function is a database query function. For more information on other database query functions, see
/// Smart Card Database Query Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows listing the reader groups.</para>
/// <para>
/// <code>LPTSTR pmszReaderGroups = NULL; LPTSTR pReaderGroup; LONG lReturn; DWORD cch = SCARD_AUTOALLOCATE; // Retrieve the list the reader groups. // hSC was set by a previous call to SCardEstablishContext. lReturn = SCardListReaderGroups(hSC, (LPTSTR)&pmszReaderGroups, &cch ); if ( SCARD_S_SUCCESS != lReturn ) printf("Failed SCardListReaderGroups\n"); else { // Do something with the multi string of reader groups. // Output the values. // A double-null terminates the list of values. pReaderGroup = pmszReaderGroups; while ( '\0' != *pReaderGroup ) { // Display the value. printf("%S\n", pReaderGroup ); // Advance to the next value. pReaderGroup = pReaderGroup + wcslen((wchar_t *) pReaderGroup) + 1; } // Remember to free pmszReaderGroups by a call to SCardFreeMemory. // ... }</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardListReaderGroups as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistreadergroupsa LONG SCardListReaderGroupsA( [in]
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
/// <para>The <c>SCardListReaders</c> function provides the list of readers within a set of named reader groups, eliminating duplicates.</para>
/// <para>
/// The caller supplies a list of reader groups, and receives the list of readers within the named groups. Unrecognized group names are
/// ignored. This function only returns readers within the named groups that are currently attached to the system and available for use.
/// </para>
/// </summary>
/// <param name="hContext">
/// <para>
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
/// </para>
/// <para>If this parameter is set to <c>NULL</c>, the search for readers is not limited to any context.</para>
/// </param>
/// <param name="mszGroups">
/// <para>
/// Names of the reader groups defined to the system, as a multi-string. Use a <c>NULL</c> value to list all readers in the system (that
/// Unused legacy value. This is an internally managed group that cannot be modified by using any reader group APIs. It is intended to be
/// used for enumeration only.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="mszReaders">
/// Multi-string that lists the card readers within the supplied reader groups. If this value is <c>NULL</c>, <c>SCardListReaders</c>
/// ignores the buffer length supplied in <c>pcchReaders</c>, writes the length of the buffer that would have been returned if this
/// parameter had not been <c>NULL</c> to <c>pcchReaders</c>, and returns a success code.
/// </param>
/// <param name="pcchReaders">
/// Length of the <c>mszReaders</c> buffer in characters. This parameter receives the actual length of the multi-string structure,
/// including all trailing <c>null</c> characters. If the buffer length is specified as SCARD_AUTOALLOCATE, then <c>mszReaders</c> is
/// converted to a pointer to a byte pointer, and receives the address of a block of memory containing the multi-string structure. This
/// block of memory must be deallocated with SCardFreeMemory.
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code/value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c> 0 (0x0)</term>
/// <term>SCARD_S_SUCCESS</term>
/// </item>
/// <item>
/// <term><c>Group contains no readers</c> 2148532270 (0x8010002E)</term>
/// <term>SCARD_E_NO_READERS_AVAILABLE</term>
/// </item>
/// <item>
/// <term><c>Specified reader is not currently available for use</c> 2148532247 (0x80100017)</term>
/// <term>SCARD_E_READER_UNAVAILABLE</term>
/// </item>
/// <item>
/// <term><c>Other</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// The <c>SCardListReaders</c> function is a database query function. For more information on other database query functions, see Smart
/// Card Database Query Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows listing the readers.</para>
/// <para>
/// <code>LPTSTR pmszReaders = NULL; LPTSTR pReader; LONG lReturn, lReturn2; DWORD cch = SCARD_AUTOALLOCATE; // Retrieve the list the readers. // hSC was set by a previous call to SCardEstablishContext. lReturn = SCardListReaders(hSC, NULL, (LPTSTR)&pmszReaders, &cch ); switch( lReturn ) { case SCARD_E_NO_READERS_AVAILABLE: printf("Reader is not in groups.\n"); // Take appropriate action. // ... break; case SCARD_S_SUCCESS: // Do something with the multi string of readers. // Output the values. // A double-null terminates the list of values. pReader = pmszReaders; while ( '\0' != *pReader ) { // Display the value. printf("Reader: %S\n", pReader ); // Advance to the next value. pReader = pReader + wcslen((wchar_t *)pReader) + 1; } // Free the memory. lReturn2 = SCardFreeMemory( hSC, pmszReaders ); if ( SCARD_S_SUCCESS != lReturn2 ) printf("Failed SCardFreeMemory\n"); break; default: printf("Failed SCardListReaders\n"); // Take appropriate action. // ... break; }</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardListReaders as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistreadersa LONG SCardListReadersA( [in] SCARDCONTEXT
/// Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
/// The <c>SCardListReadersWithDeviceInstanceId</c> function gets the list of readers that have provided a device instance identifier.
/// This function does not affect the state of the reader.
/// </summary>
/// <param name="hContext">
/// Handle that identifies the resource manager context for the query. You can set the resource manager context by a previous call to the
/// SCardEstablishContext function. This parameter cannot be <c>NULL</c>.
/// </param>
/// <param name="szDeviceInstanceId">
/// Device instance ID of the reader. You can get this value by calling the SCardGetReaderDeviceInstanceId function with the reader name
/// or by calling the SetupDiGetDeviceInstanceId function from the DDK.
/// </param>
/// <param name="mszReaders">
/// A multi-string that contain the smart card readers within the supplied device instance identifier. If this value is <c>NULL</c>, then
/// the function ignores the buffer length supplied in the <c>pcchReaders</c> parameter, writes the length of the buffer that would have
/// been returned if this parameter had not been <c>NULL</c> to <c>pcchReaders</c>, and returns a success code.
/// </param>
/// <param name="pcchReaders">
/// The length, in characters, of the <c>mszReaders</c> buffer. This parameter receives the actual length of the multiple-string
/// structure, including all terminating null characters. If the buffer length is specified as SCARD_AUTOALLOCATE, then <c>mszReaders</c>
/// is converted to a pointer to a byte pointer, and receives the address of a block of memory that contains the multiple-string
/// structure. When you have finished using this memory, deallocated it by using the SCardFreeMemory function.
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// This function is not redirected. Calling the <c>SCardListReadersWithDeviceInstanceId</c> function when inside a Remote Desktop
/// session fails with the SCARD_E_READER_UNAVAILABLE error code.
/// </para>
/// <para>Examples</para>
/// <para>
/// <code> szDeviceInstanceIdcchReaderNameLONG lReturn, lReturn2; LPTSTR pmszReaders = NULL; LPTSTR pReader = NULL;WCHAR DWORD cchReaderName = SCARD_AUTOALLOCATE; // Retrieve the reader<65>s name from it<69>s device instance ID // hContext was set by a previous call to SCardEstablishContext. // szDeviceInstanceId was obtained by calling SetupDiGetDeviceInstanceId lReturn = SCardListReadersWithDeviceInstanceId (hContext, szDeviceInstanceId, (LPTSTR)&pmszReaders, &cchReaderName); switch( lReturn ) { case SCARD_E_NO_READERS_AVAILABLE: printf("No readers have the provided device instance ID.\n"); // Take appropriate action. // ... break; case SCARD_S_SUCCESS: // Do something with the multi string of readers. // Output the values. // A double-null terminates the list of values. pReader = pmszReaders; while ( '\0' != *pReader ) { // Display the value. printf("Reader: %S\n", pReader ); // Advance to the next value. pReader = pReader + wcslen((wchar_t *)pReader) + 1; } // Free the memory. lReturn2 = SCardFreeMemory( hContext, pmszReaders ); if ( SCARD_S_SUCCESS != lReturn2 ) printf("Failed SCardFreeMemory\n"); break; default: printf("Failed SCardListReaders\n"); // Take appropriate action. // ... break;</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardListReadersWithDeviceInstanceId as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias
/// with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistreaderswithdeviceinstanceida LONG
/// The <c>SCardReconnect</c> function reestablishes an existing connection between the calling application and a smart card. This
/// function moves a card handle from direct access to general access, or acknowledges and clears an error condition that is preventing
/// further access to the card.
/// </summary>
/// <param name="hCard">Reference value obtained from a previous call to SCardConnect.</param>
/// <param name="dwShareMode">
/// <para>Flag that indicates whether other applications may form connections to this card.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_SHARE_SHARED</c></term>
/// <term>This application will share this card with other applications.</term>
/// </item>
/// <item>
/// <term><c>SCARD_SHARE_EXCLUSIVE</c></term>
/// <term>This application will not share this card with other applications.</term>
/// </item>
/// </list>
/// </param>
/// <param name="dwPreferredProtocols">
/// <para>Bitmask of acceptable protocols for this connection. Possible values may be combined with the <c>OR</c> operation.</para>
/// <para>
/// The value of this parameter should include the current protocol. Attempting to reconnect with a protocol other than the current
/// protocol will result in an error.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_PROTOCOL_T0</c></term>
/// <term>T=0 is an acceptable protocol.</term>
/// </item>
/// <item>
/// <term><c>SCARD_PROTOCOL_T1</c></term>
/// <term>T=1 is an acceptable protocol.</term>
/// </item>
/// </list>
/// </param>
/// <param name="dwInitialization">
/// <para>Type of initialization that should be performed on the card.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_LEAVE_CARD</c></term>
/// <term>Do not do anything special on reconnect.</term>
/// </item>
/// <item>
/// <term><c>SCARD_RESET_CARD</c></term>
/// <term>Reset the card (Warm Reset).</term>
/// </item>
/// <item>
/// <term><c>SCARD_UNPOWER_CARD</c></term>
/// <term>Power down the card and reset it (Cold Reset).</term>
/// </item>
/// </list>
/// </param>
/// <param name="pdwActiveProtocol">
/// <para>Flag that indicates the established active protocol.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_PROTOCOL_T0</c></term>
/// <term>T=0 is the active protocol.</term>
/// </item>
/// <item>
/// <term><c>SCARD_PROTOCOL_T1</c></term>
/// <term>T=1 is the active protocol.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// <c>SCardReconnect</c> is a smart card and reader access function. For information about other access functions, see Smart Card and
/// Reader Access Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows reestablishing a connection.</para>
/// <para>
/// <code>DWORD dwAP; LONG lReturn; // Reconnect. // hCardHandle was set by a previous call to SCardConnect. lReturn = SCardReconnect(hCardHandle, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, SCARD_LEAVE_CARD, &dwAP ); if ( SCARD_S_SUCCESS != lReturn ) printf("Failed SCardReconnect\n");</code>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardreconnect LONG SCardReconnect( [in] SCARDHANDLE hCard,
/// Unused legacy value. This is an internally managed group that cannot be modified by using any reader group APIs. It is intended to be
/// used for enumeration only.
/// </term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>When the last reader is removed from a group, the group is automatically forgotten.</para>
/// <para>
/// The <c>SCardRemoveReaderFromGroup</c> function is a database management function. For information about other database management
/// functions, see Smart Card Database Management Functions.
/// </para>
/// <para>To add a reader to a reader group, use SCardAddReaderToGroup.</para>
/// <para>Examples</para>
/// <para>The following example shows how to remove a reader from the group.</para>
/// <para>
/// <code>// Remove a reader from the group. // lReturn is of type LONG. // hContext was set by a previous call to SCardEstablishContext. // The group is automatically forgotten if no readers remain in it. lReturn = SCardRemoveReaderFromGroup(hContext, L"MyReader", L"MyReaderGroup"); if ( SCARD_S_SUCCESS != lReturn ) printf("Failed SCardRemoveReaderFromGroup\n");</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardRemoveReaderFromGroup as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardremovereaderfromgroupa LONG SCardRemoveReaderFromGroupA(
/// Suppress sending of T=1 IFSD packet from the reader to the card. (Can be used if the currently inserted card does not support an IFSD request.)
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="pbAttr">Pointer to a buffer that supplies the attribute whose ID is supplied in <c>dwAttrId</c>.</param>
/// <param name="cbAttrLen">Length (in bytes) of the attribute value in the <c>pbAttr</c> buffer.</param>
/// <returns>
/// <para>This function returns different values depending on whether it succeeds or fails.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term><c>Success</c></term>
/// <term>SCARD_S_SUCCESS.</term>
/// </item>
/// <item>
/// <term><c>Failure</c></term>
/// <term>An error code. For more information, see Smart Card Return Values.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// The <c>SCardSetAttrib</c> function is a direct card access function. For information about other direct access functions, see Direct
/// Card Access Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows how to set an attribute.</para>
/// <para>
/// <code>// Set the attribute. // hCardHandle was set by a previous call to SCardConnect. // dwAttrID is a DWORD value, specifying the attribute ID. // pbAttr points to the buffer of the new value. // cByte is the count of bytes in the buffer. lReturn = SCardSetAttrib(hCardHandle, dwAttrID, (LPBYTE)pbAttr, cByte); if ( SCARD_S_SUCCESS != lReturn ) printf("Failed SCardSetAttrib\n");</code>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardsetattrib LONG SCardSetAttrib( [in] SCARDHANDLE hCard,
/// The <c>SCardStatus</c> function provides the current status of a smart card in a reader. You can call it any time after a successful
/// call to SCardConnect and before a successful call to SCardDisconnect. It does not affect the state of the reader or reader driver.
/// </summary>
/// <param name="hCard">Reference value returned from SCardConnect.</param>
/// <param name="mszReaderNames">List of display names (multiple string) by which the currently connected reader is known.</param>
/// <param name="pcchReaderLen">
/// <para>On input, supplies the length of the <c>szReaderName</c> buffer.</para>
/// <para>
/// On output, receives the actual length (in characters) of the reader name list, including the trailing <c>NULL</c> character. If this
/// buffer length is specified as SCARD_AUTOALLOCATE, then <c>szReaderName</c> is converted to a pointer to a byte pointer, and it
/// receives the address of a block of memory that contains the multiple-string structure.
/// </para>
/// </param>
/// <param name="pdwState">
/// <para>Current state of the smart card in the reader. Upon success, it receives one of the following state indicators.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_ABSENT</c></term>
/// <term>There is no card in the reader.</term>
/// </item>
/// <item>
/// <term><c>SCARD_PRESENT</c></term>
/// <term>There is a card in the reader, but it has not been moved into position for use.</term>
/// </item>
/// <item>
/// <term><c>SCARD_SWALLOWED</c></term>
/// <term>There is a card in the reader in position for use. The card is not powered.</term>
/// </item>
/// <item>
/// <term><c>SCARD_POWERED</c></term>
/// <term>Power is being provided to the card, but the reader driver is unaware of the mode of the card.</term>
/// </item>
/// <item>
/// <term><c>SCARD_NEGOTIABLE</c></term>
/// <term>The card has been reset and is awaiting PTS negotiation.</term>
/// </item>
/// <item>
/// <term><c>SCARD_SPECIFIC</c></term>
/// <term>The card has been reset and specific communication protocols have been established.</term>
/// </item>
/// </list>
/// </param>
/// <param name="pdwProtocol">
/// <para>Current protocol, if any. The returned value is meaningful only if the returned value of <c>pdwState</c> is SCARD_SPECIFICMODE.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SCARD_PROTOCOL_RAW</c></term>
/// <term>The Raw Transfer protocol is in use.</term>
/// </item>
/// <item>
/// <term><c>SCARD_PROTOCOL_T0</c></term>
/// <term>The ISO 7816/3 T=0 protocol is in use.</term>
/// </item>
/// <item>
/// <term><c>SCARD_PROTOCOL_T1</c></term>
/// <term>The ISO 7816/3 T=1 protocol is in use.</term>
/// </item>
/// </list>
/// </param>
/// <param name="pbAtr">Pointer to a 32-byte buffer that receives the ATR string from the currently inserted card, if available.</param>
/// <param name="pcbAtrLen">
/// On input, supplies the length of the <c>pbAtr</c> buffer. On output, receives the number of bytes in the ATR string (32 bytes
/// maximum). If this buffer length is specified as SCARD_AUTOALLOCATE, then <c>pbAtr</c> is converted to a pointer to a byte pointer,
/// and it receives the address of a block of memory that contains the multiple-string structure.
/// </param>
/// <returns>
/// <para>If the function successfully provides the current status of a smart card in a reader, the return value is SCARD_S_SUCCESS.</para>
/// <para>If the function fails, it returns an error code. For more information, see Smart Card Return Values.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>SCardStatus</c> function is a smart card and reader access function. For information about other access functions, see Smart
/// Card and Reader Access Functions.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows how to determine the state of the smart card.</para>
/// <para>
/// <code>WCHAR szReader[200]; DWORD cch = 200; BYTE bAttr[32]; DWORD cByte = 32; DWORD dwState, dwProtocol; LONG lReturn; // Determine the status. // hCardHandle was set by an earlier call to SCardConnect. lReturn = SCardStatus(hCardHandle, szReader, &cch, &dwState, &dwProtocol, (LPBYTE)&bAttr, &cByte); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardStatus\n"); exit(1); // or other appropriate action } // Examine retrieved status elements. // Look at the reader name and card state. printf("%S\n", szReader ); switch ( dwState ) { case SCARD_ABSENT: printf("Card absent.\n"); break; case SCARD_PRESENT: printf("Card present.\n"); break; case SCARD_SWALLOWED: printf("Card swallowed.\n"); break; case SCARD_POWERED: printf("Card has power.\n"); break; case SCARD_NEGOTIABLE: printf("Card reset and waiting PTS negotiation.\n"); break; case SCARD_SPECIFIC: printf("Card has specific communication protocols set.\n"); break; default: printf("Unknown or unexpected card state.\n"); break; }</code>
/// </para>
/// <para>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines SCardStatus as an alias which automatically selects the ANSI or Unicode version of this function based
/// on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardstatusa LONG SCardStatusA( [in] SCARDHANDLE hCard, [out]
/// The <c>SCardTransmit</c> function sends a service request to the smart card and expects to receive data back from the card.
/// </summary>
/// <param name="hCard">A reference value returned from the SCardConnect function.</param>
/// <param name="pioSendPci">
/// <para>
/// A pointer to the protocol header structure for the instruction. This buffer is in the format of an SCARD_IO_REQUEST structure,
/// followed by the specific protocol control information (PCI).
/// </para>
/// <para>
/// For the T=0, T=1, and Raw protocols, the PCI structure is constant. The smart card subsystem supplies a global T=0, T=1, or Raw PCI
/// structure, which you can reference by using the symbols SCARD_PCI_T0, SCARD_PCI_T1, and SCARD_PCI_RAW respectively.
/// </para>
/// </param>
/// <param name="pbSendBuffer">
/// <para>A pointer to the actual data to be written to the card.</para>
/// <para>For T=0, the data parameters are placed into the address pointed to by <c>pbSendBuffer</c> according to the following structure:</para>
/// <para>
/// The data sent to the card should immediately follow the send buffer. In the special case where no data is sent to the card and no
/// data is expected in return, <c>bP3</c> is not sent.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Member</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c><c>bCla</c></c></term>
/// <term>The T=0 instruction class.</term>
/// </item>
/// <item>
/// <term><c><c>bIns</c></c></term>
/// <term>An instruction code in the T=0 instruction class.</term>
/// </item>
/// <item>
/// <term><c><c>bP1</c>, <c>bP2</c></c></term>
/// <term>Reference codes that complete the instruction code.</term>
/// </item>
/// <item>
/// <term><c><c>bP3</c></c></term>
/// <term>The number of data bytes to be transmitted during the command, per ISO 7816-4, Section 8.2.1.</term>
/// </item>
/// </list>
/// </param>
/// <param name="cbSendLength">
/// <para>The length, in bytes, of the <c>pbSendBuffer</c> parameter.</para>
/// <para>
/// For T=0, in the special case where no data is sent to the card and no data expected in return, this length must reflect that the
/// <c>bP3</c> member is not being sent; the length should be
/// <code>sizeof(CmdBytes) - sizeof(BYTE)</code>
/// .
/// </para>
/// </param>
/// <param name="pioRecvPci">
/// Pointer to the protocol header structure for the instruction, followed by a buffer in which to receive any returned protocol control
/// information (PCI) specific to the protocol in use. This parameter can be <c>NULL</c> if no PCI is returned.
/// </param>
/// <param name="pbRecvBuffer">
/// <para>Pointer to any data returned from the card.</para>
/// <para>
/// For T=0, the data is immediately followed by the SW1 and SW2 status bytes. If no data is returned from the card, then this buffer
/// will only contain the SW1 and SW2 status bytes.
/// </para>
/// </param>
/// <param name="pcbRecvLength">
/// <para>
/// Supplies the length, in bytes, of the <c>pbRecvBuffer</c> parameter and receives the actual number of bytes received from the smart card.
/// </para>
/// <para>This value cannot be SCARD_AUTOALLOCATE because <c>SCardTransmit</c> does not support SCARD_AUTOALLOCATE.</para>
/// <para>For T=0, the receive buffer must be at least two bytes long to receive the SW1 and SW2 status bytes.</para>
/// </param>
/// <returns>
/// <para>If the function successfully sends a service request to the smart card, the return value is SCARD_S_SUCCESS.</para>
/// <para>If the function fails, it returns an error code. For more information, see Smart Card Return Values.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>SCardTransmit</c> function is a smart card and reader access function. For information about other access functions, see Smart
/// Card and Reader Access Functions.
/// </para>
/// <para>
/// For the T=0 protocol, the data received back are the SW1 and SW2 status codes, possibly preceded by response data. The following
/// paragraphs provide information about the send and receive buffers used to transfer data and issue a command.
/// </para>
/// <para>Examples</para>
/// <para>The following example shows sending a service request to the smart card.</para>
/// <para>
/// <code>// Transmit the request. // lReturn is of type LONG. // hCardHandle was set by a previous call to SCardConnect. // pbSend points to the buffer of bytes to send. // dwSend is the DWORD value for the number of bytes to send. // pbRecv points to the buffer for returned bytes. // dwRecv is the DWORD value for the number of returned bytes. lReturn = SCardTransmit(hCardHandle, SCARD_PCI_T0, pbSend, dwSend, NULL, pbRecv, &dwRecv ); if ( SCARD_S_SUCCESS != lReturn ) { printf("Failed SCardTransmit\n"); exit(1); // or other appropriate error action }</code>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardtransmit LONG SCardTransmit( [in] SCARDHANDLE hCard, [in]
/// <summary>The maximum number of bytes (ANSI version) or characters (Unicode version) in the <c>lpstrCardNames</c> string.</summary>
publicuintnMaxCardNames;
/// <summary>Reserved for future use. Set to <c>NULL</c>. An array of GUIDs that identify the interfaces required.</summary>
publicIntPtrrgguidInterfaces;
/// <summary>Reserved for futures use. Set to <c>NULL</c>. The number of interfaces in the <c>rgguidInterfaces</c> array.</summary>
publicuintcguidInterfaces;
/// <summary>
/// If the card is located, the <c>lpstrRdr</c> buffer contains the name of the reader that contains the located card. The buffer
/// should be at least 256 characters long.
/// </summary>
[MarshalAs(UnmanagedType.LPTStr)]
publicstringlpstrRdr;
/// <summary>
/// The size, in bytes (ANSI version) or characters (Unicode version), of the buffer pointed to by <c>lpstrRdr</c>. If the buffer is
/// too small to contain the reader information, GetOpenCardName returns SCARD_E_NO_MEMORY and the required size of the buffer
/// pointed to by <c>lpstrRdr</c>.
/// </summary>
publicuintnMaxRdr;
/// <summary>
/// If the card is located, the <c>lpstrCard</c> buffer contains the name of the located card. The buffer should be at least 256
/// characters long.
/// </summary>
[MarshalAs(UnmanagedType.LPTStr)]
publicstringlpstrCard;
/// <summary>
/// The size, in bytes (ANSI version) or characters (Unicode version), of the buffer pointed to by <c>lpstrCard</c>. If the buffer is
/// too small to contain the card information, GetOpenCardName returns SCARD_E_NO_MEMORY and the required size of the buffer in <c>nMaxCard</c>.
/// </summary>
publicuintnMaxCard;
/// <summary>
/// A pointer to a string to be placed in the title bar of the dialog box. If this member is <c>NULL</c>, the system uses the default
/// title "Select Card:".
/// </summary>
[MarshalAs(UnmanagedType.LPTStr)]
publicstringlpstrTitle;
/// <summary>
/// <para>
/// A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it sets these flags to indicate the
/// input of the user. This member can be a combination of the following flags.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term><c>SC_DLG_MINIMAL_UI</c></term>
/// <term>
/// Displays the dialog box only if the card being searched for by the calling application is not located and available for use in a
/// reader. This allows the card to be found, connected (either through the internal dialog box mechanism or the user callback
/// functions), and returned to the calling application.
/// </term>
/// </item>
/// <item>
/// <term><c>SC_DLG_NO_UI</c></term>
/// <term>Force no display of the <c>Select Card</c> user interface (UI), regardless of search outcome.</term>
/// </item>
/// <item>
/// <term><c>SC_DLG_FORCE_UI</c></term>
/// <term>Force display of the <c>Select Card</c> UI, regardless of the search outcome.</term>
/// </item>
/// </list>
/// </summary>
publicSC_DLGdwFlags;
/// <summary>A void pointer to user data. This pointer is passed back to the caller on the Connect, Check, and Disconnect routines.</summary>
publicIntPtrpvUserData;
/// <summary>
/// <para>If <c>lpfnConnect</c> is not <c>NULL</c>, the <c>dwShareMode</c> and <c>dwPreferredProtocols</c> members are ignored.</para>
/// <para>
/// If <c>lpfnConnect</c> is <c>NULL</c> and <c>dwShareMode</c> is nonzero, then an internal call is made to SCardConnect that uses
/// <c>dwShareMode</c> and <c>dwPreferredProtocols</c> as the <c>dwShareMode</c> and <c>dwPreferredProtocols</c> parameters. If the
/// connect succeeds, <c>hCardHandle</c> is set to the handle returned by <c>hSCardConnect</c>.
/// </para>
/// <para>If <c>lpfnConnect</c> is <c>NULL</c> and <c>dwShareMode</c> is zero, the dialog box returns <c>hCardHandle</c> as <c>NULL</c>.</para>
/// </summary>
publicSCARD_SHAREdwShareMode;
/// <summary>Used for internal connection as described in <c>dwShareMode</c>.</summary>
publicSCARD_PROTOCOLdwPreferredProtocols;
/// <summary>Returns the actual protocol in use when the dialog box makes a connection to a card.</summary>
publicSCARD_PROTOCOLdwActiveProtocol;
/// <summary>
/// <para>
/// A pointer to the card connect routine of the caller. If the caller needs to perform additional processing to connect to the card,
/// this function pointer is set to the connect function for the user. If the connect function is successful, the card is left
/// connected and initialized, and the card handle is returned.
/// </para>
/// <para>The prototype for the connect routine is as follows.</para>
/// </summary>
publicLPOCNCONNPROClpfnConnect;
/// <summary>
/// <para>A pointer to the card verify routine of the caller. If no special card verification is required, this pointer is <c>NULL</c>.</para>
/// <para>If the card is rejected by the verify routine, <c>FALSE</c> is returned and the card is disconnected, as indicated by <c>lpfnDisconnect</c>.</para>
/// <para>
/// If the card is accepted by the verify routine, <c>TRUE</c> is returned. When the user accepts the card, all other cards currently
/// connected will be disconnected, as indicated by <c>lpfnDisconnect</c>, and this card will be returned as the located card. The
/// located card will remain connected.
/// </para>
/// <para>The prototype for the check routine is as follows.</para>
/// </summary>
publicLPOCNCHKPROClpfnCheck;
/// <summary>
/// <para>A pointer to the card disconnect routine of the caller.</para>
/// <para>The prototype for the disconnect routine is as follows.</para>
/// </summary>
publicLPOCNDSCPROClpfnDisconnect;
/// <summary>
/// <c>Note</c> When using <c>lpfnConnect</c>, <c>lpfnCheck</c>, and <c>lpfnDisconnect</c>, all three callback procedures should be
/// present. Using these callbacks allows further verification that the calling application has found the appropriate card. This is
/// the best way to ensure the appropriate card is selected.
/// </summary>
/// <summary>A handle of the connected card (either through an internal dialog box connect or an <c>lpfnConnect</c> callback).</summary>
publicSCARDHANDLEhCardHandle;
}
/// <summary>
/// The <c>OPENCARDNAME_EX</c> structure contains the information that the SCardUIDlgSelectCard function uses to initialize a smart card
/// <c>Select Card</c> dialog box.
/// </summary>
/// <remarks>
/// <para>Note</para>
/// <para>
/// The winscard.h header defines OPENCARDNAME_EX as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for