RealProxy.GetCOMIUnknown(Boolean) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
要求目前 Proxy 執行個體所表示之物件的 Unmanaged 參考。
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 和目前處理序中的 Unmanaged 物件進行通訊,則為 false。
傳回
nativeint
如果要求物件參考是為了透過 COM 和目前處理序中的 Unmanaged 物件進行通訊,則為 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
備註
如果要求 Proxy 進行封送處理,則會 IUnknown 傳回目前 Proxy 實例所代表對象的介面。
IUnknown如果 先前由 SetCOMIUnknown 方法快取 ,則會傳回該實例,否則會傳回新的實例。
如果 Proxy 未要求封送處理,但用於與目前進程中 Unmanaged 對象的通訊,則會傳回 COM 可呼叫包裝函 式 (CCW) ,此程式可用於透過 COM 進行通訊的目前程式。