Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call c++ class library from Delphi

Tags:

c++

dll

delphi

Is it possible to call C++ class library from delphi 2007? What is the way of doing that? I know how to call dll function, but how to deal with class?

like image 737
vico Avatar asked Dec 25 '22 12:12

vico


1 Answers

There are several ways to do this, but you can't use a C++ class directly. Both useful ways to achieve this require some work and are extensively described here:

Using C++ objects in Delphi (http://rvelthuis.de/articles/articles-cppobjs.html)

Update

OK, I was asked to do an update. The article describes two ways:

  • Writing and exposing C functions that take the C++ object as (first) parameter (the C++ type is simply passed on as opaque type in Delphi), which simply perform the functionality the class provides by calling the class methods with the right parameters. The C functions can be called from Delphi.
  • Writing a COM wrapper for the class. The article describes how this can be done in C++.

Details can be found in the article.

like image 185
Rudy Velthuis Avatar answered Jan 06 '23 11:01

Rudy Velthuis