| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Kevin Crosbie" |
| Date: |
25 Apr 2005 10:34:42 AM |
| Object: |
Re-exporting functions from dynamically linked DLL |
Hi,
I have the following situation:
I have a 3rd party DLL which does not include a LIB file, just a header file
with typedef declarations for exported functions (It is intended for dynamic
linking)
I need to wrap the DLL to allow for callbacks to my own code (in Lisp), and
to do this I need to load the DLL using LoadLibrary and access each function
that I need using GetProcAddress.
So for example:
The third party header will say:
typedef INT (WINAPI * lp_function)();
Then in my c wrapper file:
#include "3rdparty.h"
#ifdef _WIN32
#define DllExport __declspec(dllexport)
#else
#define DllExport
#endif
HINSTANCE hInstance;
lp_function f1;
DllExport int initialiseAPI()
{
if(NULL==(hInstance=LoadLibrary("demoapi.dll")))
{
return 1;
}
if(NULL==(f1=(lp_function)GetProcAddress(hInstance,"function")))
{
return 1;
}
}
etc.
The I implement the callback code which in turn calls code on my Lisp side.
So my question is:
I want to re-export these dynamically linked functions. I could easily
wrap them:
DllExport void wrappedf1 (int arg)
{
f1(arg);
}
but I would prefer to just declare it as exported somehow. If I try
something like changing their header file to say:
typedef DllExport INT (WINAPI * lp_function)();
and my code to declare:
DllExport lp_function f1;
I get a Segmentation Violation.
Anyone have any ideas?
.
|
|
| User: "Victor Bazarov" |
|
| Title: Re: Re-exporting functions from dynamically linked DLL |
25 Apr 2005 10:40:30 AM |
|
|
Kevin Crosbie wrote:
I have a 3rd party DLL which does not include a LIB file, just a header file
with typedef declarations for exported functions (It is intended for dynamic
linking)
I need to wrap the DLL to allow for callbacks to my own code (in Lisp), and
to do this I need to load the DLL using LoadLibrary and access each function
that I need using GetProcAddress.
[...]
Anyone have any ideas?
Wrong newsgroup. DLLs are not part of C++ language, they are quite
platform-specific. Post to comp.os.ms-windows.programmer.win32 or to
a newsgroup for your C++ compiler.
V
.
|
|
|
| User: "Kevin Crosbie" |
|
| Title: Re: Re-exporting functions from dynamically linked DLL |
25 Apr 2005 11:00:46 AM |
|
|
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:Pb8be.65910$NC6.2487@newsread1.mlpsca01.us.to.verio.net...
Wrong newsgroup. DLLs are not part of C++ language, they are quite
platform-specific. Post to comp.os.ms-windows.programmer.win32 or to
a newsgroup for your C++ compiler.
V
Will do. Thanks Victor.
.
|
|
|
|
|

|
Related Articles |
|
|