Пример #1
0
 /// <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 HRESULT AsIID(Guid *riid, ComPtr <IUnknown> *other)
 {
     return(((IUnknown *)ptr_)->QueryInterface(riid, (void **)other->ReleaseAndGetAddressOf()));
 }
Пример #2
0
 /// <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 HRESULT As <U>(ComPtr <U> *p)
     where U : unmanaged
 {
     return(((IUnknown *)ptr_)->QueryInterface(__uuidof <U>(), (void **)p->ReleaseAndGetAddressOf()));
 }
Пример #3
0
 /// <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();
 }
Пример #4
0
 /// <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 HRESULT CopyTo(Guid *riid, ComPtr <IUnknown> *p)
 {
     return(((IUnknown *)ptr_)->QueryInterface(riid, (void **)p->ReleaseAndGetAddressOf()));
 }
Пример #5
0
 /// <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 HRESULT CopyTo(ref ComPtr <T> other)
 {
     InternalAddRef();
     other.Attach(ptr_);
     return(S_OK);
 }
Пример #6
0
 /// <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 HRESULT CopyTo(ComPtr <T> *p)
 {
     InternalAddRef();
     *p->ReleaseAndGetAddressOf() = ptr_;
     return(S_OK);
 }