/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary> /// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param> /// <param name="other">A raw pointer to the target <see cref="ComPtr{T}"/> value to write to.</param> /// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns> /// <remarks>This method will automatically release the target COM object pointed to by <paramref name="other"/>, if any.</remarks> public readonly int AsIID(Guid *riid, ComPtr <IUnknown> *other) { return(((IUnknown *)ptr_)->QueryInterface(riid, (void **)other->ReleaseAndGetAddressOf())); }
/// <summary>Converts the current object reference to type <typeparamref name="U"/> and assigns that to a target <see cref="ComPtr{T}"/> value.</summary> /// <typeparam name="U">The interface type to use to try casting the current COM object.</typeparam> /// <param name="p">A raw pointer to the target <see cref="ComPtr{T}"/> value to write to.</param> /// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns> /// <remarks>This method will automatically release the target COM object pointed to by <paramref name="p"/>, if any.</remarks> public readonly int As <U>(ComPtr <U> *p) where U : unmanaged { return(((IUnknown *)ptr_)->QueryInterface(__uuidof <U>(), (void **)p->ReleaseAndGetAddressOf())); }
/// <summary>Creates a new <see cref="ComPtr{T}"/> instance from a second one and increments the ref count.</summary> /// <param name="other">The other <see cref="ComPtr{T}"/> instance to copy.</param> public ComPtr(ComPtr <T> other) { ptr_ = other.ptr_; InternalAddRef(); }
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary> /// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param> /// <param name="p">The target raw pointer to copy the address of the current COM object to.</param> /// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns> public readonly int CopyTo(Guid *riid, ComPtr <IUnknown> *p) { return(((IUnknown *)ptr_)->QueryInterface(riid, (void **)p->ReleaseAndGetAddressOf())); }
/// <summary>Increments the reference count for the current COM object, if any, and copies its address to a target <see cref="ComPtr{T}"/>.</summary> /// <param name="other">The target reference to copy the address of the current COM object to.</param> /// <returns>This method always returns <see cref="S_OK"/>.</returns> public readonly int CopyTo(ref ComPtr <T> other) { InternalAddRef(); other.Attach(ptr_); return(S_OK); }
/// <summary>Increments the reference count for the current COM object, if any, and copies its address to a target <see cref="ComPtr{T}"/>.</summary> /// <param name="p">The target raw pointer to copy the address of the current COM object to.</param> /// <returns>This method always returns <see cref="S_OK"/>.</returns> public readonly int CopyTo(ComPtr <T> *p) { InternalAddRef(); *p->ReleaseAndGetAddressOf() = ptr_; return(S_OK); }