Meh Nada
Meh Nada

Reputation: 229

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++?

Upvotes: 2

Views: 1316

Answers (1)

David Heffernan
David Heffernan

Reputation: 613461

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;

Upvotes: 5

Related Questions