WindowsDuplicateString function winrt
Creates a copy of the specified string.
Throws a WindowsException on failure.
To learn more, see learn.microsoft.com/windows/win32/api/winstring/nf-winstring-windowsduplicatestring.
Implementation
HSTRING WindowsDuplicateString(HSTRING? string) {
final newString = adaptiveCalloc<Pointer>();
final hr$ = HRESULT(_WindowsDuplicateString(string ?? nullptr, newString));
if (hr$.isError) {
free(newString);
throw WindowsException(hr$);
}
final result$ = newString.value;
free(newString);
return .new(result$);
}