Share via


ComPtr::CopyTo Method

Copies the current or specified interface associated with this ComPtr to the specified pointer.

HRESULT CopyTo(
   _Deref_out_ InterfaceType** ptr
);

HRESULT CopyTo(
   REFIID riid,
   _Deref_out_ void** ptr
) const;
template<
   typename U
>

HRESULT CopyTo(
   _Deref_out_ U** ptr
) const;

Parameters

  • U
    A type name.

  • ptr
    When this operation completes, a pointer to the requested interface.

  • riid
    An interface ID.

Return Value

S_OK if successful; otherwise, an HRESULT that indicates why the implicit QueryInterface operation failed.

Remarks

The first function returns a copy of a pointer to the interface associated with this ComPtr. This function always returns S_OK.

The second function performs a QueryInterface operation on the interface associated with this ComPtr for the interface specified by the riid parameter.

The third function performs a QueryInterface operation on the interface associated with this ComPtr for the underlying interface of the U parameter.

Requirements

Header: client.h

Namespace: Microsoft::WRL

See Also

Reference

ComPtr Class