ReactOS  0.4.14-dev-55-g2da92ac
shell.c
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "wshom_private.h"
20 #include "wshom.h"
21 
22 #include "shellapi.h"
23 #include "shlobj.h"
24 #include "dispex.h"
25 
26 #include "wine/debug.h"
27 #include "wine/heap.h"
28 #include "wine/unicode.h"
29 
31 
32 typedef struct
33 {
35  IWshShell3 IWshShell3_iface;
36 } WshShellImpl;
38 
39 typedef struct
40 {
42  IWshCollection IWshCollection_iface;
45 
46 typedef struct
47 {
49  IWshShortcut IWshShortcut_iface;
51 
54 } WshShortcut;
55 
56 typedef struct
57 {
59  IWshEnvironment IWshEnvironment_iface;
62 
63 typedef struct
64 {
66  IWshExec IWshExec_iface;
69 } WshExecImpl;
70 
71 static inline WshCollection *impl_from_IWshCollection( IWshCollection *iface )
72 {
73  return CONTAINING_RECORD(iface, WshCollection, IWshCollection_iface);
74 }
75 
76 static inline WshShortcut *impl_from_IWshShortcut( IWshShortcut *iface )
77 {
78  return CONTAINING_RECORD(iface, WshShortcut, IWshShortcut_iface);
79 }
80 
81 static inline WshEnvironment *impl_from_IWshEnvironment( IWshEnvironment *iface )
82 {
83  return CONTAINING_RECORD(iface, WshEnvironment, IWshEnvironment_iface);
84 }
85 
86 static inline WshExecImpl *impl_from_IWshExec( IWshExec *iface )
87 {
88  return CONTAINING_RECORD(iface, WshExecImpl, IWshExec_iface);
89 }
90 
91 static HRESULT WINAPI WshExec_QueryInterface(IWshExec *iface, REFIID riid, void **obj)
92 {
94 
95  TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
96 
98  IsEqualGUID(riid, &IID_IWshExec) ||
100  {
101  *obj = iface;
102  }
104  {
105  *obj = &This->classinfo.IProvideClassInfo_iface;
106  }
107  else {
108  FIXME("Unknown iface %s\n", debugstr_guid(riid));
109  *obj = NULL;
110  return E_NOINTERFACE;
111  }
112 
113  IUnknown_AddRef((IUnknown *)*obj);
114  return S_OK;
115 }
116 
117 static ULONG WINAPI WshExec_AddRef(IWshExec *iface)
118 {
121  TRACE("(%p) ref = %d\n", This, ref);
122  return ref;
123 }
124 
125 static ULONG WINAPI WshExec_Release(IWshExec *iface)
126 {
129  TRACE("(%p) ref = %d\n", This, ref);
130 
131  if (!ref) {
132  CloseHandle(This->info.hThread);
133  CloseHandle(This->info.hProcess);
134  heap_free(This);
135  }
136 
137  return ref;
138 }
139 
140 static HRESULT WINAPI WshExec_GetTypeInfoCount(IWshExec *iface, UINT *pctinfo)
141 {
143  TRACE("(%p)->(%p)\n", This, pctinfo);
144  *pctinfo = 1;
145  return S_OK;
146 }
147 
148 static HRESULT WINAPI WshExec_GetTypeInfo(IWshExec *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
149 {
151  TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
152  return get_typeinfo(IWshExec_tid, ppTInfo);
153 }
154 
155 static HRESULT WINAPI WshExec_GetIDsOfNames(IWshExec *iface, REFIID riid, LPOLESTR *rgszNames,
156  UINT cNames, LCID lcid, DISPID *rgDispId)
157 {
160  HRESULT hr;
161 
162  TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
163 
165  if(SUCCEEDED(hr))
166  {
167  hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
168  ITypeInfo_Release(typeinfo);
169  }
170 
171  return hr;
172 }
173 
174 static HRESULT WINAPI WshExec_Invoke(IWshExec *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
175  WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
176 {
179  HRESULT hr;
180 
181  TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
182  lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
183 
185  if(SUCCEEDED(hr))
186  {
187  hr = ITypeInfo_Invoke(typeinfo, &This->IWshExec_iface, dispIdMember, wFlags,
188  pDispParams, pVarResult, pExcepInfo, puArgErr);
189  ITypeInfo_Release(typeinfo);
190  }
191 
192  return hr;
193 }
194 
196 {
198  DWORD code;
199 
200  TRACE("(%p)->(%p)\n", This, status);
201 
202  if (!status)
203  return E_INVALIDARG;
204 
205  if (!GetExitCodeProcess(This->info.hProcess, &code))
207 
208  switch (code)
209  {
210  case 0:
211  *status = WshFinished;
212  break;
213  case STILL_ACTIVE:
214  *status = WshRunning;
215  break;
216  default:
217  *status = WshFailed;
218  }
219 
220  return S_OK;
221 }
222 
223 static HRESULT WINAPI WshExec_get_StdIn(IWshExec *iface, ITextStream **stream)
224 {
226 
227  FIXME("(%p)->(%p): stub\n", This, stream);
228 
229  return E_NOTIMPL;
230 }
231 
232 static HRESULT WINAPI WshExec_get_StdOut(IWshExec *iface, ITextStream **stream)
233 {
235 
236  FIXME("(%p)->(%p): stub\n", This, stream);
237 
238  return E_NOTIMPL;
239 }
240 
241 static HRESULT WINAPI WshExec_get_StdErr(IWshExec *iface, ITextStream **stream)
242 {
244 
245  FIXME("(%p)->(%p): stub\n", This, stream);
246 
247  return E_NOTIMPL;
248 }
249 
250 static HRESULT WINAPI WshExec_get_ProcessID(IWshExec *iface, DWORD *pid)
251 {
253 
254  TRACE("(%p)->(%p)\n", This, pid);
255 
256  if (!pid)
257  return E_INVALIDARG;
258 
259  *pid = This->info.dwProcessId;
260  return S_OK;
261 }
262 
263 static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, DWORD *code)
264 {
266 
267  FIXME("(%p)->(%p): stub\n", This, code);
268 
269  return E_NOTIMPL;
270 }
271 
273 {
274  INT *count = (INT*)lParam;
275 
276  (*count)++;
277  PostMessageW(hwnd, WM_CLOSE, 0, 0);
278  /* try to send it to all windows, even if failed for some */
279  return TRUE;
280 }
281 
282 static HRESULT WINAPI WshExec_Terminate(IWshExec *iface)
283 {
285  BOOL ret, kill = FALSE;
286  INT count = 0;
287 
288  TRACE("(%p)\n", This);
289 
290  ret = EnumThreadWindows(This->info.dwThreadId, enum_thread_wnd_proc, (LPARAM)&count);
291  if (ret && count) {
292  /* manual testing shows that it waits 2 seconds before forcing termination */
293  if (WaitForSingleObject(This->info.hProcess, 2000) != WAIT_OBJECT_0)
294  kill = TRUE;
295  }
296  else
297  kill = TRUE;
298 
299  if (kill)
300  TerminateProcess(This->info.hProcess, 0);
301 
302  return S_OK;
303 }
304 
305 static const IWshExecVtbl WshExecVtbl = {
320 };
321 
322 static HRESULT WshExec_create(BSTR command, IWshExec **ret)
323 {
324  STARTUPINFOW si = {0};
325  WshExecImpl *This;
326 
327  *ret = NULL;
328 
329  This = heap_alloc(sizeof(*This));
330  if (!This)
331  return E_OUTOFMEMORY;
332 
333  This->IWshExec_iface.lpVtbl = &WshExecVtbl;
334  This->ref = 1;
335 
336  if (!CreateProcessW(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &This->info)) {
337  heap_free(This);
339  }
340 
341  init_classinfo(&CLSID_WshExec, (IUnknown *)&This->IWshExec_iface, &This->classinfo);
342  *ret = &This->IWshExec_iface;
343  return S_OK;
344 }
345 
346 static HRESULT WINAPI WshEnvironment_QueryInterface(IWshEnvironment *iface, REFIID riid, void **obj)
347 {
349 
350  TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
351 
352  if (IsEqualGUID(riid, &IID_IUnknown) ||
354  IsEqualGUID(riid, &IID_IWshEnvironment))
355  {
356  *obj = iface;
357  }
359  {
360  *obj = &This->classinfo.IProvideClassInfo_iface;
361  }
362  else {
363  FIXME("Unknown iface %s\n", debugstr_guid(riid));
364  *obj = NULL;
365  return E_NOINTERFACE;
366  }
367 
368  IUnknown_AddRef((IUnknown*)*obj);
369  return S_OK;
370 }
371 
372 static ULONG WINAPI WshEnvironment_AddRef(IWshEnvironment *iface)
373 {
376  TRACE("(%p) ref = %d\n", This, ref);
377  return ref;
378 }
379 
380 static ULONG WINAPI WshEnvironment_Release(IWshEnvironment *iface)
381 {
384  TRACE("(%p) ref = %d\n", This, ref);
385 
386  if (!ref)
387  heap_free(This);
388 
389  return ref;
390 }
391 
392 static HRESULT WINAPI WshEnvironment_GetTypeInfoCount(IWshEnvironment *iface, UINT *pctinfo)
393 {
395  TRACE("(%p)->(%p)\n", This, pctinfo);
396  *pctinfo = 1;
397  return S_OK;
398 }
399 
400 static HRESULT WINAPI WshEnvironment_GetTypeInfo(IWshEnvironment *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
401 {
403  TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
404  return get_typeinfo(IWshEnvironment_tid, ppTInfo);
405 }
406 
407 static HRESULT WINAPI WshEnvironment_GetIDsOfNames(IWshEnvironment *iface, REFIID riid, LPOLESTR *rgszNames,
408  UINT cNames, LCID lcid, DISPID *rgDispId)
409 {
412  HRESULT hr;
413 
414  TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
415 
417  if(SUCCEEDED(hr))
418  {
419  hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
420  ITypeInfo_Release(typeinfo);
421  }
422 
423  return hr;
424 }
425 
426 static HRESULT WINAPI WshEnvironment_Invoke(IWshEnvironment *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
427  WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
428 {
431  HRESULT hr;
432 
433  TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
434  lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
435 
437  if(SUCCEEDED(hr))
438  {
439  hr = ITypeInfo_Invoke(typeinfo, &This->IWshEnvironment_iface, dispIdMember, wFlags,
440  pDispParams, pVarResult, pExcepInfo, puArgErr);
441  ITypeInfo_Release(typeinfo);
442  }
443 
444  return hr;
445 }
446 
447 static HRESULT WINAPI WshEnvironment_get_Item(IWshEnvironment *iface, BSTR name, BSTR *value)
448 {
450  DWORD len;
451 
452  TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), value);
453 
454  if (!value)
455  return E_POINTER;
456 
459  if (!*value)
460  return E_OUTOFMEMORY;
461 
462  if (len)
464 
465  return S_OK;
466 }
467 
468 static HRESULT WINAPI WshEnvironment_put_Item(IWshEnvironment *iface, BSTR name, BSTR value)
469 {
471  FIXME("(%p)->(%s %s): stub\n", This, debugstr_w(name), debugstr_w(value));
472  return E_NOTIMPL;
473 }
474 
475 static HRESULT WINAPI WshEnvironment_Count(IWshEnvironment *iface, LONG *count)
476 {
478  FIXME("(%p)->(%p): stub\n", This, count);
479  return E_NOTIMPL;
480 }
481 
482 static HRESULT WINAPI WshEnvironment_get_length(IWshEnvironment *iface, LONG *len)
483 {
485  FIXME("(%p)->(%p): stub\n", This, len);
486  return E_NOTIMPL;
487 }
488 
489 static HRESULT WINAPI WshEnvironment__NewEnum(IWshEnvironment *iface, IUnknown **penum)
490 {
492  FIXME("(%p)->(%p): stub\n", This, penum);
493  return E_NOTIMPL;
494 }
495 
496 static HRESULT WINAPI WshEnvironment_Remove(IWshEnvironment *iface, BSTR name)
497 {
499  FIXME("(%p)->(%s): stub\n", This, debugstr_w(name));
500  return E_NOTIMPL;
501 }
502 
503 static const IWshEnvironmentVtbl WshEnvironmentVtbl = {
517 };
518 
519 static HRESULT WshEnvironment_Create(IWshEnvironment **env)
520 {
522 
523  This = heap_alloc(sizeof(*This));
524  if (!This) return E_OUTOFMEMORY;
525 
526  This->IWshEnvironment_iface.lpVtbl = &WshEnvironmentVtbl;
527  This->ref = 1;
528 
529  init_classinfo(&IID_IWshEnvironment, (IUnknown *)&This->IWshEnvironment_iface, &This->classinfo);
530  *env = &This->IWshEnvironment_iface;
531 
532  return S_OK;
533 }
534 
535 static HRESULT WINAPI WshCollection_QueryInterface(IWshCollection *iface, REFIID riid, void **ppv)
536 {
538 
539  TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
540 
541  if (IsEqualGUID(riid, &IID_IUnknown) ||
543  IsEqualGUID(riid, &IID_IWshCollection))
544  {
545  *ppv = iface;
546  }
548  {
549  *ppv = &This->classinfo.IProvideClassInfo_iface;
550  }
551  else {
552  FIXME("Unknown iface %s\n", debugstr_guid(riid));
553  *ppv = NULL;
554  return E_NOINTERFACE;
555  }
556 
557  IUnknown_AddRef((IUnknown*)*ppv);
558  return S_OK;
559 }
560 
561 static ULONG WINAPI WshCollection_AddRef(IWshCollection *iface)
562 {
565  TRACE("(%p) ref = %d\n", This, ref);
566  return ref;
567 }
568 
569 static ULONG WINAPI WshCollection_Release(IWshCollection *iface)
570 {
573  TRACE("(%p) ref = %d\n", This, ref);
574 
575  if (!ref)
576  heap_free(This);
577 
578  return ref;
579 }
580 
581 static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT *pctinfo)
582 {
584  TRACE("(%p)->(%p)\n", This, pctinfo);
585  *pctinfo = 1;
586  return S_OK;
587 }
588 
589 static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
590 {
592  TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
593  return get_typeinfo(IWshCollection_tid, ppTInfo);
594 }
595 
596 static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID riid, LPOLESTR *rgszNames,
597  UINT cNames, LCID lcid, DISPID *rgDispId)
598 {
601  HRESULT hr;
602 
603  TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
604 
606  if(SUCCEEDED(hr))
607  {
608  hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
609  ITypeInfo_Release(typeinfo);
610  }
611 
612  return hr;
613 }
614 
615 static HRESULT WINAPI WshCollection_Invoke(IWshCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
616  WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
617 {
620  HRESULT hr;
621 
622  TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
623  lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
624 
626  if(SUCCEEDED(hr))
627  {
628  hr = ITypeInfo_Invoke(typeinfo, &This->IWshCollection_iface, dispIdMember, wFlags,
629  pDispParams, pVarResult, pExcepInfo, puArgErr);
630  ITypeInfo_Release(typeinfo);
631  }
632 
633  return hr;
634 }
635 
636 static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value)
637 {
639  static const WCHAR allusersdesktopW[] = {'A','l','l','U','s','e','r','s','D','e','s','k','t','o','p',0};
640  static const WCHAR allusersprogramsW[] = {'A','l','l','U','s','e','r','s','P','r','o','g','r','a','m','s',0};
641  static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
642  PIDLIST_ABSOLUTE pidl;
643  WCHAR pathW[MAX_PATH];
644  int kind = 0;
645  BSTR folder;
646  HRESULT hr;
647 
648  TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), value);
649 
650  if (V_VT(index) != VT_BSTR)
651  {
652  FIXME("only BSTR index supported, got %d\n", V_VT(index));
653  return E_NOTIMPL;
654  }
655 
656  folder = V_BSTR(index);
657  if (!strcmpiW(folder, desktopW))
658  kind = CSIDL_DESKTOP;
659  else if (!strcmpiW(folder, allusersdesktopW))
661  else if (!strcmpiW(folder, allusersprogramsW))
662  kind = CSIDL_COMMON_PROGRAMS;
663  else
664  {
665  FIXME("folder kind %s not supported\n", debugstr_w(folder));
666  return E_NOTIMPL;
667  }
668 
669  hr = SHGetSpecialFolderLocation(NULL, kind, &pidl);
670  if (hr != S_OK) return hr;
671 
672  if (SHGetPathFromIDListW(pidl, pathW))
673  {
674  V_VT(value) = VT_BSTR;
675  V_BSTR(value) = SysAllocString(pathW);
677  }
678  else
679  hr = E_FAIL;
680 
681  CoTaskMemFree(pidl);
682 
683  return hr;
684 }
685 
686 static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count)
687 {
689  FIXME("(%p)->(%p): stub\n", This, count);
690  return E_NOTIMPL;
691 }
692 
693 static HRESULT WINAPI WshCollection_get_length(IWshCollection *iface, LONG *count)
694 {
696  FIXME("(%p)->(%p): stub\n", This, count);
697  return E_NOTIMPL;
698 }
699 
700 static HRESULT WINAPI WshCollection__NewEnum(IWshCollection *iface, IUnknown *Enum)
701 {
703  FIXME("(%p)->(%p): stub\n", This, Enum);
704  return E_NOTIMPL;
705 }
706 
707 static const IWshCollectionVtbl WshCollectionVtbl = {
719 };
720 
721 static HRESULT WshCollection_Create(IWshCollection **collection)
722 {
724 
725  This = heap_alloc(sizeof(*This));
726  if (!This) return E_OUTOFMEMORY;
727 
728  This->IWshCollection_iface.lpVtbl = &WshCollectionVtbl;
729  This->ref = 1;
730 
731  init_classinfo(&IID_IWshCollection, (IUnknown *)&This->IWshCollection_iface, &This->classinfo);
732  *collection = &This->IWshCollection_iface;
733 
734  return S_OK;
735 }
736 
737 /* IWshShortcut */
738 static HRESULT WINAPI WshShortcut_QueryInterface(IWshShortcut *iface, REFIID riid, void **ppv)
739 {
741 
742  TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
743 
744  if (IsEqualGUID(riid, &IID_IUnknown) ||
746  IsEqualGUID(riid, &IID_IWshShortcut))
747  {
748  *ppv = iface;
749  }
751  {
752  *ppv = &This->classinfo.IProvideClassInfo_iface;
753  }
754  else {
755  FIXME("Unknown iface %s\n", debugstr_guid(riid));
756  *ppv = NULL;
757  return E_NOINTERFACE;
758  }
759 
760  IUnknown_AddRef((IUnknown*)*ppv);
761  return S_OK;
762 }
763 
764 static ULONG WINAPI WshShortcut_AddRef(IWshShortcut *iface)
765 {
768  TRACE("(%p) ref = %d\n", This, ref);
769  return ref;
770 }
771 
772 static ULONG WINAPI WshShortcut_Release(IWshShortcut *iface)
773 {
776  TRACE("(%p) ref = %d\n", This, ref);
777 
778  if (!ref)
779  {
780  SysFreeString(This->path_link);
781  IShellLinkW_Release(This->link);
782  heap_free(This);
783  }
784 
785  return ref;
786 }
787 
788 static HRESULT WINAPI WshShortcut_GetTypeInfoCount(IWshShortcut *iface, UINT *pctinfo)
789 {
791  TRACE("(%p)->(%p)\n", This, pctinfo);
792  *pctinfo = 1;
793  return S_OK;
794 }
795 
796 static HRESULT WINAPI WshShortcut_GetTypeInfo(IWshShortcut *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
797 {
799  TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
800  return get_typeinfo(IWshShortcut_tid, ppTInfo);
801 }
802 
803 static HRESULT WINAPI WshShortcut_GetIDsOfNames(IWshShortcut *iface, REFIID riid, LPOLESTR *rgszNames,
804  UINT cNames, LCID lcid, DISPID *rgDispId)
805 {
808  HRESULT hr;
809 
810  TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
811 
813  if(SUCCEEDED(hr))
814  {
815  hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
816  ITypeInfo_Release(typeinfo);
817  }
818 
819  return hr;
820 }
821 
822 static HRESULT WINAPI WshShortcut_Invoke(IWshShortcut *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
823  WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
824 {
827  HRESULT hr;
828 
829  TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
830  lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
831 
833  if(SUCCEEDED(hr))
834  {
835  hr = ITypeInfo_Invoke(typeinfo, &This->IWshShortcut_iface, dispIdMember, wFlags,
836  pDispParams, pVarResult, pExcepInfo, puArgErr);
837  ITypeInfo_Release(typeinfo);
838  }
839 
840  return hr;
841 }
842 
843 static HRESULT WINAPI WshShortcut_get_FullName(IWshShortcut *iface, BSTR *name)
844 {
846  FIXME("(%p)->(%p): stub\n", This, name);
847  return E_NOTIMPL;
848 }
849 
850 static HRESULT WINAPI WshShortcut_get_Arguments(IWshShortcut *iface, BSTR *Arguments)
851 {
853  WCHAR buffW[INFOTIPSIZE];
854  HRESULT hr;
855 
856  TRACE("(%p)->(%p)\n", This, Arguments);
857 
858  if (!Arguments)
859  return E_POINTER;
860 
861  *Arguments = NULL;
862 
863  hr = IShellLinkW_GetArguments(This->link, buffW, ARRAY_SIZE(buffW));
864  if (FAILED(hr))
865  return hr;
866 
867  *Arguments = SysAllocString(buffW);
868  return *Arguments ? S_OK : E_OUTOFMEMORY;
869 }
870 
871 static HRESULT WINAPI WshShortcut_put_Arguments(IWshShortcut *iface, BSTR Arguments)
872 {
874 
875  TRACE("(%p)->(%s)\n", This, debugstr_w(Arguments));
876 
877  return IShellLinkW_SetArguments(This->link, Arguments);
878 }
879 
881 {
883  FIXME("(%p)->(%p): stub\n", This, Description);
884  return E_NOTIMPL;
885 }
886 
888 {
890  TRACE("(%p)->(%s)\n", This, debugstr_w(Description));
891  return IShellLinkW_SetDescription(This->link, Description);
892 }
893 
894 static HRESULT WINAPI WshShortcut_get_Hotkey(IWshShortcut *iface, BSTR *Hotkey)
895 {
897  FIXME("(%p)->(%p): stub\n", This, Hotkey);
898  return E_NOTIMPL;
899 }
900 
901 static HRESULT WINAPI WshShortcut_put_Hotkey(IWshShortcut *iface, BSTR Hotkey)
902 {
904  FIXME("(%p)->(%s): stub\n", This, debugstr_w(Hotkey));
905  return E_NOTIMPL;
906 }
907 
909 {
910  static const WCHAR fmtW[] = {'%','s',',',' ','%','d',0};
912  WCHAR buffW[MAX_PATH], pathW[MAX_PATH];
913  INT icon = 0;
914  HRESULT hr;
915 
916  TRACE("(%p)->(%p)\n", This, IconPath);
917 
918  if (!IconPath)
919  return E_POINTER;
920 
921  hr = IShellLinkW_GetIconLocation(This->link, buffW, ARRAY_SIZE(buffW), &icon);
922  if (FAILED(hr)) return hr;
923 
924  sprintfW(pathW, fmtW, buffW, icon);
925  *IconPath = SysAllocString(pathW);
926  if (!*IconPath) return E_OUTOFMEMORY;
927 
928  return S_OK;
929 }
930 
932 {
934  HRESULT hr;
935  WCHAR *ptr;
936  BSTR path;
937  INT icon;
938 
939  TRACE("(%p)->(%s)\n", This, debugstr_w(IconPath));
940 
941  /* scan for icon id */
942  ptr = strrchrW(IconPath, ',');
943  if (!ptr)
944  {
945  WARN("icon index not found\n");
946  return E_FAIL;
947  }
948 
950 
951  /* skip spaces if any */
952  while (isspaceW(*++ptr))
953  ;
954 
955  icon = atoiW(ptr);
956 
957  hr = IShellLinkW_SetIconLocation(This->link, path, icon);
959 
960  return hr;
961 }
962 
963 static HRESULT WINAPI WshShortcut_put_RelativePath(IWshShortcut *iface, BSTR rhs)
964 {
966  FIXME("(%p)->(%s): stub\n", This, debugstr_w(rhs));
967  return E_NOTIMPL;
968 }
969 
970 static HRESULT WINAPI WshShortcut_get_TargetPath(IWshShortcut *iface, BSTR *Path)
971 {
973  FIXME("(%p)->(%p): stub\n", This, Path);
974  return E_NOTIMPL;
975 }
976 
977 static HRESULT WINAPI WshShortcut_put_TargetPath(IWshShortcut *iface, BSTR Path)
978 {
980  TRACE("(%p)->(%s)\n", This, debugstr_w(Path));
981  return IShellLinkW_SetPath(This->link, Path);
982 }
983 
984 static HRESULT WINAPI WshShortcut_get_WindowStyle(IWshShortcut *iface, int *ShowCmd)
985 {
987  TRACE("(%p)->(%p)\n", This, ShowCmd);
988  return IShellLinkW_GetShowCmd(This->link, ShowCmd);
989 }
990 
991 static HRESULT WINAPI WshShortcut_put_WindowStyle(IWshShortcut *iface, int ShowCmd)
992 {
994  TRACE("(%p)->(%d)\n", This, ShowCmd);
995  return IShellLinkW_SetShowCmd(This->link, ShowCmd);
996 }
997 
998 static HRESULT WINAPI WshShortcut_get_WorkingDirectory(IWshShortcut *iface, BSTR *WorkingDirectory)
999 {
1001  WCHAR buffW[MAX_PATH];
1002  HRESULT hr;
1003 
1004  TRACE("(%p)->(%p)\n", This, WorkingDirectory);
1005 
1006  if (!WorkingDirectory)
1007  return E_POINTER;
1008 
1009  *WorkingDirectory = NULL;
1010  hr = IShellLinkW_GetWorkingDirectory(This->link, buffW, ARRAY_SIZE(buffW));
1011  if (FAILED(hr)) return hr;
1012 
1013  *WorkingDirectory = SysAllocString(buffW);
1014  return *WorkingDirectory ? S_OK : E_OUTOFMEMORY;
1015 }
1016 
1017 static HRESULT WINAPI WshShortcut_put_WorkingDirectory(IWshShortcut *iface, BSTR WorkingDirectory)
1018 {
1020  TRACE("(%p)->(%s)\n", This, debugstr_w(WorkingDirectory));
1021  return IShellLinkW_SetWorkingDirectory(This->link, WorkingDirectory);
1022 }
1023 
1024 static HRESULT WINAPI WshShortcut_Load(IWshShortcut *iface, BSTR PathLink)
1025 {
1027  FIXME("(%p)->(%s): stub\n", This, debugstr_w(PathLink));
1028  return E_NOTIMPL;
1029 }
1030 
1031 static HRESULT WINAPI WshShortcut_Save(IWshShortcut *iface)
1032 {
1034  IPersistFile *file;
1035  HRESULT hr;
1036 
1037  TRACE("(%p)\n", This);
1038 
1039  IShellLinkW_QueryInterface(This->link, &IID_IPersistFile, (void**)&file);
1040  hr = IPersistFile_Save(file, This->path_link, TRUE);
1041  IPersistFile_Release(file);
1042 
1043  return hr;
1044 }
1045 
1046 static const IWshShortcutVtbl WshShortcutVtbl = {
1072 };
1073 
1074 static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut)
1075 {
1076  WshShortcut *This;
1077  HRESULT hr;
1078 
1079  *shortcut = NULL;
1080 
1081  This = heap_alloc(sizeof(*This));
1082  if (!This) return E_OUTOFMEMORY;
1083 
1084  This->IWshShortcut_iface.lpVtbl = &WshShortcutVtbl;
1085  This->ref = 1;
1086 
1087  hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
1088  &IID_IShellLinkW, (void**)&This->link);
1089  if (FAILED(hr))
1090  {
1091  heap_free(This);
1092  return hr;
1093  }
1094 
1095  This->path_link = SysAllocString(path);
1096  if (!This->path_link)
1097  {
1098  IShellLinkW_Release(This->link);
1099  heap_free(This);
1100  return E_OUTOFMEMORY;
1101  }
1102 
1103  init_classinfo(&IID_IWshShortcut, (IUnknown *)&This->IWshShortcut_iface, &This->classinfo);
1104  *shortcut = (IDispatch*)&This->IWshShortcut_iface;
1105 
1106  return S_OK;
1107 }
1108 
1109 static HRESULT WINAPI WshShell3_QueryInterface(IWshShell3 *iface, REFIID riid, void **ppv)
1110 {
1111  TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
1112 
1113  *ppv = NULL;
1114 
1115  if (IsEqualGUID(riid, &IID_IDispatch) ||
1116  IsEqualGUID(riid, &IID_IWshShell3) ||
1117  IsEqualGUID(riid, &IID_IWshShell2) ||
1118  IsEqualGUID(riid, &IID_IWshShell) ||
1120  {
1121  *ppv = iface;
1122  }
1123  else if (IsEqualGUID(riid, &IID_IDispatchEx))
1124  {
1125  return E_NOINTERFACE;
1126  }
1128  {
1129  *ppv = &WshShell3.classinfo.IProvideClassInfo_iface;
1130  }
1131  else
1132  {
1133  WARN("unknown iface %s\n", debugstr_guid(riid));
1134  return E_NOINTERFACE;
1135  }
1136 
1137  IUnknown_AddRef((IUnknown *)*ppv);
1138  return S_OK;
1139 }
1140 
1141 static ULONG WINAPI WshShell3_AddRef(IWshShell3 *iface)
1142 {
1143  TRACE("()\n");
1144  return 2;
1145 }
1146 
1147 static ULONG WINAPI WshShell3_Release(IWshShell3 *iface)
1148 {
1149  TRACE("()\n");
1150  return 2;
1151 }
1152 
1153 static HRESULT WINAPI WshShell3_GetTypeInfoCount(IWshShell3 *iface, UINT *pctinfo)
1154 {
1155  TRACE("(%p)\n", pctinfo);
1156  *pctinfo = 1;
1157  return S_OK;
1158 }
1159 
1160 static HRESULT WINAPI WshShell3_GetTypeInfo(IWshShell3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1161 {
1162  TRACE("(%u %u %p)\n", iTInfo, lcid, ppTInfo);
1163  return get_typeinfo(IWshShell3_tid, ppTInfo);
1164 }
1165 
1166 static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames,
1167  UINT cNames, LCID lcid, DISPID *rgDispId)
1168 {
1170  HRESULT hr;
1171 
1172  TRACE("(%s %p %u %u %p)\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1173 
1175  if(SUCCEEDED(hr))
1176  {
1177  hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1178  ITypeInfo_Release(typeinfo);
1179  }
1180 
1181  return hr;
1182 }
1183 
1184 static HRESULT WINAPI WshShell3_Invoke(IWshShell3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
1185  WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1186 {
1188  HRESULT hr;
1189 
1190  TRACE("(%d %s %d %d %p %p %p %p)\n", dispIdMember, debugstr_guid(riid),
1191  lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1192 
1194  if(SUCCEEDED(hr))
1195  {
1196  hr = ITypeInfo_Invoke(typeinfo, &WshShell3.IWshShell3_iface, dispIdMember, wFlags,
1197  pDispParams, pVarResult, pExcepInfo, puArgErr);
1198  ITypeInfo_Release(typeinfo);
1199  }
1200 
1201  return hr;
1202 }
1203 
1204 static HRESULT WINAPI WshShell3_get_SpecialFolders(IWshShell3 *iface, IWshCollection **folders)
1205 {
1206  TRACE("(%p)\n", folders);
1207  return WshCollection_Create(folders);
1208 }
1209 
1210 static HRESULT WINAPI WshShell3_get_Environment(IWshShell3 *iface, VARIANT *type, IWshEnvironment **env)
1211 {
1212  FIXME("(%s %p): semi-stub\n", debugstr_variant(type), env);
1213  return WshEnvironment_Create(env);
1214 }
1215 
1216 static inline BOOL is_optional_argument(const VARIANT *arg)
1217 {
1218  return V_VT(arg) == VT_ERROR && V_ERROR(arg) == DISP_E_PARAMNOTFOUND;
1219 }
1220 
1221 static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, DWORD *exit_code)
1222 {
1224  int waitforprocess;
1225  VARIANT s;
1226  HRESULT hr;
1227 
1228  TRACE("(%s %s %s %p)\n", debugstr_w(cmd), debugstr_variant(style), debugstr_variant(wait), exit_code);
1229 
1230  if (!style || !wait || !exit_code)
1231  return E_POINTER;
1232 
1233  VariantInit(&s);
1234  hr = VariantChangeType(&s, style, 0, VT_I4);
1235  if (FAILED(hr))
1236  {
1237  ERR("failed to convert style argument, 0x%08x\n", hr);
1238  return hr;
1239  }
1240 
1241  if (is_optional_argument(wait))
1242  waitforprocess = 0;
1243  else {
1244  VARIANT w;
1245 
1246  VariantInit(&w);
1247  hr = VariantChangeType(&w, wait, 0, VT_I4);
1248  if (FAILED(hr))
1249  return hr;
1250 
1251  waitforprocess = V_I4(&w);
1252  }
1253 
1254  memset(&info, 0, sizeof(info));
1255  info.cbSize = sizeof(info);
1256  info.fMask = waitforprocess ? SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS : SEE_MASK_DEFAULT;
1257  info.lpFile = cmd;
1258  info.nShow = V_I4(&s);
1259 
1260  if (!ShellExecuteExW(&info))
1261  {
1262  TRACE("ShellExecute failed, %d\n", GetLastError());
1263  return HRESULT_FROM_WIN32(GetLastError());
1264  }
1265  else
1266  {
1267  if (waitforprocess)
1268  {
1269  GetExitCodeProcess(info.hProcess, exit_code);
1270  CloseHandle(info.hProcess);
1271  }
1272  else
1273  *exit_code = 0;
1274 
1275  return S_OK;
1276  }
1277 }
1278 
1280 {
1285 };
1286 
1288 {
1289  static const WCHAR defaulttitleW[] = {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0};
1290  struct popup_thread_param *param = (struct popup_thread_param *)arg;
1291 
1292  param->button = MessageBoxW(NULL, param->text, is_optional_argument(&param->title) ?
1293  defaulttitleW : V_BSTR(&param->title), V_I4(&param->type));
1294  return 0;
1295 }
1296 
1297 static HRESULT WINAPI WshShell3_Popup(IWshShell3 *iface, BSTR text, VARIANT *seconds_to_wait, VARIANT *title,
1298  VARIANT *type, int *button)
1299 {
1300  struct popup_thread_param param;
1301  DWORD tid, status;
1302  VARIANT timeout;
1303  HANDLE hthread;
1304  HRESULT hr;
1305 
1306  TRACE("(%s %s %s %s %p)\n", debugstr_w(text), debugstr_variant(seconds_to_wait), debugstr_variant(title),
1308 
1309  if (!seconds_to_wait || !title || !type || !button)
1310  return E_POINTER;
1311 
1312  VariantInit(&timeout);
1313  if (!is_optional_argument(seconds_to_wait))
1314  {
1315  hr = VariantChangeType(&timeout, seconds_to_wait, 0, VT_I4);
1316  if (FAILED(hr))
1317  return hr;
1318  }
1319 #ifdef __REACTOS__
1320  else
1321  {
1323  }
1324 #endif
1325 
1326  VariantInit(&param.type);
1327  if (!is_optional_argument(type))
1328  {
1329  hr = VariantChangeType(&param.type, type, 0, VT_I4);
1330  if (FAILED(hr))
1331  return hr;
1332  }
1333 #ifdef __REACTOS__
1334  else
1335  {
1336  VariantChangeType(&param.type, &param.type, 0, VT_I4);
1337  }
1338 #endif
1339 
1341  param.title = *title;
1342  else
1343  {
1344  VariantInit(&param.title);
1345  hr = VariantChangeType(&param.title, title, 0, VT_BSTR);
1346  if (FAILED(hr))
1347  return hr;
1348  }
1349 
1350  param.text = text;
1351  param.button = -1;
1352  hthread = CreateThread(NULL, 0, popup_thread_proc, &param, 0, &tid);
1353  status = MsgWaitForMultipleObjects(1, &hthread, FALSE, V_I4(&timeout) ? V_I4(&timeout) * 1000: INFINITE, 0);
1354  if (status == WAIT_TIMEOUT)
1355  {
1356  PostThreadMessageW(tid, WM_QUIT, 0, 0);
1357  MsgWaitForMultipleObjects(1, &hthread, FALSE, INFINITE, 0);
1358  param.button = -1;
1359  }
1360  *button = param.button;
1361 
1362  VariantClear(&param.title);
1363  CloseHandle(hthread);
1364 
1365  return S_OK;
1366 }
1367 
1368 static HRESULT WINAPI WshShell3_CreateShortcut(IWshShell3 *iface, BSTR PathLink, IDispatch** Shortcut)
1369 {
1370  TRACE("(%s %p)\n", debugstr_w(PathLink), Shortcut);
1371  return WshShortcut_Create(PathLink, Shortcut);
1372 }
1373 
1375 {
1376  DWORD ret;
1377 
1378  TRACE("(%s %p)\n", debugstr_w(Src), Dst);
1379 
1380  if (!Src || !Dst) return E_POINTER;
1381 
1382  ret = ExpandEnvironmentStringsW(Src, NULL, 0);
1384  if (!*Dst) return E_OUTOFMEMORY;
1385 
1386  if (ExpandEnvironmentStringsW(Src, *Dst, ret))
1387  return S_OK;
1388  else
1389  {
1390  SysFreeString(*Dst);
1391  *Dst = NULL;
1392  return HRESULT_FROM_WIN32(GetLastError());
1393  }
1394 }
1395 
1396 static HKEY get_root_key(const WCHAR *path)
1397 {
1398  static const struct {
1399  const WCHAR full[20];
1400  const WCHAR abbrev[5];
1401  HKEY hkey;
1402  } rootkeys[] = {
1403  { {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}, {'H','K','C','U',0}, HKEY_CURRENT_USER },
1404  { {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}, {'H','K','L','M',0}, HKEY_LOCAL_MACHINE },
1405  { {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}, {'H','K','C','R',0}, HKEY_CLASSES_ROOT },
1406  { {'H','K','E','Y','_','U','S','E','R','S',0}, {0}, HKEY_USERS },
1407  { {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0}, {0}, HKEY_CURRENT_CONFIG }
1408  };
1409  int i;
1410 
1411  for (i = 0; i < ARRAY_SIZE(rootkeys); i++) {
1412  if (!strncmpW(path, rootkeys[i].full, strlenW(rootkeys[i].full)))
1413  return rootkeys[i].hkey;
1414  if (rootkeys[i].abbrev[0] && !strncmpW(path, rootkeys[i].abbrev, strlenW(rootkeys[i].abbrev)))
1415  return rootkeys[i].hkey;
1416  }
1417 
1418  return NULL;
1419 }
1420 
1421 /* Caller is responsible to free 'subkey' if 'value' is not NULL */
1422 static HRESULT split_reg_path(const WCHAR *path, WCHAR **subkey, WCHAR **value)
1423 {
1424  *value = NULL;
1425 
1426  /* at least one separator should be present */
1427  *subkey = strchrW(path, '\\');
1428  if (!*subkey)
1430 
1431  /* default value or not */
1432  if ((*subkey)[strlenW(*subkey)-1] == '\\') {
1433  (*subkey)++;
1434  *value = NULL;
1435  }
1436  else {
1437  *value = strrchrW(*subkey, '\\');
1438  if (*value - *subkey > 1) {
1439  unsigned int len = *value - *subkey - 1;
1440  WCHAR *ret;
1441 
1442  ret = heap_alloc((len + 1)*sizeof(WCHAR));
1443  if (!ret)
1444  return E_OUTOFMEMORY;
1445 
1446  memcpy(ret, *subkey + 1, len*sizeof(WCHAR));
1447  ret[len] = 0;
1448  *subkey = ret;
1449  }
1450  (*value)++;
1451  }
1452 
1453  return S_OK;
1454 }
1455 
1456 static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *value)
1457 {
1458  DWORD type, datalen, ret;
1459  WCHAR *subkey, *val;
1460  HRESULT hr;
1461  HKEY root;
1462 
1463  TRACE("(%s %p)\n", debugstr_w(name), value);
1464 
1465  if (!name || !value)
1466  return E_POINTER;
1467 
1468  root = get_root_key(name);
1469  if (!root)
1471 
1472  hr = split_reg_path(name, &subkey, &val);
1473  if (FAILED(hr))
1474  return hr;
1475 
1476  type = REG_NONE;
1477  datalen = 0;
1478  ret = RegGetValueW(root, subkey, val, RRF_RT_ANY, &type, NULL, &datalen);
1479  if (ret == ERROR_SUCCESS) {
1480  void *data;
1481 
1482  data = heap_alloc(datalen);
1483  if (!data) {
1484  hr = E_OUTOFMEMORY;
1485  goto fail;
1486  }
1487 
1488  ret = RegGetValueW(root, subkey, val, RRF_RT_ANY, &type, data, &datalen);
1489  if (ret) {
1490  heap_free(data);
1492  goto fail;
1493  }
1494 
1495  switch (type) {
1496  case REG_SZ:
1497  case REG_EXPAND_SZ:
1498  V_VT(value) = VT_BSTR;
1500  if (!V_BSTR(value))
1501  hr = E_OUTOFMEMORY;
1502  break;
1503  case REG_DWORD:
1504  V_VT(value) = VT_I4;
1505  V_I4(value) = *(DWORD*)data;
1506  break;
1507  case REG_BINARY:
1508  {
1509  BYTE *ptr = (BYTE*)data;
1510  SAFEARRAYBOUND bound;
1511  unsigned int i;
1512  SAFEARRAY *sa;
1513  VARIANT *v;
1514 
1515  bound.lLbound = 0;
1516  bound.cElements = datalen;
1517  sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
1518  if (!sa)
1519  break;
1520 
1521  hr = SafeArrayAccessData(sa, (void**)&v);
1522  if (FAILED(hr)) {
1524  break;
1525  }
1526 
1527  for (i = 0; i < datalen; i++) {
1528  V_VT(&v[i]) = VT_UI1;
1529  V_UI1(&v[i]) = ptr[i];
1530  }
1532 
1534  V_ARRAY(value) = sa;
1535  break;
1536  }
1537  case REG_MULTI_SZ:
1538  {
1539  WCHAR *ptr = (WCHAR*)data;
1540  SAFEARRAYBOUND bound;
1541  SAFEARRAY *sa;
1542  VARIANT *v;
1543 
1544  /* get element count first */
1545  bound.lLbound = 0;
1546  bound.cElements = 0;
1547  while (*ptr) {
1548  bound.cElements++;
1549  ptr += strlenW(ptr)+1;
1550  }
1551 
1552  sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
1553  if (!sa)
1554  break;
1555 
1556  hr = SafeArrayAccessData(sa, (void**)&v);
1557  if (FAILED(hr)) {
1559  break;
1560  }
1561 
1562  ptr = (WCHAR*)data;
1563  while (*ptr) {
1564  V_VT(v) = VT_BSTR;
1565  V_BSTR(v) = SysAllocString(ptr);
1566  ptr += strlenW(ptr)+1;
1567  v++;
1568  }
1569 
1572  V_ARRAY(value) = sa;
1573  break;
1574  }
1575  default:
1576  FIXME("value type %d not supported\n", type);
1577  hr = E_FAIL;
1578  };
1579 
1580  heap_free(data);
1581  if (FAILED(hr))
1582  VariantInit(value);
1583  }
1584  else
1586 
1587 fail:
1588  if (val)
1589  heap_free(subkey);
1590  return hr;
1591 }
1592 
1594 {
1595  static const WCHAR regexpandszW[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
1596  static const WCHAR regszW[] = {'R','E','G','_','S','Z',0};
1597  static const WCHAR regdwordW[] = {'R','E','G','_','D','W','O','R','D',0};
1598  static const WCHAR regbinaryW[] = {'R','E','G','_','B','I','N','A','R','Y',0};
1599 
1600  DWORD regtype, data_len;
1601  WCHAR *subkey, *val;
1602  const BYTE *data;
1603  HRESULT hr;
1604  HKEY root;
1605  VARIANT v;
1606  LONG ret;
1607 
1609 
1610  if (!name || !value || !type)
1611  return E_POINTER;
1612 
1613  root = get_root_key(name);
1614  if (!root)
1616 
1617  /* value type */
1619  regtype = REG_SZ;
1620  else {
1621  if (V_VT(type) != VT_BSTR)
1622  return E_INVALIDARG;
1623 
1624  if (!strcmpW(V_BSTR(type), regszW))
1625  regtype = REG_SZ;
1626  else if (!strcmpW(V_BSTR(type), regdwordW))
1627  regtype = REG_DWORD;
1628  else if (!strcmpW(V_BSTR(type), regexpandszW))
1629  regtype = REG_EXPAND_SZ;
1630  else if (!strcmpW(V_BSTR(type), regbinaryW))
1631  regtype = REG_BINARY;
1632  else {
1633  FIXME("unrecognized value type %s\n", debugstr_w(V_BSTR(type)));
1634  return E_FAIL;
1635  }
1636  }
1637 
1638  /* it's always a string or a DWORD */
1639  VariantInit(&v);
1640  switch (regtype)
1641  {
1642  case REG_SZ:
1643  case REG_EXPAND_SZ:
1644  hr = VariantChangeType(&v, value, 0, VT_BSTR);
1645  if (hr == S_OK) {
1646  data = (BYTE*)V_BSTR(&v);
1647  data_len = SysStringByteLen(V_BSTR(&v)) + sizeof(WCHAR);
1648  }
1649  break;
1650  case REG_DWORD:
1651  case REG_BINARY:
1652  hr = VariantChangeType(&v, value, 0, VT_I4);
1653  data = (BYTE*)&V_I4(&v);
1654  data_len = sizeof(DWORD);
1655  break;
1656  default:
1657  FIXME("unexpected regtype %d\n", regtype);
1658  return E_FAIL;
1659  };
1660 
1661  if (FAILED(hr)) {
1662  FIXME("failed to convert value, regtype %d, 0x%08x\n", regtype, hr);
1663  return hr;
1664  }
1665 
1666  hr = split_reg_path(name, &subkey, &val);
1667  if (FAILED(hr))
1668  goto fail;
1669 
1670  ret = RegSetKeyValueW(root, subkey, val, regtype, data, data_len);
1671  if (ret)
1673 
1674 fail:
1675  VariantClear(&v);
1676  if (val)
1677  heap_free(subkey);
1678  return hr;
1679 }
1680 
1681 static HRESULT WINAPI WshShell3_RegDelete(IWshShell3 *iface, BSTR Name)
1682 {
1683  FIXME("(%s): stub\n", debugstr_w(Name));
1684  return E_NOTIMPL;
1685 }
1686 
1687 static HRESULT WINAPI WshShell3_LogEvent(IWshShell3 *iface, VARIANT *Type, BSTR Message, BSTR Target, VARIANT_BOOL *out_Success)
1688 {
1689  FIXME("(%s %s %s %p): stub\n", debugstr_variant(Type), debugstr_w(Message), debugstr_w(Target), out_Success);
1690  return E_NOTIMPL;
1691 }
1692 
1693 static HRESULT WINAPI WshShell3_AppActivate(IWshShell3 *iface, VARIANT *App, VARIANT *Wait, VARIANT_BOOL *out_Success)
1694 {
1695  FIXME("(%s %s %p): stub\n", debugstr_variant(App), debugstr_variant(Wait), out_Success);
1696  return E_NOTIMPL;
1697 }
1698 
1699 static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *Wait)
1700 {
1701  FIXME("(%s %p): stub\n", debugstr_w(Keys), Wait);
1702  return E_NOTIMPL;
1703 }
1704 
1705 static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec **ret)
1706 {
1707  TRACE("(%s %p)\n", debugstr_w(command), ret);
1708 
1709  if (!ret)
1710  return E_POINTER;
1711 
1712  if (!command)
1713  return DISP_E_EXCEPTION;
1714 
1715  return WshExec_create(command, ret);
1716 }
1717 
1719 {
1720  DWORD ret;
1721 
1722  TRACE("(%p)\n", dir);
1723 
1725  if (!ret)
1726  return HRESULT_FROM_WIN32(GetLastError());
1727 
1728  *dir = SysAllocStringLen(NULL, ret-1);
1729  if (!*dir)
1730  return E_OUTOFMEMORY;
1731 
1733  if (!ret) {
1734  SysFreeString(*dir);
1735  *dir = NULL;
1736  return HRESULT_FROM_WIN32(GetLastError());
1737  }
1738 
1739  return S_OK;
1740 }
1741 
1743 {
1744  TRACE("(%s)\n", debugstr_w(dir));
1745 
1746  if (!dir)
1747  return E_INVALIDARG;
1748 
1749  if (!SetCurrentDirectoryW(dir))
1750  return HRESULT_FROM_WIN32(GetLastError());
1751 
1752  return S_OK;
1753 }
1754 
1755 static const IWshShell3Vtbl WshShell3Vtbl = {
1765  WshShell3_Run,
1778 };
1779 
1781 {
1782  TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
1783 
1786  return IWshShell3_QueryInterface(&WshShell3.IWshShell3_iface, riid, ppv);
1787 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define HKEY_USERS
Definition: winreg.h:13
static HRESULT WINAPI WshShortcut_put_TargetPath(IWshShortcut *iface, BSTR Path)
Definition: shell.c:977
#define DISP_E_EXCEPTION
Definition: winerror.h:2518
IWshShortcut IWshShortcut_iface
Definition: shell.c:49
static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:596
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
struct provideclassinfo classinfo
Definition: shell.c:34
IWshExec IWshExec_iface
Definition: shell.c:66
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
LONG ref
Definition: shell.c:50
static HRESULT WINAPI WshShell3_RegDelete(IWshShell3 *iface, BSTR Name)
Definition: shell.c:1681
static HRESULT WINAPI WshShell3_AppActivate(IWshShell3 *iface, VARIANT *App, VARIANT *Wait, VARIANT_BOOL *out_Success)
Definition: shell.c:1693
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:965
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
IWshEnvironment IWshEnvironment_iface
Definition: shell.c:59
static HRESULT WshEnvironment_Create(IWshEnvironment **env)
Definition: shell.c:519
#define CloseHandle
Definition: compat.h:398
static WshShellImpl WshShell3
Definition: shell.c:37
#define E_NOINTERFACE
Definition: winerror.h:2364
static WshExecImpl * impl_from_IWshExec(IWshExec *iface)
Definition: shell.c:86
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
Definition: compat.h:1939
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
static HRESULT WINAPI WshShell3_GetTypeInfoCount(IWshShell3 *iface, UINT *pctinfo)
Definition: shell.c:1153
Definition: fci.c:115
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
Type
Definition: Type.h:6
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, DWORD *code)
Definition: shell.c:263
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
static ULONG WINAPI WshCollection_Release(IWshCollection *iface)
Definition: shell.c:569
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2027
static HRESULT WINAPI WshShortcut_put_WorkingDirectory(IWshShortcut *iface, BSTR WorkingDirectory)
Definition: shell.c:1017
#define REG_BINARY
Definition: nt_native.h:1496
Definition: ftp_var.h:139
static ULONG WINAPI WshShell3_AddRef(IWshShell3 *iface)
Definition: shell.c:1141
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:31
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
GLsizei const GLchar ** path
Definition: glext.h:7234
REFIID riid
Definition: precomp.h:44
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
const WCHAR * text
Definition: package.c:1827
static HRESULT WINAPI WshEnvironment_GetTypeInfoCount(IWshEnvironment *iface, UINT *pctinfo)
Definition: shell.c:392
LONG WINAPI RegSetKeyValueW(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValueName OPTIONAL, IN DWORD dwType, IN LPCVOID lpData OPTIONAL, IN DWORD cbData)
Definition: reg.c:2172
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, DWORD *exit_code)
Definition: shell.c:1221
struct _root root
#define V_ARRAY(A)
Definition: oleauto.h:222
static HRESULT WshCollection_Create(IWshCollection **collection)
Definition: shell.c:721
#define WARN(fmt,...)
Definition: debug.h:111
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
#define CALLBACK
Definition: compat.h:27
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define WM_QUIT
Definition: winuser.h:1605
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
static BOOL is_optional_argument(const VARIANT *arg)
Definition: shell.c:1216
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
classinfo
Definition: clsfactory.c:43
char * cmd
Definition: vfdcmd.c:85
static HRESULT WINAPI WshShell3_Invoke(IWshShell3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: shell.c:1184
Definition: dhcpd.h:245
DWORD LCID
Definition: nls.h:13
static ULONG WINAPI WshShortcut_AddRef(IWshShortcut *iface)
Definition: shell.c:764
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:218
OLECHAR * BSTR
Definition: compat.h:1934
static const WCHAR Description[]
Definition: oid.c:1266
WCHAR * text
Definition: shell.c:1281
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1027
static HRESULT WINAPI WshShortcut_get_IconLocation(IWshShortcut *iface, BSTR *IconPath)
Definition: shell.c:908
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
static const IWshEnvironmentVtbl WshEnvironmentVtbl
Definition: shell.c:503
static LPOLESTR
Definition: stg_prop.c:27
static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *value)
Definition: shell.c:1456
static HRESULT WINAPI WshShell3_get_Environment(IWshShell3 *iface, VARIANT *type, IWshEnvironment **env)
Definition: shell.c:1210
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT WINAPI WshEnvironment_Remove(IWshEnvironment *iface, BSTR name)
Definition: shell.c:496
#define DWORD
Definition: nt_native.h:44
static HRESULT WINAPI WshShell3_CreateShortcut(IWshShell3 *iface, BSTR PathLink, IDispatch **Shortcut)
Definition: shell.c:1368
int32_t INT
Definition: typedefs.h:56
short VARIANT_BOOL
Definition: compat.h:1931
Definition: send.c:47
GLbitfield GLuint64 timeout
Definition: glext.h:7164
static HRESULT WINAPI WshExec_GetTypeInfoCount(IWshExec *iface, UINT *pctinfo)
Definition: shell.c:140
static HRESULT WINAPI WshShortcut_get_Hotkey(IWshShortcut *iface, BSTR *Hotkey)
Definition: shell.c:894
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:2513
#define V_I4(A)
Definition: oleauto.h:247
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
static HRESULT WINAPI WshShell3_RegWrite(IWshShell3 *iface, BSTR name, VARIANT *value, VARIANT *type)
Definition: shell.c:1593
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2025
static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:1166
static HRESULT WINAPI WshEnvironment_get_Item(IWshEnvironment *iface, BSTR name, BSTR *value)
Definition: shell.c:447
struct _test_info info[]
Definition: SetCursorPos.c:19
static HRESULT WINAPI WshShell3_ExpandEnvironmentStrings(IWshShell3 *iface, BSTR Src, BSTR *Dst)
Definition: shell.c:1374
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG ref
Definition: shell.c:67
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static WshCollection * impl_from_IWshCollection(IWshCollection *iface)
Definition: shell.c:71
static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value)
Definition: shell.c:636
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1139
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static HRESULT WINAPI WshEnvironment_GetTypeInfo(IWshEnvironment *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:400
static HRESULT WINAPI WshShortcut_put_Arguments(IWshShortcut *iface, BSTR Arguments)
Definition: shell.c:871
const GUID IID_IProvideClassInfo
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define debugstr_w
Definition: kernel32.h:32
static HKEY get_root_key(const WCHAR *path)
Definition: shell.c:1396
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static const IWshCollectionVtbl WshCollectionVtbl
Definition: shell.c:707
static HRESULT WINAPI WshCollection_Invoke(IWshCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: shell.c:615
static HRESULT WINAPI WshCollection__NewEnum(IWshCollection *iface, IUnknown *Enum)
Definition: shell.c:700
#define E_INVALIDARG
Definition: ddrawi.h:101
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
static HRESULT WINAPI WshCollection_get_length(IWshCollection *iface, LONG *count)
Definition: shell.c:693
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_NOASYNC
Definition: shellapi.h:33
static HRESULT WINAPI WshShortcut_get_FullName(IWshShortcut *iface, BSTR *name)
Definition: shell.c:843
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
HRESULT get_typeinfo(enum type_id tid, ITypeInfo **ret)
Definition: apps.c:120
LONG_PTR LPARAM
Definition: windef.h:208
static WshShortcut * impl_from_IWshShortcut(IWshShortcut *iface)
Definition: shell.c:76
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2197
GLuint index
Definition: glext.h:6031
unsigned int dir
Definition: maze.c:112
struct CFFOLDER folder
Definition: fdi.c:110
static HRESULT WINAPI WshExec_get_StdErr(IWshExec *iface, ITextStream **stream)
Definition: shell.c:241
static HRESULT WINAPI WshShell3_get_SpecialFolders(IWshShell3 *iface, IWshCollection **folders)
Definition: shell.c:1204
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4593
static HRESULT WINAPI WshShortcut_Invoke(IWshShortcut *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: shell.c:822
GLuint GLfloat * val
Definition: glext.h:7180
static UINT exit_code
Definition: process.c:78
static const IWshExecVtbl WshExecVtbl
Definition: shell.c:305
#define TRACE(s)
Definition: solgame.cpp:4
static WshEnvironment * impl_from_IWshEnvironment(IWshEnvironment *iface)
Definition: shell.c:81
VARIANT type
Definition: shell.c:1283
static HRESULT WINAPI WshShortcut_Load(IWshShortcut *iface, BSTR PathLink)
Definition: shell.c:1024
#define WAIT_OBJECT_0
Definition: winbase.h:387
static HRESULT WINAPI WshEnvironment__NewEnum(IWshEnvironment *iface, IUnknown **penum)
Definition: shell.c:489
PROCESS_INFORMATION info
Definition: shell.c:68
static ULONG WINAPI WshEnvironment_Release(IWshEnvironment *iface)
Definition: shell.c:380
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2687
#define STILL_ACTIVE
Definition: winbase.h:230
LONG HRESULT
Definition: typedefs.h:77
static ULONG WINAPI WshShell3_Release(IWshShell3 *iface)
Definition: shell.c:1147
static BOOL CALLBACK enum_thread_wnd_proc(HWND hwnd, LPARAM lParam)
Definition: shell.c:272
static const IWshShortcutVtbl WshShortcutVtbl
Definition: shell.c:1046
const GUID IID_IUnknown
static HRESULT WINAPI WshShell3_QueryInterface(IWshShell3 *iface, REFIID riid, void **ppv)
Definition: shell.c:1109
#define WM_CLOSE
Definition: winuser.h:1603
#define V_UI1(A)
Definition: oleauto.h:266
IWshCollection IWshCollection_iface
Definition: shell.c:42
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
const char file[]
Definition: icontest.c:11
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static const IWshShell3Vtbl WshShell3Vtbl
Definition: shell.c:1755
static HRESULT WINAPI WshCollection_QueryInterface(IWshCollection *iface, REFIID riid, void **ppv)
Definition: shell.c:535
void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
Definition: scrrun.c:233
static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *Wait)
Definition: shell.c:1699
LONG ref
Definition: shell.c:43
static HRESULT WINAPI WshShortcut_put_Description(IWshShortcut *iface, BSTR Description)
Definition: shell.c:887
static HRESULT WINAPI WshShell3_GetTypeInfo(IWshShell3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:1160
static HRESULT WINAPI WshEnvironment_put_Item(IWshEnvironment *iface, BSTR name, BSTR value)
Definition: shell.c:468
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
IShellLinkW * link
Definition: shell.c:52
#define WAIT_TIMEOUT
Definition: dderror.h:14
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1349
CHAR Message[80]
Definition: alive.c:5
static HRESULT WINAPI WshShell3_LogEvent(IWshShell3 *iface, VARIANT *Type, BSTR Message, BSTR Target, VARIANT_BOOL *out_Success)
Definition: shell.c:1687
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
const GUID IID_IDispatch
int ret
static const WCHAR desktopW[]
Definition: main.c:42
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
static ULONG WINAPI WshShortcut_Release(IWshShortcut *iface)
Definition: shell.c:772
WINE_DEFAULT_DEBUG_CHANNEL(wshom)
static ITypeInfo * typeinfo[last_tid]
Definition: apps.c:106
static HRESULT WINAPI WshExec_Invoke(IWshExec *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: shell.c:174
#define InterlockedDecrement
Definition: armddk.h:52
Definition: parse.h:22
static HRESULT WINAPI WshEnvironment_Invoke(IWshEnvironment *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: shell.c:426
static ULONG WINAPI WshEnvironment_AddRef(IWshEnvironment *iface)
Definition: shell.c:372
#define V_VT(A)
Definition: oleauto.h:211
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
GLdouble s
Definition: gl.h:2039
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:225
BSTR path_link
Definition: shell.c:53
int code
Definition: i386-dis.c:3591
static HRESULT WINAPI WshShortcut_get_Arguments(IWshShortcut *iface, BSTR *Arguments)
Definition: shell.c:850
static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec **ret)
Definition: shell.c:1705
#define V_BSTR(A)
Definition: oleauto.h:226
static HRESULT WINAPI WshEnvironment_QueryInterface(IWshEnvironment *iface, REFIID riid, void **obj)
Definition: shell.c:346
static HRESULT WINAPI WshShortcut_put_IconLocation(IWshShortcut *iface, BSTR IconPath)
Definition: shell.c:931
static HRESULT split_reg_path(const WCHAR *path, WCHAR **subkey, WCHAR **value)
Definition: shell.c:1422
#define Dst
Definition: mesh.h:153
#define strcmpiW(s1, s2)
Definition: unicode.h:39
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
#define ERR(fmt,...)
Definition: debug.h:109
static HRESULT WINAPI WshExec_GetIDsOfNames(IWshExec *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:155
static HRESULT WINAPI WshExec_get_StdIn(IWshExec *iface, ITextStream **stream)
Definition: shell.c:223
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:602
static HRESULT WINAPI WshEnvironment_GetIDsOfNames(IWshEnvironment *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:407
struct stdole::EXCEPINFO EXCEPINFO
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define S_OK
Definition: intsafe.h:59
PRTL_UNICODE_STRING_BUFFER Path
static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:589
#define InterlockedIncrement
Definition: armddk.h:53
const GLdouble * v
Definition: gl.h:2040
static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut)
Definition: shell.c:1074
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: shell.c:1780
static ULONG WINAPI WshCollection_AddRef(IWshCollection *iface)
Definition: shell.c:561
static HRESULT WINAPI WshShortcut_get_TargetPath(IWshShortcut *iface, BSTR *Path)
Definition: shell.c:970
static ULONG WINAPI WshExec_AddRef(IWshExec *iface)
Definition: shell.c:117
static ICollection collection
Definition: typelib.c:184
#define ARRAY_SIZE(a)
Definition: main.h:24
#define INFOTIPSIZE
Definition: commctrl.h:124
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
static HRESULT WINAPI WshExec_get_Status(IWshExec *iface, WshExecStatus *status)
Definition: shell.c:195
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LONG ref
Definition: shell.c:60
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: services.c:325
#define sprintfW
Definition: unicode.h:58
static HRESULT WINAPI WshShortcut_put_WindowStyle(IWshShortcut *iface, int ShowCmd)
Definition: shell.c:991
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
#define V_ERROR(A)
Definition: oleauto.h:241
static HRESULT WINAPI WshShortcut_GetTypeInfo(IWshShortcut *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:796
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
static ULONG WINAPI WshExec_Release(IWshExec *iface)
Definition: shell.c:125
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:168
static HRESULT WINAPI WshShortcut_put_RelativePath(IWshShortcut *iface, BSTR rhs)
Definition: shell.c:963
static const WCHAR IconPath[]
Definition: install.c:50
static HRESULT WINAPI WshShortcut_QueryInterface(IWshShortcut *iface, REFIID riid, void **ppv)
Definition: shell.c:738
static HRESULT WINAPI WshShell3_get_CurrentDirectory(IWshShell3 *iface, BSTR *dir)
Definition: shell.c:1718
static HRESULT WINAPI WshShortcut_get_WindowStyle(IWshShortcut *iface, int *ShowCmd)
Definition: shell.c:984
const GUID IID_IPersistFile
static HRESULT WINAPI WshShell3_put_CurrentDirectory(IWshShell3 *iface, BSTR dir)
Definition: shell.c:1742
Definition: name.c:36
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
static HRESULT WshExec_create(BSTR command, IWshExec **ret)
Definition: shell.c:322
struct stdole::DISPPARAMS DISPPARAMS
static HRESULT WINAPI WshShell3_Popup(IWshShell3 *iface, BSTR text, VARIANT *seconds_to_wait, VARIANT *title, VARIANT *type, int *button)
Definition: shell.c:1297
static DWORD WINAPI popup_thread_proc(void *arg)
Definition: shell.c:1287
static HRESULT WINAPI WshExec_GetTypeInfo(IWshExec *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:148
unsigned int ULONG
Definition: retypes.h:1
IWshShell3 IWshShell3_iface
Definition: shell.c:35
#define SEE_MASK_DEFAULT
Definition: shellapi.h:24
static HRESULT WINAPI WshShortcut_Save(IWshShortcut *iface)
Definition: shell.c:1031
static HRESULT WINAPI WshEnvironment_Count(IWshEnvironment *iface, LONG *count)
Definition: shell.c:475
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
static HRESULT WINAPI WshExec_get_ProcessID(IWshExec *iface, DWORD *pid)
Definition: shell.c:250
static HRESULT WINAPI WshExec_QueryInterface(IWshExec *iface, REFIID riid, void **obj)
Definition: shell.c:91
#define RRF_RT_ANY
Definition: winreg.h:64
static HRESULT WINAPI WshExec_Terminate(IWshExec *iface)
Definition: shell.c:282
#define REG_NONE
Definition: nt_native.h:1492
static HRESULT WINAPI WshEnvironment_get_length(IWshEnvironment *iface, LONG *len)
Definition: shell.c:482
static HRESULT WINAPI WshExec_get_StdOut(IWshExec *iface, ITextStream **stream)
Definition: shell.c:232
#define E_POINTER
Definition: winerror.h:2365
#define INFINITE
Definition: serial.h:102
Arabic default style
Definition: afstyles.h:93
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:412
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static TfClientId tid
static HRESULT WINAPI WshShortcut_get_WorkingDirectory(IWshShortcut *iface, BSTR *WorkingDirectory)
Definition: shell.c:998
static HRESULT WINAPI WshShortcut_get_Description(IWshShortcut *iface, BSTR *Description)
Definition: shell.c:880
LPARAM lParam
Definition: combotst.c:139
static char title[]
Definition: ps.c:92
static HRESULT WINAPI WshShortcut_put_Hotkey(IWshShortcut *iface, BSTR Hotkey)
Definition: shell.c:901
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static HRESULT WINAPI WshShortcut_GetTypeInfoCount(IWshShortcut *iface, UINT *pctinfo)
Definition: shell.c:788
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1170
static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count)
Definition: shell.c:686
#define SUCCEEDED(hr)
Definition: intsafe.h:57
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT *pctinfo)
Definition: shell.c:581
static HRESULT WINAPI WshShortcut_GetIDsOfNames(IWshShortcut *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:803
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
IN BOOLEAN Wait
Definition: fatprocs.h:1529
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
VARIANT title
Definition: shell.c:1282
Definition: fci.c:126
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97