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
27 #include "wine/test.h"
29 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
31 #define EXPECT_HR(hr,hr_exp) \
32 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
34 static void test_wshshell(void)
36 static const WCHAR desktopW
[] = {'D','e','s','k','t','o','p',0};
37 static const WCHAR lnk1W
[] = {'f','i','l','e','.','l','n','k',0};
41 IDispatch
*disp
, *shortcut
;
42 IUnknown
*shell
, *unk
;
43 IFolderCollection
*folders
;
53 hr
= CoCreateInstance(&CLSID_WshShell
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
54 &IID_IDispatch
, (void**)&disp
);
56 win_skip("Could not create WshShell object: %08x\n", hr
);
60 hr
= IDispatch_QueryInterface(disp
, &IID_IWshShell3
, (void**)&shell
);
62 IDispatch_Release(disp
);
64 hr
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
65 EXPECT_HR(hr
, E_NOINTERFACE
);
67 hr
= IDispatch_QueryInterface(shell
, &IID_IWshShell3
, (void**)&sh3
);
70 hr
= IWshShell3_get_SpecialFolders(sh3
, &coll
);
73 hr
= IWshCollection_QueryInterface(coll
, &IID_IFolderCollection
, (void**)&folders
);
74 EXPECT_HR(hr
, E_NOINTERFACE
);
76 hr
= IWshCollection_QueryInterface(coll
, &IID_IDispatch
, (void**)&disp
);
79 hr
= IDispatch_GetTypeInfo(disp
, 0, 0, &ti
);
82 hr
= ITypeInfo_GetTypeAttr(ti
, &tattr
);
84 ok(IsEqualIID(&tattr
->guid
, &IID_IWshCollection
), "got wrong type guid\n");
85 ITypeInfo_ReleaseTypeAttr(ti
, tattr
);
87 /* try to call Item() with normal IDispatch procedure */
88 str
= SysAllocString(desktopW
);
92 dp
.rgdispidNamedArgs
= NULL
;
95 hr
= IDispatch_Invoke(disp
, DISPID_VALUE
, &IID_NULL
, 1033, DISPATCH_PROPERTYGET
, &dp
, &res
, &ei
, &err
);
96 EXPECT_HR(hr
, DISP_E_MEMBERNOTFOUND
);
98 /* try Item() directly, it returns directory path apparently */
99 V_VT(&res
) = VT_EMPTY
;
100 hr
= IWshCollection_Item(coll
, &arg
, &res
);
102 ok(V_VT(&res
) == VT_BSTR
, "got res type %d\n", V_VT(&res
));
106 /* CreateShortcut() */
107 str
= SysAllocString(lnk1W
);
108 hr
= IWshShell3_CreateShortcut(sh3
, str
, &shortcut
);
111 hr
= IDispatch_QueryInterface(shortcut
, &IID_IWshShortcut
, (void**)&unk
);
113 IUnknown_Release(unk
);
114 IDispatch_Release(shortcut
);
116 IWshCollection_Release(coll
);
117 IDispatch_Release(disp
);
118 IWshShell3_Release(sh3
);
119 IUnknown_Release(shell
);