Solved

Using DLL's with no reference.

Posted on 2001-08-15
10
124 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Making delphi communicate with a c# service 16 102
Delphi 2 59
tvirtualstringtree freeze when load too manny images 10 60
How to build JSON File in Delphi 6 3 32
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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