fix openFolder on Windows

This commit is contained in:
HJfod 2024-01-06 19:31:26 +02:00
parent a555f736d0
commit 154c5a2522
2 changed files with 12 additions and 3 deletions

View file

@ -13,4 +13,4 @@ struct MyGameToolbox : Modify<MyGameToolbox, GameToolbox> {
CCEGLView::get()->setScissorInPoints(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
}
}
};
};

View file

@ -75,8 +75,17 @@ std::string utils::clipboard::read() {
}
bool utils::file::openFolder(ghc::filesystem::path const& path) {
ShellExecuteA(NULL, "open", path.string().c_str(), NULL, NULL, SW_SHOWDEFAULT);
return true;
auto success = false;
if (CoInitializeEx(nullptr, COINIT_MULTITHREADED) == S_OK) {
if (auto id = ILCreateFromPathW(path.wstring().c_str())) {
if (SHOpenFolderAndSelectItems(id, 0, nullptr, 0) == S_OK) {
success = true;
}
ILFree(id);
}
CoUninitialize();
}
return success;
}
Result<ghc::filesystem::path> utils::file::pickFile(