ComWrappers.GetOrCreateComInterfaceForObject 方法

定义

创建提供的对象的 COM 表示形式,该对象可以传递给非托管环境。

public:
 IntPtr GetOrCreateComInterfaceForObject(System::Object ^ instance, System::Runtime::InteropServices::CreateComInterfaceFlags flags);
public IntPtr GetOrCreateComInterfaceForObject (object instance, System.Runtime.InteropServices.CreateComInterfaceFlags flags);
member this.GetOrCreateComInterfaceForObject : obj * System.Runtime.InteropServices.CreateComInterfaceFlags -> nativeint
Public Function GetOrCreateComInterfaceForObject (instance As Object, flags As CreateComInterfaceFlags) As IntPtr

参数

instance
Object

在 .NET 运行时外部公开的托管对象。

flags
CreateComInterfaceFlags

用于配置生成的接口的标志。

返回

IntPtr

nativeint

生成的 COM 接口,作为指向接口实现的 IUnknown 指针,可在 .NET 运行时外部传递。

注解

如果以前使用此ComWrappers实例为指定的 instance 创建 COM 表示形式,则将返回以前创建的 COM 接口。 否则,将创建一个新。

适用于