General information
Category:
Coding, syntax & commands
This worked for me:
1. put this in the header of your DLL
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
MYDLL_API int fnMyDll(int num);
#ifdef __cplusplus
}
#endif
2. put this in the header of your calling program
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
MYDLL_API int fnMyDll(int num);
MYDLL_EXPORTS is a compiler flag that gets set when you compile as a DLL.
Your function gets defined as an export within the DLL, but as an import within the calling program.
3. Then call the function normally.
int liRslt = fnMyDll(0);
Hope this helps,
Ken
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only