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
22 #include "wine/port.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
40 IShellDispatch IShellDispatch_iface
;
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
)
55 ret
= LoadRegTypeLib(&LIBID_Shell32
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &typelib
);
58 ERR("LoadRegTypeLib failed: %08x\n", ret
);
62 ret
= ITypeLib_GetTypeInfoOfGuid(typelib
, guid
, pptinfo
);
63 ITypeLib_Release(typelib
);
65 ERR("failed to load ITypeInfo\n");
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
))
85 FIXME("not implemented for %s\n", shdebugstr_guid(riid
));
89 IUnknown_AddRef((IUnknown
*)*ppv
);
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
);
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
);
112 ITypeInfo_Release(This
->iTypeInfo
);
113 HeapFree(GetProcessHeap(), 0, This
);
118 static HRESULT WINAPI
ShellDispatch_GetTypeInfoCount(IShellDispatch
*iface
,
121 TRACE("(%p,%p)\n", iface
, pctinfo
);
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
;
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
,
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
,
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
,
167 FIXME("(%p,%p)\n", iface
, ppid
);
173 static HRESULT WINAPI
ShellDispatch_get_Parent(IShellDispatch
*iface
,
176 FIXME("(%p,%p)\n", iface
, ppid
);
182 static HRESULT WINAPI
ShellDispatch_NameSpace(IShellDispatch
*iface
,
183 VARIANT vDir
, Folder
**ppsdf
)
185 FIXME("(%p,%p)\n", iface
, ppsdf
);
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
);
200 static HRESULT WINAPI
ShellDispatch_Windows(IShellDispatch
*iface
,
203 FIXME("(%p,%p)\n", iface
, ppid
);
209 static HRESULT WINAPI
ShellDispatch_Open(IShellDispatch
*iface
, VARIANT vDir
)
211 FIXME("(%p)\n", iface
);
216 static HRESULT WINAPI
ShellDispatch_Explore(IShellDispatch
*iface
, VARIANT vDir
)
218 FIXME("(%p)\n", iface
);
223 static HRESULT WINAPI
ShellDispatch_MinimizeAll(IShellDispatch
*iface
)
225 FIXME("(%p)\n", iface
);
230 static HRESULT WINAPI
ShellDispatch_UndoMinimizeALL(IShellDispatch
*iface
)
232 FIXME("(%p)\n", iface
);
237 static HRESULT WINAPI
ShellDispatch_FileRun(IShellDispatch
*iface
)
239 FIXME("(%p)\n", iface
);
244 static HRESULT WINAPI
ShellDispatch_CascadeWindows(IShellDispatch
*iface
)
246 FIXME("(%p)\n", iface
);
251 static HRESULT WINAPI
ShellDispatch_TileVertically(IShellDispatch
*iface
)
253 FIXME("(%p)\n", iface
);
258 static HRESULT WINAPI
ShellDispatch_TileHorizontally(IShellDispatch
*iface
)
260 FIXME("(%p)\n", iface
);
265 static HRESULT WINAPI
ShellDispatch_ShutdownWindows(IShellDispatch
*iface
)
267 FIXME("(%p)\n", iface
);
272 static HRESULT WINAPI
ShellDispatch_Suspend(IShellDispatch
*iface
)
274 FIXME("(%p)\n", iface
);
279 static HRESULT WINAPI
ShellDispatch_EjectPC(IShellDispatch
*iface
)
281 FIXME("(%p)\n", iface
);
286 static HRESULT WINAPI
ShellDispatch_SetTime(IShellDispatch
*iface
)
288 FIXME("(%p)\n", iface
);
293 static HRESULT WINAPI
ShellDispatch_TrayProperties(IShellDispatch
*iface
)
295 FIXME("(%p)\n", iface
);
300 static HRESULT WINAPI
ShellDispatch_Help(IShellDispatch
*iface
)
302 FIXME("(%p)\n", iface
);
307 static HRESULT WINAPI
ShellDispatch_FindFiles(IShellDispatch
*iface
)
309 FIXME("(%p)\n", iface
);
314 static HRESULT WINAPI
ShellDispatch_FindComputer(IShellDispatch
*iface
)
316 FIXME("(%p)\n", iface
);
321 static HRESULT WINAPI
ShellDispatch_RefreshMenu(IShellDispatch
*iface
)
323 FIXME("(%p)\n", iface
);
328 static HRESULT WINAPI
ShellDispatch_ControlPanelItem(IShellDispatch
*iface
,
331 FIXME("(%p,%s)\n", iface
, debugstr_w(szDir
));
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
,
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
,
363 ShellDispatch_FindFiles
,
364 ShellDispatch_FindComputer
,
365 ShellDispatch_RefreshMenu
,
366 ShellDispatch_ControlPanelItem
369 HRESULT WINAPI
IShellDispatch_Constructor(IUnknown
*pUnkOuter
, REFIID riid
,
375 TRACE("(%p,%s)\n", pUnkOuter
, debugstr_guid(riid
));
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
;
386 ret
= load_type_info(&IID_IShellDispatch
, &This
->iTypeInfo
);
389 HeapFree(GetProcessHeap(), 0, This
);
393 ret
= ShellDispatch_QueryInterface(&This
->IShellDispatch_iface
, riid
, ppv
);
394 ShellDispatch_Release(&This
->IShellDispatch_iface
);