Compartilhar via


ComPtr::As Method

Returns a ComPtr object that represents the interface identified by the specified template parameter.

template<
   typename U
>
HRESULT As(
   _Out_ ComPtr<U>* p
) const;

template<
   typename U
>
HRESULT As(
   _Out_ Details::ComPtrRef<ComPtr<U>> p
) const;

Parameters

  • U
    The interface to be represented by parameter p.

  • p
    A ComPtr object that represents the interface specified by parameter U. Parameter p must not refer to the current ComPtr object.

Remarks

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.

Return Value

S_OK if successful; otherwise, an HRESULT that indicates the error.

Requirements

Header: client.h

Namespace: Microsoft::WRL

See Also

Reference

ComPtr Class