SCardListReaderGroupsW function (winscard.h)
The SCardListReaderGroups function provides the list of reader groups that have previously been introduced to the system.
Syntax
LONG SCardListReaderGroupsW(
[in] SCARDCONTEXT hContext,
[out] LPWSTR mszGroups,
[in, out] LPDWORD pcchGroups
);
Parameters
[in] hContext
Handle that identifies the resource manager context for the query. The resource manager context can be set by a previous call to SCardEstablishContext.
If this parameter is set to NULL, the search for reader groups is not limited to any context.
[out] mszGroups
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 NULL, SCardListReaderGroups ignores the buffer length supplied in pcchGroups, writes the length of the buffer that would have been returned if this parameter had not been NULL to pcchGroups, and returns a success code.
[in, out] pcchGroups
Length of the mszGroups buffer in characters, and receives the actual length of the multi-string structure, including all trailing null characters. If the buffer length is specified as SCARD_AUTOALLOCATE, then mszGroups 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.
Return value
This function returns different values depending on whether it succeeds or fails.
Return code | Description |
---|---|
|
SCARD_S_SUCCESS. |
|
An error code. For more information, see Smart Card Return Values. |
Remarks
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.
The SCardListReaderGroups function is a database query function. For more information on other database query functions, see Smart Card Database Query Functions.
Examples
The following example shows listing the reader groups.
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.
// ...
}
Note
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.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | winscard.h |
Library | Winscard.lib |
DLL | Winscard.dll |