H
Halvdan Friis
Hi,
I've run into a problem with exporting and importing a function from a DLL.
Hopefully somebody here can tell me how this should be done properly.
My DLL function is as follows:
void DoSomething();
This would be exported using a DEF file.
The calling application links to my DLL dynamically, and does something like
this in order to import and call the function:
typedef void (*DOSOMETHINGTYPE)();
HANDLE hDll = LoadLibrary(...);
DOSOMETHINGTYPE DoSomethingPtr = (DOSOMETHINGTYPE)GetProcAddress(hDll,
"DoSomething");
DoSomethingPtr();
Now, I would like to change my exported function to be defined as follows:
extern "C" __declspec(dllexport) void __stdcall DoSomething();
Then, how do I need to typedef the function in the calling app? I've tried a
few variations on the following, but I get loads of compiler errors:
typedef extern "C" __declspec(dllimport) void __stdcall
(*DOSOMETHINGTYPE)();
I am using the Microsoft Visual C++ compiler here.
Can anybody help me?
Cheers,
HF
I've run into a problem with exporting and importing a function from a DLL.
Hopefully somebody here can tell me how this should be done properly.
My DLL function is as follows:
void DoSomething();
This would be exported using a DEF file.
The calling application links to my DLL dynamically, and does something like
this in order to import and call the function:
typedef void (*DOSOMETHINGTYPE)();
HANDLE hDll = LoadLibrary(...);
DOSOMETHINGTYPE DoSomethingPtr = (DOSOMETHINGTYPE)GetProcAddress(hDll,
"DoSomething");
DoSomethingPtr();
Now, I would like to change my exported function to be defined as follows:
extern "C" __declspec(dllexport) void __stdcall DoSomething();
Then, how do I need to typedef the function in the calling app? I've tried a
few variations on the following, but I get loads of compiler errors:
typedef extern "C" __declspec(dllimport) void __stdcall
(*DOSOMETHINGTYPE)();
I am using the Microsoft Visual C++ compiler here.
Can anybody help me?
Cheers,
HF