ReactOS 0.4.17-dev-966-gf06eace
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#ifdef __REACTOS__
20#include <wchar.h>
21#define STATUS_PENDING ((DWORD)0x00000103)
22#endif
23
24#include "wshom_private.h"
25#include "wshom.h"
26
27#include "shellapi.h"
28#include "shlobj.h"
29#include "dispex.h"
30
31#include "wine/debug.h"
32
33extern HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **stream);
34
36
37typedef struct
38{
40 IWshShell3 IWshShell3_iface;
43
44typedef struct
45{
47 IWshCollection IWshCollection_iface;
50
51typedef struct
52{
54 IWshShortcut IWshShortcut_iface;
56
60
61typedef struct
62{
64 IWshEnvironment IWshEnvironment_iface;
67
68typedef struct
69{
74 ITextStream *stdin_stream;
75 ITextStream *stdout_stream;
76 ITextStream *stderr_stream;
78
79static inline WshCollection *impl_from_IWshCollection( IWshCollection *iface )
80{
81 return CONTAINING_RECORD(iface, WshCollection, IWshCollection_iface);
82}
83
84static inline WshShortcut *impl_from_IWshShortcut( IWshShortcut *iface )
85{
86 return CONTAINING_RECORD(iface, WshShortcut, IWshShortcut_iface);
87}
88
89static inline WshEnvironment *impl_from_IWshEnvironment( IWshEnvironment *iface )
90{
91 return CONTAINING_RECORD(iface, WshEnvironment, IWshEnvironment_iface);
92}
93
94static inline WshExecImpl *impl_from_IWshExec( IWshExec *iface )
95{
96 return CONTAINING_RECORD(iface, WshExecImpl, IWshExec_iface);
97}
98
99static HRESULT WINAPI WshExec_QueryInterface(IWshExec *iface, REFIID riid, void **obj)
100{
102
103 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
104
106 IsEqualGUID(riid, &IID_IWshExec) ||
108 {
109 *obj = iface;
110 }
112 {
113 *obj = &This->classinfo.IProvideClassInfo_iface;
114 }
115 else {
116 FIXME("Unknown iface %s\n", debugstr_guid(riid));
117 *obj = NULL;
118 return E_NOINTERFACE;
119 }
120
121 IUnknown_AddRef((IUnknown *)*obj);
122 return S_OK;
123}
124
125static ULONG WINAPI WshExec_AddRef(IWshExec *iface)
126{
129 TRACE("%p, refcount %ld.\n", iface, ref);
130 return ref;
131}
132
133static ULONG WINAPI WshExec_Release(IWshExec *iface)
134{
135 WshExecImpl *exec = impl_from_IWshExec(iface);
137
138 TRACE("%p, refcount %ld.\n", iface, ref);
139
140 if (!ref)
141 {
142 CloseHandle(exec->info.hThread);
144 if (exec->stdin_stream)
145 ITextStream_Release(exec->stdin_stream);
146 if (exec->stdout_stream)
147 ITextStream_Release(exec->stdout_stream);
148 if (exec->stderr_stream)
149 ITextStream_Release(exec->stderr_stream);
150 free(exec);
151 }
152
153 return ref;
154}
155
156static HRESULT WINAPI WshExec_GetTypeInfoCount(IWshExec *iface, UINT *pctinfo)
157{
159 TRACE("(%p)->(%p)\n", This, pctinfo);
160 *pctinfo = 1;
161 return S_OK;
162}
163
164static HRESULT WINAPI WshExec_GetTypeInfo(IWshExec *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
165{
166 TRACE("%p, %u, %lx, %p.\n", iface, iTInfo, lcid, ppTInfo);
167
168 return get_typeinfo(IWshExec_tid, ppTInfo);
169}
170
171static HRESULT WINAPI WshExec_GetIDsOfNames(IWshExec *iface, REFIID riid, LPOLESTR *rgszNames,
172 UINT cNames, LCID lcid, DISPID *rgDispId)
173{
175 HRESULT hr;
176
177 TRACE("%p, %s, %p, %u, %lx, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
178
180 if(SUCCEEDED(hr))
181 {
182 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
183 ITypeInfo_Release(typeinfo);
184 }
185
186 return hr;
187}
188
189static HRESULT WINAPI WshExec_Invoke(IWshExec *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
190 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
191{
193 HRESULT hr;
194
195 TRACE("%p, %ld, %s, %lx, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
196 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
197
199 if(SUCCEEDED(hr))
200 {
201 hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
202 ITypeInfo_Release(typeinfo);
203 }
204
205 return hr;
206}
207
208static HRESULT WINAPI WshExec_get_Status(IWshExec *iface, WshExecStatus *status)
209{
211 DWORD code;
212
213 TRACE("(%p)->(%p)\n", This, status);
214
215 if (!status)
216 return E_INVALIDARG;
217
218 if (!GetExitCodeProcess(This->info.hProcess, &code))
220
221 switch (code)
222 {
223 case 0:
224 *status = WshFinished;
225 break;
226 case STILL_ACTIVE:
227 *status = WshRunning;
228 break;
229 default:
230 *status = WshFailed;
231 }
232
233 return S_OK;
234}
235
236static HRESULT WINAPI WshExec_get_StdIn(IWshExec *iface, ITextStream **stream)
237{
238 WshExecImpl *exec = impl_from_IWshExec(iface);
239
240 TRACE("%p, %p.\n", iface, stream);
241
242 *stream = exec->stdin_stream;
243 ITextStream_AddRef(*stream);
244
245 return S_OK;
246}
247
248static HRESULT WINAPI WshExec_get_StdOut(IWshExec *iface, ITextStream **stream)
249{
250 WshExecImpl *exec = impl_from_IWshExec(iface);
251
252 TRACE("%p, %p.\n", iface, stream);
253
254 *stream = exec->stdout_stream;
255 ITextStream_AddRef(*stream);
256
257 return S_OK;
258}
259
260static HRESULT WINAPI WshExec_get_StdErr(IWshExec *iface, ITextStream **stream)
261{
262 WshExecImpl *exec = impl_from_IWshExec(iface);
263
264 TRACE("%p, %p.\n", iface, stream);
265
266 *stream = exec->stderr_stream;
267 ITextStream_AddRef(*stream);
268
269 return S_OK;
270}
271
272static HRESULT WINAPI WshExec_get_ProcessID(IWshExec *iface, int *pid)
273{
275
276 TRACE("(%p)->(%p)\n", This, pid);
277
278 if (!pid)
279 return E_INVALIDARG;
280
281 *pid = This->info.dwProcessId;
282 return S_OK;
283}
284
285static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, int *code)
286{
288
289 FIXME("(%p)->(%p): stub\n", This, code);
290
291 return E_NOTIMPL;
292}
293
295{
296 INT *count = (INT*)lParam;
297
298 (*count)++;
299 PostMessageW(hwnd, WM_CLOSE, 0, 0);
300 /* try to send it to all windows, even if failed for some */
301 return TRUE;
302}
303
304static HRESULT WINAPI WshExec_Terminate(IWshExec *iface)
305{
307 BOOL ret, kill = FALSE;
308 INT count = 0;
309
310 TRACE("(%p)\n", This);
311
313 if (ret && count) {
314 /* manual testing shows that it waits 2 seconds before forcing termination */
315 if (WaitForSingleObject(This->info.hProcess, 2000) != WAIT_OBJECT_0)
316 kill = TRUE;
317 }
318 else
319 kill = TRUE;
320
321 if (kill)
322 TerminateProcess(This->info.hProcess, 0);
323
324 return S_OK;
325}
326
327static const IWshExecVtbl WshExecVtbl = {
342};
343
345{
347
348 sa.nLength = sizeof(sa);
349 sa.bInheritHandle = TRUE;
350 sa.lpSecurityDescriptor = NULL;
351
352 *hread = *hwrite = NULL;
353 if (!CreatePipe(hread, hwrite, &sa, 0))
355 return S_OK;
356}
357
358static void close_pipe(HANDLE *hread, HANDLE *hwrite)
359{
361 CloseHandle(*hwrite);
362 *hread = *hwrite = NULL;
363}
364
366{
367 HANDLE stdout_read, stdout_write;
368 HANDLE stderr_read, stderr_write;
369 HANDLE stdin_read, stdin_write;
370 STARTUPINFOW si = {0};
372 HRESULT hr;
373
374 *ret = NULL;
375
376 if (!(object = calloc(1, sizeof(*object))))
377 return E_OUTOFMEMORY;
378
379 object->IWshExec_iface.lpVtbl = &WshExecVtbl;
380 object->ref = 1;
381 init_classinfo(&CLSID_WshExec, (IUnknown *)&object->IWshExec_iface, &object->classinfo);
382
383 if (FAILED(hr = create_pipe(&stdin_read, &stdin_write)))
384 {
385 WARN("Failed to create stdin pipe.\n");
386 goto failed;
387 }
388
389 if (FAILED(hr = create_pipe(&stdout_read, &stdout_write)))
390 {
391 close_pipe(&stdin_read, &stdin_write);
392 WARN("Failed to create stdout pipe.\n");
393 goto failed;
394 }
395
396 if (FAILED(hr = create_pipe(&stderr_read, &stderr_write)))
397 {
398 close_pipe(&stdin_read, &stdin_write);
399 close_pipe(&stdout_read, &stdout_write);
400 WARN("Failed to create stderr pipe.\n");
401 goto failed;
402 }
403
404 if (SUCCEEDED(hr))
405 {
409 }
410
411 if (SUCCEEDED(hr))
412 hr = DoOpenPipeStream(stdin_write, ForWriting, &object->stdin_stream);
413 if (SUCCEEDED(hr))
414 hr = DoOpenPipeStream(stdout_read, ForReading, &object->stdout_stream);
415 if (SUCCEEDED(hr))
416 hr = DoOpenPipeStream(stderr_read, ForReading, &object->stderr_stream);
417
418 si.cb = sizeof(si);
419 si.hStdError = stderr_write;
420 si.hStdOutput = stdout_write;
421 si.hStdInput = stdin_read;
422 si.dwFlags = STARTF_USESTDHANDLES;
423
424 if (SUCCEEDED(hr))
425 {
426 if (!CreateProcessW(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &object->info))
428 }
429
430 CloseHandle(stderr_write);
431 CloseHandle(stdout_write);
432 CloseHandle(stdin_read);
433
434 if (SUCCEEDED(hr))
435 {
436 *ret = &object->IWshExec_iface;
437
438 return S_OK;
439 }
440
441failed:
442
443 IWshExec_Release(&object->IWshExec_iface);
444
445 return hr;
446}
447
448static HRESULT WINAPI WshEnvironment_QueryInterface(IWshEnvironment *iface, REFIID riid, void **obj)
449{
451
452 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
453
456 IsEqualGUID(riid, &IID_IWshEnvironment))
457 {
458 *obj = iface;
459 }
461 {
462 *obj = &This->classinfo.IProvideClassInfo_iface;
463 }
464 else {
465 FIXME("Unknown iface %s\n", debugstr_guid(riid));
466 *obj = NULL;
467 return E_NOINTERFACE;
468 }
469
470 IUnknown_AddRef((IUnknown*)*obj);
471 return S_OK;
472}
473
474static ULONG WINAPI WshEnvironment_AddRef(IWshEnvironment *iface)
475{
478 TRACE("%p, refcount %ld.\n", iface, ref);
479 return ref;
480}
481
482static ULONG WINAPI WshEnvironment_Release(IWshEnvironment *iface)
483{
486 TRACE("%p, refcount %ld.\n", iface, ref);
487
488 if (!ref)
489 free(This);
490
491 return ref;
492}
493
494static HRESULT WINAPI WshEnvironment_GetTypeInfoCount(IWshEnvironment *iface, UINT *pctinfo)
495{
497 TRACE("(%p)->(%p)\n", This, pctinfo);
498 *pctinfo = 1;
499 return S_OK;
500}
501
502static HRESULT WINAPI WshEnvironment_GetTypeInfo(IWshEnvironment *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
503{
504 TRACE("%p, %u, %lx, %p.\n", iface, iTInfo, lcid, ppTInfo);
505
506 return get_typeinfo(IWshEnvironment_tid, ppTInfo);
507}
508
509static HRESULT WINAPI WshEnvironment_GetIDsOfNames(IWshEnvironment *iface, REFIID riid, LPOLESTR *rgszNames,
510 UINT cNames, LCID lcid, DISPID *rgDispId)
511{
513 HRESULT hr;
514
515 TRACE("%p, %s, %p, %u, %lx, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
516
518 if(SUCCEEDED(hr))
519 {
520 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
521 ITypeInfo_Release(typeinfo);
522 }
523
524 return hr;
525}
526
527static HRESULT WINAPI WshEnvironment_Invoke(IWshEnvironment *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
528 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
529{
531 HRESULT hr;
532
533 TRACE("%p, %ld, %s, %lx, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
534 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
535
537 if(SUCCEEDED(hr))
538 {
539 hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
540 ITypeInfo_Release(typeinfo);
541 }
542
543 return hr;
544}
545
547{
548 DWORD len;
549
551 if (len)
552 {
554 if (*value)
556 }
557 else
559
560 return *value ? S_OK : E_OUTOFMEMORY;
561}
562
563static HRESULT WINAPI WshEnvironment_get_Item(IWshEnvironment *iface, BSTR name, BSTR *value)
564{
566
567 TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), value);
568
569 if (!value)
570 return E_POINTER;
571
572 return get_env_var(name, value);
573}
574
575static HRESULT WINAPI WshEnvironment_put_Item(IWshEnvironment *iface, BSTR name, BSTR value)
576{
578 FIXME("(%p)->(%s %s): stub\n", This, debugstr_w(name), debugstr_w(value));
579 return E_NOTIMPL;
580}
581
582static HRESULT WINAPI WshEnvironment_Count(IWshEnvironment *iface, LONG *count)
583{
585 FIXME("(%p)->(%p): stub\n", This, count);
586 return E_NOTIMPL;
587}
588
589static HRESULT WINAPI WshEnvironment_get_length(IWshEnvironment *iface, LONG *len)
590{
592 FIXME("(%p)->(%p): stub\n", This, len);
593 return E_NOTIMPL;
594}
595
596static HRESULT WINAPI WshEnvironment__NewEnum(IWshEnvironment *iface, IUnknown **penum)
597{
599 FIXME("(%p)->(%p): stub\n", This, penum);
600 return E_NOTIMPL;
601}
602
603static HRESULT WINAPI WshEnvironment_Remove(IWshEnvironment *iface, BSTR name)
604{
606 FIXME("(%p)->(%s): stub\n", This, debugstr_w(name));
607 return E_NOTIMPL;
608}
609
610static const IWshEnvironmentVtbl WshEnvironmentVtbl = {
624};
625
626static HRESULT WshEnvironment_Create(IWshEnvironment **env)
627{
629
630 if (!(object = calloc(1, sizeof(*object))))
631 return E_OUTOFMEMORY;
632
633 object->IWshEnvironment_iface.lpVtbl = &WshEnvironmentVtbl;
634 object->ref = 1;
635
636 init_classinfo(&IID_IWshEnvironment, (IUnknown *)&object->IWshEnvironment_iface, &object->classinfo);
637 *env = &object->IWshEnvironment_iface;
638
639 return S_OK;
640}
641
642static HRESULT WINAPI WshCollection_QueryInterface(IWshCollection *iface, REFIID riid, void **ppv)
643{
645
646 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
647
650 IsEqualGUID(riid, &IID_IWshCollection))
651 {
652 *ppv = iface;
653 }
655 {
656 *ppv = &This->classinfo.IProvideClassInfo_iface;
657 }
658 else {
659 FIXME("Unknown iface %s\n", debugstr_guid(riid));
660 *ppv = NULL;
661 return E_NOINTERFACE;
662 }
663
664 IUnknown_AddRef((IUnknown*)*ppv);
665 return S_OK;
666}
667
668static ULONG WINAPI WshCollection_AddRef(IWshCollection *iface)
669{
672
673 TRACE("%p, refcount %ld.\n", iface, ref);
674
675 return ref;
676}
677
678static ULONG WINAPI WshCollection_Release(IWshCollection *iface)
679{
682 TRACE("%p, refcount %ld.\n", iface, ref);
683
684 if (!ref)
686
687 return ref;
688}
689
690static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT *pctinfo)
691{
693 TRACE("(%p)->(%p)\n", This, pctinfo);
694 *pctinfo = 1;
695 return S_OK;
696}
697
698static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
699{
700 TRACE("%p, %u, %lx, %p.\n", iface, iTInfo, lcid, ppTInfo);
701
702 return get_typeinfo(IWshCollection_tid, ppTInfo);
703}
704
705static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID riid, LPOLESTR *rgszNames,
706 UINT cNames, LCID lcid, DISPID *rgDispId)
707{
709 HRESULT hr;
710
711 TRACE("%p, %s, %p, %u, %lx, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
712
714 if(SUCCEEDED(hr))
715 {
716 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
717 ITypeInfo_Release(typeinfo);
718 }
719
720 return hr;
721}
722
723static HRESULT WINAPI WshCollection_Invoke(IWshCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
724 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
725{
727 HRESULT hr;
728
729 TRACE("%p, %ld, %s, %lx, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
730 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
731
733 if(SUCCEEDED(hr))
734 {
735 hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
736 ITypeInfo_Release(typeinfo);
737 }
738
739 return hr;
740}
741
742static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value)
743{
745 PIDLIST_ABSOLUTE pidl;
747 int kind = 0;
748 BSTR folder;
749 HRESULT hr;
750
751 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(index), value);
752
753 if (V_VT(index) != VT_BSTR)
754 {
755 FIXME("only BSTR index supported, got %d\n", V_VT(index));
756 return E_NOTIMPL;
757 }
758
760 if (!wcsicmp(folder, L"Desktop"))
761 kind = CSIDL_DESKTOP;
762 else if (!wcsicmp(folder, L"AllUsersDesktop"))
764 else if (!wcsicmp(folder, L"AllUsersPrograms"))
766 else
767 {
768 FIXME("folder kind %s not supported\n", debugstr_w(folder));
769 return E_NOTIMPL;
770 }
771
772 hr = SHGetSpecialFolderLocation(NULL, kind, &pidl);
773 if (hr != S_OK) return hr;
774
775 if (SHGetPathFromIDListW(pidl, pathW))
776 {
777 V_VT(value) = VT_BSTR;
780 }
781 else
782 hr = E_FAIL;
783
784 CoTaskMemFree(pidl);
785
786 return hr;
787}
788
789static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count)
790{
792 FIXME("(%p)->(%p): stub\n", This, count);
793 return E_NOTIMPL;
794}
795
796static HRESULT WINAPI WshCollection_get_length(IWshCollection *iface, LONG *count)
797{
799 FIXME("(%p)->(%p): stub\n", This, count);
800 return E_NOTIMPL;
801}
802
803static HRESULT WINAPI WshCollection__NewEnum(IWshCollection *iface, IUnknown **Enum)
804{
806 FIXME("(%p)->(%p): stub\n", This, Enum);
807 return E_NOTIMPL;
808}
809
810static const IWshCollectionVtbl WshCollectionVtbl = {
822};
823
825{
827
828 if (!(object = calloc(1, sizeof(*object))))
829 return E_OUTOFMEMORY;
830
831 object->IWshCollection_iface.lpVtbl = &WshCollectionVtbl;
832 object->ref = 1;
833
834 init_classinfo(&IID_IWshCollection, (IUnknown *)&object->IWshCollection_iface, &object->classinfo);
835 *collection = &object->IWshCollection_iface;
836
837 return S_OK;
838}
839
840/* IWshShortcut */
841static HRESULT WINAPI WshShortcut_QueryInterface(IWshShortcut *iface, REFIID riid, void **ppv)
842{
844
845 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
846
849 IsEqualGUID(riid, &IID_IWshShortcut))
850 {
851 *ppv = iface;
852 }
854 {
855 *ppv = &This->classinfo.IProvideClassInfo_iface;
856 }
857 else {
858 FIXME("Unknown iface %s\n", debugstr_guid(riid));
859 *ppv = NULL;
860 return E_NOINTERFACE;
861 }
862
863 IUnknown_AddRef((IUnknown*)*ppv);
864 return S_OK;
865}
866
867static ULONG WINAPI WshShortcut_AddRef(IWshShortcut *iface)
868{
871 TRACE("%p, refcount %ld.\n", iface, ref);
872 return ref;
873}
874
875static ULONG WINAPI WshShortcut_Release(IWshShortcut *iface)
876{
879 TRACE("%p, refcount %ld.\n", iface, ref);
880
881 if (!ref)
882 {
883 IShellLinkW_Release(This->link);
884 free(This->path_link);
885 free(This);
886 }
887
888 return ref;
889}
890
891static HRESULT WINAPI WshShortcut_GetTypeInfoCount(IWshShortcut *iface, UINT *pctinfo)
892{
894 TRACE("(%p)->(%p)\n", This, pctinfo);
895 *pctinfo = 1;
896 return S_OK;
897}
898
899static HRESULT WINAPI WshShortcut_GetTypeInfo(IWshShortcut *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
900{
901 TRACE("%p, %u, %lx, %p.\n", iface, iTInfo, lcid, ppTInfo);
902
903 return get_typeinfo(IWshShortcut_tid, ppTInfo);
904}
905
906static HRESULT WINAPI WshShortcut_GetIDsOfNames(IWshShortcut *iface, REFIID riid, LPOLESTR *rgszNames,
907 UINT cNames, LCID lcid, DISPID *rgDispId)
908{
910 HRESULT hr;
911
912 TRACE("%p, %s, %p, %u, %lx, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
913
915 if(SUCCEEDED(hr))
916 {
917 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
918 ITypeInfo_Release(typeinfo);
919 }
920
921 return hr;
922}
923
924static HRESULT WINAPI WshShortcut_Invoke(IWshShortcut *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
925 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
926{
928 HRESULT hr;
929
930 TRACE("%p, %ld, %s, %lx, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
931 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
932
934 if(SUCCEEDED(hr))
935 {
936 hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
937 ITypeInfo_Release(typeinfo);
938 }
939
940 return hr;
941}
942
943static HRESULT WINAPI WshShortcut_get_FullName(IWshShortcut *iface, BSTR *name)
944{
946 FIXME("(%p)->(%p): stub\n", This, name);
947 return E_NOTIMPL;
948}
949
950static HRESULT WINAPI WshShortcut_get_Arguments(IWshShortcut *iface, BSTR *Arguments)
951{
953 WCHAR buffW[INFOTIPSIZE];
954 HRESULT hr;
955
956 TRACE("(%p)->(%p)\n", This, Arguments);
957
958 if (!Arguments)
959 return E_POINTER;
960
961 *Arguments = NULL;
962
963 hr = IShellLinkW_GetArguments(This->link, buffW, ARRAY_SIZE(buffW));
964 if (FAILED(hr))
965 return hr;
966
967 *Arguments = SysAllocString(buffW);
968 return *Arguments ? S_OK : E_OUTOFMEMORY;
969}
970
971static HRESULT WINAPI WshShortcut_put_Arguments(IWshShortcut *iface, BSTR Arguments)
972{
974
975 TRACE("(%p)->(%s)\n", This, debugstr_w(Arguments));
976
977 return IShellLinkW_SetArguments(This->link, Arguments);
978}
979
981{
983 FIXME("(%p)->(%p): stub\n", This, Description);
984 return E_NOTIMPL;
985}
986
988{
990 TRACE("(%p)->(%s)\n", This, debugstr_w(Description));
991 return IShellLinkW_SetDescription(This->link, Description);
992}
993
994static HRESULT WINAPI WshShortcut_get_Hotkey(IWshShortcut *iface, BSTR *Hotkey)
995{
997 FIXME("(%p)->(%p): stub\n", This, Hotkey);
998 return E_NOTIMPL;
999}
1000
1001static HRESULT WINAPI WshShortcut_put_Hotkey(IWshShortcut *iface, BSTR Hotkey)
1002{
1004 FIXME("(%p)->(%s): stub\n", This, debugstr_w(Hotkey));
1005 return E_NOTIMPL;
1006}
1007
1009{
1011 WCHAR buffW[MAX_PATH], pathW[MAX_PATH];
1012 INT icon = 0;
1013 HRESULT hr;
1014
1015 TRACE("(%p)->(%p)\n", This, IconPath);
1016
1017 if (!IconPath)
1018 return E_POINTER;
1019
1020 hr = IShellLinkW_GetIconLocation(This->link, buffW, ARRAY_SIZE(buffW), &icon);
1021 if (FAILED(hr)) return hr;
1022
1023 swprintf(pathW, ARRAY_SIZE(pathW), L"%s, %d", buffW, icon);
1025 if (!*IconPath) return E_OUTOFMEMORY;
1026
1027 return S_OK;
1028}
1029
1031{
1033 HRESULT hr;
1034 WCHAR *ptr;
1035 BSTR path;
1036 INT icon;
1037
1038 TRACE("(%p)->(%s)\n", This, debugstr_w(IconPath));
1039
1040 /* scan for icon id */
1041 ptr = wcsrchr(IconPath, ',');
1042 if (!ptr)
1043 {
1044 WARN("icon index not found\n");
1045 return E_FAIL;
1046 }
1047
1049
1050 /* skip spaces if any */
1051 while (iswspace(*++ptr))
1052 ;
1053
1054 icon = wcstol(ptr, NULL, 10);
1055
1056 hr = IShellLinkW_SetIconLocation(This->link, path, icon);
1058
1059 return hr;
1060}
1061
1062static HRESULT WINAPI WshShortcut_put_RelativePath(IWshShortcut *iface, BSTR rhs)
1063{
1065 FIXME("(%p)->(%s): stub\n", This, debugstr_w(rhs));
1066 return E_NOTIMPL;
1067}
1068
1070{
1072 FIXME("(%p)->(%p): stub\n", This, Path);
1073 return E_NOTIMPL;
1074}
1075
1077{
1079 TRACE("(%p)->(%s)\n", This, debugstr_w(Path));
1080 return IShellLinkW_SetPath(This->link, Path);
1081}
1082
1083static HRESULT WINAPI WshShortcut_get_WindowStyle(IWshShortcut *iface, int *ShowCmd)
1084{
1086 TRACE("(%p)->(%p)\n", This, ShowCmd);
1087 return IShellLinkW_GetShowCmd(This->link, ShowCmd);
1088}
1089
1090static HRESULT WINAPI WshShortcut_put_WindowStyle(IWshShortcut *iface, int ShowCmd)
1091{
1093 TRACE("(%p)->(%d)\n", This, ShowCmd);
1094 return IShellLinkW_SetShowCmd(This->link, ShowCmd);
1095}
1096
1097static HRESULT WINAPI WshShortcut_get_WorkingDirectory(IWshShortcut *iface, BSTR *WorkingDirectory)
1098{
1100 WCHAR buffW[MAX_PATH];
1101 HRESULT hr;
1102
1103 TRACE("(%p)->(%p)\n", This, WorkingDirectory);
1104
1105 if (!WorkingDirectory)
1106 return E_POINTER;
1107
1108 *WorkingDirectory = NULL;
1109 hr = IShellLinkW_GetWorkingDirectory(This->link, buffW, ARRAY_SIZE(buffW));
1110 if (FAILED(hr)) return hr;
1111
1112 *WorkingDirectory = SysAllocString(buffW);
1113 return *WorkingDirectory ? S_OK : E_OUTOFMEMORY;
1114}
1115
1116static HRESULT WINAPI WshShortcut_put_WorkingDirectory(IWshShortcut *iface, BSTR WorkingDirectory)
1117{
1119 TRACE("(%p)->(%s)\n", This, debugstr_w(WorkingDirectory));
1120 return IShellLinkW_SetWorkingDirectory(This->link, WorkingDirectory);
1121}
1122
1123static HRESULT WINAPI WshShortcut_Load(IWshShortcut *iface, BSTR PathLink)
1124{
1126 FIXME("(%p)->(%s): stub\n", This, debugstr_w(PathLink));
1127 return E_NOTIMPL;
1128}
1129
1130static HRESULT WINAPI WshShortcut_Save(IWshShortcut *iface)
1131{
1134 HRESULT hr;
1135
1136 TRACE("(%p)\n", This);
1137
1138 IShellLinkW_QueryInterface(This->link, &IID_IPersistFile, (void**)&file);
1139 hr = IPersistFile_Save(file, This->path_link, TRUE);
1140 IPersistFile_Release(file);
1141
1142 return hr;
1143}
1144
1145static const IWshShortcutVtbl WshShortcutVtbl = {
1171};
1172
1174{
1176 HRESULT hr;
1177
1178 *shortcut = NULL;
1179
1180 if (!(object = calloc(1, sizeof(*object))))
1181 return E_OUTOFMEMORY;
1182
1183 object->IWshShortcut_iface.lpVtbl = &WshShortcutVtbl;
1184 object->ref = 1;
1185
1186 hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (void **)&object->link);
1187 if (FAILED(hr))
1188 {
1189 free(object);
1190 return hr;
1191 }
1192
1193 object->path_link = wcsdup(path);
1194 if (!object->path_link)
1195 {
1196 IShellLinkW_Release(object->link);
1197 free(object);
1198 return E_OUTOFMEMORY;
1199 }
1200
1201 init_classinfo(&IID_IWshShortcut, (IUnknown *)&object->IWshShortcut_iface, &object->classinfo);
1202 *shortcut = (IDispatch *)&object->IWshShortcut_iface;
1203
1204 return S_OK;
1205}
1206
1207static HRESULT WINAPI WshShell3_QueryInterface(IWshShell3 *iface, REFIID riid, void **ppv)
1208{
1209 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
1210
1211 *ppv = NULL;
1212
1214 IsEqualGUID(riid, &IID_IWshShell3) ||
1215 IsEqualGUID(riid, &IID_IWshShell2) ||
1216 IsEqualGUID(riid, &IID_IWshShell) ||
1218 {
1219 *ppv = iface;
1220 }
1221 else if (IsEqualGUID(riid, &IID_IDispatchEx))
1222 {
1223 return E_NOINTERFACE;
1224 }
1226 {
1227 *ppv = &WshShell3.classinfo.IProvideClassInfo_iface;
1228 }
1229 else
1230 {
1231 WARN("unknown iface %s\n", debugstr_guid(riid));
1232 return E_NOINTERFACE;
1233 }
1234
1235 IUnknown_AddRef((IUnknown *)*ppv);
1236 return S_OK;
1237}
1238
1239static ULONG WINAPI WshShell3_AddRef(IWshShell3 *iface)
1240{
1241 TRACE("()\n");
1242 return 2;
1243}
1244
1245static ULONG WINAPI WshShell3_Release(IWshShell3 *iface)
1246{
1247 TRACE("()\n");
1248 return 2;
1249}
1250
1251static HRESULT WINAPI WshShell3_GetTypeInfoCount(IWshShell3 *iface, UINT *pctinfo)
1252{
1253 TRACE("(%p)\n", pctinfo);
1254 *pctinfo = 1;
1255 return S_OK;
1256}
1257
1258static HRESULT WINAPI WshShell3_GetTypeInfo(IWshShell3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
1259{
1260 TRACE("%u, %lx, %p.\n", iTInfo, lcid, ppTInfo);
1261
1262 return get_typeinfo(IWshShell3_tid, ppTInfo);
1263}
1264
1265static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames,
1266 UINT cNames, LCID lcid, DISPID *rgDispId)
1267{
1269 HRESULT hr;
1270
1271 TRACE("%s, %p, %u, %lx, %p.\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1272
1274 if(SUCCEEDED(hr))
1275 {
1276 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1277 ITypeInfo_Release(typeinfo);
1278 }
1279
1280 return hr;
1281}
1282
1283static HRESULT WINAPI WshShell3_Invoke(IWshShell3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
1284 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1285{
1287 HRESULT hr;
1288
1289 TRACE("%ld, %s, %lx, %d, %p, %p, %p, %p.\n", dispIdMember, debugstr_guid(riid),
1290 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1291
1293 if(SUCCEEDED(hr))
1294 {
1295 hr = ITypeInfo_Invoke(typeinfo, &WshShell3.IWshShell3_iface, dispIdMember, wFlags,
1296 pDispParams, pVarResult, pExcepInfo, puArgErr);
1297 ITypeInfo_Release(typeinfo);
1298 }
1299
1300 return hr;
1301}
1302
1303static HRESULT WINAPI WshShell3_get_SpecialFolders(IWshShell3 *iface, IWshCollection **folders)
1304{
1305 TRACE("(%p)\n", folders);
1306 return WshCollection_Create(folders);
1307}
1308
1309static HRESULT WINAPI WshShell3_get_Environment(IWshShell3 *iface, VARIANT *type, IWshEnvironment **env)
1310{
1311 FIXME("(%s %p): semi-stub\n", debugstr_variant(type), env);
1312 return WshEnvironment_Create(env);
1313}
1314
1316{
1317 return V_VT(arg) == VT_ERROR && V_ERROR(arg) == DISP_E_PARAMNOTFOUND;
1318}
1319
1321{
1322 WCHAR *ret, *ptr;
1323 BOOL in_quotes = FALSE;
1324
1325 if (!(ret = wcsdup(cmd))) return NULL;
1326
1327 *params = NULL;
1328 for (ptr = ret; *ptr; ptr++)
1329 {
1330 if (*ptr == '"') in_quotes = !in_quotes;
1331 else if (*ptr == ' ' && !in_quotes)
1332 {
1333 *ptr = 0;
1334 *params = ptr + 1;
1335 break;
1336 }
1337 }
1338
1339 return ret;
1340}
1341
1342static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, int *exit_code)
1343{
1345 int waitforprocess, show;
1346 WCHAR *file, *params;
1347 VARIANT v;
1348 HRESULT hr;
1349 BOOL ret;
1350
1351 TRACE("(%s %s %s %p)\n", debugstr_w(cmd), debugstr_variant(style), debugstr_variant(wait), exit_code);
1352
1353 if (!style || !wait || !exit_code)
1354 return E_POINTER;
1355
1357 show = SW_SHOWNORMAL;
1358 else {
1359 VariantInit(&v);
1360 hr = VariantChangeType(&v, style, 0, VT_I4);
1361 if (FAILED(hr))
1362 return hr;
1363
1364 show = V_I4(&v);
1365 }
1366
1367 if (is_optional_argument(wait))
1368 waitforprocess = 0;
1369 else {
1370 VariantInit(&v);
1371 hr = VariantChangeType(&v, wait, 0, VT_I4);
1372 if (FAILED(hr))
1373 return hr;
1374
1375 waitforprocess = V_I4(&v);
1376 }
1377
1378 if (!(file = split_command(cmd, &params))) return E_OUTOFMEMORY;
1379
1380 memset(&info, 0, sizeof(info));
1381 info.cbSize = sizeof(info);
1382 info.fMask = SEE_MASK_FLAG_NO_UI;
1383 info.fMask |= waitforprocess ? SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS : SEE_MASK_DEFAULT;
1384 info.lpFile = file;
1385 info.lpParameters = params;
1386 info.nShow = show;
1387
1389 free(file);
1390 if (!ret)
1391 {
1392 TRACE("ShellExecute failed, %ld\n", GetLastError());
1394 }
1395 else
1396 {
1397 if (waitforprocess)
1398 {
1399 DWORD code;
1401 GetExitCodeProcess(info.hProcess, &code);
1402 CloseHandle(info.hProcess);
1403 *exit_code = code;
1404 }
1405 else
1406 *exit_code = 0;
1407
1408 }
1409 return S_OK;
1410}
1411
1413{
1418};
1419
1421{
1422 struct popup_thread_param *param = (struct popup_thread_param *)arg;
1423
1424 param->button = MessageBoxW(NULL, param->text, is_optional_argument(&param->title) ?
1425 L"Windows Script Host" : V_BSTR(&param->title), V_I4(&param->type));
1426 return 0;
1427}
1428
1429static HRESULT WINAPI WshShell3_Popup(IWshShell3 *iface, BSTR text, VARIANT *seconds_to_wait, VARIANT *title,
1430 VARIANT *type, int *button)
1431{
1433 DWORD tid, status;
1435 HANDLE hthread;
1436 HRESULT hr;
1437
1438 TRACE("(%s %s %s %s %p)\n", debugstr_w(text), debugstr_variant(seconds_to_wait), debugstr_variant(title),
1440
1441 if (!seconds_to_wait || !title || !type || !button)
1442 return E_POINTER;
1443
1445 if (!is_optional_argument(seconds_to_wait))
1446 {
1447 hr = VariantChangeType(&timeout, seconds_to_wait, 0, VT_I4);
1448 if (FAILED(hr))
1449 return hr;
1450 }
1451#ifdef __REACTOS__
1452 else
1453 {
1455 }
1456#endif
1457
1458 VariantInit(&param.type);
1460 {
1461 hr = VariantChangeType(&param.type, type, 0, VT_I4);
1462 if (FAILED(hr))
1463 return hr;
1464 }
1465#ifdef __REACTOS__
1466 else
1467 {
1468 VariantChangeType(&param.type, &param.type, 0, VT_I4);
1469 }
1470#endif
1471
1473 param.title = *title;
1474 else
1475 {
1476 VariantInit(&param.title);
1477 hr = VariantChangeType(&param.title, title, 0, VT_BSTR);
1478 if (FAILED(hr))
1479 return hr;
1480 }
1481
1482 param.text = text;
1483 param.button = -1;
1484 hthread = CreateThread(NULL, 0, popup_thread_proc, &param, 0, &tid);
1485 status = MsgWaitForMultipleObjects(1, &hthread, FALSE, V_I4(&timeout) ? V_I4(&timeout) * 1000: INFINITE, 0);
1486 if (status == WAIT_TIMEOUT)
1487 {
1489 MsgWaitForMultipleObjects(1, &hthread, FALSE, INFINITE, 0);
1490 param.button = -1;
1491 }
1492 *button = param.button;
1493
1494 VariantClear(&param.title);
1495 CloseHandle(hthread);
1496
1497 return S_OK;
1498}
1499
1500static HRESULT WINAPI WshShell3_CreateShortcut(IWshShell3 *iface, BSTR PathLink, IDispatch** Shortcut)
1501{
1502 TRACE("(%s %p)\n", debugstr_w(PathLink), Shortcut);
1503 return WshShortcut_Create(PathLink, Shortcut);
1504}
1505
1507{
1508 DWORD ret;
1509
1510 TRACE("(%s %p)\n", debugstr_w(Src), Dst);
1511
1512 if (!Src || !Dst) return E_POINTER;
1513
1516 if (!*Dst) return E_OUTOFMEMORY;
1517
1518 if (ExpandEnvironmentStringsW(Src, *Dst, ret))
1519 return S_OK;
1520 else
1521 {
1523 *Dst = NULL;
1525 }
1526}
1527
1529{
1530 static const struct {
1531 const WCHAR full[20];
1532 const WCHAR abbrev[5];
1533 HKEY hkey;
1534 } rootkeys[] = {
1535 { L"HKEY_CURRENT_USER", L"HKCU", HKEY_CURRENT_USER },
1536 { L"HKEY_LOCAL_MACHINE", L"HKLM", HKEY_LOCAL_MACHINE },
1537 { L"HKEY_CLASSES_ROOT", L"HKCR", HKEY_CLASSES_ROOT },
1538 { L"HKEY_USERS", {0}, HKEY_USERS },
1539 { L"HKEY_CURRENT_CONFIG", {0}, HKEY_CURRENT_CONFIG }
1540 };
1541 int i;
1542
1543 for (i = 0; i < ARRAY_SIZE(rootkeys); i++) {
1544 if (!wcsncmp(path, rootkeys[i].full, lstrlenW(rootkeys[i].full)))
1545 return rootkeys[i].hkey;
1546 if (rootkeys[i].abbrev[0] && !wcsncmp(path, rootkeys[i].abbrev, lstrlenW(rootkeys[i].abbrev)))
1547 return rootkeys[i].hkey;
1548 }
1549
1550 return NULL;
1551}
1552
1553/* Caller is responsible to free 'subkey' if 'value' is not NULL */
1554static HRESULT split_reg_path(const WCHAR *path, WCHAR **subkey, WCHAR **value)
1555{
1556 *value = NULL;
1557
1558 /* at least one separator should be present */
1559 *subkey = wcschr(path, '\\');
1560 if (!*subkey)
1562
1563 /* default value or not */
1564 if ((*subkey)[lstrlenW(*subkey)-1] == '\\') {
1565 (*subkey)++;
1566 *value = NULL;
1567 }
1568 else {
1569 *value = wcsrchr(*subkey, '\\');
1570 if (*value - *subkey > 1) {
1571 unsigned int len = *value - *subkey - 1;
1572 WCHAR *ret;
1573
1574 ret = malloc((len + 1)*sizeof(WCHAR));
1575 if (!ret)
1576 return E_OUTOFMEMORY;
1577
1578 memcpy(ret, *subkey + 1, len*sizeof(WCHAR));
1579 ret[len] = 0;
1580 *subkey = ret;
1581 }
1582 (*value)++;
1583 }
1584
1585 return S_OK;
1586}
1587
1589{
1591 WCHAR *subkey, *val;
1592 HRESULT hr;
1593 HKEY root;
1594
1595 TRACE("(%s %p)\n", debugstr_w(name), value);
1596
1597 if (!name || !value)
1598 return E_POINTER;
1599
1601 if (!root)
1603
1604 hr = split_reg_path(name, &subkey, &val);
1605 if (FAILED(hr))
1606 return hr;
1607
1608 type = REG_NONE;
1609 datalen = 0;
1610 ret = RegGetValueW(root, subkey, val, RRF_RT_ANY, &type, NULL, &datalen);
1611 if (ret == ERROR_SUCCESS) {
1612 void *data;
1613
1614 data = malloc(datalen);
1615 if (!data) {
1616 hr = E_OUTOFMEMORY;
1617 goto fail;
1618 }
1619
1620 ret = RegGetValueW(root, subkey, val, RRF_RT_ANY, &type, data, &datalen);
1621 if (ret) {
1622 free(data);
1624 goto fail;
1625 }
1626
1627 switch (type) {
1628 case REG_SZ:
1629 case REG_EXPAND_SZ:
1630 V_VT(value) = VT_BSTR;
1632 if (!V_BSTR(value))
1633 hr = E_OUTOFMEMORY;
1634 break;
1635 case REG_DWORD:
1636 V_VT(value) = VT_I4;
1637 V_I4(value) = *(DWORD*)data;
1638 break;
1639 case REG_BINARY:
1640 {
1641 BYTE *ptr = (BYTE*)data;
1642 SAFEARRAYBOUND bound;
1643 unsigned int i;
1644 SAFEARRAY *sa;
1645 VARIANT *v;
1646
1647 bound.lLbound = 0;
1648 bound.cElements = datalen;
1649 sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
1650 if (!sa)
1651 break;
1652
1653 hr = SafeArrayAccessData(sa, (void**)&v);
1654 if (FAILED(hr)) {
1656 break;
1657 }
1658
1659 for (i = 0; i < datalen; i++) {
1660 V_VT(&v[i]) = VT_UI1;
1661 V_UI1(&v[i]) = ptr[i];
1662 }
1664
1666 V_ARRAY(value) = sa;
1667 break;
1668 }
1669 case REG_MULTI_SZ:
1670 {
1671 WCHAR *ptr = (WCHAR*)data;
1672 SAFEARRAYBOUND bound;
1673 SAFEARRAY *sa;
1674 VARIANT *v;
1675
1676 /* get element count first */
1677 bound.lLbound = 0;
1678 bound.cElements = 0;
1679 while (*ptr) {
1680 bound.cElements++;
1681 ptr += lstrlenW(ptr)+1;
1682 }
1683
1684 sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
1685 if (!sa)
1686 break;
1687
1688 hr = SafeArrayAccessData(sa, (void**)&v);
1689 if (FAILED(hr)) {
1691 break;
1692 }
1693
1694 ptr = (WCHAR*)data;
1695 while (*ptr) {
1696 V_VT(v) = VT_BSTR;
1698 ptr += lstrlenW(ptr)+1;
1699 v++;
1700 }
1701
1704 V_ARRAY(value) = sa;
1705 break;
1706 }
1707 default:
1708 FIXME("value type %ld not supported\n", type);
1709 hr = E_FAIL;
1710 };
1711
1712 free(data);
1713 if (FAILED(hr))
1715 }
1716 else
1718
1719fail:
1720 if (val)
1721 free(subkey);
1722 return hr;
1723}
1724
1726{
1727 DWORD regtype, data_len;
1728 WCHAR *subkey, *val;
1729 const BYTE *data;
1730 HRESULT hr;
1731 HKEY root;
1732 VARIANT v;
1733 LONG ret;
1734
1736
1737 if (!name || !value || !type)
1738 return E_POINTER;
1739
1741 if (!root)
1743
1744 /* value type */
1746 regtype = REG_SZ;
1747 else {
1748 if (V_VT(type) != VT_BSTR)
1749 return E_INVALIDARG;
1750
1751 if (!wcscmp(V_BSTR(type), L"REG_SZ"))
1752 regtype = REG_SZ;
1753 else if (!wcscmp(V_BSTR(type), L"REG_DWORD"))
1754 regtype = REG_DWORD;
1755 else if (!wcscmp(V_BSTR(type), L"REG_EXPAND_SZ"))
1756 regtype = REG_EXPAND_SZ;
1757 else if (!wcscmp(V_BSTR(type), L"REG_BINARY"))
1758 regtype = REG_BINARY;
1759 else {
1760 FIXME("unrecognized value type %s\n", debugstr_w(V_BSTR(type)));
1761 return E_FAIL;
1762 }
1763 }
1764
1765 /* it's always a string or a DWORD */
1766 VariantInit(&v);
1767 switch (regtype)
1768 {
1769 case REG_SZ:
1770 case REG_EXPAND_SZ:
1772 if (hr == S_OK) {
1773 data = (BYTE*)V_BSTR(&v);
1774 data_len = SysStringByteLen(V_BSTR(&v)) + sizeof(WCHAR);
1775 }
1776 break;
1777 case REG_DWORD:
1778 case REG_BINARY:
1779 hr = VariantChangeType(&v, value, 0, VT_I4);
1780 data = (BYTE*)&V_I4(&v);
1781 data_len = sizeof(DWORD);
1782 break;
1783 default:
1784 FIXME("unexpected regtype %ld\n", regtype);
1785 return E_FAIL;
1786 };
1787
1788 if (FAILED(hr)) {
1789 FIXME("failed to convert value, regtype %ld, %#lx.\n", regtype, hr);
1790 return hr;
1791 }
1792
1793 hr = split_reg_path(name, &subkey, &val);
1794 if (FAILED(hr))
1795 goto fail;
1796
1797 ret = RegSetKeyValueW(root, subkey, val, regtype, data, data_len);
1798 if (ret)
1800
1801fail:
1802 VariantClear(&v);
1803 if (val)
1804 free(subkey);
1805 return hr;
1806}
1807
1808static HRESULT WINAPI WshShell3_RegDelete(IWshShell3 *iface, BSTR Name)
1809{
1810 FIXME("(%s): stub\n", debugstr_w(Name));
1811 return E_NOTIMPL;
1812}
1813
1815{
1816 FIXME("(%s %s %s %p): stub\n", debugstr_variant(Type), debugstr_w(Message), debugstr_w(Target), out_Success);
1817 return E_NOTIMPL;
1818}
1819
1820static HRESULT WINAPI WshShell3_AppActivate(IWshShell3 *iface, VARIANT *App, VARIANT *Wait, VARIANT_BOOL *out_Success)
1821{
1822 FIXME("(%s %s %p): stub\n", debugstr_variant(App), debugstr_variant(Wait), out_Success);
1823 return E_NOTIMPL;
1824}
1825
1826static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *Wait)
1827{
1828 FIXME("(%s %p): stub\n", debugstr_w(Keys), Wait);
1829 return E_NOTIMPL;
1830}
1831
1832static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec **ret)
1833{
1834 BSTR expandedcmd;
1835 HRESULT hr;
1836
1837 TRACE("(%s %p)\n", debugstr_w(command), ret);
1838
1839 if (!ret)
1840 return E_POINTER;
1841
1842 if (!command)
1843 return DISP_E_EXCEPTION;
1844
1845 hr = WshShell3_ExpandEnvironmentStrings(iface, command, &expandedcmd);
1846 if (FAILED(hr))
1847 return hr;
1848
1849 hr = WshExec_create(expandedcmd, ret);
1850 SysFreeString(expandedcmd);
1851 return hr;
1852}
1853
1855{
1856 DWORD ret;
1857
1858 TRACE("(%p)\n", dir);
1859
1861 if (!ret)
1863
1865 if (!*dir)
1866 return E_OUTOFMEMORY;
1867
1869 if (!ret) {
1871 *dir = NULL;
1873 }
1874
1875 return S_OK;
1876}
1877
1879{
1880 TRACE("(%s)\n", debugstr_w(dir));
1881
1882 if (!dir)
1883 return E_INVALIDARG;
1884
1887
1888 return S_OK;
1889}
1890
1891static const IWshShell3Vtbl WshShell3Vtbl = {
1914};
1915
1917{
1918 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
1919
1922 return IWshShell3_QueryInterface(&WshShell3.IWshShell3_iface, riid, ppv);
1923}
PRTL_UNICODE_STRING_BUFFER Path
Type
Definition: Type.h:7
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define REG_SZ
Definition: layer.c:22
unsigned int dir
Definition: maze.c:112
HRESULT get_typeinfo(enum type_id tid, ITypeInfo **ret)
Definition: apps.c:125
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
struct _root root
LPARAM lParam
Definition: combotst.c:139
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:171
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR Name
Definition: desk.c:124
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
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:2139
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define wcsrchr
Definition: compat.h:16
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
OLECHAR * BSTR
Definition: compat.h:2293
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
short VARIANT_BOOL
Definition: compat.h:2290
@ VT_BSTR
Definition: compat.h:2303
@ VT_ERROR
Definition: compat.h:2305
@ VT_ARRAY
Definition: compat.h:2341
@ VT_VARIANT
Definition: compat.h:2307
@ VT_I4
Definition: compat.h:2298
@ VT_UI1
Definition: compat.h:2311
#define wcsicmp
Definition: compat.h:15
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
BOOL WINAPI SetHandleInformation(IN HANDLE hObject, IN DWORD dwMask, IN DWORD dwFlags)
Definition: handle.c:78
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2267
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:4491
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1215
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1425
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:137
LCID lcid
Definition: locale.c:5660
const WCHAR * text
Definition: package.c:1826
_ACRTIMP __msvcrt_long __cdecl wcstol(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2752
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
_ACRTIMP int __cdecl wcsncmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:523
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1137
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1168
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
static const WCHAR IconPath[]
Definition: install.c:51
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3385
MIXER_STATUS Enum(IN PVOID EnumContext, IN ULONG DeviceIndex, OUT LPWSTR *DeviceName, OUT PHANDLE OutHandle, OUT PHANDLE OutKey)
Definition: mmixer.c:220
#define swprintf
Definition: precomp.h:40
static const WCHAR Message[]
Definition: register.c:74
static ULONG WINAPI WshExec_Release(IWshExec *iface)
Definition: shell.c:133
static HRESULT WINAPI WshShell3_GetTypeInfoCount(IWshShell3 *iface, UINT *pctinfo)
Definition: shell.c:1251
static HRESULT WINAPI WshShortcut_get_WindowStyle(IWshShortcut *iface, int *ShowCmd)
Definition: shell.c:1083
static HRESULT WINAPI WshCollection_QueryInterface(IWshCollection *iface, REFIID riid, void **ppv)
Definition: shell.c:642
static WshShellImpl WshShell3
Definition: shell.c:42
static HRESULT WINAPI WshEnvironment_GetTypeInfoCount(IWshEnvironment *iface, UINT *pctinfo)
Definition: shell.c:494
static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, int *exit_code)
Definition: shell.c:1342
static HRESULT WINAPI WshShortcut_put_Hotkey(IWshShortcut *iface, BSTR Hotkey)
Definition: shell.c:1001
static HRESULT WINAPI WshShell3_AppActivate(IWshShell3 *iface, VARIANT *App, VARIANT *Wait, VARIANT_BOOL *out_Success)
Definition: shell.c:1820
static WshEnvironment * impl_from_IWshEnvironment(IWshEnvironment *iface)
Definition: shell.c:89
static HRESULT WINAPI WshShortcut_put_Arguments(IWshShortcut *iface, BSTR Arguments)
Definition: shell.c:971
static HRESULT WINAPI WshShortcut_get_Arguments(IWshShortcut *iface, BSTR *Arguments)
Definition: shell.c:950
static HRESULT WINAPI WshShell3_RegDelete(IWshShell3 *iface, BSTR Name)
Definition: shell.c:1808
static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value)
Definition: shell.c:742
static HRESULT WshEnvironment_Create(IWshEnvironment **env)
Definition: shell.c:626
static HRESULT WINAPI WshShortcut_get_WorkingDirectory(IWshShortcut *iface, BSTR *WorkingDirectory)
Definition: shell.c:1097
static HRESULT WINAPI WshExec_Terminate(IWshExec *iface)
Definition: shell.c:304
static HRESULT WINAPI WshShell3_get_CurrentDirectory(IWshShell3 *iface, BSTR *dir)
Definition: shell.c:1854
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:723
static WshExecImpl * impl_from_IWshExec(IWshExec *iface)
Definition: shell.c:94
static ULONG WINAPI WshShell3_Release(IWshShell3 *iface)
Definition: shell.c:1245
static HRESULT WINAPI WshEnvironment__NewEnum(IWshEnvironment *iface, IUnknown **penum)
Definition: shell.c:596
static HRESULT WINAPI WshExec_QueryInterface(IWshExec *iface, REFIID riid, void **obj)
Definition: shell.c:99
static HRESULT WINAPI WshShortcut_put_WorkingDirectory(IWshShortcut *iface, BSTR WorkingDirectory)
Definition: shell.c:1116
static HRESULT WINAPI WshEnvironment_GetTypeInfo(IWshEnvironment *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:502
static ULONG WINAPI WshShell3_AddRef(IWshShell3 *iface)
Definition: shell.c:1239
static HRESULT WINAPI WshShortcut_put_RelativePath(IWshShortcut *iface, BSTR rhs)
Definition: shell.c:1062
static HRESULT WINAPI WshShortcut_put_TargetPath(IWshShortcut *iface, BSTR Path)
Definition: shell.c:1076
static HRESULT WINAPI WshExec_GetTypeInfo(IWshExec *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:164
HRESULT get_env_var(const WCHAR *name, BSTR *value)
Definition: shell.c:546
static HRESULT WINAPI WshShortcut_get_Description(IWshShortcut *iface, BSTR *Description)
Definition: shell.c:980
static HRESULT WINAPI WshShell3_RegWrite(IWshShell3 *iface, BSTR name, VARIANT *value, VARIANT *type)
Definition: shell.c:1725
static HRESULT WshExec_create(BSTR command, IWshExec **ret)
Definition: shell.c:365
static const IWshShortcutVtbl WshShortcutVtbl
Definition: shell.c:1145
static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:698
static HRESULT WINAPI WshExec_get_ExitCode(IWshExec *iface, int *code)
Definition: shell.c:285
static HRESULT WINAPI WshEnvironment_put_Item(IWshEnvironment *iface, BSTR name, BSTR value)
Definition: shell.c:575
static HRESULT WINAPI WshExec_get_StdIn(IWshExec *iface, ITextStream **stream)
Definition: shell.c:236
static const IWshShell3Vtbl WshShell3Vtbl
Definition: shell.c:1891
static HRESULT WINAPI WshShortcut_put_WindowStyle(IWshShortcut *iface, int ShowCmd)
Definition: shell.c:1090
static HRESULT WINAPI WshShortcut_Load(IWshShortcut *iface, BSTR PathLink)
Definition: shell.c:1123
static HRESULT WINAPI WshExec_GetIDsOfNames(IWshExec *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:171
static HRESULT WINAPI WshEnvironment_get_length(IWshEnvironment *iface, LONG *len)
Definition: shell.c:589
static HRESULT WINAPI WshEnvironment_get_Item(IWshEnvironment *iface, BSTR name, BSTR *value)
Definition: shell.c:563
static BOOL CALLBACK enum_thread_wnd_proc(HWND hwnd, LPARAM lParam)
Definition: shell.c:294
static HRESULT WINAPI WshShortcut_GetIDsOfNames(IWshShortcut *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:906
static HRESULT WINAPI WshShell3_get_SpecialFolders(IWshShell3 *iface, IWshCollection **folders)
Definition: shell.c:1303
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:527
static const IWshExecVtbl WshExecVtbl
Definition: shell.c:327
static const IWshEnvironmentVtbl WshEnvironmentVtbl
Definition: shell.c:610
static HRESULT WINAPI WshShortcut_get_TargetPath(IWshShortcut *iface, BSTR *Path)
Definition: shell.c:1069
static HRESULT WINAPI WshExec_GetTypeInfoCount(IWshExec *iface, UINT *pctinfo)
Definition: shell.c:156
static HRESULT WINAPI WshShortcut_put_IconLocation(IWshShortcut *iface, BSTR IconPath)
Definition: shell.c:1030
static HRESULT split_reg_path(const WCHAR *path, WCHAR **subkey, WCHAR **value)
Definition: shell.c:1554
static HRESULT WINAPI WshShortcut_get_IconLocation(IWshShortcut *iface, BSTR *IconPath)
Definition: shell.c:1008
static HRESULT WINAPI WshEnvironment_Remove(IWshEnvironment *iface, BSTR name)
Definition: shell.c:603
static ULONG WINAPI WshCollection_Release(IWshCollection *iface)
Definition: shell.c:678
static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *Wait)
Definition: shell.c:1826
static HKEY get_root_key(const WCHAR *path)
Definition: shell.c:1528
static ULONG WINAPI WshShortcut_AddRef(IWshShortcut *iface)
Definition: shell.c:867
static HRESULT WINAPI WshEnvironment_QueryInterface(IWshEnvironment *iface, REFIID riid, void **obj)
Definition: shell.c:448
static HRESULT WINAPI WshShell3_GetTypeInfo(IWshShell3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:1258
static WshCollection * impl_from_IWshCollection(IWshCollection *iface)
Definition: shell.c:79
static HRESULT WINAPI WshShortcut_QueryInterface(IWshShortcut *iface, REFIID riid, void **ppv)
Definition: shell.c:841
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:1283
static HRESULT WINAPI WshCollection_get_length(IWshCollection *iface, LONG *count)
Definition: shell.c:796
static HRESULT WINAPI WshShell3_QueryInterface(IWshShell3 *iface, REFIID riid, void **ppv)
Definition: shell.c:1207
static HRESULT WINAPI WshShell3_LogEvent(IWshShell3 *iface, VARIANT *Type, BSTR Message, BSTR Target, VARIANT_BOOL *out_Success)
Definition: shell.c:1814
static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *value)
Definition: shell.c:1588
static HRESULT create_pipe(HANDLE *hread, HANDLE *hwrite)
Definition: shell.c:344
static ULONG WINAPI WshShortcut_Release(IWshShortcut *iface)
Definition: shell.c:875
static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:1265
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: shell.c:1916
static HRESULT WINAPI WshExec_get_StdErr(IWshExec *iface, ITextStream **stream)
Definition: shell.c:260
static ULONG WINAPI WshCollection_AddRef(IWshCollection *iface)
Definition: shell.c:668
static BOOL is_optional_argument(const VARIANT *arg)
Definition: shell.c:1315
static HRESULT WINAPI WshShell3_Exec(IWshShell3 *iface, BSTR command, IWshExec **ret)
Definition: shell.c:1832
static HRESULT WINAPI WshShortcut_get_FullName(IWshShortcut *iface, BSTR *name)
Definition: shell.c:943
static HRESULT WINAPI WshShortcut_GetTypeInfoCount(IWshShortcut *iface, UINT *pctinfo)
Definition: shell.c:891
static ULONG WINAPI WshEnvironment_Release(IWshEnvironment *iface)
Definition: shell.c:482
static ULONG WINAPI WshEnvironment_AddRef(IWshEnvironment *iface)
Definition: shell.c:474
static HRESULT WINAPI WshShortcut_GetTypeInfo(IWshShortcut *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: shell.c:899
static WCHAR * split_command(BSTR cmd, WCHAR **params)
Definition: shell.c:1320
static HRESULT WINAPI WshExec_get_ProcessID(IWshExec *iface, int *pid)
Definition: shell.c:272
static HRESULT WINAPI WshCollection__NewEnum(IWshCollection *iface, IUnknown **Enum)
Definition: shell.c:803
static void close_pipe(HANDLE *hread, HANDLE *hwrite)
Definition: shell.c:358
static HRESULT WshShortcut_Create(const WCHAR *path, IDispatch **shortcut)
Definition: shell.c:1173
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:189
static ULONG WINAPI WshExec_AddRef(IWshExec *iface)
Definition: shell.c:125
static HRESULT WINAPI WshShell3_CreateShortcut(IWshShell3 *iface, BSTR PathLink, IDispatch **Shortcut)
Definition: shell.c:1500
static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:705
static HRESULT WINAPI WshShell3_get_Environment(IWshShell3 *iface, VARIANT *type, IWshEnvironment **env)
Definition: shell.c:1309
static HRESULT WINAPI WshShortcut_put_Description(IWshShortcut *iface, BSTR Description)
Definition: shell.c:987
static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count)
Definition: shell.c:789
static HRESULT WINAPI WshShortcut_Save(IWshShortcut *iface)
Definition: shell.c:1130
static HRESULT WINAPI WshExec_get_Status(IWshExec *iface, WshExecStatus *status)
Definition: shell.c:208
static HRESULT WINAPI WshShell3_ExpandEnvironmentStrings(IWshShell3 *iface, BSTR Src, BSTR *Dst)
Definition: shell.c:1506
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:924
HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **stream)
Definition: filesystem.c:966
static const IWshCollectionVtbl WshCollectionVtbl
Definition: shell.c:810
static HRESULT WINAPI WshEnvironment_GetIDsOfNames(IWshEnvironment *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: shell.c:509
static HRESULT WINAPI WshShell3_put_CurrentDirectory(IWshShell3 *iface, BSTR dir)
Definition: shell.c:1878
static WshShortcut * impl_from_IWshShortcut(IWshShortcut *iface)
Definition: shell.c:84
static HRESULT WshCollection_Create(IWshCollection **collection)
Definition: shell.c:824
static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT *pctinfo)
Definition: shell.c:690
static DWORD WINAPI popup_thread_proc(void *arg)
Definition: shell.c:1420
static HRESULT WINAPI WshShell3_Popup(IWshShell3 *iface, BSTR text, VARIANT *seconds_to_wait, VARIANT *title, VARIANT *type, int *button)
Definition: shell.c:1429
static HRESULT WINAPI WshExec_get_StdOut(IWshExec *iface, ITextStream **stream)
Definition: shell.c:248
static HRESULT WINAPI WshEnvironment_Count(IWshEnvironment *iface, LONG *count)
Definition: shell.c:582
static HRESULT WINAPI WshShortcut_get_Hotkey(IWshShortcut *iface, BSTR *Hotkey)
Definition: shell.c:994
static const char * debugstr_variant(const VARIANT *var)
Definition: dom.c:505
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
#define INFINITE
Definition: serial.h:102
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint index
Definition: glext.h:6031
GLenum mode
Definition: glext.h:6217
GLenum const GLfloat * params
Definition: glext.h:5645
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
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
unsigned int UINT
Definition: sysinfo.c:13
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
static TfClientId tid
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1033
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define Dst
Definition: mesh.h:153
#define STILL_ACTIVE
Definition: minwinbase.h:43
LONG_PTR LPARAM
Definition: minwindef.h:175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
DWORD button
Definition: button.c:166
static const WCHAR pathW[]
Definition: path.c:2368
static UINT exit_code
Definition: process.c:80
static SYSTEM_INFO si
Definition: virtual.c:39
static IUnknown * outer
Definition: compobj.c:82
static VARIANTARG static DISPID
Definition: ordinal.c:49
BOOL WINAPI CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
Definition: npipe.c:117
#define REG_BINARY
Definition: nt_native.h:1499
#define REG_MULTI_SZ
Definition: nt_native.h:1504
#define DWORD
Definition: nt_native.h:44
#define REG_NONE
Definition: nt_native.h:1495
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
_Must_inspect_result_ _In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ LPGUID _In_opt_ HANDLE _In_opt_ ULONG _In_opt_ ULONG _In_opt_ ULONG _In_opt_ PLARGE_INTEGER _In_opt_ PUNICODE_STRING Description
Definition: nttmapi.h:425
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:217
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:240
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:341
#define V_ERROR(A)
Definition: oleauto.h:241
#define V_UI1(A)
Definition: oleauto.h:266
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
const GUID IID_IProvideClassInfo
const GUID IID_IDispatch
const GUID IID_IPersistFile
static HDC hread
Definition: opengl.c:36
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
static char title[]
Definition: ps.c:92
#define INFOTIPSIZE
Definition: commctrl.h:124
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define WM_CLOSE
Definition: winuser.h:1649
#define WM_QUIT
Definition: winuser.h:1651
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
#define calloc
Definition: rosglue.h:14
void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
Definition: scrrun.c:230
#define REG_DWORD
Definition: sdbapi.c:615
#define iswspace(_c)
Definition: ctype.h:669
DWORD LCID
Definition: nls.h:13
#define memset(x, y, z)
Definition: compat.h:39
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:33
#define SEE_MASK_NOASYNC
Definition: shellapi.h:35
#define SEE_MASK_DEFAULT
Definition: shellapi.h:24
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:38
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2732
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2215
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2213
#define CSIDL_DESKTOP
Definition: shlobj.h:2191
#define TRACE(s)
Definition: solgame.cpp:4
LONG ref
Definition: shell.c:48
IWshCollection IWshCollection_iface
Definition: shell.c:47
LONG ref
Definition: shell.c:65
IWshEnvironment IWshEnvironment_iface
Definition: shell.c:64
ITextStream * stdout_stream
Definition: shell.c:75
ITextStream * stderr_stream
Definition: shell.c:76
ITextStream * stdin_stream
Definition: shell.c:74
IWshExec IWshExec_iface
Definition: shell.c:71
PROCESS_INFORMATION info
Definition: shell.c:73
LONG ref
Definition: shell.c:72
IWshShell3 IWshShell3_iface
Definition: shell.c:40
struct provideclassinfo classinfo
Definition: shell.c:39
IWshShortcut IWshShortcut_iface
Definition: shell.c:54
LONG ref
Definition: shell.c:55
IShellLinkW * link
Definition: shell.c:57
WCHAR * path_link
Definition: shell.c:58
Definition: ftp_var.h:139
Definition: inflate.c:139
LONG ref
Definition: collection.c:58
Definition: fci.c:123
Definition: fci.c:112
Definition: name.c:39
WCHAR * text
Definition: shell.c:1414
VARIANT title
Definition: shell.c:1415
VARIANT type
Definition: shell.c:1416
Definition: send.c:48
Definition: ps.c:97
Definition: parse.h:23
Definition: style.c:91
Definition: dhcpd.h:248
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
int32_t INT
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:64
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, const VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:939
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:626
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:547
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HANDLE_FLAG_INHERIT
Definition: winbase.h:289
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define STARTF_USESTDHANDLES
Definition: winbase.h:476
WINBASEAPI _In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon_undoc.h:337
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define DISP_E_PARAMNOTFOUND
Definition: winerror.h:3616
#define E_NOINTERFACE
Definition: winerror.h:3479
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define DISP_E_EXCEPTION
Definition: winerror.h:3621
#define E_POINTER
Definition: winerror.h:3480
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RRF_RT_ANY
Definition: winreg.h:66
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_USERS
Definition: winreg.h:13
@ IWshEnvironment_tid
Definition: wshom_private.h:34
@ IWshShortcut_tid
Definition: wshom_private.h:37
@ IWshExec_tid
Definition: wshom_private.h:35
@ IWshShell3_tid
Definition: wshom_private.h:36
@ IWshCollection_tid
Definition: wshom_private.h:33
unsigned char BYTE
Definition: xxhash.c:193