accessing DLL headers

R

readytoride39

First of all I apologize in advance if this topic does not exactly fi
but if someone could still address it I would appreciate it.

My boss tasked me to take out all references of this third part
software ie functions, headers, libs and put them in a dll. I recentl
moved the main functions, the libs, and the includes out of the exe an
into the dll.

I am using loadlibrary to load the dll into memory and I am usin
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
need to use in the main exe. These uses are used for typecasting amon
other things. I can not simply move these uses over into the dl
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 properl
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 t
access the dll contain a structure that needs to be returned to th
calling program - so a definition of the structure has to exist in th
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 heade
file and create my own header file. But this turned out to be far t
tedious and did not buy me much. In fact that lead me to beleive tha
if I do that then why not just rename the header files and include the
directly in my project. This will make it compile but I feel as i
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
header file?

I found this link in her
http://www.codecomments.com/message1331748.htm - i
s this a viable option for me?

If more info is needed then let me know

Thoughts? Can anyone help - please?


Thanks for all your hel


-
readytoride3
 
C

Carl Daniel [VC++ MVP]

readytoride39 said:
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
http://www.codecomments.com/message1331748.htm - 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top