[The BuildCmd method is available for use in the operating systems specified in the Requirements section. It is not available for use in Windows Server 2003 with Service Pack 1 (SP1) and later, Windows Vista, Windows Server 2008, and subsequent versions of the operating system. The Smart Card Modules provide similar functionality.]
The BuildCmd method constructs a valid command application protocol data unit (APDU) for transmission to a smart card.
Syntax
HRESULT BuildCmd(
[in] BYTE byClassId,
[in] BYTE byInsId,
[in] BYTE byP1,
[in] BYTE byP2,
[in] LPBYTEBUFFER pbyData,
[in] LONG *p1Le
);
Parameters
byClassId [in]
Command class identifier.
byInsId [in]
Command instruction identifier.
byP1 [in]
Command's first parameter.
byP2 [in]
Command's second parameter.
pbyData [in]
Pointer to the data portion of the command.
p1Le [in]
Pointer to a LONG integer containing the expected length of the returned data.
Return value
The method returns one of the following possible values.
| Return code | Description |
|---|---|
| S_OK | Operation completed successfully. |
| E_INVALIDARG | One of the parameters is not valid. |
| E_POINTER | A bad pointer was passed in. |
| E_OUTOFMEMORY | Out of memory. |
Remarks
To encapsulate the command into another command, call Encapsulate.
For a list of all the methods provided by this interface, see ISCardCmd.
In addition to the COM error codes listed above, this interface may return a smart card error code if a smart card function was called to complete the request. For more information, see Smart Card Return Values.
Examples
The following example shows how to construct a command APDU. The example assumes that pISCardCmd is a valid pointer to an instance of the ISCardCmd interface and that pIByteRequest is a valid pointer to an instance of the IByteBuffer interface initialized with a previous call to the IByteBuffer::Initialize method.
LONG lLe = 0;
HRESULT hr;
hr = pISCardCmd->BuildCmd(0x00, // Some cards prefer 0xC0
0xa4, // 'Select File'
0x00,
0x00,
pIByteRequest,
&lLe);
if (FAILED(hr))
{
printf("Failed ISCardCmd::BuildCmd\n");
// Take other error handling action as needed.
}
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows XP [desktop apps only] |
| Minimum supported server | Windows Server 2003 [desktop apps only] |
| End of client support | Windows XP |
| End of server support | Windows Server 2003 |
| Header | Scarddat.h |
| Type library | Scarddat.tlb |
| DLL | Scardssp.dll |
| IID | IID_ISCardCmd is defined as D5778AE3-43DE-11D0-9171-00AA00C18068 |
See also
Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
