RealProxy.GetCOMIUnknown(Boolean) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Demande une référence non managée à l’objet représenté par l’instance de proxy actuelle.
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 d’objet est demandée pour le marshaling vers un emplacement distant ; false si la référence d’objet est demandée pour la communication avec des objets non managés dans le processus actuel via COM.
Retours
nativeint
Pointeur vers un wrapper POUVANT appeler COM si la référence d’objet est demandée pour la communication avec des objets non managés dans le processus actuel via COM, ou un pointeur vers une interface COM mise en cache ou nouvellement générée IUnknown si la référence d’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 de proxy actuelle est retournée. Si une IUnknown instance a été précédemment mise 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 pouvant être appelé (CCW), qui peut être utilisé dans le processus actuel pour la communication via COM, est retourné.