changeset 1122:4a17c9f977d0

(issue54) Add parameter handling to desktopshellrun
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 17 Sep 2014 12:10:50 +0200
parents a162f4cbba75
children 425a9a861d17
files packaging/desktopshellrun.cpp
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packaging/desktopshellrun.cpp	Wed Sep 17 10:57:54 2014 +0200
+++ b/packaging/desktopshellrun.cpp	Wed Sep 17 12:10:50 2014 +0200
@@ -75,11 +75,12 @@
  *
  * @param[in] disp The shell dispatcher to use for shell execute.
  * @param[in] fName The file that should be exectued.
+ * @param[in] param Optinal parameters to add.
  *
  * @returns true on success.
  */
 static bool
-shellexecute(IShellDispatch2 *disp, wchar_t *fName)
+shellexecute(IShellDispatch2 *disp, wchar_t *fName, wchar_t *param)
 {
   BSTR bName = NULL,
        bParam = NULL,
@@ -95,7 +96,7 @@
     }
 
   bName = SysAllocString(fName);
-  bParam = SysAllocString(L"");
+  bParam = SysAllocString(param ? param : L"");
   bDir = SysAllocString(L"");
   bOp = SysAllocString(L"");
 
@@ -163,7 +164,8 @@
   UNUSED(hwndParent);
   UNUSED(string_size);
   HRESULT hr;
-  wchar_t *wbuf = NULL;
+  wchar_t *wbuf = NULL,
+          *params = NULL;
   IShellWindows *shellWindows = NULL;
   IShellBrowser *shellBrowser = NULL;
   IShellView *shellView = NULL;
@@ -278,11 +280,17 @@
       goto done;
     }
 
-  if (!shellexecute(shellDispatch, wbuf))
+  if ((*stacktop)->next && (*stacktop)->next->text)
+    {
+      params = utf8_to_wchar((*stacktop)->next->text, strlen((*stacktop)->next->text));
+    }
+
+  if (!shellexecute(shellDispatch, wbuf, params))
     {
       ERRORPRINTF ("Failed to execute.");
     }
   xfree (wbuf);
+  xfree (params);
 done:
   if (folderView)
     {

http://wald.intevation.org/projects/trustbridge/