Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/explorer_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

#include <windows.h>
#include <shellapi.h>

#include <filesystem>
#include <string>
Expand Down Expand Up @@ -162,20 +163,10 @@ class __declspec(uuid(DLL_UUID)) ExplorerCommandHandler final : public RuntimeCl
wil::unique_cotaskmem_string path;
result = item->GetDisplayName(SIGDN_FILESYSPATH, &path);
if (SUCCEEDED(result)) {
auto command{ wil::str_printf<std::wstring>(LR"-("%s" %s)-", module_path.c_str(), QuoteForCommandLineArg(path.get()).c_str()) };
wil::unique_process_information process_info;
STARTUPINFOW startup_info = {sizeof(startup_info)};
RETURN_IF_WIN32_BOOL_FALSE(CreateProcessW(
nullptr,
command.data(),
nullptr /* lpProcessAttributes */,
nullptr /* lpThreadAttributes */,
false /* bInheritHandles */,
CREATE_NO_WINDOW,
nullptr,
nullptr,
&startup_info,
&process_info));
HINSTANCE ret = ShellExecuteW(nullptr, L"open", module_path.c_str(), QuoteForCommandLineArg(path.get()).c_str(), nullptr, SW_SHOW);
if ((INT_PTR)ret <= HINSTANCE_ERROR) {
RETURN_LAST_ERROR();
}
}
}
}
Expand Down