* ==========================================================================
* Get free space in byte
* ==========================================================================


#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
store 0 to dwFreeSpace


cmddata = space(1024)
buffer = space(1024)


	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

	*Get free space in byte
	errcode = DIC_Command(hic, GETFREESPACE, @cmddata)
	dwFreeSpace=DIC_Get( @cmddata,0,BY_VALUE+4,NULL)
	?"FreeSpace:",dwFreeSpace,"bytes",dwFreeSpace/1024,"k,"
	
	errcode = DIC_Close(hic) 
	
clear dlls
return 	