Movatterモバイル変換


[0]ホーム

URL:


Skip to main contentSkip to in-page navigation

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

Marshal.QueryInterface(IntPtr, Guid, IntPtr) Method

Definition

Namespace:
System.Runtime.InteropServices
Assemblies:
mscorlib.dll, System.Runtime.InteropServices.dll
Assemblies:
netstandard.dll, System.Runtime.InteropServices.dll
Assembly:
System.Runtime.InteropServices.dll
Assembly:
mscorlib.dll
Assembly:
netstandard.dll
Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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);
public static int QueryInterface(IntPtr pUnk, in 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);
[<System.Security.SecurityCritical>]static member QueryInterface : nativeint * Guid * nativeint -> int
static member QueryInterface : nativeint * Guid * nativeint -> int
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]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

TheQueryInterface method exposes theIUnknown::QueryInterface method of a COM object, which attempts to obtain a specific interface pointer. UsingQueryInterface 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 useMarshal.Release to decrement the reference count once you have finished with the pointer. To obtain anIntPtr value that represents aIUnknown interface pointer, you can callMarshal.GetComInterfaceForObject,Marshal.GetIUnknownForObject, orMarshal.GetIDispatchForObject.

Applies to

See also

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo