1
votes

There is a dll method exported written in delphi: DllGetClassObject: function(const CLSID, IID: TGUID; var Obj): HResult; stdcall;

I need to write equivalent method in c# as a delegate. How should it looks like?

1

1 Answers

2
votes

Like this:

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate uint DllGetClassObjectDelegate(
    [MarshalAs(UnmanagedType.LPStruct)]
    Guid rclsid,
    [MarshalAs(UnmanagedType.LPStruct)]
    Guid riid,
    [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex=1)]
    out object ppv
);

Source: http://blog.kutulu.org/2012/01/com-interop-part-9-custom-activations.html?m=1