简体   繁体   English

创建一个DLL Delphi,该DLL导出C ++类

[英]Create a DLL Delphi, which exports C++ Classes

for a plugin I need to create a DLL which exports C++ classes. 对于插件,我需要创建一个导出C ++类的DLL。 (for Siemens HMI Operate) My problem is, that I want to write this plugin in Delphi. (对于Siemens HMI Operate)我的问题是,我想用Delphi编写此插件。 I need to use a lot of my own libs which are all Delphi. 我需要使用我自己的很多都是Delphi的库。

So the question is: Can such a DLL be created with Delphi? 所以问题是:可以用Delphi创建这样的DLL吗?

When I open such a plugin DLL (written in Visual C++) in PE Explorer it exports look like this: 当我在PE资源管理器中打开这样的插件DLL(用Visual C ++编写)时,其导出如下所示:

?createDialogBar@SlGfwPluginByMakroBase@@UAEPAVSlGfwDialogBar@@ABVQString@@PAVQWidget@@0@Z

public: virtual class SlGfwDialogBar * __thiscall SlGfwPluginByMakroBase::createDialogBar(class QString const &,class QWidget *,class QString const &)

Can such a DLL be created with Delphi? 可以用Delphi创建这样的DLL吗?

No it cannot. 不,它不能。 You'll need to create the DLL using the specific C++ implementation that the host process expects. 您需要使用宿主进程期望的特定C ++实现来创建DLL。

Perhaps the best you can do is to create the plugin DLL in that specific C++ implementation, and then implement the methods of the class by calling into your Delphi code. 也许您能做的最好的就是在该特定C ++实现中创建插件DLL,然后通过调用您的Delphi代码来实现该类的方法。 But the C++ class that is imported by the host process must be implemented using C++. 但是主机进程导入的C ++类必须使用C ++实现。 In other words you use C++ to make a bridge between the plugin interface which mandates a specific C++ implementation, and your code which is written in Delphi. 换句话说,您使用C ++在要求特定C ++实现的插件接口和用Delphi编写的代码之间架起了桥梁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM