2828#include " rapidassist/filesystem_utf8.h"
2929#include " PropertyManager.h"
3030
31+ #include < windows.h>
3132#pragma warning( push )
3233#pragma warning( disable: 4355 ) // glog\install_dir\include\glog/logging.h(1167): warning C4355: 'this' : used in base member initializer list
3334#include < glog/logging.h>
@@ -45,7 +46,56 @@ namespace shellanything
4546 {
4647 }
4748
48- bool ActionExecute::Execute (const Context & iContext) const
49+ bool ActionExecute::Execute (const Context& iContext) const
50+ {
51+ PropertyManager& pmgr = PropertyManager::GetInstance ();
52+ std::string path = pmgr.Expand (mPath );
53+ std::string basedir = pmgr.Expand (mBaseDir );
54+ std::string arguments = pmgr.Expand (mArguments );
55+ std::string verb = pmgr.Expand (mVerb );
56+
57+ std::wstring pathW = ra::unicode::Utf8ToUnicode (path);
58+ std::wstring argumentsW = ra::unicode::Utf8ToUnicode (arguments);
59+ std::wstring basedirW = ra::unicode::Utf8ToUnicode (basedir);
60+ std::wstring verbW = ra::unicode::Utf8ToUnicode (verb);
61+
62+ SHELLEXECUTEINFOW info = { 0 };
63+
64+ info.cbSize = sizeof (SHELLEXECUTEINFOW);
65+
66+ info.fMask |= SEE_MASK_NOCLOSEPROCESS;
67+ info.fMask |= SEE_MASK_NOASYNC;
68+ info.fMask |= SEE_MASK_FLAG_DDEWAIT;
69+
70+ info.hwnd = HWND_DESKTOP;
71+ info.nShow = SW_SHOWDEFAULT;
72+ info.lpFile = pathW.c_str ();
73+
74+ LOG (INFO) << " Exec: '" << path;
75+
76+ if (!verb.empty ())
77+ {
78+ info.lpVerb = verbW.c_str (); // Verb
79+ LOG (INFO) << " Verb: '" << verb;
80+ }
81+
82+ if (!arguments.empty ())
83+ {
84+ info.lpParameters = argumentsW.c_str (); // Arguments
85+ LOG (INFO) << " Arguments: '" << arguments;
86+ }
87+
88+ if (!basedir.empty ())
89+ {
90+ info.lpDirectory = basedirW.c_str (); // Default directory
91+ LOG (INFO) << " Basedir: '" << basedir;
92+ }
93+
94+ BOOL success = ShellExecuteExW (&info);
95+ return (success == TRUE );
96+ }
97+
98+ bool ActionExecute::StartProcess (const Context & iContext) const
4999 {
50100 PropertyManager & pmgr = PropertyManager::GetInstance ();
51101 std::string path = pmgr.Expand (mPath );
@@ -146,4 +196,14 @@ namespace shellanything
146196 mArguments = iArguments;
147197 }
148198
199+ const std::string& ActionExecute::GetVerb () const
200+ {
201+ return mArguments ;
202+ }
203+
204+ void ActionExecute::SetVerb (const std::string& iVerb)
205+ {
206+ mVerb = iVerb;
207+ }
208+
149209} // namespace shellanything
0 commit comments