Solved

Delphi DLL called from Delphi and then from C

Posted on 2002-04-17
4
189 Views
Last Modified: 2010-04-04
The DLL has two entry points
Func1 and Func2. Delphi Exe calls
Func1 which opens a file and writes to it, it works.
I want to call Func2 from C and append to the
same file.
I have :

Procedure func2(Param: PChar): PChar; stdcall;
     external ;
 
export
 func1 index 1,
 func2 index 2;
 
 From C do I just do:
   int func2(char*);
            ....
   nRet = func2("Hi Mom!");
   
   Any tips? What statement goes in the C code
to reference the DLL - here by number;
   
   Many Thanks , Mark
0
Comment
Question by:mebarron
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6947305
In C you will have to generate the .lib file to statically link to.
Also your C declaration needs a declspec(dllimport) to force the stdcall calling convention.
0
 

Author Comment

by:mebarron
ID: 6947496
I do not understand your first sentence.How
do I statically generate a .lib file?
0
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 50 total points
ID: 6947774
You will need to generate a .lib file from the DLL.
There is a tool somewhere with your C++ compiler. Maybe the project automatically generates it already (i am not used to modern C++ compilers).
To use the DLL you add the .lib file to the files the linker should link in.
0
 

Author Comment

by:mebarron
ID: 6947830
many thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 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

19 Experts available now in Live!

Get 1:1 Help Now