RealProxy.GetCOMIUnknown(Boolean) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
请求对当前代理实例所表示的对象的非托管引用。
public:
virtual IntPtr GetCOMIUnknown(bool fIsMarshalled);
public virtual IntPtr GetCOMIUnknown (bool fIsMarshalled);
[System.Security.SecurityCritical]
public virtual IntPtr GetCOMIUnknown (bool fIsMarshalled);
abstract member GetCOMIUnknown : bool -> nativeint
override this.GetCOMIUnknown : bool -> nativeint
[<System.Security.SecurityCritical>]
abstract member GetCOMIUnknown : bool -> nativeint
override this.GetCOMIUnknown : bool -> nativeint
Public Overridable Function GetCOMIUnknown (fIsMarshalled As Boolean) As IntPtr
参数
- fIsMarshalled
- Boolean
如果请求该对象引用是为了封送到远程位置,则为 true
;如果请求该对象引用是为了通过 COM 与当前进程中的非托管对象进行通信,则为 false
。
返回
IntPtr
nativeint
如果请求该对象引用是为了通过 COM 与当前进程中的非托管对象进行通讯,则为指向 COM 可调用包装器的指针;如果请求该对象引用是为了封送到远程位置,则为指向缓存的或新生成的 IUnknown
COM 接口的指针。
- 属性
示例
[SecurityPermission(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::Infrastructure)]
IntPtr SupportsInterface( Guid * /*myGuid*/ )
{
Console::WriteLine( "SupportsInterface method called" );
// Object reference is requested for communication with unmanaged objects
// in the current process through COM.
IntPtr myIntPtr = this->GetCOMIUnknown( false );
// Stores an unmanaged proxy of the object.
this->SetCOMIUnknown( myIntPtr );
// return COM Runtime Wrapper pointer.
return myIntPtr;
}
public override IntPtr SupportsInterface(ref Guid myGuid)
{
Console.WriteLine("SupportsInterface method called");
// Object reference is requested for communication with unmanaged objects
// in the current process through COM.
IntPtr myIntPtr = this.GetCOMIUnknown(false);
// Stores an unmanaged proxy of the object.
this.SetCOMIUnknown(myIntPtr);
// return COM Runtime Wrapper pointer.
return myIntPtr;
}
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Overrides Function SupportsInterface(ByRef myGuid As Guid) As IntPtr
Console.WriteLine("SupportsInterface method called")
' Object reference is requested for communication with unmanaged objects
' in the current process through COM.
Dim myIntPtr As IntPtr = Me.GetCOMIUnknown(False)
' Stores an unmanaged proxy of the object.
Me.SetCOMIUnknown(myIntPtr)
' return COM Runtime Wrapper pointer.
Return myIntPtr
End Function 'SupportsInterface
注解
如果请求代理进行封送处理,则 IUnknown
返回由当前代理实例表示的 对象的接口。
IUnknown
如果 方法之前缓存了 SetCOMIUnknown ,则返回该实例;否则返回新实例。
如果请求代理不是为了封送处理,而是请求与当前进程中的非托管对象通信,则返回 COM 可调用包装器 (CCW) (可在当前通过 COM 进行通信的进程中使用)。