2 * Copyright 2011 Jacek Caban for CodeWeavers
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.
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.
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
19 #include "wshom_private.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wshom
);
31 static const char *debugstr_variant(const VARIANT
*v
)
42 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v
));
44 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v
));
46 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v
)));
48 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v
));
50 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v
));
52 return wine_dbg_sprintf("{VT_UNKNOWN: %p}", V_UNKNOWN(v
));
54 return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v
));
55 case VT_BSTR
|VT_BYREF
:
56 return wine_dbg_sprintf("{VT_BSTR|VT_BYREF: ptr %p, data %s}",
57 V_BSTRREF(v
), debugstr_w(V_BSTRREF(v
) ? *V_BSTRREF(v
) : NULL
));
59 return wine_dbg_sprintf("{vt %d}", V_VT(v
));
63 static IWshShell3 WshShell3
;
67 IWshCollection IWshCollection_iface
;
73 IWshShortcut IWshShortcut_iface
;
80 static inline WshCollection
*impl_from_IWshCollection( IWshCollection
*iface
)
82 return CONTAINING_RECORD(iface
, WshCollection
, IWshCollection_iface
);
85 static inline WshShortcut
*impl_from_IWshShortcut( IWshShortcut
*iface
)
87 return CONTAINING_RECORD(iface
, WshShortcut
, IWshShortcut_iface
);
90 static HRESULT WINAPI
WshCollection_QueryInterface(IWshCollection
*iface
, REFIID riid
, void **ppv
)
92 WshCollection
*This
= impl_from_IWshCollection(iface
);
94 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
96 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
97 IsEqualGUID(riid
, &IID_IDispatch
) ||
98 IsEqualGUID(riid
, &IID_IWshCollection
))
102 FIXME("Unknown iface %s\n", debugstr_guid(riid
));
104 return E_NOINTERFACE
;
107 IUnknown_AddRef((IUnknown
*)*ppv
);
111 static ULONG WINAPI
WshCollection_AddRef(IWshCollection
*iface
)
113 WshCollection
*This
= impl_from_IWshCollection(iface
);
114 LONG ref
= InterlockedIncrement(&This
->ref
);
115 TRACE("(%p) ref = %d\n", This
, ref
);
119 static ULONG WINAPI
WshCollection_Release(IWshCollection
*iface
)
121 WshCollection
*This
= impl_from_IWshCollection(iface
);
122 LONG ref
= InterlockedDecrement(&This
->ref
);
123 TRACE("(%p) ref = %d\n", This
, ref
);
126 HeapFree(GetProcessHeap(), 0, This
);
131 static HRESULT WINAPI
WshCollection_GetTypeInfoCount(IWshCollection
*iface
, UINT
*pctinfo
)
133 WshCollection
*This
= impl_from_IWshCollection(iface
);
134 TRACE("(%p)->(%p)\n", This
, pctinfo
);
139 static HRESULT WINAPI
WshCollection_GetTypeInfo(IWshCollection
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
141 WshCollection
*This
= impl_from_IWshCollection(iface
);
142 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
143 return get_typeinfo(IWshCollection_tid
, ppTInfo
);
146 static HRESULT WINAPI
WshCollection_GetIDsOfNames(IWshCollection
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
147 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
149 WshCollection
*This
= impl_from_IWshCollection(iface
);
153 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
155 hr
= get_typeinfo(IWshCollection_tid
, &typeinfo
);
158 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
159 ITypeInfo_Release(typeinfo
);
165 static HRESULT WINAPI
WshCollection_Invoke(IWshCollection
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
166 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
168 WshCollection
*This
= impl_from_IWshCollection(iface
);
172 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
173 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
175 hr
= get_typeinfo(IWshCollection_tid
, &typeinfo
);
178 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IWshCollection_iface
, dispIdMember
, wFlags
,
179 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
180 ITypeInfo_Release(typeinfo
);
186 static HRESULT WINAPI
WshCollection_Item(IWshCollection
*iface
, VARIANT
*index
, VARIANT
*value
)
188 WshCollection
*This
= impl_from_IWshCollection(iface
);
189 static const WCHAR allusersdesktopW
[] = {'A','l','l','U','s','e','r','s','D','e','s','k','t','o','p',0};
190 static const WCHAR allusersprogramsW
[] = {'A','l','l','U','s','e','r','s','P','r','o','g','r','a','m','s',0};
191 static const WCHAR desktopW
[] = {'D','e','s','k','t','o','p',0};
192 PIDLIST_ABSOLUTE pidl
;
193 WCHAR pathW
[MAX_PATH
];
198 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(index
), value
);
200 if (V_VT(index
) != VT_BSTR
)
202 FIXME("only BSTR index supported, got %d\n", V_VT(index
));
206 folder
= V_BSTR(index
);
207 if (!strcmpiW(folder
, desktopW
))
208 kind
= CSIDL_DESKTOP
;
209 else if (!strcmpiW(folder
, allusersdesktopW
))
210 kind
= CSIDL_COMMON_DESKTOPDIRECTORY
;
211 else if (!strcmpiW(folder
, allusersprogramsW
))
212 kind
= CSIDL_COMMON_PROGRAMS
;
215 FIXME("folder kind %s not supported\n", debugstr_w(folder
));
219 hr
= SHGetSpecialFolderLocation(NULL
, kind
, &pidl
);
220 if (hr
!= S_OK
) return hr
;
222 if (SHGetPathFromIDListW(pidl
, pathW
))
224 V_VT(value
) = VT_BSTR
;
225 V_BSTR(value
) = SysAllocString(pathW
);
226 hr
= V_BSTR(value
) ? S_OK
: E_OUTOFMEMORY
;
236 static HRESULT WINAPI
WshCollection_Count(IWshCollection
*iface
, LONG
*count
)
238 WshCollection
*This
= impl_from_IWshCollection(iface
);
239 FIXME("(%p)->(%p): stub\n", This
, count
);
243 static HRESULT WINAPI
WshCollection_get_length(IWshCollection
*iface
, LONG
*count
)
245 WshCollection
*This
= impl_from_IWshCollection(iface
);
246 FIXME("(%p)->(%p): stub\n", This
, count
);
250 static HRESULT WINAPI
WshCollection__NewEnum(IWshCollection
*iface
, IUnknown
*Enum
)
252 WshCollection
*This
= impl_from_IWshCollection(iface
);
253 FIXME("(%p)->(%p): stub\n", This
, Enum
);
257 static const IWshCollectionVtbl WshCollectionVtbl
= {
258 WshCollection_QueryInterface
,
259 WshCollection_AddRef
,
260 WshCollection_Release
,
261 WshCollection_GetTypeInfoCount
,
262 WshCollection_GetTypeInfo
,
263 WshCollection_GetIDsOfNames
,
264 WshCollection_Invoke
,
267 WshCollection_get_length
,
268 WshCollection__NewEnum
271 static HRESULT
WshCollection_Create(IWshCollection
**collection
)
275 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
276 if (!This
) return E_OUTOFMEMORY
;
278 This
->IWshCollection_iface
.lpVtbl
= &WshCollectionVtbl
;
281 *collection
= &This
->IWshCollection_iface
;
287 static HRESULT WINAPI
WshShortcut_QueryInterface(IWshShortcut
*iface
, REFIID riid
, void **ppv
)
289 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
291 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
293 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
294 IsEqualGUID(riid
, &IID_IDispatch
) ||
295 IsEqualGUID(riid
, &IID_IWshShortcut
))
299 FIXME("Unknown iface %s\n", debugstr_guid(riid
));
301 return E_NOINTERFACE
;
304 IUnknown_AddRef((IUnknown
*)*ppv
);
308 static ULONG WINAPI
WshShortcut_AddRef(IWshShortcut
*iface
)
310 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
311 LONG ref
= InterlockedIncrement(&This
->ref
);
312 TRACE("(%p) ref = %d\n", This
, ref
);
316 static ULONG WINAPI
WshShortcut_Release(IWshShortcut
*iface
)
318 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
319 LONG ref
= InterlockedDecrement(&This
->ref
);
320 TRACE("(%p) ref = %d\n", This
, ref
);
324 SysFreeString(This
->path_link
);
325 IShellLinkW_Release(This
->link
);
326 HeapFree(GetProcessHeap(), 0, This
);
332 static HRESULT WINAPI
WshShortcut_GetTypeInfoCount(IWshShortcut
*iface
, UINT
*pctinfo
)
334 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
335 TRACE("(%p)->(%p)\n", This
, pctinfo
);
340 static HRESULT WINAPI
WshShortcut_GetTypeInfo(IWshShortcut
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
342 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
343 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
344 return get_typeinfo(IWshShortcut_tid
, ppTInfo
);
347 static HRESULT WINAPI
WshShortcut_GetIDsOfNames(IWshShortcut
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
348 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
350 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
354 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
356 hr
= get_typeinfo(IWshShortcut_tid
, &typeinfo
);
359 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
360 ITypeInfo_Release(typeinfo
);
366 static HRESULT WINAPI
WshShortcut_Invoke(IWshShortcut
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
367 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
369 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
373 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
374 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
376 hr
= get_typeinfo(IWshShortcut_tid
, &typeinfo
);
379 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IWshShortcut_iface
, dispIdMember
, wFlags
,
380 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
381 ITypeInfo_Release(typeinfo
);
387 static HRESULT WINAPI
WshShortcut_get_FullName(IWshShortcut
*iface
, BSTR
*name
)
389 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
390 FIXME("(%p)->(%p): stub\n", This
, name
);
394 static HRESULT WINAPI
WshShortcut_get_Arguments(IWshShortcut
*iface
, BSTR
*Arguments
)
396 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
397 WCHAR buffW
[INFOTIPSIZE
];
400 TRACE("(%p)->(%p)\n", This
, Arguments
);
407 hr
= IShellLinkW_GetArguments(This
->link
, buffW
, sizeof(buffW
)/sizeof(WCHAR
));
411 *Arguments
= SysAllocString(buffW
);
412 return *Arguments
? S_OK
: E_OUTOFMEMORY
;
415 static HRESULT WINAPI
WshShortcut_put_Arguments(IWshShortcut
*iface
, BSTR Arguments
)
417 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
419 TRACE("(%p)->(%s)\n", This
, debugstr_w(Arguments
));
421 return IShellLinkW_SetArguments(This
->link
, Arguments
);
424 static HRESULT WINAPI
WshShortcut_get_Description(IWshShortcut
*iface
, BSTR
*Description
)
426 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
427 FIXME("(%p)->(%p): stub\n", This
, Description
);
431 static HRESULT WINAPI
WshShortcut_put_Description(IWshShortcut
*iface
, BSTR Description
)
433 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
434 TRACE("(%p)->(%s)\n", This
, debugstr_w(Description
));
435 return IShellLinkW_SetDescription(This
->link
, Description
);
438 static HRESULT WINAPI
WshShortcut_get_Hotkey(IWshShortcut
*iface
, BSTR
*Hotkey
)
440 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
441 FIXME("(%p)->(%p): stub\n", This
, Hotkey
);
445 static HRESULT WINAPI
WshShortcut_put_Hotkey(IWshShortcut
*iface
, BSTR Hotkey
)
447 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
448 FIXME("(%p)->(%s): stub\n", This
, debugstr_w(Hotkey
));
452 static HRESULT WINAPI
WshShortcut_get_IconLocation(IWshShortcut
*iface
, BSTR
*IconPath
)
454 static const WCHAR fmtW
[] = {'%','s',',',' ','%','d',0};
455 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
456 WCHAR buffW
[MAX_PATH
], pathW
[MAX_PATH
];
460 TRACE("(%p)->(%p)\n", This
, IconPath
);
465 hr
= IShellLinkW_GetIconLocation(This
->link
, buffW
, sizeof(buffW
)/sizeof(WCHAR
), &icon
);
466 if (FAILED(hr
)) return hr
;
468 sprintfW(pathW
, fmtW
, buffW
, icon
);
469 *IconPath
= SysAllocString(pathW
);
470 if (!*IconPath
) return E_OUTOFMEMORY
;
475 static HRESULT WINAPI
WshShortcut_put_IconLocation(IWshShortcut
*iface
, BSTR IconPath
)
477 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
483 TRACE("(%p)->(%s)\n", This
, debugstr_w(IconPath
));
485 /* scan for icon id */
486 ptr
= strrchrW(IconPath
, ',');
489 WARN("icon index not found\n");
493 path
= SysAllocStringLen(IconPath
, ptr
-IconPath
);
495 /* skip spaces if any */
496 while (isspaceW(*++ptr
))
501 hr
= IShellLinkW_SetIconLocation(This
->link
, path
, icon
);
507 static HRESULT WINAPI
WshShortcut_put_RelativePath(IWshShortcut
*iface
, BSTR rhs
)
509 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
510 FIXME("(%p)->(%s): stub\n", This
, debugstr_w(rhs
));
514 static HRESULT WINAPI
WshShortcut_get_TargetPath(IWshShortcut
*iface
, BSTR
*Path
)
516 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
517 FIXME("(%p)->(%p): stub\n", This
, Path
);
521 static HRESULT WINAPI
WshShortcut_put_TargetPath(IWshShortcut
*iface
, BSTR Path
)
523 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
524 TRACE("(%p)->(%s)\n", This
, debugstr_w(Path
));
525 return IShellLinkW_SetPath(This
->link
, Path
);
528 static HRESULT WINAPI
WshShortcut_get_WindowStyle(IWshShortcut
*iface
, int *ShowCmd
)
530 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
531 TRACE("(%p)->(%p)\n", This
, ShowCmd
);
532 return IShellLinkW_GetShowCmd(This
->link
, ShowCmd
);
535 static HRESULT WINAPI
WshShortcut_put_WindowStyle(IWshShortcut
*iface
, int ShowCmd
)
537 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
538 TRACE("(%p)->(%d)\n", This
, ShowCmd
);
539 return IShellLinkW_SetShowCmd(This
->link
, ShowCmd
);
542 static HRESULT WINAPI
WshShortcut_get_WorkingDirectory(IWshShortcut
*iface
, BSTR
*WorkingDirectory
)
544 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
545 WCHAR buffW
[MAX_PATH
];
548 TRACE("(%p)->(%p)\n", This
, WorkingDirectory
);
550 if (!WorkingDirectory
)
553 *WorkingDirectory
= NULL
;
554 hr
= IShellLinkW_GetWorkingDirectory(This
->link
, buffW
, sizeof(buffW
)/sizeof(WCHAR
));
555 if (FAILED(hr
)) return hr
;
557 *WorkingDirectory
= SysAllocString(buffW
);
558 return *WorkingDirectory
? S_OK
: E_OUTOFMEMORY
;
561 static HRESULT WINAPI
WshShortcut_put_WorkingDirectory(IWshShortcut
*iface
, BSTR WorkingDirectory
)
563 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
564 TRACE("(%p)->(%s)\n", This
, debugstr_w(WorkingDirectory
));
565 return IShellLinkW_SetWorkingDirectory(This
->link
, WorkingDirectory
);
568 static HRESULT WINAPI
WshShortcut_Load(IWshShortcut
*iface
, BSTR PathLink
)
570 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
571 FIXME("(%p)->(%s): stub\n", This
, debugstr_w(PathLink
));
575 static HRESULT WINAPI
WshShortcut_Save(IWshShortcut
*iface
)
577 WshShortcut
*This
= impl_from_IWshShortcut(iface
);
581 TRACE("(%p)\n", This
);
583 IShellLinkW_QueryInterface(This
->link
, &IID_IPersistFile
, (void**)&file
);
584 hr
= IPersistFile_Save(file
, This
->path_link
, TRUE
);
585 IPersistFile_Release(file
);
590 static const IWshShortcutVtbl WshShortcutVtbl
= {
591 WshShortcut_QueryInterface
,
594 WshShortcut_GetTypeInfoCount
,
595 WshShortcut_GetTypeInfo
,
596 WshShortcut_GetIDsOfNames
,
598 WshShortcut_get_FullName
,
599 WshShortcut_get_Arguments
,
600 WshShortcut_put_Arguments
,
601 WshShortcut_get_Description
,
602 WshShortcut_put_Description
,
603 WshShortcut_get_Hotkey
,
604 WshShortcut_put_Hotkey
,
605 WshShortcut_get_IconLocation
,
606 WshShortcut_put_IconLocation
,
607 WshShortcut_put_RelativePath
,
608 WshShortcut_get_TargetPath
,
609 WshShortcut_put_TargetPath
,
610 WshShortcut_get_WindowStyle
,
611 WshShortcut_put_WindowStyle
,
612 WshShortcut_get_WorkingDirectory
,
613 WshShortcut_put_WorkingDirectory
,
618 static HRESULT
WshShortcut_Create(const WCHAR
*path
, IDispatch
**shortcut
)
625 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
626 if (!This
) return E_OUTOFMEMORY
;
628 This
->IWshShortcut_iface
.lpVtbl
= &WshShortcutVtbl
;
631 hr
= CoCreateInstance(&CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
632 &IID_IShellLinkW
, (void**)&This
->link
);
635 HeapFree(GetProcessHeap(), 0, This
);
639 This
->path_link
= SysAllocString(path
);
640 if (!This
->path_link
)
642 IShellLinkW_Release(This
->link
);
643 HeapFree(GetProcessHeap(), 0, This
);
644 return E_OUTOFMEMORY
;
647 *shortcut
= (IDispatch
*)&This
->IWshShortcut_iface
;
652 static HRESULT WINAPI
WshShell3_QueryInterface(IWshShell3
*iface
, REFIID riid
, void **ppv
)
654 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
658 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
659 IsEqualGUID(riid
, &IID_IDispatch
) ||
660 IsEqualGUID(riid
, &IID_IWshShell3
))
664 else if (IsEqualGUID(riid
, &IID_IDispatchEx
))
666 return E_NOINTERFACE
;
670 FIXME("Unknown iface %s\n", debugstr_guid(riid
));
671 return E_NOINTERFACE
;
674 IWshShell3_AddRef(iface
);
678 static ULONG WINAPI
WshShell3_AddRef(IWshShell3
*iface
)
684 static ULONG WINAPI
WshShell3_Release(IWshShell3
*iface
)
690 static HRESULT WINAPI
WshShell3_GetTypeInfoCount(IWshShell3
*iface
, UINT
*pctinfo
)
692 TRACE("(%p)\n", pctinfo
);
697 static HRESULT WINAPI
WshShell3_GetTypeInfo(IWshShell3
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
699 TRACE("(%u %u %p)\n", iTInfo
, lcid
, ppTInfo
);
700 return get_typeinfo(IWshShell3_tid
, ppTInfo
);
703 static HRESULT WINAPI
WshShell3_GetIDsOfNames(IWshShell3
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
704 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
709 TRACE("(%s %p %u %u %p)\n", debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
711 hr
= get_typeinfo(IWshShell3_tid
, &typeinfo
);
714 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
715 ITypeInfo_Release(typeinfo
);
721 static HRESULT WINAPI
WshShell3_Invoke(IWshShell3
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
722 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
727 TRACE("(%d %s %d %d %p %p %p %p)\n", dispIdMember
, debugstr_guid(riid
),
728 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
730 hr
= get_typeinfo(IWshShell3_tid
, &typeinfo
);
733 hr
= ITypeInfo_Invoke(typeinfo
, &WshShell3
, dispIdMember
, wFlags
,
734 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
735 ITypeInfo_Release(typeinfo
);
741 static HRESULT WINAPI
WshShell3_get_SpecialFolders(IWshShell3
*iface
, IWshCollection
**folders
)
743 TRACE("(%p)\n", folders
);
744 return WshCollection_Create(folders
);
747 static HRESULT WINAPI
WshShell3_get_Environment(IWshShell3
*iface
, VARIANT
*Type
, IWshEnvironment
**out_Env
)
749 FIXME("(%p %p): stub\n", Type
, out_Env
);
753 static HRESULT WINAPI
WshShell3_Run(IWshShell3
*iface
, BSTR cmd
, VARIANT
*style
, VARIANT
*WaitOnReturn
, int *exit_code
)
755 SHELLEXECUTEINFOW info
;
760 TRACE("(%s %s %s %p)\n", debugstr_w(cmd
), debugstr_variant(style
), debugstr_variant(WaitOnReturn
), exit_code
);
763 hr
= VariantChangeType(&s
, style
, 0, VT_I4
);
766 ERR("failed to convert style argument, 0x%08x\n", hr
);
771 hr
= VariantChangeType(&w
, WaitOnReturn
, 0, VT_I4
);
774 ERR("failed to convert wait argument, 0x%08x\n", hr
);
778 memset(&info
, 0, sizeof(info
));
779 info
.cbSize
= sizeof(info
);
781 waitforprocess
= V_I4(&w
);
783 info
.fMask
= waitforprocess
? SEE_MASK_NOASYNC
| SEE_MASK_NOCLOSEPROCESS
: SEE_MASK_DEFAULT
;
785 info
.nShow
= V_I4(&s
);
787 if (!ShellExecuteExW(&info
))
789 TRACE("ShellExecute failed, %d\n", GetLastError());
790 return HRESULT_FROM_WIN32(GetLastError());
799 GetExitCodeProcess(info
.hProcess
, &code
);
802 CloseHandle(info
.hProcess
);
805 if (exit_code
) *exit_code
= 0;
811 static HRESULT WINAPI
WshShell3_Popup(IWshShell3
*iface
, BSTR Text
, VARIANT
* SecondsToWait
, VARIANT
*Title
, VARIANT
*Type
, int *button
)
813 FIXME("(%s %s %s %s %p): stub\n", debugstr_w(Text
), debugstr_variant(SecondsToWait
),
814 debugstr_variant(Title
), debugstr_variant(Type
), button
);
818 static HRESULT WINAPI
WshShell3_CreateShortcut(IWshShell3
*iface
, BSTR PathLink
, IDispatch
** Shortcut
)
820 TRACE("(%s %p)\n", debugstr_w(PathLink
), Shortcut
);
821 return WshShortcut_Create(PathLink
, Shortcut
);
824 static HRESULT WINAPI
WshShell3_ExpandEnvironmentStrings(IWshShell3
*iface
, BSTR Src
, BSTR
* Dst
)
828 TRACE("(%s %p)\n", debugstr_w(Src
), Dst
);
830 if (!Src
|| !Dst
) return E_POINTER
;
832 ret
= ExpandEnvironmentStringsW(Src
, NULL
, 0);
833 *Dst
= SysAllocStringLen(NULL
, ret
);
834 if (!*Dst
) return E_OUTOFMEMORY
;
836 if (ExpandEnvironmentStringsW(Src
, *Dst
, ret
))
842 return HRESULT_FROM_WIN32(GetLastError());
846 static HRESULT WINAPI
WshShell3_RegRead(IWshShell3
*iface
, BSTR Name
, VARIANT
* out_Value
)
848 FIXME("(%s %p): stub\n", debugstr_w(Name
), out_Value
);
852 static HRESULT WINAPI
WshShell3_RegWrite(IWshShell3
*iface
, BSTR Name
, VARIANT
*Value
, VARIANT
*Type
)
854 FIXME("(%s %s %s): stub\n", debugstr_w(Name
), debugstr_variant(Value
), debugstr_variant(Type
));
858 static HRESULT WINAPI
WshShell3_RegDelete(IWshShell3
*iface
, BSTR Name
)
860 FIXME("(%s): stub\n", debugstr_w(Name
));
864 static HRESULT WINAPI
WshShell3_LogEvent(IWshShell3
*iface
, VARIANT
*Type
, BSTR Message
, BSTR Target
, VARIANT_BOOL
*out_Success
)
866 FIXME("(%s %s %s %p): stub\n", debugstr_variant(Type
), debugstr_w(Message
), debugstr_w(Target
), out_Success
);
870 static HRESULT WINAPI
WshShell3_AppActivate(IWshShell3
*iface
, VARIANT
*App
, VARIANT
*Wait
, VARIANT_BOOL
*out_Success
)
872 FIXME("(%s %s %p): stub\n", debugstr_variant(App
), debugstr_variant(Wait
), out_Success
);
876 static HRESULT WINAPI
WshShell3_SendKeys(IWshShell3
*iface
, BSTR Keys
, VARIANT
*Wait
)
878 FIXME("(%s %p): stub\n", debugstr_w(Keys
), Wait
);
882 static const IWshShell3Vtbl WshShell3Vtbl
= {
883 WshShell3_QueryInterface
,
886 WshShell3_GetTypeInfoCount
,
887 WshShell3_GetTypeInfo
,
888 WshShell3_GetIDsOfNames
,
890 WshShell3_get_SpecialFolders
,
891 WshShell3_get_Environment
,
894 WshShell3_CreateShortcut
,
895 WshShell3_ExpandEnvironmentStrings
,
900 WshShell3_AppActivate
,
904 static IWshShell3 WshShell3
= { &WshShell3Vtbl
};
906 HRESULT WINAPI
WshShellFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
908 TRACE("(%p %s %p)\n", outer
, debugstr_guid(riid
), ppv
);
910 return IWshShell3_QueryInterface(&WshShell3
, riid
, ppv
);