• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Delphi DLL called from Delphi and then from C

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 ;
 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
  • 2
  • 2
1 Solution
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.
mebarronAuthor Commented:
I do not understand your first sentence.How
do I statically generate a .lib file?
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.
mebarronAuthor Commented:
many thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now