Solved

Using DLL's with no reference.

Posted on 2001-08-15
10
127 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
Independent Software Vendors: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Firemonkey webbrowser scrollbars ? 1 57
Dynamically Created Query 3 69
Sending files from  idTcpServer Socket to idTcpClient 2 52
DBCtrlGrid, Delphi, Scroll 8 55
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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