chpicker
Programmer
- Apr 10, 2001
- 1,316
Hey guys,
I decided that I wanted to code a function in C++ rather than VFP because of the speed that C++ can give me. The function runs in 1/10 the time. However, I now want to put this function into a DLL and call it from VFP just like I do the win32api functions. It's not working.
I created a DLL project in Visual C++ 6.0 and let the wizard create one that exports some symbols so I could see how it worked. I compiled it into a DLL file, using the pre-created function as-is. When I DECLARE the function in VFP, I get no error, but I get the "Cannot find the entry point" error when I try to call the function. And yes, I am absolutely sure I got the case correct in both the function declaration and the function call.
I created a simple C++ program that calls the function, and it works just fine. Is there something special you have to do to a DLL file for VFP to recognize it?
On a side note, as an experiment I also tried exporting the functions "DllRegisterServer" and "DllUnregisterServer", but regsvr32 still complains that it can't find those entry points, either. That could be because I don't know the parameters that are passed, though.
I condensed the DLL code into a single file that compiles correctly for me. Here it is:
I created an empty Win32 Console Application and used this code to access the DLL. It prints 42 on the screen, as you would expect:
What changes do I need to make to my DLL project so I can call the function from VFP and get 42? I find it hard to believe that all of the standard Windows API functions are compiled with the VFP API, which is why I feel there's something simple I can do to fix this.
On another side note, I DID create an FLL using the VFP API and got the "42" function to work using SET LIBRARY. I don't want to do it this way, though. I want this DLL to be accessible to other languages.
Ian
I decided that I wanted to code a function in C++ rather than VFP because of the speed that C++ can give me. The function runs in 1/10 the time. However, I now want to put this function into a DLL and call it from VFP just like I do the win32api functions. It's not working.
I created a DLL project in Visual C++ 6.0 and let the wizard create one that exports some symbols so I could see how it worked. I compiled it into a DLL file, using the pre-created function as-is. When I DECLARE the function in VFP, I get no error, but I get the "Cannot find the entry point" error when I try to call the function. And yes, I am absolutely sure I got the case correct in both the function declaration and the function call.
I created a simple C++ program that calls the function, and it works just fine. Is there something special you have to do to a DLL file for VFP to recognize it?
On a side note, as an experiment I also tried exporting the functions "DllRegisterServer" and "DllUnregisterServer", but regsvr32 still complains that it can't find those entry points, either. That could be because I don't know the parameters that are passed, though.
I condensed the DLL code into a single file that compiles correctly for me. Here it is:
Code:
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#define MYDLL_API __declspec(dllexport)
MYDLL_API int fnMydll(void);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
MYDLL_API int fnMydll(void)
{
return 42;
}
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream.h>
#define MYDLL_API __declspec(dllimport)
MYDLL_API int fnMydll(void);
int main(int argc, char* argv[])
{
int answer=fnMydll();
cout << answer << endl;
return 0;
}
On another side note, I DID create an FLL using the VFP API and got the "42" function to work using SET LIBRARY. I don't want to do it this way, though. I want this DLL to be accessible to other languages.
Ian