* ==========================================================================
* Demo:  Get Zone Code, Agent Code, User Code 1, and User Code 2
* Caution: no error check for the sake of briefness and understandability
* Tips:
* (1) Manage code information includes Zone code, Agent code, User code 1
*     and User code 2. Those information have been set before vendeing, user 
*     cannot modify them.  Those codes are used for management of distribution. 
*	   For developer , the manage code of all ROCKEY devices they got from agent are
*     same, Other developers cannot got ROCKEY devices with the same management code.
*	   Those information is key data to tell whether the dongle is yours.  the "Same-code dangle"
*     means dangle with same management code.
*     a) Zone: Zone code
*     b) Agent:Agent code
*     c) User1:User code 1
*     d) User2:User code 2
* (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  iZone, iAgent, iUser1, iUser2



	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_MANAGER_CODE, @cmddata) 
	iZone = DIC_Get(@cmddata, ZONE, BY_VALUE, NULL) 
	iAgent = DIC_Get(@cmddata, AGENT, BY_VALUE, NULL) 
	iUser1 = DIC_Get(@cmddata, USER1, BY_VALUE, NULL) 
	iUser2 = DIC_Get(@cmddata, USER2, BY_VALUE, NULL) 
	?"Zone code  ", iZone 
	?"Agent code ", iAgent 
	?"User code 1  ", iUser1 
	?"User code 2  ", iUser2 

	errcode = DIC_Close(hic)  
clear dlls
return 	