简体   繁体   中英

Export Interface from Dll. C# Delphi VB C++ etc

I've created an application in Delphi that is capable of loading plugins from a dll. The dll exports one function which looks like this

function GetPlugin: IPluginInterface;

IPluginInterface is a ActiveX Type Library. I figured because I was using a type library I could then use C# or any other language to export IPluginInterface from a dll, though after a bit of googling I found out this is not the case as there is a lot of talk of managed and unmanaged code and reasons why this can't be done. So my question is, am I still able to create a plugin in C# that will export a function like above? If not, what languages are able to do that apart from C++?

So my question is, am I still able to create a plugin in C# that will export a function like above? If not, what languages are able to do that apart from C++?

All of the mainstream programming environments on Windows can produce and consume COM interfaces. C, C++, C#, VB6, VB.net, Delphi and so on. So, yes, you can use COM interfaces for your task.

As a point of detail, what you can't do is pass an interface out of a Delphi DLL as the return value of a function. That's because Delphi uses non-standard semantics for function return values . Instead you need to return it via an out parameter.

So you'd need to write your GetPlugin like this:

procedure GetPlugin(out Plugin: IPluginInterface); stdcall;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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