* ==========================================================
* This example demonstrate how to find,open,close ROCKEY device.
* it's the most simple demonstrate for operations of a single ROCKEY.
* ==========================================================
#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

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

	?"Open ROCKEY"
	for  i=0  to num-1	
		hic = DIC_Open(i, NULL) 	&& we needn't know the name of card reader£¬set to NULL.
		if (hic >= 0) 
		   exit		&& Stop searching once one is found.
		endif
	endfor
	if (i == num)
		?"Not found any device with card"
		return
	endif

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

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