1

有一个用delphi写的dll导出方法: DllGetClassObject: function(const CLSID, IID: TGUID; var Obj): HResult; 标准调用;

我需要在 c# 中编写等效方法作为委托。它应该是什么样子?

4

1 回答 1

2

像这样:

[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
);

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

于 2012-11-05T07:30:19.303 回答