Re: accessing DLL headers

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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


.



Relevant Pages

  • Re: Converting .lib to .dll
    ... Adding the header file to the project does nothing. ... a DLL file. ... EXPORT_SETTING int VP_DoWhatever(int parameter1, int parameter2) ... And when you compile this, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Appl. Security Problems
    ... When I Release compile the exe and dll' are in one directory on the network. ... the key you use to sign your production assemblies ...
    (microsoft.public.dotnet.security)
  • Re: DLL Woes
    ... How do I get them to display after I "Make" it into an .exe? ... Do you happen to have a check in the Unattended Execution checkbox? ... compile it' ... DLL Hell problems? ...
    (microsoft.public.vb.general.discussion)
  • Re: Converting .lib to .dll
    ... This would be the equivalent of you referencing a ... Adding the header file to the project does nothing. ... DLL file. ... And when you compile this, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Creating classes via DLL.
    ... The code for the call back is in your main exe, ... without any knowledge of the code of the dll. ... must contain a definition of what comprises TMyClass or it won't compile. ... Now you need to compile another free-standing module which is the dll. ...
    (comp.lang.pascal.delphi.misc)