Как использовать Классы C++, экспортируемые dll в Delphi

Вы могли использовать закодировать функцию эта библиотека .

6
задан Tobias Langner 30 September 2009 в 06:00
поделиться

2 ответа

You can't import a class. You can only import functions. Rudy Velthuis has written at length on the topic. Although you can't directly use an exported C++ class, he describes a couple of techniques to achieve the same effect:

  • "Flatten" the object, so on the calling side there is no object anymore, just a pointer that gets passed to the DLL along with other parameters for a series of functions that wrap the object's methods. Writing the wrapper is very simple, although it can be tedious.

  • Use pure virtual classes. Windows C++ compilers and Delphi have generally the same VMT layouts, so if the C++ class can be described by a list of pure virtual methods, you can create an equivalent Delphi declaration, do some type-casting with the object pointer returned by the DLL, and proceed.

Complete examples of both ways are given in the article.

11
ответ дан 8 December 2019 в 16:05
поделиться

Насколько мне известно, в Delphi нельзя использовать классы C ++, экспортированные из DLL; вы можете использовать функции C и импортировать COM-классы в Delphi.

4
ответ дан 8 December 2019 в 16:05
поделиться
Другие вопросы по тегам:

Похожие вопросы: