Re: accessing DLL headers
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Tue, 6 Dec 2005 07:06:26 -0800
readytoride39 wrote:
> First of all I apologize in advance if this topic does not exactly fit
> but if someone could still address it I would appreciate it.
>
> My boss tasked me to take out all references of this third party
> software ie functions, headers, libs and put them in a dll. I
> recently moved the main functions, the libs, and the includes out of
> the exe and into the dll.
>
> I am using loadlibrary to load the dll into memory and I am using
> getprocaddress to get the address of the functions in the dll.
>
> What is presenting a problem is the fact that I have several
> datatypes, defined attributes, and structures defined in the header
> files that I need to use in the main exe. These uses are used for
> typecasting among other things. I can not simply move these uses over
> into the dll because then I would have the exact opposite problem.
>
> My question is - Is there a way to export these structures, datatypes,
> and defined attributes from the dll so that 1)I can compile properly
> and 2) use them in the exe and the dll when running the application?
>
> I should also mention that the generic functions that I am calling to
> access the dll contain a structure that needs to be returned to the
> calling program - so a definition of the structure has to exist in the
> calling exe as well in order for it to compile and run properly.
>
> Things I thought of where to take what I need from the existing header
> file and create my own header file. But this turned out to be far to
> tedious and did not buy me much. In fact that lead me to beleive
> that if I do that then why not just rename the header files and
> include them directly in my project. This will make it compile but I
> feel as if it's cheating(is this cheating or am I overthinking this
> idea).
>
> Can I use GetProcAddress to get access to a header or a value in a
> header file?
>
> I found this link in here
> [url]http://www.codecomments.com/message1331748.htm[/url] - i
> s this a viable option for me?
>
> If more info is needed then let me know
>
> Thoughts? Can anyone help - please?
A DLL contains compiled code and initialized data that can be used at
runtime by a program. A header file contains declartions and definitions
used at compile time by the compiler. Two very different things.
Typically, when you package code (such as a 3rd party library) into a DLL,
you still need to have a header file that provides the declarations needed
to call the code.
There are two notable exceptions to this:
1. You could package the library as a COM DLL with an embedded type library.
The compiler can then create a header file from this DLL (using #import) so
you have only a single thing (the DLL) that needs to be distributed to the
developers using the library.
2. You could package the library as a managed (.NET) assembly, which
includes rich meta data. Someone targeting the library can then get the
definitiong using the #using directive.
But for native non-COM development, you'll typically just distribute the
DLL, the associated import library (for static linking against the DLL - no
LoadLibrary/GetProcAddress) and the header file(s) to your developers.
-cd
.
- References:
- accessing DLL headers
- From: readytoride39
- accessing DLL headers
- Prev by Date: Re: Cast HDC to long
- Next by Date: Re: Cast HDC to long
- Previous by thread: accessing DLL headers
- Next by thread: Re: Converting a VS6.0 project to VS2005
- Index(es):
Relevant Pages
|