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

所要求介面的介面識別項 (IID)。

ppv
IntPtr

nativeint

這個方法傳回時,會包含到傳回介面的參考。

傳回

表示呼叫成功或失敗的 HRESULT。

屬性

備註

方法 QueryInterface 會公開 COM 物件的 IUnknown::QueryInterface 方法,該方法會嘗試取得特定的介面指標。 在 QueryInterface COM 物件上使用 與在 Managed 程式代碼中執行轉換作業相同。 使用這個方法呼叫 物件,會導致傳回指標之前,介面指標上的參考計數遞增。 當您完成指標之後,請一律使用 Marshal.Release 來遞減參考計數。 若要取得 IntPtr 代表 IUnknown 介面指標的值,您可以呼叫 Marshal.GetComInterfaceForObjectMarshal.GetIUnknownForObjectMarshal.GetIDispatchForObject

適用於

另請參閱