mirror of https://github.com/dahall/Vanara.git
Made Vanara.Extensions.InteropExtensions.QueryInterface an extension method for `object`.
parent
7e05dd64bf
commit
92c1f53cb6
|
@ -448,7 +448,7 @@ public static partial class InteropExtensions
|
||||||
/// <param name="iid">The interface identifier (IID) of the requested interface.</param>
|
/// <param name="iid">The interface identifier (IID) of the requested interface.</param>
|
||||||
/// <param name="ppv">When this method returns, contains a reference to the returned interface.</param>
|
/// <param name="ppv">When this method returns, contains a reference to the returned interface.</param>
|
||||||
/// <returns>An HRESULT that indicates the success or failure of the call.</returns>
|
/// <returns>An HRESULT that indicates the success or failure of the call.</returns>
|
||||||
public static int QueryInterface(object iUnk, Guid iid, out object? ppv)
|
public static int QueryInterface(this object iUnk, Guid iid, out object? ppv)
|
||||||
{
|
{
|
||||||
var hr = Marshal.QueryInterface(Marshal.GetIUnknownForObject(iUnk), ref iid, out IntPtr ippv);
|
var hr = Marshal.QueryInterface(Marshal.GetIUnknownForObject(iUnk), ref iid, out IntPtr ippv);
|
||||||
ppv = hr == 0 ? Marshal.GetObjectForIUnknown(ippv) : null;
|
ppv = hr == 0 ? Marshal.GetObjectForIUnknown(ippv) : null;
|
||||||
|
|
Loading…
Reference in New Issue