ComPtr::As Method

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at 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.

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.

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

Header: client.h

Namespace: Microsoft::WRL

ComPtr Class

Show: