in ComObject.cs [161:172]
public static T QueryInterfaceOrNull<T>(IntPtr comPointer) where T : ComObject
{
if (comPointer == IntPtr.Zero)
{
return null;
}
var guid = typeof(T).GetTypeInfo().GUID;
IntPtr pointerT;
var result = (Result)Marshal.QueryInterface(comPointer, ref guid, out pointerT);
return (result.Failure) ? null : FromPointer<T>(pointerT);
}