Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a C++ DLL to use with FoxPro
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00048334
Message ID:
00048414
Views:
35
>How do I go about compiling a C program in C++ 5.0 to a DLL so that I can call it in FoxPro? I have the Visual Developer Studio, and I know the basics of C++.

Basically, you can create 2 kinds of DLLs with VC++5: With MFC or without MFC. If you need MFC, chose MFC DLL type app when you create your workspace. The wizard will generate the skeleton for you.

If you don't need MFC, create a simple DLL workspace. This will not generate any code for you, but it's easier. Please note that your source files must have the extension .C, not .CPP. This is important: if you use CPP no error or warning is generated, but the generated DLL cannot be used.

Here you have a very, very simple DLL skeleton code. Anything else you need is straight C language.

Please note that DLL function names are case sensitive, so you must match the case when you test the DLL.

HTH,
Vlad
#include <windows.h>
#define DllExport __declspec( dllexport )

BOOL APIENTRY DllMain( HANDLE hModule, 
                        DWORD ul_reason_for_call, 
                        LPVOID lpReserved )
{
/* Usually, here you must have code that handles ul_reason_for_call.
   Being only a very, very simple example, I don't include it here.
   You can find samples for it in the MS KB. */
    return TRUE;
}

DllExport long SingleSingle( long longParam)
{
// This function returns the value it receives.
return longParam;
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform