BSTR.fromString constructor

BSTR.fromString(
  1. String str
)

Create a BSTR from a given Dart string.

This allocates native memory for the BSTR; it can be released with free.

Implementation

factory BSTR.fromString(String str) {
  final pStr = str.toNativeUtf16();
  final pbstr = SysAllocString(pStr);
  calloc.free(pStr);
  return BSTR._(pbstr);
}