advapi32: Add tests for kernel objects accessed with 0 and ACCESS_SYSTEM_SECURITY.
[wine/multimedia.git] / dlls / wshom.ocx / tests / wshom.c
blobc70696c66dd2cc30db794ec6a7d6ffd566e1cf03
1 /*
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 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <initguid.h>
23 #include <ole2.h>
24 #include <dispex.h>
26 #include "wshom.h"
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};
38 IWshShell3 *sh3;
39 IDispatchEx *dispex;
40 IWshCollection *coll;
41 IDispatch *disp, *shortcut;
42 IUnknown *shell, *unk;
43 IFolderCollection *folders;
44 ITypeInfo *ti;
45 HRESULT hr;
46 TYPEATTR *tattr;
47 DISPPARAMS dp;
48 EXCEPINFO ei;
49 VARIANT arg, res;
50 BSTR str;
51 UINT err;
53 hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
54 &IID_IDispatch, (void**)&disp);
55 if(FAILED(hr)) {
56 win_skip("Could not create WshShell object: %08x\n", hr);
57 return;
60 hr = IDispatch_QueryInterface(disp, &IID_IWshShell3, (void**)&shell);
61 EXPECT_HR(hr, S_OK);
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);
68 EXPECT_HR(hr, S_OK);
70 hr = IWshShell3_get_SpecialFolders(sh3, &coll);
71 EXPECT_HR(hr, S_OK);
73 hr = IWshCollection_QueryInterface(coll, &IID_IFolderCollection, (void**)&folders);
74 EXPECT_HR(hr, E_NOINTERFACE);
76 hr = IWshCollection_QueryInterface(coll, &IID_IDispatch, (void**)&disp);
77 EXPECT_HR(hr, S_OK);
79 hr = IDispatch_GetTypeInfo(disp, 0, 0, &ti);
80 EXPECT_HR(hr, S_OK);
82 hr = ITypeInfo_GetTypeAttr(ti, &tattr);
83 EXPECT_HR(hr, S_OK);
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);
89 V_VT(&arg) = VT_BSTR;
90 V_BSTR(&arg) = str;
91 dp.rgvarg = &arg;
92 dp.rgdispidNamedArgs = NULL;
93 dp.cArgs = 1;
94 dp.cNamedArgs = 0;
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);
101 EXPECT_HR(hr, S_OK);
102 ok(V_VT(&res) == VT_BSTR, "got res type %d\n", V_VT(&res));
103 SysFreeString(str);
104 VariantClear(&res);
106 /* CreateShortcut() */
107 str = SysAllocString(lnk1W);
108 hr = IWshShell3_CreateShortcut(sh3, str, &shortcut);
109 EXPECT_HR(hr, S_OK);
110 SysFreeString(str);
111 hr = IDispatch_QueryInterface(shortcut, &IID_IWshShortcut, (void**)&unk);
112 EXPECT_HR(hr, S_OK);
113 IUnknown_Release(unk);
114 IDispatch_Release(shortcut);
116 IWshCollection_Release(coll);
117 IDispatch_Release(disp);
118 IWshShell3_Release(sh3);
119 IUnknown_Release(shell);
122 START_TEST(wshom)
124 CoInitialize(NULL);
126 test_wshshell();
128 CoUninitialize();