Share via


WeakRef::CopyTo Method

Assigns a pointer to an interface, if available, to the specified pointer variable.

HRESULT CopyTo(
   REFIID riid,
   _Deref_out_ IInspectable** ptr
);

template<
   typename U
>
HRESULT CopyTo(
   _Deref_out_ U** ptr
);

HRESULT CopyTo(
   _Deref_out_ IWeakReference** ptr
);

Parameters

  • U
    Pointer an IInspectable interface. An error is emitted if U is not derived from IInspectable.

  • riid
    An interface ID. An error is emitted if riid is not derived from IWeakReference.

  • ptr
    A doubly-indirect pointer to IInspectable or IWeakReference.

Return Value

S_OK if successful; otherwise, an HRESULT that describes the failure. For more information, see Remarks.

Remarks

A return value of S_OK means that this operation succeeded, but doesn't indicate whether the weak reference was resolved to a strong reference. If S_OK is returned, test that parameter p is a strong reference; that is, parameter p isn't equal to nullptr.

Requirements

Header: client.h

Namespace: Microsoft::WRL

See Also

Reference

WeakRef Class