HStringReference Class


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 HStringReference Class.

Represents an HSTRING that is created from an existing string.

class HStringReference;  

The lifetime of the backing buffer in the new HSTRING is not managed by the Windows Runtime. The caller allocates a source string on the stack frame to avoid a heap allocation and to eliminate the risk of a memory leak. Also, the caller must ensure that source string remains unchanged during the lifetime of the attached HSTRING. For more information, see WindowsCreateStringReference function.

Public Constructors

HStringReference::HStringReference ConstructorInitializes a new instance of the HStringReference class.


HStringReference::CopyTo MethodCopies the current HStringReference object to an HSTRING object.
HStringReference::Get MethodRetrieves the value of the underlying HSTRING handle.

Public Operators

HStringReference::Operator= OperatorMoves the value of another HStringReference object to the current HStringReference object.
HStringReference::Operator== OperatorIndicates whether the two parameters are equal.
HStringReference::Operator!= OperatorIndicates whether the two parameters are not equal.


Header: corewrappers.h

Namespace: Microsoft::WRL::Wrappers

Microsoft::WRL::Wrappers Namespace