Share via


RealProxy.SupportsInterface(Guid) 方法

定義

要求具有指定 ID 的 COM 介面。

public:
 virtual IntPtr SupportsInterface(Guid % iid);
public virtual IntPtr SupportsInterface (ref Guid iid);
abstract member SupportsInterface : Guid -> nativeint
override this.SupportsInterface : Guid -> nativeint
Public Overridable Function SupportsInterface (ByRef iid As Guid) As IntPtr

參數

iid
Guid

受要求介面的參考。

傳回

IntPtr

nativeint

受要求介面的指標。

範例

[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

備註

方法 SupportsInterface 可讓目前的 Proxy 實例代表目前實例所代表的伺服器對象實作其他 COM 介面。 目前的方法會產生要求的介面,並傳回其指標。 這個方法可以產生的 COM 介面類型取決於 Proxy 類型,而此類型可能取決於目前 Proxy 實例所代表的伺服器物件類型。

如需詳細資訊,請參閱ProxyAttribute

適用於