ddraw: COM cleanup for the IClassFactory iface.
[wine/multimedia.git] / dlls / shell32 / shelldispatch.c
blob9b2422b33cccaeefaaff157294474796b982e679
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
28 #include "windef.h"
29 #include "winbase.h"
31 #include "shlobj.h"
32 #include "shldisp.h"
33 #include "debughlp.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(shell);
39 typedef struct {
40 IShellDispatch IShellDispatch_iface;
41 LONG ref;
42 ITypeInfo *iTypeInfo;
43 } ShellDispatch;
45 static inline ShellDispatch *impl_from_IShellDispatch(IShellDispatch *iface)
47 return CONTAINING_RECORD(iface, ShellDispatch, IShellDispatch_iface);
50 static HRESULT load_type_info(REFGUID guid, ITypeInfo **pptinfo)
52 ITypeLib *typelib;
53 HRESULT ret;
55 ret = LoadRegTypeLib(&LIBID_Shell32, 1, 0, LOCALE_SYSTEM_DEFAULT, &typelib);
56 if (FAILED(ret))
58 ERR("LoadRegTypeLib failed: %08x\n", ret);
59 return ret;
62 ret = ITypeLib_GetTypeInfoOfGuid(typelib, guid, pptinfo);
63 ITypeLib_Release(typelib);
64 if (FAILED(ret))
65 ERR("failed to load ITypeInfo\n");
67 return ret;
70 static HRESULT WINAPI ShellDispatch_QueryInterface(IShellDispatch *iface,
71 REFIID riid, LPVOID *ppv)
73 ShellDispatch *This = impl_from_IShellDispatch(iface);
75 TRACE("(%p,%p,%p)\n", iface, riid, ppv);
77 if (!ppv) return E_INVALIDARG;
79 if (IsEqualIID(&IID_IUnknown, riid) ||
80 IsEqualIID(&IID_IDispatch, riid) ||
81 IsEqualIID(&IID_IShellDispatch, riid))
82 *ppv = This;
83 else
85 FIXME("not implemented for %s\n", shdebugstr_guid(riid));
86 *ppv = NULL;
87 return E_NOINTERFACE;
89 IUnknown_AddRef((IUnknown*)*ppv);
90 return S_OK;
93 static ULONG WINAPI ShellDispatch_AddRef(IShellDispatch *iface)
95 ShellDispatch *This = impl_from_IShellDispatch(iface);
96 ULONG ref = InterlockedIncrement(&This->ref);
98 TRACE("(%p), new refcount=%i\n", iface, ref);
100 return ref;
103 static ULONG WINAPI ShellDispatch_Release(IShellDispatch *iface)
105 ShellDispatch *This = impl_from_IShellDispatch(iface);
106 ULONG ref = InterlockedDecrement(&This->ref);
108 TRACE("(%p), new refcount=%i\n", iface, ref);
110 if (!ref)
112 ITypeInfo_Release(This->iTypeInfo);
113 HeapFree(GetProcessHeap(), 0, This);
115 return ref;
118 static HRESULT WINAPI ShellDispatch_GetTypeInfoCount(IShellDispatch *iface,
119 UINT *pctinfo)
121 TRACE("(%p,%p)\n", iface, pctinfo);
123 *pctinfo = 1;
124 return S_OK;
127 static HRESULT WINAPI ShellDispatch_GetTypeInfo(IShellDispatch *iface,
128 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
130 ShellDispatch *This = impl_from_IShellDispatch(iface);
132 TRACE("(%p,%u,%d,%p)\n", iface, iTInfo, lcid, ppTInfo);
134 ITypeInfo_AddRef(This->iTypeInfo);
135 *ppTInfo = This->iTypeInfo;
136 return S_OK;
139 static HRESULT WINAPI ShellDispatch_GetIDsOfNames(IShellDispatch *iface,
140 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
142 ShellDispatch *This = impl_from_IShellDispatch(iface);
144 TRACE("(%p,%p,%p,%u,%d,%p)\n", iface, riid, rgszNames, cNames, lcid,
145 rgDispId);
147 return ITypeInfo_GetIDsOfNames(This->iTypeInfo, rgszNames, cNames, rgDispId);
150 static HRESULT WINAPI ShellDispatch_Invoke(IShellDispatch *iface,
151 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
152 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
153 UINT *puArgErr)
155 ShellDispatch *This = impl_from_IShellDispatch(iface);
157 TRACE("(%p,%d,%p,%d,%u,%p,%p,%p,%p)\n", iface, dispIdMember, riid, lcid,
158 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
160 return ITypeInfo_Invoke(This->iTypeInfo, This, dispIdMember, wFlags,
161 pDispParams, pVarResult, pExcepInfo, puArgErr);
164 static HRESULT WINAPI ShellDispatch_get_Application(IShellDispatch *iface,
165 IDispatch **ppid)
167 FIXME("(%p,%p)\n", iface, ppid);
169 *ppid = NULL;
170 return E_NOTIMPL;
173 static HRESULT WINAPI ShellDispatch_get_Parent(IShellDispatch *iface,
174 IDispatch **ppid)
176 FIXME("(%p,%p)\n", iface, ppid);
178 *ppid = NULL;
179 return E_NOTIMPL;
182 static HRESULT WINAPI ShellDispatch_NameSpace(IShellDispatch *iface,
183 VARIANT vDir, Folder **ppsdf)
185 FIXME("(%p,%p)\n", iface, ppsdf);
187 *ppsdf = NULL;
188 return E_NOTIMPL;
191 static HRESULT WINAPI ShellDispatch_BrowseForFolder(IShellDispatch *iface,
192 LONG Hwnd, BSTR Title, LONG Options, VARIANT RootFolder, Folder **ppsdf)
194 FIXME("(%p,%x,%s,%x,%p)\n", iface, Hwnd, debugstr_w(Title), Options, ppsdf);
196 *ppsdf = NULL;
197 return E_NOTIMPL;
200 static HRESULT WINAPI ShellDispatch_Windows(IShellDispatch *iface,
201 IDispatch **ppid)
203 FIXME("(%p,%p)\n", iface, ppid);
205 *ppid = NULL;
206 return E_NOTIMPL;
209 static HRESULT WINAPI ShellDispatch_Open(IShellDispatch *iface, VARIANT vDir)
211 FIXME("(%p)\n", iface);
213 return E_NOTIMPL;
216 static HRESULT WINAPI ShellDispatch_Explore(IShellDispatch *iface, VARIANT vDir)
218 FIXME("(%p)\n", iface);
220 return E_NOTIMPL;
223 static HRESULT WINAPI ShellDispatch_MinimizeAll(IShellDispatch *iface)
225 FIXME("(%p)\n", iface);
227 return E_NOTIMPL;
230 static HRESULT WINAPI ShellDispatch_UndoMinimizeALL(IShellDispatch *iface)
232 FIXME("(%p)\n", iface);
234 return E_NOTIMPL;
237 static HRESULT WINAPI ShellDispatch_FileRun(IShellDispatch *iface)
239 FIXME("(%p)\n", iface);
241 return E_NOTIMPL;
244 static HRESULT WINAPI ShellDispatch_CascadeWindows(IShellDispatch *iface)
246 FIXME("(%p)\n", iface);
248 return E_NOTIMPL;
251 static HRESULT WINAPI ShellDispatch_TileVertically(IShellDispatch *iface)
253 FIXME("(%p)\n", iface);
255 return E_NOTIMPL;
258 static HRESULT WINAPI ShellDispatch_TileHorizontally(IShellDispatch *iface)
260 FIXME("(%p)\n", iface);
262 return E_NOTIMPL;
265 static HRESULT WINAPI ShellDispatch_ShutdownWindows(IShellDispatch *iface)
267 FIXME("(%p)\n", iface);
269 return E_NOTIMPL;
272 static HRESULT WINAPI ShellDispatch_Suspend(IShellDispatch *iface)
274 FIXME("(%p)\n", iface);
276 return E_NOTIMPL;
279 static HRESULT WINAPI ShellDispatch_EjectPC(IShellDispatch *iface)
281 FIXME("(%p)\n", iface);
283 return E_NOTIMPL;
286 static HRESULT WINAPI ShellDispatch_SetTime(IShellDispatch *iface)
288 FIXME("(%p)\n", iface);
290 return E_NOTIMPL;
293 static HRESULT WINAPI ShellDispatch_TrayProperties(IShellDispatch *iface)
295 FIXME("(%p)\n", iface);
297 return E_NOTIMPL;
300 static HRESULT WINAPI ShellDispatch_Help(IShellDispatch *iface)
302 FIXME("(%p)\n", iface);
304 return E_NOTIMPL;
307 static HRESULT WINAPI ShellDispatch_FindFiles(IShellDispatch *iface)
309 FIXME("(%p)\n", iface);
311 return E_NOTIMPL;
314 static HRESULT WINAPI ShellDispatch_FindComputer(IShellDispatch *iface)
316 FIXME("(%p)\n", iface);
318 return E_NOTIMPL;
321 static HRESULT WINAPI ShellDispatch_RefreshMenu(IShellDispatch *iface)
323 FIXME("(%p)\n", iface);
325 return E_NOTIMPL;
328 static HRESULT WINAPI ShellDispatch_ControlPanelItem(IShellDispatch *iface,
329 BSTR szDir)
331 FIXME("(%p,%s)\n", iface, debugstr_w(szDir));
333 return E_NOTIMPL;
336 static const IShellDispatchVtbl ShellDispatch_Vtbl = {
337 ShellDispatch_QueryInterface,
338 ShellDispatch_AddRef,
339 ShellDispatch_Release,
340 ShellDispatch_GetTypeInfoCount,
341 ShellDispatch_GetTypeInfo,
342 ShellDispatch_GetIDsOfNames,
343 ShellDispatch_Invoke,
344 ShellDispatch_get_Application,
345 ShellDispatch_get_Parent,
346 ShellDispatch_NameSpace,
347 ShellDispatch_BrowseForFolder,
348 ShellDispatch_Windows,
349 ShellDispatch_Open,
350 ShellDispatch_Explore,
351 ShellDispatch_MinimizeAll,
352 ShellDispatch_UndoMinimizeALL,
353 ShellDispatch_FileRun,
354 ShellDispatch_CascadeWindows,
355 ShellDispatch_TileVertically,
356 ShellDispatch_TileHorizontally,
357 ShellDispatch_ShutdownWindows,
358 ShellDispatch_Suspend,
359 ShellDispatch_EjectPC,
360 ShellDispatch_SetTime,
361 ShellDispatch_TrayProperties,
362 ShellDispatch_Help,
363 ShellDispatch_FindFiles,
364 ShellDispatch_FindComputer,
365 ShellDispatch_RefreshMenu,
366 ShellDispatch_ControlPanelItem
369 HRESULT WINAPI IShellDispatch_Constructor(IUnknown *pUnkOuter, REFIID riid,
370 LPVOID *ppv)
372 ShellDispatch *This;
373 HRESULT ret;
375 TRACE("(%p,%s)\n", pUnkOuter, debugstr_guid(riid));
377 *ppv = NULL;
379 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
381 This = HeapAlloc(GetProcessHeap(), 0, sizeof(ShellDispatch));
382 if (!This) return E_OUTOFMEMORY;
383 This->IShellDispatch_iface.lpVtbl = &ShellDispatch_Vtbl;
384 This->ref = 1;
386 ret = load_type_info(&IID_IShellDispatch, &This->iTypeInfo);
387 if (FAILED(ret))
389 HeapFree(GetProcessHeap(), 0, This);
390 return ret;
393 ret = ShellDispatch_QueryInterface(&This->IShellDispatch_iface, riid, ppv);
394 ShellDispatch_Release(&This->IShellDispatch_iface);
395 return ret;