示例#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 reference 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, ref ComPtr <IUnknown> other)
        {
            IUnknown *ptr;
            HRESULT   result = ((IUnknown *)ptr_)->QueryInterface(riid, (void **)&ptr);

            other.Attach(ptr);
            return(result);
        }
示例#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="other">A reference 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="other"/>, if any.</remarks>
        public readonly HRESULT As <U>(ref ComPtr <U> other)
            where U : unmanaged
        {
            U *     ptr;
            HRESULT result = ((IUnknown *)ptr_)->QueryInterface(__uuidof <U>(), (void **)&ptr);

            other.Attach(ptr);
            return(result);
        }
示例#3
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);
 }