// ==========================================================================
// Get manufacture and main volume info
// (1) A card has two main info, the first is ATR, and the other is main volume
// (2) ATR is generated automatically when file is created. In general, manufact
//     will write its info into ATR. The max. length of ATR is 15 bytes, and such
//     info can be read by DIC_OPEN.
// (3) The main volume of a card is 16 bytes, and such volume works as a driver name
// (4) DIC_Get will read the ATR or VOLUME info into its buffer, and the return of 
//     Dic_Get is the length of buffer.
// (5) Run GET_CARD_INFO with DIC_Command before DIC_Get.
// ==========================================================================
unit main;

interface

uses
    Windows, Messages, SysUtils,  Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls ,Dic32u;

type
    TForm1 = class(TForm)
    Button1: TButton;
    List: TListBox;
    procedure Button1Click(Sender: TObject);
    private
        { Private declarations }
    public
        { Public declarations }
    end;

var
    Form1: TForm1;

implementation



{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
hDic32: THandle;
str:string;
errcode:Integer;    // error code
num:Integer;	    // number of reader
hic:Integer;        // device handle
i:Integer;
cmddata:array[0..256] of Char;
buffer :array[0..256] of Char;

begin
    List.Items.Clear();


    num := DIC_Find();
    for i:=0 to num-1 do
    begin
	    hic := DIC_Open(i, nil);
		if hic >= 0 then break;		// Find the first ROCKEY
	end;
    if i = num then exit;

    errcode := DIC_Command(hic, GET_CARD_INFO, cmddata);
    DIC_Get(cmddata, ATR, BY_ARRAY, buffer);	// abstract ATR from cmddata to bufferÖÐ
    FmtStr(str,'manufacture info: %s', [buffer]);
    List.Items.Add(str);
    DIC_Get(cmddata, VOLUME, BY_ARRAY, buffer); // abstract main Volume from cmddata to bufferÖÐ
    FmtStr(str,'main volume: %s', [buffer]);
    List.Items.Add(str);

    errcode := DIC_Close(hic);
 
end;
end.


