Share via


WeakRef::AsIID Method

Sets the specified ComPtr pointer parameter to represent the specified interface ID.

HRESULT AsIID(
   REFIID riid,
   _Out_ ComPtr<IInspectable>* ptr
);

Parameters

  • riid
    An interface ID.

  • ptr
    When this operation completes, an object that represents parameter riid.

Return Value

  • S_OK if this operation succeeds; otherwise, an HRESULT that indicates the reason the operation failed.

  • S_OK if this operation succeeds, but the current WeakRef object has already been released. Parameter ptr is set to nullptr.

  • S_OK if this operation succeeds, but the current WeakRef object is not derived from parameter riid. Parameter ptr is set to nullptr. (For more information, see Remarks.)

Remarks

An error is emitted if parameter riid is not derived from IInspectable. This error supersedes the return value.

The first template is the form that you should use in your code. The second template is an internal, helper specialization that supports C++ language features such as the auto type deduction keyword.

Requirements

Header: client.h

Namespace: Microsoft::WRL

See Also

Reference

WeakRef Class