Closed jchown closed 1 year ago
Sorry, copy and paste mistake there. I'll need to call SHCreateItemFromParsingName
(in order to call IFileDialog::SetFolder
)
Sounds good. I've just updated win32 to add this function.
My naive first attempt at this doesn't work:
if (folder != null && folder.isNotEmpty) {
final guid = GUID.fromString(IID_IShellItem);
final shellItem = COMObject.allocate();
hr = SHCreateItemFromParsingName(TEXT(folder), nullptr, guid.addressOf, shellItem.addressOf); // This succeeds
if (FAILED(hr)) throw WindowsException(hr);
hr = fileDialog.SetFolder(shellItem.addressOf); // <-- Fails and takes down the Dart VM
if (FAILED(hr)) throw WindowsException(hr);
}
It feels wrong to be using shellItem.addressOf
to both functions, as one should be a pointer-to-a-pointer and the other a plain pointer, I think? But I couldn't see how to get the type of shellItem
right otherwise.
I'm unfamiliar with the COM model, so I am a little lost.
Hi @timsneath, we are facing the same issue, do you have any update on this?
For most usages, it would be useful to set the initial folder (e.g. to the parent folder of the last loaded file).
Looking at the underlying code & win32 API, I think it would need to call
SHGetKnownFolderPath
fromshlobj.h
, and that this would need to be exposed in the win32 project by adding it towin32api.csv
.If this is the right thing to do I could have a go at it myself?