问题
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:
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
来源:https://stackoverflow.com/questions/13223629/how-do-i-write-dllgetclassobject-as-a-c-sharp-delegate