Editare

Partajați prin


Marshal.QueryInterface(IntPtr, Guid, IntPtr) Method

Definition

Requests a pointer to a specified interface from a COM object.

public:
 static int QueryInterface(IntPtr pUnk, Guid % iid, [Runtime::InteropServices::Out] IntPtr % ppv);
[System.Security.SecurityCritical]
public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv);
public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv);
public static int QueryInterface (IntPtr pUnk, in Guid iid, out IntPtr ppv);
[<System.Security.SecurityCritical>]
static member QueryInterface : nativeint * Guid * nativeint -> int
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member QueryInterface : nativeint * Guid * nativeint -> int
static member QueryInterface : nativeint * Guid * nativeint -> int
Public Shared Function QueryInterface (pUnk As IntPtr, ByRef iid As Guid, ByRef ppv As IntPtr) As Integer

Parameters

pUnk
IntPtr

nativeint

The interface to be queried.

iid
Guid

The interface identifier (IID) of the requested interface.

ppv
IntPtr

nativeint

When this method returns, contains a reference to the returned interface.

Returns

An HRESULT that indicates the success or failure of the call.

Attributes

Remarks

The QueryInterface method exposes the IUnknown::QueryInterface method of a COM object, which attempts to obtain a specific interface pointer. Using QueryInterface on a COM object is the same as performing a cast operation in managed code. Calling an object with this method causes the reference count to increment on the interface pointer before the pointer is returned. Always use Marshal.Release to decrement the reference count once you have finished with the pointer. To obtain an IntPtr value that represents a IUnknown interface pointer, you can call Marshal.GetComInterfaceForObject, Marshal.GetIUnknownForObject, or Marshal.GetIDispatchForObject.

Applies to

See also