Solved

Using DLL's with no reference.

Posted on 2001-08-15
10
122 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
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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now