feat: add logUsage to shell.openExternal() options (#37139)

Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Milan Burda 2023-02-14 09:53:18 +01:00 committed by GitHub
parent 3972073116
commit a38b711fb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View file

@ -246,10 +246,19 @@ std::string OpenExternalOnWorkerThread(
L"\"";
std::wstring working_dir = options.working_dir.value();
if (reinterpret_cast<ULONG_PTR>(
ShellExecuteW(nullptr, L"open", escaped_url.c_str(), nullptr,
working_dir.empty() ? nullptr : working_dir.c_str(),
SW_SHOWNORMAL)) <= 32) {
SHELLEXECUTEINFO info = {};
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.fMask = SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI;
info.lpVerb = L"open";
info.lpFile = escaped_url.c_str();
info.lpDirectory = working_dir.empty() ? nullptr : working_dir.c_str();
info.nShow = SW_SHOWNORMAL;
if (options.log_usage) {
info.fMask |= SEE_MASK_FLAG_LOG_USAGE;
}
if (!ShellExecuteEx(&info)) {
return "Failed to open: " +
logging::SystemErrorCodeToString(logging::GetLastSystemErrorCode());
}