diff packaging/desktopshellrun.cpp @ 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 fd85a02d771d
children ffdc8cba139a
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/