comparison 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
comparison
equal deleted inserted replaced
1121:a162f4cbba75 1122:4a17c9f977d0
73 73
74 /** @brief the actual execuation call on the shell dispatcher 74 /** @brief the actual execuation call on the shell dispatcher
75 * 75 *
76 * @param[in] disp The shell dispatcher to use for shell execute. 76 * @param[in] disp The shell dispatcher to use for shell execute.
77 * @param[in] fName The file that should be exectued. 77 * @param[in] fName The file that should be exectued.
78 * @param[in] param Optinal parameters to add.
78 * 79 *
79 * @returns true on success. 80 * @returns true on success.
80 */ 81 */
81 static bool 82 static bool
82 shellexecute(IShellDispatch2 *disp, wchar_t *fName) 83 shellexecute(IShellDispatch2 *disp, wchar_t *fName, wchar_t *param)
83 { 84 {
84 BSTR bName = NULL, 85 BSTR bName = NULL,
85 bParam = NULL, 86 bParam = NULL,
86 bDir = NULL, 87 bDir = NULL,
87 bOp = NULL; 88 bOp = NULL;
93 ERRORPRINTF ("Invalid call to shellexecute."); 94 ERRORPRINTF ("Invalid call to shellexecute.");
94 return false; 95 return false;
95 } 96 }
96 97
97 bName = SysAllocString(fName); 98 bName = SysAllocString(fName);
98 bParam = SysAllocString(L""); 99 bParam = SysAllocString(param ? param : L"");
99 bDir = SysAllocString(L""); 100 bDir = SysAllocString(L"");
100 bOp = SysAllocString(L""); 101 bOp = SysAllocString(L"");
101 102
102 if (!bName || !bParam || !bDir || !bOp) 103 if (!bName || !bParam || !bDir || !bOp)
103 { 104 {
161 stack_t **stacktop) 162 stack_t **stacktop)
162 { 163 {
163 UNUSED(hwndParent); 164 UNUSED(hwndParent);
164 UNUSED(string_size); 165 UNUSED(string_size);
165 HRESULT hr; 166 HRESULT hr;
166 wchar_t *wbuf = NULL; 167 wchar_t *wbuf = NULL,
168 *params = NULL;
167 IShellWindows *shellWindows = NULL; 169 IShellWindows *shellWindows = NULL;
168 IShellBrowser *shellBrowser = NULL; 170 IShellBrowser *shellBrowser = NULL;
169 IShellView *shellView = NULL; 171 IShellView *shellView = NULL;
170 IShellFolderViewDual *folderView = NULL; 172 IShellFolderViewDual *folderView = NULL;
171 IShellDispatch2 *shellDispatch = NULL; 173 IShellDispatch2 *shellDispatch = NULL;
276 { 278 {
277 ERRORPRINTF ("Failed to convert argument to wchar. error = 0x%lx.", hr); 279 ERRORPRINTF ("Failed to convert argument to wchar. error = 0x%lx.", hr);
278 goto done; 280 goto done;
279 } 281 }
280 282
281 if (!shellexecute(shellDispatch, wbuf)) 283 if ((*stacktop)->next && (*stacktop)->next->text)
284 {
285 params = utf8_to_wchar((*stacktop)->next->text, strlen((*stacktop)->next->text));
286 }
287
288 if (!shellexecute(shellDispatch, wbuf, params))
282 { 289 {
283 ERRORPRINTF ("Failed to execute."); 290 ERRORPRINTF ("Failed to execute.");
284 } 291 }
285 xfree (wbuf); 292 xfree (wbuf);
293 xfree (params);
286 done: 294 done:
287 if (folderView) 295 if (folderView)
288 { 296 {
289 folderView->Release(); 297 folderView->Release();
290 } 298 }

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