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 #define test_provideclassinfo(a, b) _test_provideclassinfo((IDispatch*)a, b, __LINE__)
35 static void _test_provideclassinfo(IDispatch
*disp
, const GUID
*guid
, int line
)
37 IProvideClassInfo
*classinfo
;
42 hr
= IDispatch_QueryInterface(disp
, &IID_IProvideClassInfo
, (void **)&classinfo
);
43 ok_(__FILE__
,line
) (hr
== S_OK
, "Failed to get IProvideClassInfo, %#x.\n", hr
);
45 hr
= IProvideClassInfo_GetClassInfo(classinfo
, &ti
);
46 ok_(__FILE__
,line
) (hr
== S_OK
, "GetClassInfo() failed, %#x.\n", hr
);
48 hr
= ITypeInfo_GetTypeAttr(ti
, &attr
);
49 ok_(__FILE__
,line
) (hr
== S_OK
, "GetTypeAttr() failed, %#x.\n", hr
);
51 ok_(__FILE__
,line
) (IsEqualGUID(&attr
->guid
, guid
), "Unexpected typeinfo %s, expected %s\n", wine_dbgstr_guid(&attr
->guid
),
52 wine_dbgstr_guid(guid
));
54 IProvideClassInfo_Release(classinfo
);
55 ITypeInfo_ReleaseTypeAttr(ti
, attr
);
56 ITypeInfo_Release(ti
);
59 #define CHECK_BSTR_LENGTH(str) check_bstr_length(str, __LINE__)
60 static void check_bstr_length(BSTR str
, int line
)
62 ok_(__FILE__
, line
)(SysStringLen(str
) == lstrlenW(str
), "Unexpected string length %u vs %u.\n",
63 SysStringLen(str
), lstrlenW(str
));
66 static void test_wshshell(void)
68 static const WCHAR emptyW
[] = L
"empty";
69 static const WCHAR cmdexeW
[] = L
"\\cmd.exe";
70 WCHAR path
[MAX_PATH
], path2
[MAX_PATH
], buf
[MAX_PATH
];
76 IDispatch
*disp
, *shortcut
;
77 IUnknown
*shell
, *unk
;
78 IFolderCollection
*folders
;
85 VARIANT arg
, res
, arg2
;
90 hr
= CoCreateInstance(&CLSID_WshShell
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
91 &IID_IDispatch
, (void**)&disp
);
92 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
94 hr
= IDispatch_QueryInterface(disp
, &IID_IWshShell3
, (void**)&shell
);
96 test_provideclassinfo(disp
, &IID_IWshShell3
);
98 hr
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
99 EXPECT_HR(hr
, E_NOINTERFACE
);
100 IDispatch_Release(disp
);
102 hr
= IUnknown_QueryInterface(shell
, &IID_IWshShell3
, (void**)&sh3
);
105 hr
= IWshShell3_QueryInterface(sh3
, &IID_IObjectWithSite
, (void**)&unk
);
106 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
108 hr
= IWshShell3_QueryInterface(sh3
, &IID_IWshShell
, (void**)&unk
);
109 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
110 IUnknown_Release(unk
);
112 hr
= IWshShell3_QueryInterface(sh3
, &IID_IWshShell2
, (void**)&unk
);
113 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
114 IUnknown_Release(unk
);
116 hr
= IWshShell3_get_SpecialFolders(sh3
, &coll
);
118 test_provideclassinfo(coll
, &IID_IWshCollection
);
120 hr
= IWshCollection_QueryInterface(coll
, &IID_IFolderCollection
, (void**)&folders
);
121 EXPECT_HR(hr
, E_NOINTERFACE
);
123 hr
= IWshCollection_QueryInterface(coll
, &IID_IDispatch
, (void**)&disp
);
126 hr
= IDispatch_GetTypeInfo(disp
, 0, 0, &ti
);
129 hr
= ITypeInfo_GetTypeAttr(ti
, &tattr
);
131 ok(IsEqualIID(&tattr
->guid
, &IID_IWshCollection
), "got wrong type guid\n");
132 ITypeInfo_ReleaseTypeAttr(ti
, tattr
);
134 /* try to call Item() with normal IDispatch procedure */
135 str
= SysAllocString(L
"Desktop");
136 V_VT(&arg
) = VT_BSTR
;
139 dp
.rgdispidNamedArgs
= NULL
;
142 hr
= IDispatch_Invoke(disp
, DISPID_VALUE
, &IID_NULL
, 1033, DISPATCH_PROPERTYGET
, &dp
, &res
, &ei
, &err
);
143 EXPECT_HR(hr
, DISP_E_MEMBERNOTFOUND
);
145 /* try Item() directly, it returns directory path apparently */
146 V_VT(&res
) = VT_EMPTY
;
147 hr
= IWshCollection_Item(coll
, &arg
, &res
);
149 ok(V_VT(&res
) == VT_BSTR
, "got res type %d\n", V_VT(&res
));
150 CHECK_BSTR_LENGTH(V_BSTR(&res
));
154 /* CreateShortcut() */
155 str
= SysAllocString(L
"file.lnk");
156 hr
= IWshShell3_CreateShortcut(sh3
, str
, &shortcut
);
159 hr
= IDispatch_QueryInterface(shortcut
, &IID_IWshShortcut
, (void**)&shcut
);
161 test_provideclassinfo(shortcut
, &IID_IWshShortcut
);
163 hr
= IWshShortcut_get_Arguments(shcut
, NULL
);
164 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
166 hr
= IWshShortcut_get_IconLocation(shcut
, NULL
);
167 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
169 IWshShortcut_Release(shcut
);
170 IDispatch_Release(shortcut
);
172 /* ExpandEnvironmentStrings */
173 hr
= IWshShell3_ExpandEnvironmentStrings(sh3
, NULL
, NULL
);
174 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
176 str
= SysAllocString(L
"%PATH%");
177 hr
= IWshShell3_ExpandEnvironmentStrings(sh3
, str
, NULL
);
178 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
181 V_VT(&arg
) = VT_BSTR
;
182 V_BSTR(&arg
) = SysAllocString(L
"SYSTEM");
183 hr
= IWshShell3_get_Environment(sh3
, &arg
, &env
);
184 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
187 hr
= IWshEnvironment_get_Item(env
, NULL
, NULL
);
188 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
189 test_provideclassinfo(env
, &IID_IWshEnvironment
);
192 hr
= IWshEnvironment_get_Item(env
, NULL
, &ret
);
193 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
194 ok(ret
&& !*ret
, "got %p\n", ret
);
197 /* invalid var name */
198 str
= SysAllocString(L
"file.lnk");
199 hr
= IWshEnvironment_get_Item(env
, str
, NULL
);
200 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
203 hr
= IWshEnvironment_get_Item(env
, str
, &ret
);
204 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
205 ok(ret
&& *ret
== 0, "got %s\n", wine_dbgstr_w(ret
));
206 CHECK_BSTR_LENGTH(ret
);
211 str
= SysAllocString(L
"PATH");
212 hr
= IWshEnvironment_get_Item(env
, str
, &ret
);
213 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
214 ok(ret
&& *ret
!= 0, "got %s\n", wine_dbgstr_w(ret
));
215 CHECK_BSTR_LENGTH(ret
);
219 IWshEnvironment_Release(env
);
223 V_VT(&arg2
) = VT_ERROR
;
224 V_ERROR(&arg2
) = DISP_E_PARAMNOTFOUND
;
226 str
= SysAllocString(L
"notepad.exe");
227 hr
= IWshShell3_Run(sh3
, str
, &arg
, &arg2
, NULL
);
228 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
231 hr
= IWshShell3_Run(sh3
, str
, NULL
, &arg2
, &retval
);
232 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
233 ok(retval
== 10, "got %u\n", retval
);
236 hr
= IWshShell3_Run(sh3
, str
, &arg
, NULL
, &retval
);
237 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
238 ok(retval
== 10, "got %u\n", retval
);
241 V_VT(&arg2
) = VT_ERROR
;
243 hr
= IWshShell3_Run(sh3
, str
, &arg
, &arg2
, &retval
);
244 ok(hr
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hr
);
245 ok(retval
== 10, "got %u\n", retval
);
248 V_VT(&arg2
) = VT_BOOL
;
249 V_BOOL(&arg2
) = VARIANT_TRUE
;
252 str
= SysAllocString(L
"cmd.exe /c rd /s /q c:\\nosuchdir");
253 hr
= IWshShell3_Run(sh3
, str
, &arg
, &arg2
, &retval
);
254 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
255 todo_wine
ok(retval
== ERROR_FILE_NOT_FOUND
, "got %u\n", retval
);
259 str
= SysAllocString(L
"\"cmd.exe \" /c rd /s /q c:\\nosuchdir");
260 hr
= IWshShell3_Run(sh3
, str
, &arg
, &arg2
, &retval
);
261 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
262 todo_wine
ok(retval
== ERROR_FILE_NOT_FOUND
, "got %u\n", retval
);
265 GetSystemDirectoryW(path
, ARRAY_SIZE(path
));
266 lstrcatW(path
, cmdexeW
);
267 attrs
= GetFileAttributesW(path
);
268 ok(attrs
!= INVALID_FILE_ATTRIBUTES
, "cmd.exe not found\n");
270 /* copy cmd.exe to a path with spaces */
271 GetTempPathW(ARRAY_SIZE(path2
), path2
);
272 lstrcatW(path2
, L
"wshom test dir");
273 CreateDirectoryW(path2
, NULL
);
274 lstrcatW(path2
, cmdexeW
);
275 CopyFileW(path
, path2
, FALSE
);
278 lstrcpyW(buf
+ 1, path2
);
279 buf
[lstrlenW(buf
)] = '"';
280 lstrcpyW(buf
+ lstrlenW(path2
) + 2, L
" /c rd /s /q c:\\nosuchdir");
283 str
= SysAllocString(buf
);
284 hr
= IWshShell3_Run(sh3
, str
, &arg
, &arg2
, &retval
);
285 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
286 todo_wine
ok(retval
== ERROR_FILE_NOT_FOUND
, "got %u\n", retval
);
290 path2
[lstrlenW(path2
) - lstrlenW(cmdexeW
)] = 0;
291 RemoveDirectoryW(path2
);
293 /* current directory */
294 if (0) /* crashes on native */
295 hr
= IWshShell3_get_CurrentDirectory(sh3
, NULL
);
298 hr
= IWshShell3_get_CurrentDirectory(sh3
, &str
);
299 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
300 ok(str
&& str
[0] != 0, "got empty string\n");
301 CHECK_BSTR_LENGTH(str
);
304 hr
= IWshShell3_put_CurrentDirectory(sh3
, NULL
);
305 ok(hr
== E_INVALIDARG
||
306 broken(hr
== HRESULT_FROM_WIN32(ERROR_NOACCESS
)), "got 0x%08x\n", hr
);
308 str
= SysAllocString(emptyW
);
309 hr
= IWshShell3_put_CurrentDirectory(sh3
, str
);
310 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
313 str
= SysAllocString(L
"deadparrot");
314 hr
= IWshShell3_put_CurrentDirectory(sh3
, str
);
315 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
319 hr
= IWshShell3_Exec(sh3
, NULL
, NULL
);
320 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
322 hr
= IWshShell3_Exec(sh3
, NULL
, &shexec
);
323 ok(hr
== DISP_E_EXCEPTION
, "got 0x%08x\n", hr
);
325 str
= SysAllocString(emptyW
);
326 hr
= IWshShell3_Exec(sh3
, str
, &shexec
);
327 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
330 str
= SysAllocString(L
"%deadbeaf% /c echo test");
331 hr
= IWshShell3_Exec(sh3
, str
, &shexec
);
332 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
335 str
= SysAllocString(L
"%ComSpec% /c echo test");
336 hr
= IWshShell3_Exec(sh3
, str
, &shexec
);
337 ok(hr
== HRESULT_FROM_WIN32(ERROR_SUCCESS
), "got 0x%08x\n", hr
);
340 IWshCollection_Release(coll
);
341 IDispatch_Release(disp
);
342 IWshShell3_Release(sh3
);
343 IUnknown_Release(shell
);
346 /* delete key and all its subkeys */
347 static DWORD
delete_key(HKEY hkey
)
352 while (!(ret
= RegEnumKeyA(hkey
, 0, name
, sizeof(name
)))) {
354 if (!(ret
= RegOpenKeyExA(hkey
, name
, 0, KEY_ENUMERATE_SUB_KEYS
, &tmp
))) {
355 ret
= delete_key(tmp
);
360 if (ret
!= ERROR_NO_MORE_ITEMS
) return ret
;
361 RegDeleteKeyA(hkey
, "");
365 static void test_registry(void)
367 static const WCHAR keypathW
[] = L
"HKEY_CURRENT_USER\\Software\\Wine\\Test\\";
368 static const WCHAR regszW
[] = L
"regsz";
369 WCHAR pathW
[MAX_PATH
];
381 hr
= CoCreateInstance(&CLSID_WshShell
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
382 &IID_IWshShell3
, (void**)&sh3
);
383 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
386 V_VT(&value
) = VT_I2
;
387 hr
= IWshShell3_RegRead(sh3
, NULL
, &value
);
388 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
389 ok(V_VT(&value
) == VT_I2
, "got %d\n", V_VT(&value
));
391 name
= SysAllocString(L
"HKEY_broken_key");
392 hr
= IWshShell3_RegRead(sh3
, name
, NULL
);
393 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
394 V_VT(&value
) = VT_I2
;
395 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
396 ok(hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "got 0x%08x\n", hr
);
397 ok(V_VT(&value
) == VT_I2
, "got %d\n", V_VT(&value
));
400 name
= SysAllocString(L
"HKEY_CURRENT_USERa");
401 V_VT(&value
) = VT_I2
;
402 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
403 ok(hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "got 0x%08x\n", hr
);
404 ok(V_VT(&value
) == VT_I2
, "got %d\n", V_VT(&value
));
407 ret
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &root
);
408 ok(ret
== 0, "got %d\n", ret
);
410 ret
= RegSetValueExA(root
, "regsz", 0, REG_SZ
, (const BYTE
*)"foobar", 7);
411 ok(ret
== 0, "got %d\n", ret
);
413 ret
= RegSetValueExA(root
, "regsz2", 0, REG_SZ
, (const BYTE
*)"foobar\0f", 9);
414 ok(ret
== 0, "got %d\n", ret
);
416 ret
= RegSetValueExA(root
, "regmultisz", 0, REG_MULTI_SZ
, (const BYTE
*)"foo\0bar\0", 9);
417 ok(ret
== 0, "got %d\n", ret
);
420 ret
= RegSetValueExA(root
, "regdword", 0, REG_DWORD
, (const BYTE
*)&dwvalue
, sizeof(dwvalue
));
421 ok(ret
== 0, "got %d\n", ret
);
424 ret
= RegSetValueExA(root
, "regbinary", 0, REG_BINARY
, (const BYTE
*)&dwvalue
, sizeof(dwvalue
));
425 ok(ret
== 0, "got %d\n", ret
);
428 lstrcpyW(pathW
, keypathW
);
429 lstrcatW(pathW
, regszW
);
430 name
= SysAllocString(pathW
);
432 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
433 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
434 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
435 ok(!lstrcmpW(V_BSTR(&value
), L
"foobar"), "got %s\n", wine_dbgstr_w(V_BSTR(&value
)));
436 CHECK_BSTR_LENGTH(V_BSTR(&value
));
437 VariantClear(&value
);
440 /* REG_SZ with embedded NULL */
441 lstrcpyW(pathW
, keypathW
);
442 lstrcatW(pathW
, L
"regsz2");
443 name
= SysAllocString(pathW
);
445 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
446 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
447 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
448 ok(SysStringLen(V_BSTR(&value
)) == 6, "len %d\n", SysStringLen(V_BSTR(&value
)));
449 CHECK_BSTR_LENGTH(V_BSTR(&value
));
450 VariantClear(&value
);
454 lstrcpyW(pathW
, keypathW
);
455 lstrcatW(pathW
, L
"regdword");
456 name
= SysAllocString(pathW
);
458 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
459 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
460 ok(V_VT(&value
) == VT_I4
, "got %d\n", V_VT(&value
));
461 ok(V_I4(&value
) == 10, "got %d\n", V_I4(&value
));
465 lstrcpyW(pathW
, keypathW
);
466 lstrcatW(pathW
, L
"regbinary");
467 name
= SysAllocString(pathW
);
469 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
470 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
471 ok(V_VT(&value
) == (VT_ARRAY
|VT_VARIANT
), "got 0x%x\n", V_VT(&value
));
472 dim
= SafeArrayGetDim(V_ARRAY(&value
));
473 ok(dim
== 1, "got %u\n", dim
);
475 hr
= SafeArrayGetLBound(V_ARRAY(&value
), 1, &bound
);
476 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
477 ok(bound
== 0, "got %u\n", bound
);
479 hr
= SafeArrayGetUBound(V_ARRAY(&value
), 1, &bound
);
480 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
481 ok(bound
== 3, "got %u\n", bound
);
483 hr
= SafeArrayGetVartype(V_ARRAY(&value
), &vartype
);
484 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
485 ok(vartype
== VT_VARIANT
, "got %d\n", vartype
);
488 hr
= SafeArrayGetElement(V_ARRAY(&value
), &bound
, &v
);
489 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
490 ok(V_VT(&v
) == VT_UI1
, "got %d\n", V_VT(&v
));
491 ok(V_UI1(&v
) == 11, "got %u\n", V_UI1(&v
));
493 VariantClear(&value
);
497 lstrcpyW(pathW
, keypathW
);
498 lstrcatW(pathW
, L
"regmultisz");
499 name
= SysAllocString(pathW
);
501 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
502 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
503 ok(V_VT(&value
) == (VT_ARRAY
|VT_VARIANT
), "got 0x%x\n", V_VT(&value
));
506 dim
= SafeArrayGetDim(V_ARRAY(&value
));
507 ok(dim
== 1, "got %u\n", dim
);
509 hr
= SafeArrayGetLBound(V_ARRAY(&value
), 1, &bound
);
510 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
511 ok(bound
== 0, "got %u\n", bound
);
513 hr
= SafeArrayGetUBound(V_ARRAY(&value
), 1, &bound
);
514 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
515 ok(bound
== 1, "got %u\n", bound
);
517 hr
= SafeArrayGetVartype(V_ARRAY(&value
), &vartype
);
518 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
519 ok(vartype
== VT_VARIANT
, "got %d\n", vartype
);
522 hr
= SafeArrayGetElement(V_ARRAY(&value
), &bound
, &v
);
523 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
524 ok(V_VT(&v
) == VT_BSTR
, "got %d\n", V_VT(&v
));
525 ok(!lstrcmpW(V_BSTR(&v
), L
"foo"), "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
526 CHECK_BSTR_LENGTH(V_BSTR(&v
));
528 VariantClear(&value
);
530 name
= SysAllocString(L
"HKEY_CURRENT_USER\\Software\\Wine\\Test\\regsz1");
531 V_VT(&value
) = VT_I2
;
532 hr
= IWshShell3_RegRead(sh3
, name
, &value
);
533 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
534 ok(V_VT(&value
) == VT_I2
, "got %d\n", V_VT(&value
));
535 VariantClear(&value
);
541 ret
= RegCreateKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Test", &root
);
542 ok(ret
== 0, "got %d\n", ret
);
544 hr
= IWshShell3_RegWrite(sh3
, NULL
, NULL
, NULL
);
545 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
547 lstrcpyW(pathW
, keypathW
);
548 lstrcatW(pathW
, regszW
);
549 name
= SysAllocString(pathW
);
551 hr
= IWshShell3_RegWrite(sh3
, name
, NULL
, NULL
);
552 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
555 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, NULL
);
556 ok(hr
== E_POINTER
, "got 0x%08x\n", hr
);
558 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, &value
);
559 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
561 /* type is optional */
563 V_ERROR(&v
) = DISP_E_PARAMNOTFOUND
;
564 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, &v
);
565 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
567 /* default type is REG_SZ */
568 V_VT(&value
) = VT_I4
;
570 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, &v
);
571 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
574 ret
= RegQueryValueExA(root
, "regsz", 0, &type
, NULL
, NULL
);
575 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
576 ok(type
== REG_SZ
, "got %d\n", type
);
578 ret
= RegDeleteValueA(root
, "regsz");
579 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
580 V_VT(&value
) = VT_BSTR
;
581 V_BSTR(&value
) = SysAllocString(regszW
);
582 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, &v
);
583 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
584 VariantClear(&value
);
587 ret
= RegQueryValueExA(root
, "regsz", 0, &type
, NULL
, NULL
);
588 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
589 ok(type
== REG_SZ
, "got %d\n", type
);
591 ret
= RegDeleteValueA(root
, "regsz");
592 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
593 V_VT(&value
) = VT_R4
;
595 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, &v
);
596 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
597 VariantClear(&value
);
600 ret
= RegQueryValueExA(root
, "regsz", 0, &type
, NULL
, NULL
);
601 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
602 ok(type
== REG_SZ
, "got %d\n", type
);
604 ret
= RegDeleteValueA(root
, "regsz");
605 ok(ret
== ERROR_SUCCESS
, "got %d\n", ret
);
606 V_VT(&value
) = VT_R4
;
610 hr
= IWshShell3_RegWrite(sh3
, name
, &value
, &v
);
611 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
612 VariantClear(&value
);
617 IWshShell3_Release(sh3
);
620 static void test_popup(void)
622 VARIANT timeout
, type
, title
, optional
;
628 hr
= CoCreateInstance(&CLSID_WshShell
, NULL
, CLSCTX_INPROC_SERVER
| CLSCTX_INPROC_HANDLER
,
629 &IID_IWshShell
, (void **)&sh
);
630 ok(hr
== S_OK
, "Failed to create WshShell object, hr %#x.\n", hr
);
633 text
= SysAllocString(L
"Text");
635 hr
= IWshShell_Popup(sh
, NULL
, NULL
, NULL
, NULL
, &button
);
636 ok(hr
== E_POINTER
, "Unexpected retval %#x.\n", hr
);
637 ok(button
== 123, "Unexpected button id %d.\n", button
);
639 hr
= IWshShell_Popup(sh
, text
, NULL
, NULL
, NULL
, &button
);
640 ok(hr
== E_POINTER
, "Unexpected retval %#x.\n", hr
);
641 ok(button
== 123, "Unexpected button id %d.\n", button
);
643 V_VT(&optional
) = VT_ERROR
;
644 V_ERROR(&optional
) = DISP_E_PARAMNOTFOUND
;
646 V_VT(&timeout
) = VT_I2
;
652 V_VT(&title
) = VT_BSTR
;
653 V_BSTR(&title
) = NULL
;
655 hr
= IWshShell_Popup(sh
, text
, &timeout
, &optional
, &type
, &button
);
656 ok(hr
== S_OK
, "Unexpected retval %#x.\n", hr
);
657 ok(button
== -1, "Unexpected button id %d.\n", button
);
659 hr
= IWshShell_Popup(sh
, text
, &timeout
, &title
, &optional
, &button
);
660 ok(hr
== S_OK
, "Unexpected retval %#x.\n", hr
);
661 ok(button
== -1, "Unexpected button id %d.\n", button
);
664 IWshShell_Release(sh
);
674 hr
= CoCreateInstance(&CLSID_WshShell
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
675 &IID_IUnknown
, (void**)&unk
);
677 win_skip("Could not create WshShell object: %08x\n", hr
);
680 IUnknown_Release(unk
);