* ==========================================================================
* ==========================================================================
* Demo: Get Factory Time, Hardware Serial Number, Ship Time, and COS Version 
* Caution: no error check for the sake of briefness and understandability
* Tips:
* (1) Hardware information includes factory time, hardware serial number, ship time 
*     and COS version. Those information have been set before vendeing, user cannot modify
*     them.
*     a) FactoryTime:production time, the time of production by the manufacturer.
*     b) HardSerial: hardware serial number£¬a globally unique identifier
*     c) ShipTime:   device ship time
*     d) COSVersion: COS version of the card
* (2) The following example demonstrates another skill of DIC_Get routine. If the return mode 
*     is BY_VALUE£¬the last parameter can be set to NULL. You may get the parameter from the 
*     return value.
* ==========================================================================
#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
DECLARE integer   DIC_Command  IN DIC32U.dll  integer  hic, integer cmd, string @  cmddata
DECLARE integer   DIC_Get  IN DIC32U.dll  string @  xdata, integer  p1, integer   p2, string @  buffer
DECLARE integer   DIC_Set  IN DIC32U.dll  string @  xdata, integer  p1, integer  p2, integer   p3, string @  buffer


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
cmddata=space(256)
store 0 to  FactoryTime, HardSerial, ShipTime, COSVersion
dimension temp[4]


	num = DIC_Find()
	for i=0 to num-1
		hic = DIC_Open(i, NULL)
		if (hic >= 0) 
		  exit  	&& Stop searching once one is found 
  	  endif
	endfor
	if (i == num) 
	     return
    endif

errcode = DIC_Command(hic, GET_HARDWARE_INFO, @cmddata)
	FactoryTime = DIC_Get(@cmddata, FACTORY_TIME, BY_VALUE, NULL)
	HardSerial = DIC_Get(@cmddata, HARD_SERIAL, BY_VALUE, NULL)
	ShipTime = DIC_Get(@cmddata, SHIP_TIME, BY_VALUE, NULL)
	COSVersion = DIC_Get(@cmddata, COS_VERSION, BY_VALUE, NULL)
	?"FactoryTime   ", FactoryTime 
	?"HardSerial  ", HardSerial 
	?"ShipTime  ", ShipTime 
	for i=1 to 4
	   temp[i]=mod(COSVersion,256)
	   COSVersion=COSVersion/256
	endfor
	?"COSVersion   ",chr(temp[4]) , chr(temp[3]),".",chr(temp[2]), chr(temp[1]) 

	errcode = DIC_Close(hic)  
clear dlls
return 		