po: Update Catalan translation.
[wine.git] / dlls / shell32 / shelldispatch.c
blob0ad3b1dfaef6dbd85d20f7ddf14957efebe1a13a
1 /*
2 * IShellDispatch implementation
4 * Copyright 2010 Alexander Morozov for Etersoft
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
26 #define COBJMACROS
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winreg.h"
33 #include "shlwapi.h"
34 #include "shlobj.h"
35 #include "shldisp.h"
36 #include "debughlp.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(shell);
42 typedef struct {
43 IShellDispatch IShellDispatch_iface;
44 LONG ref;
45 ITypeInfo *iTypeInfo;
46 } ShellDispatch;
48 typedef struct {
49 Folder3 Folder_iface;
50 LONG ref;
51 ITypeInfo *iTypeInfo;
52 VARIANT dir;
53 } FolderImpl;
55 typedef struct {
56 FolderItem FolderItem_iface;
57 LONG ref;
58 ITypeInfo *iTypeInfo;
59 VARIANT dir;
60 } FolderItemImpl;
62 static inline ShellDispatch *impl_from_IShellDispatch(IShellDispatch *iface)
64 return CONTAINING_RECORD(iface, ShellDispatch, IShellDispatch_iface);
67 static inline FolderImpl *impl_from_Folder(Folder3 *iface)
69 return CONTAINING_RECORD(iface, FolderImpl, Folder_iface);
72 static inline FolderItemImpl *impl_from_FolderItem(FolderItem *iface)
74 return CONTAINING_RECORD(iface, FolderItemImpl, FolderItem_iface);
77 static HRESULT load_type_info(REFGUID guid, ITypeInfo **pptinfo)
79 ITypeLib *typelib;
80 HRESULT ret;
82 ret = LoadRegTypeLib(&LIBID_Shell32, 1, 0, LOCALE_SYSTEM_DEFAULT, &typelib);
83 if (FAILED(ret))
85 ERR("LoadRegTypeLib failed: %08x\n", ret);
86 return ret;
89 ret = ITypeLib_GetTypeInfoOfGuid(typelib, guid, pptinfo);
90 ITypeLib_Release(typelib);
91 if (FAILED(ret))
92 ERR("failed to load ITypeInfo\n");
94 return ret;
97 static HRESULT WINAPI FolderItemImpl_QueryInterface(FolderItem *iface,
98 REFIID riid, LPVOID *ppv)
100 FolderItemImpl *This = impl_from_FolderItem(iface);
102 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
104 if (!ppv) return E_INVALIDARG;
106 if (IsEqualIID(&IID_IUnknown, riid) ||
107 IsEqualIID(&IID_IDispatch, riid) ||
108 IsEqualIID(&IID_FolderItem, riid))
109 *ppv = This;
110 else
112 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
113 *ppv = NULL;
114 return E_NOINTERFACE;
116 IUnknown_AddRef((IUnknown*)*ppv);
117 return S_OK;
120 static ULONG WINAPI FolderItemImpl_AddRef(FolderItem *iface)
122 FolderItemImpl *This = impl_from_FolderItem(iface);
123 ULONG ref = InterlockedIncrement(&This->ref);
125 TRACE("(%p), new refcount=%i\n", iface, ref);
127 return ref;
130 static ULONG WINAPI FolderItemImpl_Release(FolderItem *iface)
132 FolderItemImpl *This = impl_from_FolderItem(iface);
133 ULONG ref = InterlockedDecrement(&This->ref);
135 TRACE("(%p), new refcount=%i\n", iface, ref);
137 if (!ref)
139 VariantClear(&This->dir);
140 ITypeInfo_Release(This->iTypeInfo);
141 HeapFree(GetProcessHeap(), 0, This);
143 return ref;
146 static HRESULT WINAPI FolderItemImpl_GetTypeInfoCount(FolderItem *iface,
147 UINT *pctinfo)
149 TRACE("(%p,%p)\n", iface, pctinfo);
151 *pctinfo = 1;
152 return S_OK;
155 static HRESULT WINAPI FolderItemImpl_GetTypeInfo(FolderItem *iface, UINT iTInfo,
156 LCID lcid, ITypeInfo **ppTInfo)
158 FolderItemImpl *This = impl_from_FolderItem(iface);
160 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
162 ITypeInfo_AddRef(This->iTypeInfo);
163 *ppTInfo = This->iTypeInfo;
164 return S_OK;
167 static HRESULT WINAPI FolderItemImpl_GetIDsOfNames(FolderItem *iface,
168 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
169 DISPID *rgDispId)
171 FolderItemImpl *This = impl_from_FolderItem(iface);
173 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
174 rgDispId);
176 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames, rgDispId);
179 static HRESULT WINAPI FolderItemImpl_Invoke(FolderItem *iface,
180 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
181 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
182 UINT *puArgErr)
184 FolderItemImpl *This = impl_from_FolderItem(iface);
186 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
187 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
189 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
190 pDispParams, pVarResult, pExcepInfo, puArgErr);
193 static HRESULT WINAPI FolderItemImpl_get_Application(FolderItem *iface,
194 IDispatch **ppid)
196 FIXME("(%p,%p)\n", iface, ppid);
198 *ppid = NULL;
199 return E_NOTIMPL;
202 static HRESULT WINAPI FolderItemImpl_get_Parent(FolderItem *iface,
203 IDispatch **ppid)
205 FIXME("(%p,%p)\n", iface, ppid);
207 *ppid = NULL;
208 return E_NOTIMPL;
211 static HRESULT WINAPI FolderItemImpl_get_Name(FolderItem *iface, BSTR *pbs)
213 FIXME("(%p,%p)\n", iface, pbs);
215 *pbs = NULL;
216 return E_NOTIMPL;
219 static HRESULT WINAPI FolderItemImpl_put_Name(FolderItem *iface, BSTR bs)
221 FIXME("(%p,%s)\n", iface, debugstr_w(bs));
223 return E_NOTIMPL;
226 static HRESULT WINAPI FolderItemImpl_get_Path(FolderItem *iface, BSTR *pbs)
228 FolderItemImpl *This = impl_from_FolderItem(iface);
229 HRESULT ret = S_OK;
230 WCHAR *pathW;
231 int len;
233 TRACE("(%p,%p)\n", iface, pbs);
235 *pbs = NULL;
236 if (V_VT(&This->dir) == VT_I4)
238 pathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
239 if (!pathW) return E_OUTOFMEMORY;
240 ret = SHGetFolderPathW(NULL, V_I4(&This->dir), NULL, SHGFP_TYPE_CURRENT,
241 pathW);
242 if (ret == S_OK)
243 *pbs = SysAllocString(pathW);
244 else if (ret == E_INVALIDARG)
246 FIXME("not implemented for %#x\n", V_I4(&This->dir));
247 ret = E_NOTIMPL;
249 HeapFree(GetProcessHeap(), 0, pathW);
251 else /* VT_BSTR */
253 pathW = V_BSTR(&This->dir);
254 len = lstrlenW(pathW);
255 *pbs = SysAllocStringLen(pathW, pathW[len - 1] == '\\' ? len - 1 : len);
257 if (ret == S_OK && !*pbs)
258 ret = E_OUTOFMEMORY;
259 return ret;
262 static HRESULT WINAPI FolderItemImpl_get_GetLink(FolderItem *iface,
263 IDispatch **ppid)
265 FIXME("(%p,%p)\n", iface, ppid);
267 *ppid = NULL;
268 return E_NOTIMPL;
271 static HRESULT WINAPI FolderItemImpl_get_GetFolder(FolderItem *iface,
272 IDispatch **ppid)
274 FIXME("(%p,%p)\n", iface, ppid);
276 *ppid = NULL;
277 return E_NOTIMPL;
280 static HRESULT WINAPI FolderItemImpl_get_IsLink(FolderItem *iface,
281 VARIANT_BOOL *pb)
283 FIXME("(%p,%p)\n", iface, pb);
285 return E_NOTIMPL;
288 static HRESULT WINAPI FolderItemImpl_get_IsFolder(FolderItem *iface,
289 VARIANT_BOOL *pb)
291 FIXME("(%p,%p)\n", iface, pb);
293 return E_NOTIMPL;
296 static HRESULT WINAPI FolderItemImpl_get_IsFileSystem(FolderItem *iface,
297 VARIANT_BOOL *pb)
299 FIXME("(%p,%p)\n", iface, pb);
301 return E_NOTIMPL;
304 static HRESULT WINAPI FolderItemImpl_get_IsBrowsable(FolderItem *iface,
305 VARIANT_BOOL *pb)
307 FIXME("(%p,%p)\n", iface, pb);
309 return E_NOTIMPL;
312 static HRESULT WINAPI FolderItemImpl_get_ModifyDate(FolderItem *iface,
313 DATE *pdt)
315 FIXME("(%p,%p)\n", iface, pdt);
317 return E_NOTIMPL;
320 static HRESULT WINAPI FolderItemImpl_put_ModifyDate(FolderItem *iface, DATE dt)
322 FIXME("(%p,%f)\n", iface, dt);
324 return E_NOTIMPL;
327 static HRESULT WINAPI FolderItemImpl_get_Size(FolderItem *iface, LONG *pul)
329 FIXME("(%p,%p)\n", iface, pul);
331 return E_NOTIMPL;
334 static HRESULT WINAPI FolderItemImpl_get_Type(FolderItem *iface, BSTR *pbs)
336 FIXME("(%p,%p)\n", iface, pbs);
338 *pbs = NULL;
339 return E_NOTIMPL;
342 static HRESULT WINAPI FolderItemImpl_Verbs(FolderItem *iface,
343 FolderItemVerbs **ppfic)
345 FIXME("(%p,%p)\n", iface, ppfic);
347 *ppfic = NULL;
348 return E_NOTIMPL;
351 static HRESULT WINAPI FolderItemImpl_InvokeVerb(FolderItem *iface,
352 VARIANT vVerb)
354 FIXME("(%p)\n", iface);
356 return E_NOTIMPL;
359 static const FolderItemVtbl FolderItemImpl_Vtbl = {
360 FolderItemImpl_QueryInterface,
361 FolderItemImpl_AddRef,
362 FolderItemImpl_Release,
363 FolderItemImpl_GetTypeInfoCount,
364 FolderItemImpl_GetTypeInfo,
365 FolderItemImpl_GetIDsOfNames,
366 FolderItemImpl_Invoke,
367 FolderItemImpl_get_Application,
368 FolderItemImpl_get_Parent,
369 FolderItemImpl_get_Name,
370 FolderItemImpl_put_Name,
371 FolderItemImpl_get_Path,
372 FolderItemImpl_get_GetLink,
373 FolderItemImpl_get_GetFolder,
374 FolderItemImpl_get_IsLink,
375 FolderItemImpl_get_IsFolder,
376 FolderItemImpl_get_IsFileSystem,
377 FolderItemImpl_get_IsBrowsable,
378 FolderItemImpl_get_ModifyDate,
379 FolderItemImpl_put_ModifyDate,
380 FolderItemImpl_get_Size,
381 FolderItemImpl_get_Type,
382 FolderItemImpl_Verbs,
383 FolderItemImpl_InvokeVerb
386 static HRESULT FolderItem_Constructor(VARIANT *dir, FolderItem **ppfi)
388 FolderItemImpl *This;
389 HRESULT ret;
391 *ppfi = NULL;
393 This = HeapAlloc(GetProcessHeap(), 0, sizeof(FolderItemImpl));
394 if (!This) return E_OUTOFMEMORY;
395 This->FolderItem_iface.lpVtbl = &FolderItemImpl_Vtbl;
396 This->ref = 1;
398 ret = load_type_info(&IID_FolderItem, &This->iTypeInfo);
399 if (FAILED(ret))
401 HeapFree(GetProcessHeap(), 0, This);
402 return ret;
405 VariantInit(&This->dir);
406 ret = VariantCopy(&This->dir, dir);
407 if (FAILED(ret))
409 ITypeInfo_Release(This->iTypeInfo);
410 HeapFree(GetProcessHeap(), 0, This);
411 return E_OUTOFMEMORY;
414 *ppfi = (FolderItem*)This;
415 return ret;
418 static HRESULT WINAPI FolderImpl_QueryInterface(Folder3 *iface, REFIID riid,
419 LPVOID *ppv)
421 FolderImpl *This = impl_from_Folder(iface);
423 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
425 if (!ppv) return E_INVALIDARG;
427 if (IsEqualIID(&IID_IUnknown, riid) ||
428 IsEqualIID(&IID_IDispatch, riid) ||
429 IsEqualIID(&IID_Folder, riid) ||
430 IsEqualIID(&IID_Folder2, riid) ||
431 IsEqualIID(&IID_Folder3, riid))
432 *ppv = This;
433 else
435 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
436 *ppv = NULL;
437 return E_NOINTERFACE;
439 IUnknown_AddRef((IUnknown*)*ppv);
440 return S_OK;
443 static ULONG WINAPI FolderImpl_AddRef(Folder3 *iface)
445 FolderImpl *This = impl_from_Folder(iface);
446 ULONG ref = InterlockedIncrement(&This->ref);
448 TRACE("(%p), new refcount=%i\n", iface, ref);
450 return ref;
453 static ULONG WINAPI FolderImpl_Release(Folder3 *iface)
455 FolderImpl *This = impl_from_Folder(iface);
456 ULONG ref = InterlockedDecrement(&This->ref);
458 TRACE("(%p), new refcount=%i\n", iface, ref);
460 if (!ref)
462 VariantClear(&This->dir);
463 ITypeInfo_Release(This->iTypeInfo);
464 HeapFree(GetProcessHeap(), 0, This);
466 return ref;
469 static HRESULT WINAPI FolderImpl_GetTypeInfoCount(Folder3 *iface, UINT *pctinfo)
471 TRACE("(%p,%p)\n", iface, pctinfo);
473 *pctinfo = 1;
474 return S_OK;
477 static HRESULT WINAPI FolderImpl_GetTypeInfo(Folder3 *iface, UINT iTInfo,
478 LCID lcid, ITypeInfo **ppTInfo)
480 FolderImpl *This = impl_from_Folder(iface);
482 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
484 ITypeInfo_AddRef(This->iTypeInfo);
485 *ppTInfo = This->iTypeInfo;
486 return S_OK;
489 static HRESULT WINAPI FolderImpl_GetIDsOfNames(Folder3 *iface, REFIID riid,
490 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
492 FolderImpl *This = impl_from_Folder(iface);
494 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
495 rgDispId);
497 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames,
498 rgDispId);
501 static HRESULT WINAPI FolderImpl_Invoke(Folder3 *iface, DISPID dispIdMember,
502 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
503 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
505 FolderImpl *This = impl_from_Folder(iface);
507 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
508 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
510 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
511 pDispParams, pVarResult, pExcepInfo, puArgErr);
514 static HRESULT WINAPI FolderImpl_get_Title(Folder3 *iface, BSTR *pbs)
516 FolderImpl *This = impl_from_Folder(iface);
517 WCHAR *p;
518 int len;
520 TRACE("(%p,%p)\n", iface, pbs);
522 *pbs = NULL;
524 if (V_VT(&This->dir) == VT_I4)
526 FIXME("special folder constants are not supported\n");
527 return E_NOTIMPL;
529 p = PathFindFileNameW(V_BSTR(&This->dir));
530 len = lstrlenW(p);
531 *pbs = SysAllocStringLen(p, p[len - 1] == '\\' ? len - 1 : len);
532 return *pbs ? S_OK : E_OUTOFMEMORY;
535 static HRESULT WINAPI FolderImpl_get_Application(Folder3 *iface,
536 IDispatch **ppid)
538 FIXME("(%p,%p)\n", iface, ppid);
540 *ppid = NULL;
541 return E_NOTIMPL;
544 static HRESULT WINAPI FolderImpl_get_Parent(Folder3 *iface, IDispatch **ppid)
546 FIXME("(%p,%p)\n", iface, ppid);
548 *ppid = NULL;
549 return E_NOTIMPL;
552 static HRESULT WINAPI FolderImpl_get_ParentFolder(Folder3 *iface, Folder **ppsf)
554 FIXME("(%p,%p)\n", iface, ppsf);
556 *ppsf = NULL;
557 return E_NOTIMPL;
560 static HRESULT WINAPI FolderImpl_Items(Folder3 *iface, FolderItems **ppid)
562 FIXME("(%p,%p)\n", iface, ppid);
564 *ppid = NULL;
565 return E_NOTIMPL;
568 static HRESULT WINAPI FolderImpl_ParseName(Folder3 *iface, BSTR bName,
569 FolderItem **ppid)
571 FIXME("(%p,%s,%p)\n", iface, debugstr_w(bName), ppid);
573 *ppid = NULL;
574 return E_NOTIMPL;
577 static HRESULT WINAPI FolderImpl_NewFolder(Folder3 *iface, BSTR bName,
578 VARIANT vOptions)
580 FIXME("(%p,%s)\n", iface, debugstr_w(bName));
582 return E_NOTIMPL;
585 static HRESULT WINAPI FolderImpl_MoveHere(Folder3 *iface, VARIANT vItem,
586 VARIANT vOptions)
588 FIXME("(%p)\n", iface);
590 return E_NOTIMPL;
593 static HRESULT WINAPI FolderImpl_CopyHere(Folder3 *iface, VARIANT vItem,
594 VARIANT vOptions)
596 FIXME("(%p)\n", iface);
598 return E_NOTIMPL;
601 static HRESULT WINAPI FolderImpl_GetDetailsOf(Folder3 *iface, VARIANT vItem,
602 int iColumn, BSTR *pbs)
604 FIXME("(%p,%d,%p)\n", iface, iColumn, pbs);
606 *pbs = NULL;
607 return E_NOTIMPL;
610 static HRESULT WINAPI FolderImpl_get_Self(Folder3 *iface, FolderItem **ppfi)
612 FolderImpl *This = impl_from_Folder(iface);
614 TRACE("(%p,%p)\n", iface, ppfi);
616 return FolderItem_Constructor(&This->dir, ppfi);
619 static HRESULT WINAPI FolderImpl_get_OfflineStatus(Folder3 *iface, LONG *pul)
621 FIXME("(%p,%p)\n", iface, pul);
623 return E_NOTIMPL;
626 static HRESULT WINAPI FolderImpl_Synchronize(Folder3 *iface)
628 FIXME("(%p)\n", iface);
630 return E_NOTIMPL;
633 static HRESULT WINAPI FolderImpl_get_HaveToShowWebViewBarricade(Folder3 *iface,
634 VARIANT_BOOL *pbHaveToShowWebViewBarricade)
636 FIXME("(%p,%p)\n", iface, pbHaveToShowWebViewBarricade);
638 return E_NOTIMPL;
641 static HRESULT WINAPI FolderImpl_DismissedWebViewBarricade(Folder3 *iface)
643 FIXME("(%p)\n", iface);
645 return E_NOTIMPL;
648 static HRESULT WINAPI FolderImpl_get_ShowWebViewBarricade(Folder3 *iface,
649 VARIANT_BOOL *pbShowWebViewBarricade)
651 FIXME("(%p,%p)\n", iface, pbShowWebViewBarricade);
653 return E_NOTIMPL;
656 static HRESULT WINAPI FolderImpl_put_ShowWebViewBarricade(Folder3 *iface,
657 VARIANT_BOOL bShowWebViewBarricade)
659 FIXME("(%p,%d)\n", iface, bShowWebViewBarricade);
661 return E_NOTIMPL;
664 static const Folder3Vtbl FolderImpl_Vtbl = {
665 FolderImpl_QueryInterface,
666 FolderImpl_AddRef,
667 FolderImpl_Release,
668 FolderImpl_GetTypeInfoCount,
669 FolderImpl_GetTypeInfo,
670 FolderImpl_GetIDsOfNames,
671 FolderImpl_Invoke,
672 FolderImpl_get_Title,
673 FolderImpl_get_Application,
674 FolderImpl_get_Parent,
675 FolderImpl_get_ParentFolder,
676 FolderImpl_Items,
677 FolderImpl_ParseName,
678 FolderImpl_NewFolder,
679 FolderImpl_MoveHere,
680 FolderImpl_CopyHere,
681 FolderImpl_GetDetailsOf,
682 FolderImpl_get_Self,
683 FolderImpl_get_OfflineStatus,
684 FolderImpl_Synchronize,
685 FolderImpl_get_HaveToShowWebViewBarricade,
686 FolderImpl_DismissedWebViewBarricade,
687 FolderImpl_get_ShowWebViewBarricade,
688 FolderImpl_put_ShowWebViewBarricade
691 static HRESULT Folder_Constructor(VARIANT *dir, Folder **ppsdf)
693 FolderImpl *This;
694 HRESULT ret;
696 *ppsdf = NULL;
698 switch (V_VT(dir))
700 case VT_I4:
701 /* FIXME: add some checks */
702 break;
703 case VT_BSTR:
704 if (PathIsDirectoryW(V_BSTR(dir)) &&
705 !PathIsRelativeW(V_BSTR(dir)) &&
706 PathFileExistsW(V_BSTR(dir)))
707 break;
708 default:
709 return S_FALSE;
712 This = HeapAlloc(GetProcessHeap(), 0, sizeof(FolderImpl));
713 if (!This) return E_OUTOFMEMORY;
714 This->Folder_iface.lpVtbl = &FolderImpl_Vtbl;
715 This->ref = 1;
717 ret = load_type_info(&IID_Folder3, &This->iTypeInfo);
718 if (FAILED(ret))
720 HeapFree(GetProcessHeap(), 0, This);
721 return ret;
724 VariantInit(&This->dir);
725 ret = VariantCopy(&This->dir, dir);
726 if (FAILED(ret))
728 ITypeInfo_Release(This->iTypeInfo);
729 HeapFree(GetProcessHeap(), 0, This);
730 return E_OUTOFMEMORY;
733 *ppsdf = (Folder*)This;
734 return ret;
737 static HRESULT WINAPI ShellDispatch_QueryInterface(IShellDispatch *iface,
738 REFIID riid, LPVOID *ppv)
740 ShellDispatch *This = impl_from_IShellDispatch(iface);
742 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
744 if (!ppv) return E_INVALIDARG;
746 if (IsEqualIID(&IID_IUnknown, riid) ||
747 IsEqualIID(&IID_IDispatch, riid) ||
748 IsEqualIID(&IID_IShellDispatch, riid))
749 *ppv = This;
750 else
752 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
753 *ppv = NULL;
754 return E_NOINTERFACE;
756 IUnknown_AddRef((IUnknown*)*ppv);
757 return S_OK;
760 static ULONG WINAPI ShellDispatch_AddRef(IShellDispatch *iface)
762 ShellDispatch *This = impl_from_IShellDispatch(iface);
763 ULONG ref = InterlockedIncrement(&This->ref);
765 TRACE("(%p), new refcount=%i\n", iface, ref);
767 return ref;
770 static ULONG WINAPI ShellDispatch_Release(IShellDispatch *iface)
772 ShellDispatch *This = impl_from_IShellDispatch(iface);
773 ULONG ref = InterlockedDecrement(&This->ref);
775 TRACE("(%p), new refcount=%i\n", iface, ref);
777 if (!ref)
779 ITypeInfo_Release(This->iTypeInfo);
780 HeapFree(GetProcessHeap(), 0, This);
782 return ref;
785 static HRESULT WINAPI ShellDispatch_GetTypeInfoCount(IShellDispatch *iface,
786 UINT *pctinfo)
788 TRACE("(%p,%p)\n", iface, pctinfo);
790 *pctinfo = 1;
791 return S_OK;
794 static HRESULT WINAPI ShellDispatch_GetTypeInfo(IShellDispatch *iface,
795 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
797 ShellDispatch *This = impl_from_IShellDispatch(iface);
799 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
801 ITypeInfo_AddRef(This->iTypeInfo);
802 *ppTInfo = This->iTypeInfo;
803 return S_OK;
806 static HRESULT WINAPI ShellDispatch_GetIDsOfNames(IShellDispatch *iface,
807 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
809 ShellDispatch *This = impl_from_IShellDispatch(iface);
811 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
812 rgDispId);
814 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames, rgDispId);
817 static HRESULT WINAPI ShellDispatch_Invoke(IShellDispatch *iface,
818 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
819 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
820 UINT *puArgErr)
822 ShellDispatch *This = impl_from_IShellDispatch(iface);
824 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
825 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
827 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
828 pDispParams, pVarResult, pExcepInfo, puArgErr);
831 static HRESULT WINAPI ShellDispatch_get_Application(IShellDispatch *iface,
832 IDispatch **ppid)
834 FIXME("(%p,%p)\n", iface, ppid);
836 *ppid = NULL;
837 return E_NOTIMPL;
840 static HRESULT WINAPI ShellDispatch_get_Parent(IShellDispatch *iface,
841 IDispatch **ppid)
843 FIXME("(%p,%p)\n", iface, ppid);
845 *ppid = NULL;
846 return E_NOTIMPL;
849 static HRESULT WINAPI ShellDispatch_NameSpace(IShellDispatch *iface,
850 VARIANT vDir, Folder **ppsdf)
852 TRACE("(%p,%p)\n", iface, ppsdf);
854 return Folder_Constructor(&vDir, ppsdf);
857 static HRESULT WINAPI ShellDispatch_BrowseForFolder(IShellDispatch *iface,
858 LONG Hwnd, BSTR Title, LONG Options, VARIANT RootFolder, Folder **ppsdf)
860 FIXME("(%p,%x,%s,%x,%p)\n", iface, Hwnd, debugstr_w(Title), Options, ppsdf);
862 *ppsdf = NULL;
863 return E_NOTIMPL;
866 static HRESULT WINAPI ShellDispatch_Windows(IShellDispatch *iface,
867 IDispatch **ppid)
869 FIXME("(%p,%p)\n", iface, ppid);
871 *ppid = NULL;
872 return E_NOTIMPL;
875 static HRESULT WINAPI ShellDispatch_Open(IShellDispatch *iface, VARIANT vDir)
877 FIXME("(%p)\n", iface);
879 return E_NOTIMPL;
882 static HRESULT WINAPI ShellDispatch_Explore(IShellDispatch *iface, VARIANT vDir)
884 FIXME("(%p)\n", iface);
886 return E_NOTIMPL;
889 static HRESULT WINAPI ShellDispatch_MinimizeAll(IShellDispatch *iface)
891 FIXME("(%p)\n", iface);
893 return E_NOTIMPL;
896 static HRESULT WINAPI ShellDispatch_UndoMinimizeALL(IShellDispatch *iface)
898 FIXME("(%p)\n", iface);
900 return E_NOTIMPL;
903 static HRESULT WINAPI ShellDispatch_FileRun(IShellDispatch *iface)
905 FIXME("(%p)\n", iface);
907 return E_NOTIMPL;
910 static HRESULT WINAPI ShellDispatch_CascadeWindows(IShellDispatch *iface)
912 FIXME("(%p)\n", iface);
914 return E_NOTIMPL;
917 static HRESULT WINAPI ShellDispatch_TileVertically(IShellDispatch *iface)
919 FIXME("(%p)\n", iface);
921 return E_NOTIMPL;
924 static HRESULT WINAPI ShellDispatch_TileHorizontally(IShellDispatch *iface)
926 FIXME("(%p)\n", iface);
928 return E_NOTIMPL;
931 static HRESULT WINAPI ShellDispatch_ShutdownWindows(IShellDispatch *iface)
933 FIXME("(%p)\n", iface);
935 return E_NOTIMPL;
938 static HRESULT WINAPI ShellDispatch_Suspend(IShellDispatch *iface)
940 FIXME("(%p)\n", iface);
942 return E_NOTIMPL;
945 static HRESULT WINAPI ShellDispatch_EjectPC(IShellDispatch *iface)
947 FIXME("(%p)\n", iface);
949 return E_NOTIMPL;
952 static HRESULT WINAPI ShellDispatch_SetTime(IShellDispatch *iface)
954 FIXME("(%p)\n", iface);
956 return E_NOTIMPL;
959 static HRESULT WINAPI ShellDispatch_TrayProperties(IShellDispatch *iface)
961 FIXME("(%p)\n", iface);
963 return E_NOTIMPL;
966 static HRESULT WINAPI ShellDispatch_Help(IShellDispatch *iface)
968 FIXME("(%p)\n", iface);
970 return E_NOTIMPL;
973 static HRESULT WINAPI ShellDispatch_FindFiles(IShellDispatch *iface)
975 FIXME("(%p)\n", iface);
977 return E_NOTIMPL;
980 static HRESULT WINAPI ShellDispatch_FindComputer(IShellDispatch *iface)
982 FIXME("(%p)\n", iface);
984 return E_NOTIMPL;
987 static HRESULT WINAPI ShellDispatch_RefreshMenu(IShellDispatch *iface)
989 FIXME("(%p)\n", iface);
991 return E_NOTIMPL;
994 static HRESULT WINAPI ShellDispatch_ControlPanelItem(IShellDispatch *iface,
995 BSTR szDir)
997 FIXME("(%p,%s)\n", iface, debugstr_w(szDir));
999 return E_NOTIMPL;
1002 static const IShellDispatchVtbl ShellDispatch_Vtbl = {
1003 ShellDispatch_QueryInterface,
1004 ShellDispatch_AddRef,
1005 ShellDispatch_Release,
1006 ShellDispatch_GetTypeInfoCount,
1007 ShellDispatch_GetTypeInfo,
1008 ShellDispatch_GetIDsOfNames,
1009 ShellDispatch_Invoke,
1010 ShellDispatch_get_Application,
1011 ShellDispatch_get_Parent,
1012 ShellDispatch_NameSpace,
1013 ShellDispatch_BrowseForFolder,
1014 ShellDispatch_Windows,
1015 ShellDispatch_Open,
1016 ShellDispatch_Explore,
1017 ShellDispatch_MinimizeAll,
1018 ShellDispatch_UndoMinimizeALL,
1019 ShellDispatch_FileRun,
1020 ShellDispatch_CascadeWindows,
1021 ShellDispatch_TileVertically,
1022 ShellDispatch_TileHorizontally,
1023 ShellDispatch_ShutdownWindows,
1024 ShellDispatch_Suspend,
1025 ShellDispatch_EjectPC,
1026 ShellDispatch_SetTime,
1027 ShellDispatch_TrayProperties,
1028 ShellDispatch_Help,
1029 ShellDispatch_FindFiles,
1030 ShellDispatch_FindComputer,
1031 ShellDispatch_RefreshMenu,
1032 ShellDispatch_ControlPanelItem
1035 HRESULT WINAPI IShellDispatch_Constructor(IUnknown *pUnkOuter, REFIID riid,
1036 LPVOID *ppv)
1038 ShellDispatch *This;
1039 HRESULT ret;
1041 TRACE("(%p,%s)\n", pUnkOuter, debugstr_guid(riid));
1043 *ppv = NULL;
1045 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
1047 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ShellDispatch));
1048 if (!This) return E_OUTOFMEMORY;
1049 This->IShellDispatch_iface.lpVtbl = &ShellDispatch_Vtbl;
1050 This->ref = 1;
1052 ret = load_type_info(&IID_IShellDispatch, &This->iTypeInfo);
1053 if (FAILED(ret))
1055 HeapFree(GetProcessHeap(), 0, This);
1056 return ret;
1059 ret = ShellDispatch_QueryInterface(&This->IShellDispatch_iface, riid, ppv);
1060 ShellDispatch_Release(&This->IShellDispatch_iface);
1061 return ret;