WindowsDeleteStringBuffer function (winstring.h)

Discards a preallocated string buffer if it was not promoted to an HSTRING.

Syntax

HRESULT WindowsDeleteStringBuffer(
  HSTRING_BUFFER bufferHandle
);

Parameters

bufferHandle

Type: [in] HSTRING_BUFFER

The buffer to discard. The WindowsDeleteStringBuffer function raises an exception if bufferHandle was not allocated by a call to the WindowsPreallocateStringBuffer function.

Return value

Type: HRESULT

This function can return one of these values.

Return code Description
S_OK
The buffer was discarded successfully.
E_POINTER
bufferHandle is NULL.

Remarks

Use the WindowsDeleteStringBuffer function to discard a string buffer that was created by the WindowsPreallocateStringBuffer function but has not been promoted to an HSTRING by the WindowsPromoteStringBuffer function.

Note  Calling WindowsPromoteStringBuffer after calling WindowsDeleteStringBuffer with the same buffer handle is undefined.
 

Examples

The following code example demonstrates how to use the WindowsDeleteStringBuffer function.

int main()
{
    HSTRING_BUFFER hStringBuffer = NULL;
    PWSTR strBuffer = NULL;
    HRESULT hr = WindowsPreallocateStringBuffer(10, &strBuffer, &hStringBuffer);

    // You hit a case in which you need to discard the buffer.

    WindowsStringDeleteBuffer(hStringBuffer);
}

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header winstring.h
Library RuntimeObject.lib
DLL ComBase.dll

See also

HSTRING

HSTRING_BUFFER

WindowsPreallocateStringBuffer

WindowsPromoteStringBuffer