|
Windows Libraries FATS_W32.DLL / FATSXW32.DLL
The diskette "FATS for Windows 95/NT" contains the dynamic link libraries FATS_W32.DLL (basis version) resp. FATSXW32.DLL (extended version), that must be copied into the system directory of Windows:
COPY FATS?W32.DLL \WINDOWS\SYSTEM
The libraries are exporting the following functions:
Private Declare Function dll_FATSInit Lib "fats_w32.dll" Alias "FATSLibInit"(ByVal nSize As Long, ByVal nAPI As Long) As LongPrivate Declare Function dll_FATSExit Lib "fats_w32.dll" Alias "FATSLibExit" (ByVal lpFatsdata As Long) As Long
Private Declare Function dll_FATSCall Lib "fats_w32.dll" Alias "FATSLibCallA" (ByVal lpCmnd As String, nErrorcode As Long, nKeylen As Long, ByVal lpFatsdata As Long) As Long
Private Declare Sub dll_FATSGetKey Lib "fats_w32.dll" Alias "FATSLibGetKeyA" (ByVal lpFatsKey As String, ByVal lpFatsdata As Long)
The functions dll_FATSInit and dll_FATSExit are not needed when using Visual Basic for 32-Bit systems. They are used by other programming languages to allocate a data area for FATS.
If you need these functions for certain reasons, e.g. with several FATS sessions within one process, then you please read "Using several FATS environments" at the end of this paragraph.
Calling FATS
FATS commands are executed with the function dll_FATSCall:
dwRecno = dll_FATSCall(szCmnd, nErrorcode, nKeylen, 0)
Parameter Usage:
szCmnd Command string (input) nErrorcode Errorcode (output) nKeylen Length of key value (output) 0 Identification of the FATS environment respectively the data area of FATS. At specifying 0 the global memory area of the calling application is used.
To access the key value returned by FATS you have to code the following:
If nKeylen > 0 Then
szFatsKey = Space(nKeylen)
Call dll_FATSGetKey(szFatsKey, 0)
Else
szFatsKey = ""
End If
The dll_FATSCall function does the actual call to FATS and returnes the length of a found key in the nKeylen variable. This value should be used to assign to the key string variable the value SPACE$(nKeylen). Until your application assigns some value to the string variable, it has a length of 0.
The dll_FATSGetKey function copies the key value from the previous FATS call to the key string variable.
Testprograms
The FATS distribution disk for Windows 95/NT contains some test programs in the directory WIN_32I\BASIC\VBWIN that illustrate how you can use the FATS commands in your programs:
tst1_eng.mak Test program for MS-Visual-Basic for Win95/NT tst1_eng.frm (form module) tst1_eng.bas (program module)
The extended version of FATS contains the following additional test programs:
tst2_eng.frm Introduction to the Matchcode Functions mcsort.frm Use of the key-flag with command 'MC'
Using Several FATS Environments
If you want to call FATS by several threads from one application you have to take care that only one thread accesses FATS at the same time.
Therefore FATS offers the following methods:
dwRecno = dll_FATSCall(szCmnd, nErrorcode, nKeylen, 16)
Call dll_FATSGetKey(szFatsKey, 16)
Thereby the FATS environments of the individual threads are absolutely independent, i.e. thread 1 does not have an access to the data area assigned to thread 2.
With the function dll_FATSInit you create a new FATS environment:
lpFatsdata = dll_FATSInit(0,0)
The first parameter determines the size of the FATS data area. If you indicate a zero here, then the minimum needed storage space is reserved (approx. 18-20 KB). The second parameter intends the assigned programming language, for Visual Basic this value must equal to 0. The address of the data area is returned in the variable lpFatsdata.
The memory address returned by dll_FATSInit must be used to specify the FATS environment when calling the functions dll_FATSCall and dll_FATSGetKey:
dwRecno = dll_FATSCall(szCmnd, nErrorcode, nKeylen, lpFatsdata)
Call dll_FATSGetKey(szFatsKey, lpFatsdata)
Before terminating the application program you should release the storage area allocated by dll_FATSInit . You can do this by calling the function dll_FATSExit :
lpFatsdata = dll_FATSExit( lpFatsdata )
© 2008 GCS Software, Udo Gertz