RealProxy.GetCOMIUnknown(Boolean) 方法

定义

请求对当前代理实例所表示对象的非托管引用。

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

如果请求将对象引用封送到远程位置,则为 < a0/>; 如果请求对象引用通过 COM 与当前进程中的非托管对象通信,则为 。

返回

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 返回由当前代理实例表示的对象接口。 如果方法之前缓存SetCOMIUnknown了某个IUnknown实例,则返回该实例;否则返回一个新实例。

如果请求代理不是封送处理,而是用于与当前进程中非托管对象的通信,则会返回可在当前进程中用于通过 COM 进行通信的 COM 可调用包装器 (CCW)。

适用于