Marshal.GetIDispatchForObject(Object) Méthode

Définition

Retourne une interface IDispatch à partir d’un objet managé.

public:
 static IntPtr GetIDispatchForObject(System::Object ^ o);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static IntPtr GetIDispatchForObject (object o);
public static IntPtr GetIDispatchForObject (object o);
[System.Security.SecurityCritical]
public static IntPtr GetIDispatchForObject (object o);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetIDispatchForObject : obj -> nativeint
static member GetIDispatchForObject : obj -> nativeint
[<System.Security.SecurityCritical>]
static member GetIDispatchForObject : obj -> nativeint
Public Shared Function GetIDispatchForObject (o As Object) As IntPtr

Paramètres

o
Object

Objet dont l'interface IDispatch est demandée.

Retours

IntPtr

nativeint

Pointeur IDispatch pour le paramètre o.

Attributs

Exceptions

o ne prend pas en charge l'interface demandée.

Remarques

Dans le code managé, vous travaillez rarement directement avec l’interface IDispatch . Toutefois, GetIDispatchForObject il est utile d’appeler une méthode qui expose un paramètre d’objet COM en tant que IntPtr type ou avec le marshaling personnalisé. L’appel d’un objet avec cette méthode entraîne l’incrémentation du nombre de références sur le pointeur d’interface avant le retour du pointeur. Utilisez toujours cette option Marshal.Release pour décrémenter le nombre de références une fois le pointeur terminé.

Vous pouvez également utiliser cette méthode sur un objet managé pour obtenir un pointeur d’interface vers le wrapper pouvant être appelé COM pour l’objet. Pour plus d’informations, consultez Wrapper pouvant être appelé PAR COM.

S’applique à

Voir aussi