convertToIID function com
Converts a Dart string into an IID using the IIDFromString call.
You can pass this method a brace-enclosed string, such as '{00000000-0000-0000-C000-000000000046}', and it will return a pointer to a GUID struct that matches the string.
It is the caller's responsibility to deallocate the returned pointer when
they are finished with it. A FFI Arena
may be passed as a
custom allocator for ease of memory management.
Implementation
Pointer<GUID> convertToIID(String strIID, {Allocator allocator = calloc}) {
final lpszIID = strIID.toNativeUtf16();
final iid = allocator<GUID>();
try {
final hr = IIDFromString(lpszIID, iid);
if (FAILED(hr)) {
throw WindowsException(hr);
}
return iid;
} finally {
free(lpszIID);
}
}