* ==========================================================
* This example demonstrate how to find,open,close ROCKEY devices.
* Demonstration for dealing with all founded devices.
* ==========================================================
#include "Dic32_Vfp.h"
clear 
DECLARE integer   DIC_Find IN DIC32U.dll
DECLARE integer   DIC_Open IN DIC32U.dll integer hic, string @  reader_name
DECLARE integer   DIC_Close  IN DIC32U.dll  integer   hic

store 0 to  errcode		   && error code 
store 0 to  num		   && number of founded card reader(s)
store 0 to  hic		   && handle of ROCKEY device.
store 0 to  i
reader_name=space(256)

	?"Find ROCKEY: "
	num = DIC_Find()
	? num
	if (num <= 0)
		?"ROCKEY not found"
		return
	endif 

  for i=0 to num-1
	?"Open ROCKEY"
		hic = DIC_Open(i, @ reader_name)
		if (hic < 0)
			if (hic == SCARD_W_REMOVED_CARD)
				?"IC card not found"
				continue 
			endif
			?"error code : ", hic
			return 
		endif
		? reader_name

	*: ...
	*: you can add other operations here
	*: ...

    ?"Close ROCKEY"
	errcode = DIC_Close(hic)
	if (errcode <> SCARD_S_SUCCESS)
		?"error code : ", errcode
		return
	endif
endfor	
clear dlls
return 	