//-------------------------------------------------------
//Coypright (c) 2009,Feitian Technologies Co., Ltd.
//All rights reserved
//Description: sample of getusbinfos for epass3003
//Created Time:20090625
//Author:Allen of ITD
//-------------------------------------------------------
program getusbinfos;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  GetInfos in 'GetInfos.pas',
  pkcs11 in 'pkcs11\pkcs11.pas';

var
  objGetInfos:CGetInfos;
  bRv:Boolean;
  lwdRv:longword;
  info:CK_INFO;
  tokenInfo:CK_TOKEN_INFO;
  slotInfo:CK_SLOT_INFO;
label
  label_end;
begin
  objGetInfos:=CGetInfos.Create;
  WriteLn('************************************************');
  WriteLn('  Delphi sample for epass3003---GetUsbInfos  ');
  WriteLn('************************************************');
  bRv:=objGetInfos.LoadLib();
  if(bRv=false) then begin
    WriteLn('Load library error!');
    goto label_end;
  end
  else begin
    WriteLn;
    WriteLn('Get cryptoki library information');
    lwdRv:=objGetInfos.GetCryptokiInfos(@info);
    if(lwdRv<>CKR_OK) then begin
      WriteLn('Get cryptoki library information error!');
      goto label_end;
    end;
    objGetInfos.ShowCryptokiInfos(@info);
    WriteLn;
    WriteLn('Get slot information');
    lwdRv:=objGetInfos.GetSlotInfos(@slotinfo);
    if(lwdRv<>CKR_OK) then begin
      WriteLn('Get slot information error!');
      goto label_end;
    end;
    objGetInfos.ShowSlotInfo(@slotinfo);
    WriteLn;
    WriteLn('Get token information');
    lwdRv:=objGetInfos.GetTokenInfos(@tokenInfo);
    if(lwdRv<>CKR_OK) then begin
      WriteLn('Get token information error!');
      goto label_end;
    end;
    objGetInfos.ShowTokenInfo(@tokenInfo);
   // objGetInfos.FreeLib();
  end;
label_end:
  objGetInfos.FreeLib();
  objGetInfos.Free;
  ReadLn;
end.
