Creating Visual FoxPro Dynamic-Link Libraries
A Visual FoxPro dynamic-link library (FLL) is essentially a DLL that contains calls to the Visual FoxPro API. You can create the basic DLL structure in your development environment and then add the Visual FoxPro functions you want to call. The following sections describe example templates for creating FLL templates in C and C++.
Setting Up a Library Template
Each Visual FoxPro FLL library has the same basic structure. You can use a template for the structure so that you need only to add code for your specific library routine.
There are five elements in a Visual FoxPro library template:
#include statement.
Function definition.
The function definition has a void return value and is passed the ParamBlk *parm parameter. For more information about the ParamBlk parameter, see Parameters in External Libraries.
Function code.
FoxInfo structure.
The functions in the FLL interact with Visual FoxPro through the FoxInfo structure. Visual FoxPro uses FoxInfo to determine the function name and the number and type of parameters.
FoxTable structure.
The FoxTable structure is a linked list that keeps track of the FoxInfo structures.
For more information about FoxInfo and FoxTable struct definitions, see the Pro_ext.h file.
You also need the following files:
The Pro_ext.h header file.
You can print this file to see the function declarations, typedefs, and structs used in the Visual FoxPro API.
The Winapims.lib file.
Both of these files are located in the Microsoft Visual FoxPro ..\Samples\API directory.
Sample Templates
For C routines, you can use the following template:
#include <Pro_ext.h>
void Internal_Name(ParamBlk *parm)
{
// Function code goes here.
}
FoxInfo myFoxInfo[] = {
{"FUNC_NAME", (FPFI) Internal_Name, 0, ""},
};
FoxTable _FoxTable = {
(FoxTable *)0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
For C++ routines, you need to declare the FoxTable structure as external in the following template:
#include <Pro_ext.h>
void Internal_Name(ParamBlk *parm)
{
// Function code goes here.
}
FoxInfo myFoxInfo[] = {
{"FUNC_NAME", (FPFI) Internal_Name, 0, ""},
};
extern "C" {
FoxTable _FoxTable = {
(FoxTable *)0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};
}
See Also
Tasks
How to: Add Visual FoxPro API Calls