WindowsPromoteStringBuffer function winrt

HSTRING WindowsPromoteStringBuffer(
  1. HSTRING_BUFFER bufferHandle
)

Creates an HSTRING from the specified HSTRING_BUFFER.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/winstring/nf-winstring-windowspromotestringbuffer.

Implementation

HSTRING WindowsPromoteStringBuffer(HSTRING_BUFFER bufferHandle) {
  final string = adaptiveCalloc<Pointer>();
  final hr$ = HRESULT(_WindowsPromoteStringBuffer(bufferHandle, string));
  if (hr$.isError) {
    free(string);
    throw WindowsException(hr$);
  }
  final result$ = string.value;
  free(string);
  return .new(result$);
}