Marshal.QueryInterface(IntPtr, Guid, IntPtr) メソッド

定義

COM オブジェクトから指定したインターフェイスへのポインターを要求します。

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

パラメーター

pUnk
IntPtr

nativeint

照会するインターフェイス。

iid
Guid

要求したインターフェイスのインターフェイス ID (IID: Interface Identifier)。

ppv
IntPtr

nativeint

このメソッドが返されるときに、返されたインターフェイスへの参照を格納します。

戻り値

呼び出しの成功または失敗を示す HRESULT。

属性

注釈

メソッドは QueryInterface 、特定のインターフェイス ポインターを取得しようとする COM オブジェクトの IUnknown::QueryInterface メソッドを公開します。 COM オブジェクトで を使用 QueryInterface することは、マネージド コードでキャスト操作を実行するのと同じです。 このメソッドを使用して オブジェクトを呼び出すと、ポインターが返される前に、インターフェイス ポインターで参照カウントがインクリメントされます。 ポインターが終了したら、参照カウントをデクリメントするには、常に を使用 Marshal.Release します。 IUnknown インターフェイス ポインターをIntPtr表す値を取得するには、または Marshal.GetIDispatchForObjectを呼び出Marshal.GetIUnknownForObjectMarshal.GetComInterfaceForObjectします。

適用対象

こちらもご覧ください