Marshal.GetIDispatchForObject(Object) 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.
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.