summaryrefslogtreecommitdiff
path: root/zen/shell_execute.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2015-10-02 14:57:46 +0200
committerDaniel Wilhelm <daniel@wili.li>2015-10-02 14:57:46 +0200
commitad4e3d2c55e75193c41356c23619f80add41db18 (patch)
treedd836d120f50e472106e04968ef8185c25e4242e /zen/shell_execute.h
parent7.4 (diff)
downloadFreeFileSync-ad4e3d2c55e75193c41356c23619f80add41db18.tar.gz
FreeFileSync-ad4e3d2c55e75193c41356c23619f80add41db18.tar.bz2
FreeFileSync-ad4e3d2c55e75193c41356c23619f80add41db18.zip
7.5
Diffstat (limited to 'zen/shell_execute.h')
-rw-r--r--zen/shell_execute.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/zen/shell_execute.h b/zen/shell_execute.h
index b36bc5ea..2adce179 100644
--- a/zen/shell_execute.h
+++ b/zen/shell_execute.h
@@ -62,12 +62,14 @@ bool shellExecuteImpl(Function fillExecInfo, ExecutionType type)
void shellExecute(const void* /*PCIDLIST_ABSOLUTE*/ shellItemPidl, const std::wstring& displayPath, ExecutionType type) //throw FileError
{
- if (!shellExecuteImpl([&](SHELLEXECUTEINFO& execInfo)
-{
- execInfo.fMask |= SEE_MASK_IDLIST;
- execInfo.lpIDList = const_cast<void*>(shellItemPidl); //lpIDList is documented as PCIDLIST_ABSOLUTE!
- }, type)) //throw FileError
- throwFileError(_("Incorrect command line:") + L"\n" + fmtPath(displayPath), L"ShellExecuteEx", ::GetLastError());
+ auto fillExecInfo = [&](SHELLEXECUTEINFO& execInfo)
+ {
+ execInfo.fMask |= SEE_MASK_IDLIST;
+ execInfo.lpIDList = const_cast<void*>(shellItemPidl); //lpIDList is documented as PCIDLIST_ABSOLUTE!
+ };
+
+ if (!shellExecuteImpl(fillExecInfo , type)) //throw FileError
+ THROW_LAST_FILE_ERROR(_("Incorrect command line:") + L"\n" + fmtPath(displayPath), L"ShellExecuteEx");
}
#endif
@@ -97,12 +99,14 @@ void shellExecute(const Zstring& command, ExecutionType type) //throw FileError
(iter->empty() || std::any_of(iter->begin(), iter->end(), &isWhiteSpace<wchar_t>) ? L"\"" + *iter + L"\"" : *iter);
}
- if (!shellExecuteImpl([&](SHELLEXECUTEINFO& execInfo)
-{
- execInfo.lpFile = filepath.c_str();
+ auto fillExecInfo = [&](SHELLEXECUTEINFO& execInfo)
+ {
+ execInfo.lpFile = filepath.c_str();
execInfo.lpParameters = arguments.c_str();
- }, type))
- throwFileError(_("Incorrect command line:") + L"\nFile: " + fmtPath(filepath) + L"\nArg: " + copyStringTo<std::wstring>(arguments), L"ShellExecuteEx", ::GetLastError());
+ };
+
+ if (!shellExecuteImpl(fillExecInfo, type))
+ THROW_LAST_FILE_ERROR(_("Incorrect command line:") + L"\nFile: " + fmtPath(filepath) + L"\nArg: " + copyStringTo<std::wstring>(arguments), L"ShellExecuteEx");
#elif defined ZEN_LINUX || defined ZEN_MAC
/*
bgstack15