5

The LA Fox Developer Newsletter
February 1997
Undocumented Functions In
foxtools .fII
Part I
[Ed. Note: This article is the first in a three-part series on foxtools.fll. We’ll be starting out by discussing the supported functions in Part 1, move to the unsupported functions in Part 2, and discuss the Windows Clipboard functions in Part 3. This article may also be downloaded from the LA Fox Website at http://www.mesllc.com/lafox.html.]

Introduction:
These notes describe a FoxPro API library that allows FoxPro programs to call any Windows DLL functions that meet the following requirements:

1 .Take the following arguments: integer, long, float, double, string/buffer. These may be passed by reference or by value.

2.The following return types are supported: integer, long, float, double, string/buffer. These are returned by value only.

A surprising number of Windows API functions meet these criteria. Two FLL functions are used provide this functionality:

RegFn: registers a function and the arguments it takes. CalIFn: calls a registered function.

ReaFn:
RegFn(FunctionName, ArgTypes, RetumType, DLLName) returns FnHandle.

If successful, RegFn returns a number which can be used to reference the function in future calls to CallFn. It returns -1 if the library couldn’t be opened, and will additionally bring up a message box. These cannot be disabled.

The first argument is the name or the ordinal value of the function to be registered.

The second argument is a string of characters which describe what arguments the function will accept. The following values are allowed:
I:
Integer.
L:
Long.
C:
String of characters.
F:
Floating point number.
D:
Double precision floating point number.
Each argument type may be preceeded by an © to indicate that the argument is passed by reference. The default is to pass arguments by value.

The third argument is the return type of the function. The values allowed are the same as given above for the argument except that return by reference is not allowed.
The fourth argument gives the name of the DLL library that contains the function. This is optional if the function name (and not an ordinal number) is supplied in the first argument. In this case to all previously loaded libraries are searched in the reverse order that they were loaded. If the function is not found then the standard Windows libraries are searched (i.e. user.exe, krnl386.exe, and gdi.exe). If the DLL is in one of the usual places, then it doesn’t have to contain the path.

The same function can be registered more than once. This allows functions that take different arguments to be used by declaring them again with different argument types.

Many functions that accept string parameters assign a special meaning to a NULL string. You can pass a NULL pointer to a function expecting a string by passing a 0 in place of the string.

CaIIFn:
CaIIFn(FnNum, Argi, Arg2, ) returns value from FnNum

Takes at least one argument, a function handle from a previous call to RegFn. Must pass as many arguments as were declared when the function was declared or an error occurs.

All arguments must match their declared type as follows:
F, D: must be a floating point number.
I, L: must be an integral number.
C:
must be a string passed by value, or 0 (zero). If 0, a null
pointer is passed.
Returns the value that the function returned, using the type declared by ReturnType in RegFn call.

For More Information About Windows DLLs:
The functionality of this FLL is limited mostly by your imagination and your knowledge of the Windows API. Despite the seemingly stringent restrictions, a surprising amount can be done just using the Windows API alone. Look in the directory .\goodies\foxtools for some example programs that use these functions.

The Windows DLL functions are documented in the books that come with the Windows Software Development Kit. The Win-. dows SDK is also included with Microsoft C/C++ 7.0 and Visual C++. These books are also available separately at many technical bookstores.

A Little More Humor.
A group of chess enthusiasts had checked into a hotel, and were standing in the lobby discussing their recent tournament victories. After about an hour, the manager came out of the office and asked them to disperse. “But why?”, they asked, as they moved off. “Because,” he said, “I can’t stand chess nuts boasting in an open foyer.”
Page 5

5