WindowsConcatString function winrt

HSTRING WindowsConcatString(
  1. HSTRING? string1,
  2. HSTRING? string2
)

Concatenates two specified strings.

Throws a WindowsException on failure.

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

Implementation

HSTRING WindowsConcatString(HSTRING? string1, HSTRING? string2) {
  final newString = adaptiveCalloc<Pointer>();
  final hr$ = HRESULT(
    _WindowsConcatString(string1 ?? nullptr, string2 ?? nullptr, newString),
  );
  if (hr$.isError) {
    free(newString);
    throw WindowsException(hr$);
  }
  final result$ = newString.value;
  free(newString);
  return .new(result$);
}