Made Vanara.Extensions.InteropExtensions.QueryInterface an extension method for `object`.

master
David Hall 2024-06-15 15:42:02 -04:00
parent 7e05dd64bf
commit 92c1f53cb6
1 changed files with 1 additions and 1 deletions

View File

@ -448,7 +448,7 @@ public static partial class InteropExtensions
/// <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>
/// <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);
ppv = hr == 0 ? Marshal.GetObjectForIUnknown(ippv) : null;