SCardControl Function
SCardControl Function

The SCardControl function gives you direct control of the reader. You can call it any time after a successful call to SCardConnect and before a successful call to SCardDisconnect. The effect on the state of the reader depends on the control code.

Syntax

LONG WINAPI SCardControl(
  __in   SCARDHANDLE hCard,
  __in   DWORD dwControlCode,
  __in   LPCVOID lpInBuffer,
  __in   DWORD nInBufferSize,
  __out  LPVOID lpOutBuffer,
  __in   DWORD nOutBufferSize,
  __out  LPDWORD lpBytesReturned
);


Parameters

hCard [in]

Reference value returned from SCardConnect.

dwControlCode [in]

Control code for the operation. This value identifies the specific operation to be performed.

lpInBuffer [in]

Pointer to a buffer that contains the data required to perform the operation. This parameter can be NULL if the dwControlCode parameter specifies an operation that does not require input data.

nInBufferSize [in]

Size, in bytes, of the buffer pointed to by lpInBuffer.

lpOutBuffer [out]

Pointer to a buffer that receives the operation's output data. This parameter can be NULL if the dwControlCode parameter specifies an operation that does not produce output data.

nOutBufferSize [in]

Size, in bytes, of the buffer pointed to by lpOutBuffer.

lpBytesReturned [out]

Pointer to a DWORD that receives the size, in bytes, of the data stored into the buffer pointed to by lpOutBuffer.

Return Value

This function returns different values depending on whether it succeeds or fails.

Return codeDescription
Success

SCARD_S_SUCCESS.

Failure

An error code. For more information, see Smart Card Return Values.

 

Remarks

The SCardControl function is a direct card access function. For more information on other direct access functions, see Direct Card Access Functions.

Examples

The following example issues a control code. The example assumes that hCardHandle is a valid handle received from a previous call to SCardConnect and that dwControlCode is a variable of type DWORD previously initialized to a valid control code. This particular control code requires no input data and expects no output data.


lReturn = SCardControl( hCardHandle,
                        dwControlCode,
                        NULL,
                        0,
                        NULL,
                        0,
                        0 );
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardControl\n");

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinscard.h
LibraryWinscard.lib
DLLWinscard.dll

See Also

SCardConnect
SCardDisconnect

Send comments about this topic to Microsoft

Build date: 11/19/2009

© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View