convertToIID function Null safety com

Pointer<GUID> convertToIID(
  1. String strIID
)

Converts a Dart string into an IID using the IIDFromString call.

Returns a Pointer to the allocated IID. It is the caller's responsibility to deallocate the pointer when they are finished with it.

Implementation

Pointer<GUID> convertToIID(String strIID) {
  final lpszIID = strIID.toNativeUtf16();
  final iid = calloc<GUID>();

  try {
    final hr = IIDFromString(lpszIID, iid);
    if (FAILED(hr)) {
      throw WindowsException(hr);
    }
    return iid;
  } finally {
    free(lpszIID);
  }
}