Solved

Using DLL's with no reference.

Posted on 2001-08-15
10
128 Views
Last Modified: 2010-04-06
Hi.

I just wondered how I'd go about using a function in a DLL if I didn't know how it was declared.

For example, if there was a function called 'MessageBox' in a DLL called msg.dll and it needed to be called like this....

   MessageBox('This is the message', 'This is the title');

....how would I know how to do that?  If I opened the DLL within Quickview, for example, it would say that there was a function called 'MessageBox', but not give me any reference on how to use it.

Can anyone help me with this?

John.
0
Comment
Question by:Jaymol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 50 total points
ID: 6388560
The DLL does not contain any information on the function parameters.
You will need the documentation.
Normally this is the C header file (.h file) which contains the prototype of the functions.
It also gives the calling convention (usually cdecl or stdcall) of the functions.
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6388573
So are you saying that it is 100% impossible to find out this information purely from the DLL?

John.
0
 
LVL 3

Expert Comment

by:raidos
ID: 6388650
As i have understood it's not possible to get the parameter types from the dll, only the number of parameters and/or the complete size of all the parameters.

I'm not sure of this but this is what my memory tells me...

//raidos
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Jaymol
ID: 6388670
Okay.  So if I have the DLL(s) and the C header file(s), I can do it then?

John.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6389643
With the C headers it is no problem at all.
Post some function headers here and i will help you convert them to Pascal.
Also have a look at http://dlephi-jedi.org page 'API Library'.
We specialize in converting C headers to Pascal.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6389648
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6391557
If you have no C(++) headers, you could still try to reverse-engineer (disassemble) the dll. I'm not sure whether this is allowed  :-)  but, well, that's a different story. By disassembling the dll's code, you can find out how many parameters the function wants and - if you completely disassemble the function and understand it fully, you'll most probably also find out what the parameters mean. But I have to warn you: This is very very very hard work. You should do that only as the very last resort. If you have ANY chance to get a C(++) include file: Use that chance...

Regards, Madshi.
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6391651
Thanks Madshi, but I'm not going down the route you've mentioned since you're probably the only person that comes on this site capable of doing something like that!  I did disassemble it, rather than using Quickview, to see the funcs/procs and it did give me more information, but I've "aquired" the C++ files so (as suggested by Robert) I can attempt a conversion.  There's probably gonna be a lot of C to Pascal points going from my account soon!

I'll have a look into my options and get back to do pointy things.

Thanks guys.

John.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6391934
Project JEDI has many C to Pascal specialists (and i am one of them :-)
Please send me the headers to robert_marquardt@gmx.de and i will have a look.
C++ headers may be problematic if C++ methods are exported.
C++ methods are unusable in Delphi.
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6421222
Thanks guys.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question