Article View: borland.public.cppbuilder.nativeapi
Article #11363C++ Builder 6, SmartCard Reader/Writer and JavaCard
From: Marcello Scala
Date: Sun, 15 Feb 2004 12:54
Date: Sun, 15 Feb 2004 12:54
111 lines
3903 bytes
3903 bytes
Hi All.
I have make a simple source to comunicate with a SmartCard Reader and a
JavaCard.
The problem is not an Applet problem because i have tested the JavaCard on
my Developer Tools.
The problem is present only when i want interrogate the card with C++
Builder 6 but my source return an unknown error.
This is my example:
//--------------------------------------------------------------------------
-
#include <vcl.h>
#include <winscard.h>
#pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
SCARDCONTEXT hSC;
LONG lReturn;
SCARDHANDLE hCardHandle;
DWORD dwAP;
short size=12;
char buffer[]={0x00,0xa4,0x08,0x00,0x07,0x01,0x02,0x03,0x04,0x05,0x06,0x01};
// Establish the context.
lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
NULL,
NULL,
&hSC);
if ( SCARD_S_SUCCESS != lReturn )
{
Edit1->Text = "Failed SCardEstablishContext";
exit(1);
}
Edit1->Text = "Success";
lReturn = SCardConnect( hSC,
"Athena ASEDrive IIIe USB 0",
SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&hCardHandle,
&dwAP );
if ( SCARD_S_SUCCESS != lReturn )
{
Label1->Caption = "Not Success";
exit(1);
}
Label1->Caption = "Success";
lReturn = SCardTransmit(hSC,
SCARD_PCI_T0,
buffer,
12,
NULL,
NULL,
NULL );
if ( SCARD_S_SUCCESS != lReturn )
{
Label3->Caption = AnsiString(lReturn);
exit(1);
}
Label3->Caption = "Success";
lReturn = SCardDisconnect(hCardHandle, SCARD_LEAVE_CARD);
if ( SCARD_S_SUCCESS != lReturn )
{
Label1->Caption = "Failed SCardDisconnect";
exit(1);
}
Label2->Caption = "Success";
lReturn = SCardReleaseContext(hSC);
if ( SCARD_S_SUCCESS != lReturn )
Edit2->Text = "Failed SCardReleaseContext";
Edit2->Text = "Success";
}
//--------------------------------------------------------------------------
-
The problem is the return value of SCardTransmit function.
The function return the value "6".
This value is unknown and is not present into "scarderr.h".
Why?
What is the problem?
Thanks
Marcello
Technical Details
Message-ID:
<402f6b4d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nx02.iad01.newshosting.com!newshosting.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a8a0c9acf4359ee0,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-15 04:57:20 PST From: "Marcello Scala" <mscala@emails.it> Newsgroups: borland.public.cppbuilder.nativeapi Subject: C++ Builder 6, SmartCard Reader/Writer and JavaCard Date: Sun, 15 Feb 2004 13:54:57 +0100 Lines: 113 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 82.49.25.194 Message-ID: <402f6b4d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1076849485 82.49.25.194 (15 Feb 2004 04:51:25 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nx02.iad01.newshosting.com!newshosting.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail