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

@ -75,8 +75,17 @@ std::string utils::clipboard::read() {
} }
bool utils::file::openFolder(ghc::filesystem::path const& path) { bool utils::file::openFolder(ghc::filesystem::path const& path) {
ShellExecuteA(NULL, "open", path.string().c_str(), NULL, NULL, SW_SHOWDEFAULT); auto success = false;
return true; 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( Result<ghc::filesystem::path> utils::file::pickFile(