Share via


RealProxy.GetCOMIUnknown(Boolean) Méthode

Définition

Demande une référence non managée à l’objet représenté par l’instance de proxy active.

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

Paramètres

fIsMarshalled
Boolean

true si la référence de l’objet est demandée pour le marshaling vers un emplacement distant ; false si la référence de l’objet est demandée pour la communication avec des objets non managés dans le processus en cours via COM.

Retours

IntPtr

nativeint

Pointeur vers un wrapper CCW (COM Callable Wrapper) si la référence de l’objet est demandée pour la communication avec des objets non managés dans le processus en cours via COM, ou pointeur vers une interface COM IUnknown mise en cache ou générée récemment si la référence de l’objet est demandée pour le marshaling vers un emplacement distant.

Attributs

Exemples

[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

Remarques

Si le proxy est demandé pour le marshaling, une IUnknown interface pour l’objet représenté par l’instance proxy actuel est retournée. Si un IUnknown a été précédemment mis en cache par la SetCOMIUnknown méthode, cette instance est retournée ; sinon, une nouvelle instance est retournée.

Si le proxy n’est pas demandé pour le marshaling, mais pour la communication avec des objets non managés dans le processus actuel, un wrapper COM Callable Wrapper (CCW), qui peut être utilisé dans le processus actuel pour la communication via COM, est retourné.

S’applique à