2 * Tests for MSI Source functions
4 * Copyright (C) 2006 James Hawkins
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
21 #define _WIN32_MSI 300
31 #include "wine/test.h"
33 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
34 static UINT (WINAPI
*pMsiSourceListAddMediaDiskA
)
35 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, DWORD
, LPCSTR
, LPCSTR
);
36 static UINT (WINAPI
*pMsiSourceListAddSourceExA
)
37 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, LPCSTR
, DWORD
);
38 static UINT (WINAPI
*pMsiSourceListEnumMediaDisksA
)
39 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, DWORD
, LPDWORD
, LPSTR
,
40 LPDWORD
, LPSTR
, LPDWORD
);
41 static UINT (WINAPI
*pMsiSourceListEnumSourcesA
)
42 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, DWORD
, LPSTR
, LPDWORD
);
43 static UINT (WINAPI
*pMsiSourceListGetInfoA
)
44 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, LPCSTR
, LPSTR
, LPDWORD
);
45 static UINT (WINAPI
*pMsiSourceListSetInfoA
)
46 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
,LPCSTR
, LPCSTR
);
47 static UINT (WINAPI
*pMsiSourceListAddSourceA
)
48 (LPCSTR
, LPCSTR
, DWORD
, LPCSTR
);
50 static void init_functionpointers(void)
52 HMODULE hmsi
= GetModuleHandleA("msi.dll");
53 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
55 #define GET_PROC(dll, func) \
56 p ## func = (void *)GetProcAddress(dll, #func); \
58 trace("GetProcAddress(%s) failed\n", #func);
60 GET_PROC(hmsi
, MsiSourceListAddMediaDiskA
)
61 GET_PROC(hmsi
, MsiSourceListAddSourceExA
)
62 GET_PROC(hmsi
, MsiSourceListEnumMediaDisksA
)
63 GET_PROC(hmsi
, MsiSourceListEnumSourcesA
)
64 GET_PROC(hmsi
, MsiSourceListGetInfoA
)
65 GET_PROC(hmsi
, MsiSourceListSetInfoA
)
66 GET_PROC(hmsi
, MsiSourceListAddSourceA
)
68 GET_PROC(hadvapi32
, ConvertSidToStringSidA
)
73 /* copied from dlls/msi/registry.c */
74 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
79 if (FAILED(CLSIDFromString((LPOLESTR
)in
, &guid
)))
93 out
[17+i
*2] = in
[n
++];
94 out
[16+i
*2] = in
[n
++];
99 out
[17+i
*2] = in
[n
++];
100 out
[16+i
*2] = in
[n
++];
106 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
108 WCHAR guidW
[MAX_PATH
];
109 WCHAR squashedW
[MAX_PATH
];
114 hr
= CoCreateGuid(&guid
);
115 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
117 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
118 ok(size
== 39, "Expected 39, got %d\n", hr
);
120 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
121 squash_guid(guidW
, squashedW
);
122 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
125 static int get_user_sid(LPSTR
*usersid
)
133 if (!pConvertSidToStringSidA
)
135 rc
=OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
136 if (!rc
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
139 GetTokenInformation(token
, TokenUser
, buf
, size
, &size
);
140 user
= (PTOKEN_USER
)buf
;
141 pConvertSidToStringSidA(user
->User
.Sid
, usersid
);
146 static void check_reg_str(HKEY prodkey
, LPCSTR name
, LPCSTR expected
, BOOL bcase
, DWORD line
)
154 res
= RegQueryValueExA(prodkey
, name
, NULL
, &type
, (LPBYTE
)val
, &size
);
156 if (res
!= ERROR_SUCCESS
|| (type
!= REG_SZ
&& type
!= REG_EXPAND_SZ
))
158 ok_(__FILE__
, line
)(FALSE
, "Key doesn't exist or wrong type\n");
163 ok_(__FILE__
, line
)(lstrlenA(val
) == 0, "Expected empty string, got %s\n", val
);
167 ok_(__FILE__
, line
)(!lstrcmpA(val
, expected
), "Expected %s, got %s\n", expected
, val
);
169 ok_(__FILE__
, line
)(!lstrcmpiA(val
, expected
), "Expected %s, got %s\n", expected
, val
);
173 #define CHECK_REG_STR(prodkey, name, expected) \
174 check_reg_str(prodkey, name, expected, TRUE, __LINE__);
176 static void test_MsiSourceListGetInfo(void)
178 CHAR prodcode
[MAX_PATH
];
179 CHAR prod_squashed
[MAX_PATH
];
180 CHAR keypath
[MAX_PATH
*2];
181 CHAR value
[MAX_PATH
];
186 HKEY userkey
, hkey
, media
;
189 if (!pMsiSourceListGetInfoA
)
191 skip("Skipping MsiSourceListGetInfoA tests\n");
195 create_test_guid(prodcode
, prod_squashed
);
196 if (!get_user_sid(&usersid
))
198 skip("User SID not available -> skipping MsiSourceListGetInfoA tests\n");
202 /* NULL szProductCodeOrPatchCode */
203 r
= pMsiSourceListGetInfoA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
204 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
205 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
207 /* empty szProductCodeOrPatchCode */
208 r
= pMsiSourceListGetInfoA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
209 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
210 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
212 /* garbage szProductCodeOrPatchCode */
213 r
= pMsiSourceListGetInfoA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
214 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
215 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
217 /* szProductCodeOrPatchCode */
218 r
= pMsiSourceListGetInfoA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
219 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
220 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
222 /* guid without brackets */
223 r
= pMsiSourceListGetInfoA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
224 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
225 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
227 /* guid with brackets */
228 r
= pMsiSourceListGetInfoA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
229 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
230 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
232 /* same length as guid, but random */
233 r
= pMsiSourceListGetInfoA("ADKD-2KSDFF2-DKK1KNFJASD9GLKWME-1I3KAD", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
234 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
235 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
237 /* invalid context */
238 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_NONE
,
239 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
240 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
242 /* another invalid context */
243 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_ALLUSERMANAGED
,
244 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
245 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
247 /* yet another invalid context */
248 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_ALL
,
249 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
250 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
252 /* mix two valid contexts */
253 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
| MSIINSTALLCONTEXT_USERUNMANAGED
,
254 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
255 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
258 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
259 4, INSTALLPROPERTY_PACKAGENAME
, NULL
, NULL
);
260 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
263 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
264 MSICODE_PRODUCT
, NULL
, NULL
, NULL
);
265 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
268 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
269 MSICODE_PRODUCT
, "", NULL
, NULL
);
270 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
272 /* value is non-NULL while size is NULL */
273 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
274 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, value
, NULL
);
275 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
277 /* size is non-NULL while value is NULL */
279 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
280 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, &size
);
281 ok(r
== ERROR_UNKNOWN_PRODUCT
|| ERROR_INVALID_PARAMETER
,
282 "Expected ERROR_UNKNOWN_PRODUCT or ERROR_INVALID_PARAMETER, got %d\n", r
);
284 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
285 lstrcatA(keypath
, prod_squashed
);
287 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
288 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
290 /* user product key exists */
292 lstrcpyA(value
, "aaa");
293 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
294 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
295 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
296 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got \"%s\"\n", value
);
298 res
= RegCreateKeyA(userkey
, "SourceList", &hkey
);
299 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
301 /* SourceList key exists */
303 lstrcpyA(value
, "aaa");
304 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
305 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
307 ok(size
== 0, "Expected 0, got %d\n", size
);
308 ok(!lstrcmpA(value
, ""), "Expected \"\", got \"%s\"\n", value
);
310 data
= "msitest.msi";
311 res
= RegSetValueExA(hkey
, "PackageName", 0, REG_SZ
, (const BYTE
*)data
, lstrlenA(data
) + 1);
312 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
314 /* PackageName value exists */
316 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
317 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, NULL
, &size
);
318 ok(r
== ERROR_SUCCESS
|| r
== ERROR_INVALID_PARAMETER
,
319 "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r
);
320 ok(size
== 11 || r
!= ERROR_SUCCESS
, "Expected 11, got %d\n", size
);
322 /* read the value, don't change size */
324 lstrcpyA(value
, "aaa");
325 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
326 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
327 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
328 ok(!lstrcmpA(value
, "aaa"), "Expected 'aaa', got %s\n", value
);
329 ok(size
== 11, "Expected 11, got %d\n", size
);
331 /* read the value, fix size */
333 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
334 MSICODE_PRODUCT
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
335 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
336 ok(!lstrcmpA(value
, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value
);
337 ok(size
== 11, "Expected 11, got %d\n", size
);
339 /* empty property now that product key exists */
341 lstrcpyA(value
, "aaa");
342 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
343 MSICODE_PRODUCT
, "", value
, &size
);
344 ok(r
== ERROR_UNKNOWN_PROPERTY
, "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
345 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
346 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got \"%s\"\n", value
);
348 /* nonexistent property now that product key exists */
350 lstrcpyA(value
, "aaa");
351 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
352 MSICODE_PRODUCT
, "nonexistent", value
, &size
);
353 ok(r
== ERROR_UNKNOWN_PROPERTY
, "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
354 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
355 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got \"%s\"\n", value
);
358 res
= RegSetValueExA(hkey
, "nonexistent", 0, REG_SZ
, (const BYTE
*)data
, lstrlenA(data
) + 1);
359 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
361 /* nonexistent property now that nonexistent value exists */
363 lstrcpyA(value
, "aaa");
364 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
365 MSICODE_PRODUCT
, "nonexistent", value
, &size
);
366 ok(r
== ERROR_UNKNOWN_PROPERTY
, "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
367 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
368 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got \"%s\"\n", value
);
370 /* invalid option now that product key exists */
372 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
373 4, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
374 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
375 ok(size
== 11, "Expected 11, got %d\n", size
);
377 /* INSTALLPROPERTY_MEDIAPACKAGEPATH, media key does not exist */
379 lstrcpyA(value
, "aaa");
380 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
381 MSICODE_PRODUCT
, INSTALLPROPERTY_MEDIAPACKAGEPATH
,
383 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
384 ok(!lstrcmpA(value
, ""), "Expected \"\", got \"%s\"\n", value
);
385 ok(size
== 0, "Expected 0, got %d\n", size
);
387 res
= RegCreateKeyA(hkey
, "Media", &media
);
388 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
391 res
= RegSetValueExA(media
, "MediaPackage", 0, REG_SZ
,
392 (const BYTE
*)data
, lstrlenA(data
) + 1);
393 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
395 /* INSTALLPROPERTY_MEDIAPACKAGEPATH */
397 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
398 MSICODE_PRODUCT
, INSTALLPROPERTY_MEDIAPACKAGEPATH
,
400 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
401 ok(!lstrcmpA(value
, "path"), "Expected \"path\", got \"%s\"\n", value
);
402 ok(size
== 4, "Expected 4, got %d\n", size
);
404 /* INSTALLPROPERTY_DISKPROMPT */
406 res
= RegSetValueExA(media
, "DiskPrompt", 0, REG_SZ
,
407 (const BYTE
*)data
, lstrlenA(data
) + 1);
408 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
411 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
412 MSICODE_PRODUCT
, INSTALLPROPERTY_DISKPROMPT
,
414 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
415 ok(!lstrcmpA(value
, "prompt"), "Expected \"prompt\", got \"%s\"\n", value
);
416 ok(size
== 6, "Expected 6, got %d\n", size
);
419 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
420 (const BYTE
*)data
, lstrlenA(data
) + 1);
421 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
423 /* INSTALLPROPERTY_LASTUSEDSOURCE, source is empty */
425 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
426 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
,
428 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
429 ok(!lstrcmpA(value
, ""), "Expected \"\", got \"%s\"\n", value
);
430 ok(size
== 0, "Expected 0, got %d\n", size
);
433 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
434 (const BYTE
*)data
, lstrlenA(data
) + 1);
435 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
437 /* INSTALLPROPERTY_LASTUSEDSOURCE */
439 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
440 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
,
442 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
443 ok(!lstrcmpA(value
, "source"), "Expected \"source\", got \"%s\"\n", value
);
444 ok(size
== 6, "Expected 6, got %d\n", size
);
446 /* INSTALLPROPERTY_LASTUSEDSOURCE, size is too short */
448 lstrcpyA(value
, "aaa");
449 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
450 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
,
452 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
453 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got \"%s\"\n", value
);
454 ok(size
== 6, "Expected 6, got %d\n", size
);
456 /* INSTALLPROPERTY_LASTUSEDSOURCE, size is exactly 6 */
458 lstrcpyA(value
, "aaa");
459 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
460 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
,
462 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
463 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got \"%s\"\n", value
);
464 ok(size
== 6, "Expected 6, got %d\n", size
);
467 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
468 (const BYTE
*)data
, lstrlenA(data
) + 1);
469 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
471 /* INSTALLPROPERTY_LASTUSEDSOURCE, one semi-colon */
473 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
474 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
,
476 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
477 ok(!lstrcmpA(value
, "source"), "Expected \"source\", got \"%s\"\n", value
);
478 ok(size
== 6, "Expected 6, got %d\n", size
);
481 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
482 (const BYTE
*)data
, lstrlenA(data
) + 1);
483 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
485 /* INSTALLPROPERTY_LASTUSEDSOURCE, one colon */
487 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
488 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
,
490 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
491 ok(!lstrcmpA(value
, "a:source"), "Expected \"a:source\", got \"%s\"\n", value
);
492 ok(size
== 8, "Expected 8, got %d\n", size
);
494 /* INSTALLPROPERTY_LASTUSEDTYPE, invalid source format */
496 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
497 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDTYPE
,
499 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
500 ok(!lstrcmpA(value
, ""), "Expected \"\", got \"%s\"\n", value
);
501 ok(size
== 0, "Expected 0, got %d\n", size
);
504 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
505 (const BYTE
*)data
, lstrlenA(data
) + 1);
506 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
508 /* INSTALLPROPERTY_LASTUSEDTYPE, invalid source format */
510 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
511 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDTYPE
,
513 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
514 ok(!lstrcmpA(value
, ""), "Expected \"\", got \"%s\"\n", value
);
515 ok(size
== 0, "Expected 0, got %d\n", size
);
518 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
519 (const BYTE
*)data
, lstrlenA(data
) + 1);
520 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
522 /* INSTALLPROPERTY_LASTUSEDTYPE */
524 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
525 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDTYPE
,
527 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
528 ok(!lstrcmpA(value
, "n"), "Expected \"n\", got \"%s\"\n", value
);
529 ok(size
== 1, "Expected 1, got %d\n", size
);
532 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
533 (const BYTE
*)data
, lstrlenA(data
) + 1);
534 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
536 /* INSTALLPROPERTY_LASTUSEDTYPE */
538 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
539 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDTYPE
,
541 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
542 ok(!lstrcmpA(value
, "n"), "Expected \"n\", got \"%s\"\n", value
);
543 ok(size
== 1, "Expected 1, got %d\n", size
);
546 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
547 (const BYTE
*)data
, lstrlenA(data
) + 1);
548 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
550 /* INSTALLPROPERTY_LASTUSEDTYPE */
552 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
553 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDTYPE
,
555 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
556 ok(!lstrcmpA(value
, "m"), "Expected \"m\", got \"%s\"\n", value
);
557 ok(size
== 1, "Expected 1, got %d\n", size
);
560 res
= RegSetValueExA(hkey
, "LastUsedSource", 0, REG_SZ
,
561 (const BYTE
*)data
, lstrlenA(data
) + 1);
562 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
564 /* INSTALLPROPERTY_LASTUSEDTYPE */
566 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
567 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDTYPE
,
569 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
570 ok(!lstrcmpA(value
, "u"), "Expected \"u\", got \"%s\"\n", value
);
571 ok(size
== 1, "Expected 1, got %d\n", size
);
573 RegDeleteValueA(media
, "MediaPackage");
574 RegDeleteValueA(media
, "DiskPrompt");
575 RegDeleteKeyA(media
, "");
576 RegDeleteValueA(hkey
, "LastUsedSource");
577 RegDeleteValueA(hkey
, "nonexistent");
578 RegDeleteValueA(hkey
, "PackageName");
579 RegDeleteKeyA(hkey
, "");
580 RegDeleteKeyA(userkey
, "");
582 RegCloseKey(userkey
);
586 lstrcpyA(value
, "aaa");
587 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
588 MSICODE_PATCH
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
589 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
590 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
591 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got \"%s\"\n", value
);
593 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Patches\\");
594 lstrcatA(keypath
, prod_squashed
);
596 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
597 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
600 * NOTE: using prodcode guid, but it really doesn't matter
603 lstrcpyA(value
, "aaa");
604 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
605 MSICODE_PATCH
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
606 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
607 ok(size
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, size
);
608 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got \"%s\"\n", value
);
610 res
= RegCreateKeyA(userkey
, "SourceList", &hkey
);
611 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
613 /* SourceList key exists */
615 lstrcpyA(value
, "aaa");
616 r
= pMsiSourceListGetInfoA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
617 MSICODE_PATCH
, INSTALLPROPERTY_PACKAGENAME
, value
, &size
);
618 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
619 ok(!lstrcmpA(value
, ""), "Expected \"\", got \"%s\"\n", value
);
620 ok(size
== 0, "Expected 0, got %d\n", size
);
622 RegDeleteKeyA(hkey
, "");
623 RegDeleteKeyA(userkey
, "");
625 RegCloseKey(userkey
);
628 static void test_MsiSourceListAddSourceEx(void)
630 CHAR prodcode
[MAX_PATH
];
631 CHAR prod_squashed
[MAX_PATH
];
632 CHAR keypath
[MAX_PATH
*2];
633 CHAR value
[MAX_PATH
];
637 HKEY prodkey
, userkey
, hkey
;
641 if (!pMsiSourceListAddSourceExA
)
643 skip("Skipping MsiSourceListAddSourceExA tests\n");
647 create_test_guid(prodcode
, prod_squashed
);
648 if (!get_user_sid(&usersid
))
650 skip("User SID not available -> skipping MsiSourceListAddSourceExA tests\n");
654 /* GetLastError is not set by the function */
656 /* NULL szProductCodeOrPatchCode */
657 r
= pMsiSourceListAddSourceExA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
658 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
659 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
661 /* empty szProductCodeOrPatchCode */
662 r
= pMsiSourceListAddSourceExA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
663 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
664 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
666 /* garbage szProductCodeOrPatchCode */
667 r
= pMsiSourceListAddSourceExA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
668 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
669 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
671 /* guid without brackets */
672 r
= pMsiSourceListAddSourceExA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", usersid
,
673 MSIINSTALLCONTEXT_USERUNMANAGED
,
674 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
675 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
677 /* guid with brackets */
678 r
= pMsiSourceListAddSourceExA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}", usersid
,
679 MSIINSTALLCONTEXT_USERUNMANAGED
,
680 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
681 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
683 /* MSIINSTALLCONTEXT_USERUNMANAGED */
685 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
686 MSIINSTALLCONTEXT_USERUNMANAGED
,
687 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
688 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
690 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
691 lstrcatA(keypath
, prod_squashed
);
693 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
694 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
696 /* user product key exists */
697 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
698 MSIINSTALLCONTEXT_USERUNMANAGED
,
699 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
700 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
702 res
= RegCreateKeyA(userkey
, "SourceList", &url
);
703 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
706 /* SourceList key exists */
707 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
708 MSIINSTALLCONTEXT_USERUNMANAGED
,
709 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
710 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
712 res
= RegOpenKeyA(userkey
, "SourceList\\URL", &url
);
713 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
716 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
717 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
718 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
719 ok(size
== 11, "Expected 11, got %d\n", size
);
721 /* add another source, index 0 */
722 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
723 MSIINSTALLCONTEXT_USERUNMANAGED
,
724 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "another", 0);
725 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
728 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
729 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
730 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
731 ok(size
== 11, "Expected 11, got %d\n", size
);
734 res
= RegQueryValueExA(url
, "2", NULL
, NULL
, (LPBYTE
)value
, &size
);
735 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
736 ok(!lstrcmpA(value
, "another/"), "Expected 'another/', got %s\n", value
);
737 ok(size
== 9, "Expected 9, got %d\n", size
);
739 /* add another source, index 1 */
740 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
741 MSIINSTALLCONTEXT_USERUNMANAGED
,
742 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "third/", 1);
743 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
746 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
747 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
748 ok(!lstrcmpA(value
, "third/"), "Expected 'third/', got %s\n", value
);
749 ok(size
== 7, "Expected 7, got %d\n", size
);
752 res
= RegQueryValueExA(url
, "2", NULL
, NULL
, (LPBYTE
)value
, &size
);
753 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
754 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
755 ok(size
== 11, "Expected 11, got %d\n", size
);
758 res
= RegQueryValueExA(url
, "3", NULL
, NULL
, (LPBYTE
)value
, &size
);
759 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
760 ok(!lstrcmpA(value
, "another/"), "Expected 'another/', got %s\n", value
);
761 ok(size
== 9, "Expected 9, got %d\n", size
);
763 /* add another source, index > N */
764 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
765 MSIINSTALLCONTEXT_USERUNMANAGED
,
766 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "last/", 5);
767 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
770 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
771 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
772 ok(!lstrcmpA(value
, "third/"), "Expected 'third/', got %s\n", value
);
773 ok(size
== 7, "Expected 7, got %d\n", size
);
776 res
= RegQueryValueExA(url
, "2", NULL
, NULL
, (LPBYTE
)value
, &size
);
777 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
778 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
779 ok(size
== 11, "Expected 11, got %d\n", size
);
782 res
= RegQueryValueExA(url
, "3", NULL
, NULL
, (LPBYTE
)value
, &size
);
783 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
784 ok(!lstrcmpA(value
, "another/"), "Expected 'another/', got %s\n", value
);
785 ok(size
== 9, "Expected 9, got %d\n", size
);
788 res
= RegQueryValueExA(url
, "4", NULL
, NULL
, (LPBYTE
)value
, &size
);
789 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
790 ok(!lstrcmpA(value
, "last/"), "Expected 'last/', got %s\n", value
);
791 ok(size
== 6, "Expected 6, got %d\n", size
);
793 /* just MSISOURCETYPE_NETWORK */
794 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
795 MSIINSTALLCONTEXT_USERUNMANAGED
,
796 MSISOURCETYPE_NETWORK
, "source", 0);
797 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
799 res
= RegOpenKeyA(userkey
, "SourceList\\Net", &net
);
800 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
803 res
= RegQueryValueExA(net
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
804 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
805 ok(!lstrcmpA(value
, "source\\"), "Expected 'source\\', got %s\n", value
);
806 ok(size
== 8, "Expected 8, got %d\n", size
);
808 /* just MSISOURCETYPE_URL */
809 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
810 MSIINSTALLCONTEXT_USERUNMANAGED
,
811 MSISOURCETYPE_URL
, "source", 0);
812 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
815 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
816 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
817 ok(!lstrcmpA(value
, "third/"), "Expected 'third/', got %s\n", value
);
818 ok(size
== 7, "Expected 7, got %d\n", size
);
821 res
= RegQueryValueExA(url
, "2", NULL
, NULL
, (LPBYTE
)value
, &size
);
822 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
823 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
824 ok(size
== 11, "Expected 11, got %d\n", size
);
827 res
= RegQueryValueExA(url
, "3", NULL
, NULL
, (LPBYTE
)value
, &size
);
828 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
829 ok(!lstrcmpA(value
, "another/"), "Expected 'another/', got %s\n", value
);
830 ok(size
== 9, "Expected 9, got %d\n", size
);
833 res
= RegQueryValueExA(url
, "4", NULL
, NULL
, (LPBYTE
)value
, &size
);
834 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
835 ok(!lstrcmpA(value
, "last/"), "Expected 'last/', got %s\n", value
);
836 ok(size
== 6, "Expected 6, got %d\n", size
);
839 res
= RegQueryValueExA(url
, "5", NULL
, NULL
, (LPBYTE
)value
, &size
);
840 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
841 ok(!lstrcmpA(value
, "source/"), "Expected 'source/', got %s\n", value
);
842 ok(size
== 8, "Expected 8, got %d\n", size
);
845 r
= pMsiSourceListAddSourceExA(prodcode
, NULL
,
846 MSIINSTALLCONTEXT_USERUNMANAGED
,
847 MSISOURCETYPE_NETWORK
, "nousersid", 0);
848 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
851 res
= RegQueryValueExA(net
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
852 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
853 ok(!lstrcmpA(value
, "source\\"), "Expected 'source\\', got %s\n", value
);
854 ok(size
== 8, "Expected 8, got %d\n", size
);
857 res
= RegQueryValueExA(net
, "2", NULL
, NULL
, (LPBYTE
)value
, &size
);
858 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
859 ok(!lstrcmpA(value
, "nousersid\\"), "Expected 'nousersid\\', got %s\n", value
);
860 ok(size
== 11, "Expected 11, got %d\n", size
);
862 /* invalid options, must have source type */
863 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
864 MSIINSTALLCONTEXT_USERUNMANAGED
,
865 MSICODE_PRODUCT
, "source", 0);
866 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
868 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
869 MSIINSTALLCONTEXT_USERUNMANAGED
,
870 MSICODE_PATCH
, "source", 0);
871 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
874 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
875 MSIINSTALLCONTEXT_USERUNMANAGED
,
876 MSISOURCETYPE_URL
, NULL
, 1);
877 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
880 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
881 MSIINSTALLCONTEXT_USERUNMANAGED
,
882 MSISOURCETYPE_URL
, "", 1);
883 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
885 /* MSIINSTALLCONTEXT_USERMANAGED, non-NULL szUserSid */
887 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
888 MSIINSTALLCONTEXT_USERMANAGED
,
889 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
890 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
892 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
893 lstrcatA(keypath
, usersid
);
894 lstrcatA(keypath
, "\\Installer\\Products\\");
895 lstrcatA(keypath
, prod_squashed
);
897 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
898 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
900 /* product key exists */
901 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
902 MSIINSTALLCONTEXT_USERMANAGED
,
903 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
904 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
906 res
= RegCreateKeyA(prodkey
, "SourceList", &hkey
);
907 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
910 /* SourceList exists */
911 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
912 MSIINSTALLCONTEXT_USERMANAGED
,
913 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
914 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
916 res
= RegOpenKeyA(prodkey
, "SourceList\\URL", &url
);
917 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
920 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
921 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
922 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
923 ok(size
== 11, "Expected 11, got %d\n", size
);
927 /* MSIINSTALLCONTEXT_USERMANAGED, NULL szUserSid */
929 r
= pMsiSourceListAddSourceExA(prodcode
, NULL
,
930 MSIINSTALLCONTEXT_USERMANAGED
,
931 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "another", 0);
932 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
934 res
= RegOpenKeyA(prodkey
, "SourceList\\URL", &url
);
935 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
938 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
939 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
940 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
941 ok(size
== 11, "Expected 11, got %d\n", size
);
944 res
= RegQueryValueExA(url
, "2", NULL
, NULL
, (LPBYTE
)value
, &size
);
945 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
946 ok(!lstrcmpA(value
, "another/"), "Expected 'another/', got %s\n", value
);
947 ok(size
== 9, "Expected 9, got %d\n", size
);
950 RegCloseKey(prodkey
);
952 /* MSIINSTALLCONTEXT_MACHINE */
954 /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
955 r
= pMsiSourceListAddSourceExA(prodcode
, usersid
,
956 MSIINSTALLCONTEXT_MACHINE
,
957 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
958 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
960 r
= pMsiSourceListAddSourceExA(prodcode
, NULL
,
961 MSIINSTALLCONTEXT_MACHINE
,
962 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
963 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
965 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
966 lstrcatA(keypath
, prod_squashed
);
968 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
969 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
971 /* product key exists */
972 r
= pMsiSourceListAddSourceExA(prodcode
, NULL
,
973 MSIINSTALLCONTEXT_MACHINE
,
974 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
975 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
977 res
= RegCreateKeyA(prodkey
, "SourceList", &hkey
);
978 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
981 /* SourceList exists */
982 r
= pMsiSourceListAddSourceExA(prodcode
, NULL
,
983 MSIINSTALLCONTEXT_MACHINE
,
984 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, "C:\\source", 0);
985 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
987 res
= RegOpenKeyA(prodkey
, "SourceList\\URL", &url
);
988 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
991 res
= RegQueryValueExA(url
, "1", NULL
, NULL
, (LPBYTE
)value
, &size
);
992 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
993 ok(!lstrcmpA(value
, "C:\\source/"), "Expected 'C:\\source/', got %s\n", value
);
994 ok(size
== 11, "Expected 11, got %d\n", size
);
997 RegCloseKey(prodkey
);
998 HeapFree(GetProcessHeap(), 0, usersid
);
1001 static void test_MsiSourceListEnumSources(void)
1003 CHAR prodcode
[MAX_PATH
];
1004 CHAR prod_squashed
[MAX_PATH
];
1005 CHAR keypath
[MAX_PATH
*2];
1006 CHAR value
[MAX_PATH
];
1010 HKEY prodkey
, userkey
;
1011 HKEY url
, net
, source
;
1014 if (!pMsiSourceListEnumSourcesA
)
1016 skip("MsiSourceListEnumSourcesA is not available\n");
1020 create_test_guid(prodcode
, prod_squashed
);
1021 if (!get_user_sid(&usersid
))
1023 skip("User SID not available -> skipping MsiSourceListEnumSourcesA tests\n");
1027 /* GetLastError is not set by the function */
1029 /* NULL szProductCodeOrPatchCode */
1031 r
= pMsiSourceListEnumSourcesA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1032 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1033 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1034 ok(size
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size
);
1036 /* empty szProductCodeOrPatchCode */
1038 r
= pMsiSourceListEnumSourcesA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1039 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1040 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1041 ok(size
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size
);
1043 /* garbage szProductCodeOrPatchCode */
1045 r
= pMsiSourceListEnumSourcesA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1046 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1047 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1048 ok(size
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size
);
1050 /* guid without brackets */
1052 r
= pMsiSourceListEnumSourcesA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
1053 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1054 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1055 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1056 ok(size
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size
);
1058 /* guid with brackets */
1060 r
= pMsiSourceListEnumSourcesA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
1061 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1062 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1063 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1064 ok(size
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size
);
1066 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1069 lstrcpyA(value
, "aaa");
1070 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1071 MSIINSTALLCONTEXT_USERUNMANAGED
,
1072 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1073 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1074 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1075 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1077 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
1078 lstrcatA(keypath
, prod_squashed
);
1080 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
1081 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1083 /* user product key exists */
1085 lstrcpyA(value
, "aaa");
1086 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1087 MSIINSTALLCONTEXT_USERUNMANAGED
,
1088 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1089 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
1090 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1091 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1093 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
1094 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1096 /* SourceList key exists */
1098 lstrcpyA(value
, "aaa");
1099 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1100 MSIINSTALLCONTEXT_USERUNMANAGED
,
1101 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1102 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1103 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1104 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1106 res
= RegCreateKeyA(source
, "URL", &url
);
1107 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1109 /* URL key exists */
1111 lstrcpyA(value
, "aaa");
1112 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1113 MSIINSTALLCONTEXT_USERUNMANAGED
,
1114 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1115 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1116 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1117 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1119 res
= RegSetValueExA(url
, "1", 0, REG_SZ
, (LPBYTE
)"first", 6);
1120 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1122 res
= RegSetValueExA(url
, "2", 0, REG_SZ
, (LPBYTE
)"second", 7);
1123 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1125 res
= RegSetValueExA(url
, "4", 0, REG_SZ
, (LPBYTE
)"fourth", 7);
1126 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1130 lstrcpyA(value
, "aaa");
1131 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1132 MSIINSTALLCONTEXT_USERUNMANAGED
,
1133 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1134 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1135 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1136 ok(size
== 5, "Expected 5, got %d\n", size
);
1138 /* try index 0 again */
1140 lstrcpyA(value
, "aaa");
1141 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1142 MSIINSTALLCONTEXT_USERUNMANAGED
,
1143 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1144 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1145 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1146 ok(size
== 5, "Expected 5, got %d\n", size
);
1148 /* both szSource and pcchSource are NULL, index 0 */
1149 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1150 MSIINSTALLCONTEXT_USERUNMANAGED
,
1151 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, NULL
, NULL
);
1152 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1154 /* both szSource and pcchSource are NULL, index 1 */
1155 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1156 MSIINSTALLCONTEXT_USERUNMANAGED
,
1157 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 1, NULL
, NULL
);
1158 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1160 /* size is exactly 5 */
1162 lstrcpyA(value
, "aaa");
1163 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1164 MSIINSTALLCONTEXT_USERUNMANAGED
,
1165 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1166 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
1167 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got %s\n", value
);
1168 ok(size
== 5, "Expected 5, got %d\n", size
);
1170 /* szSource is non-NULL while pcchSource is NULL */
1171 lstrcpyA(value
, "aaa");
1172 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1173 MSIINSTALLCONTEXT_USERUNMANAGED
,
1174 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, NULL
);
1175 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1176 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got %s\n", value
);
1178 /* try index 1 after failure */
1180 lstrcpyA(value
, "aaa");
1181 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1182 MSIINSTALLCONTEXT_USERUNMANAGED
,
1183 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 1, value
, &size
);
1184 ok(r
== ERROR_INVALID_PARAMETER
,
1185 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1186 ok(!lstrcmpA(value
, "aaa"), "Expected \"aaa\", got %s\n", value
);
1187 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1189 /* reset the enumeration */
1191 lstrcpyA(value
, "aaa");
1192 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1193 MSIINSTALLCONTEXT_USERUNMANAGED
,
1194 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1195 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1196 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1197 ok(size
== 5, "Expected 5, got %d\n", size
);
1201 lstrcpyA(value
, "aaa");
1202 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1203 MSIINSTALLCONTEXT_USERUNMANAGED
,
1204 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 1, value
, &size
);
1205 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1206 ok(!lstrcmpA(value
, "second"), "Expected \"second\", got %s\n", value
);
1207 ok(size
== 6, "Expected 6, got %d\n", size
);
1209 /* try index 1 again */
1211 lstrcpyA(value
, "aaa");
1212 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1213 MSIINSTALLCONTEXT_USERUNMANAGED
,
1214 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 1, value
, &size
);
1215 ok(r
== ERROR_INVALID_PARAMETER
,
1216 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1217 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1218 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1222 lstrcpyA(value
, "aaa");
1223 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1224 MSIINSTALLCONTEXT_USERUNMANAGED
,
1225 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 2, value
, &size
);
1226 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1227 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1228 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1232 lstrcpyA(value
, "aaa");
1233 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1234 MSIINSTALLCONTEXT_USERUNMANAGED
,
1235 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, -1, value
, &size
);
1236 ok(r
== ERROR_INVALID_PARAMETER
,
1237 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1238 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1239 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1241 /* NULL szUserSid */
1243 lstrcpyA(value
, "aaa");
1244 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1245 MSIINSTALLCONTEXT_USERUNMANAGED
,
1246 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1248 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1249 ok(size
== 5, "Expected 5, got %d\n", size
);
1251 /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1253 lstrcpyA(value
, "aaa");
1254 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1255 MSIINSTALLCONTEXT_USERUNMANAGED
,
1256 MSICODE_PRODUCT
, 0, value
, &size
);
1257 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1258 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1259 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1261 /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1263 lstrcpyA(value
, "aaa");
1264 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1265 MSIINSTALLCONTEXT_USERUNMANAGED
,
1266 MSICODE_PATCH
, 0, value
, &size
);
1267 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1268 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1269 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1271 /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1273 lstrcpyA(value
, "aaa");
1274 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1275 MSIINSTALLCONTEXT_USERUNMANAGED
,
1276 MSICODE_PRODUCT
| MSICODE_PATCH
| MSISOURCETYPE_URL
,
1278 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_SUCCESS, got %d\n", r
);
1279 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1280 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1282 /* invalid dwOptions, must be one of MSICODE_ and MSISOURCETYPE_ */
1284 lstrcpyA(value
, "aaa");
1285 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1286 MSIINSTALLCONTEXT_USERUNMANAGED
,
1287 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
| MSISOURCETYPE_URL
,
1289 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1290 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1291 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1293 RegDeleteValueA(url
, "1");
1294 RegDeleteValueA(url
, "2");
1295 RegDeleteValueA(url
, "4");
1296 RegDeleteKeyA(url
, "");
1299 /* SourceList key exists */
1301 lstrcpyA(value
, "aaa");
1302 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1303 MSIINSTALLCONTEXT_USERUNMANAGED
,
1304 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1305 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1306 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1307 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1309 res
= RegCreateKeyA(source
, "Net", &net
);
1310 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1312 /* Net key exists */
1314 lstrcpyA(value
, "aaa");
1315 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1316 MSIINSTALLCONTEXT_USERUNMANAGED
,
1317 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1318 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1319 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1320 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1322 res
= RegSetValueExA(net
, "1", 0, REG_SZ
, (LPBYTE
)"first", 6);
1323 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1327 lstrcpyA(value
, "aaa");
1328 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1329 MSIINSTALLCONTEXT_USERUNMANAGED
,
1330 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1331 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1332 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1333 ok(size
== 5, "Expected 5, got %d\n", size
);
1335 RegDeleteValueA(net
, "1");
1336 RegDeleteKeyA(net
, "");
1338 RegDeleteKeyA(source
, "");
1339 RegCloseKey(source
);
1340 RegDeleteKeyA(userkey
, "");
1341 RegCloseKey(userkey
);
1343 /* MSIINSTALLCONTEXT_USERMANAGED */
1346 lstrcpyA(value
, "aaa");
1347 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1348 MSIINSTALLCONTEXT_USERMANAGED
,
1349 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1350 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1351 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1352 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1354 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1355 lstrcatA(keypath
, usersid
);
1356 lstrcatA(keypath
, "\\Installer\\Products\\");
1357 lstrcatA(keypath
, prod_squashed
);
1359 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &userkey
);
1360 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1362 /* user product key exists */
1364 lstrcpyA(value
, "aaa");
1365 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1366 MSIINSTALLCONTEXT_USERMANAGED
,
1367 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1368 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
1369 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1370 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1372 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
1373 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1375 /* SourceList key exists */
1377 lstrcpyA(value
, "aaa");
1378 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1379 MSIINSTALLCONTEXT_USERMANAGED
,
1380 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1381 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1382 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1383 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1385 res
= RegCreateKeyA(source
, "URL", &url
);
1386 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1388 /* URL key exists */
1390 lstrcpyA(value
, "aaa");
1391 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1392 MSIINSTALLCONTEXT_USERMANAGED
,
1393 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1394 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1395 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1396 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1398 res
= RegSetValueExA(url
, "1", 0, REG_SZ
, (LPBYTE
)"first", 6);
1399 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1403 lstrcpyA(value
, "aaa");
1404 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1405 MSIINSTALLCONTEXT_USERMANAGED
,
1406 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1407 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1408 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1409 ok(size
== 5, "Expected 5, got %d\n", size
);
1411 /* NULL szUserSid */
1413 lstrcpyA(value
, "aaa");
1414 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1415 MSIINSTALLCONTEXT_USERMANAGED
,
1416 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1417 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1418 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1419 ok(size
== 5, "Expected 5, got %d\n", size
);
1421 RegDeleteValueA(url
, "1");
1422 RegDeleteKeyA(url
, "");
1425 /* SourceList key exists */
1427 lstrcpyA(value
, "aaa");
1428 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1429 MSIINSTALLCONTEXT_USERMANAGED
,
1430 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1431 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1432 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1433 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1435 res
= RegCreateKeyA(source
, "Net", &net
);
1436 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1438 /* Net key exists */
1440 lstrcpyA(value
, "aaa");
1441 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1442 MSIINSTALLCONTEXT_USERMANAGED
,
1443 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1444 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1445 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1446 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1448 res
= RegSetValueExA(net
, "1", 0, REG_SZ
, (LPBYTE
)"first", 6);
1449 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1453 lstrcpyA(value
, "aaa");
1454 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1455 MSIINSTALLCONTEXT_USERMANAGED
,
1456 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1457 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1458 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1459 ok(size
== 5, "Expected 5, got %d\n", size
);
1461 RegDeleteValueA(net
, "1");
1462 RegDeleteKeyA(net
, "");
1464 RegDeleteKeyA(source
, "");
1465 RegCloseKey(source
);
1466 RegDeleteKeyA(userkey
, "");
1467 RegCloseKey(userkey
);
1469 /* MSIINSTALLCONTEXT_MACHINE */
1471 /* szUserSid is non-NULL */
1473 lstrcpyA(value
, "aaa");
1474 r
= pMsiSourceListEnumSourcesA(prodcode
, usersid
,
1475 MSIINSTALLCONTEXT_MACHINE
,
1476 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1477 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1478 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1479 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1481 /* szUserSid is non-NULL */
1483 lstrcpyA(value
, "aaa");
1484 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1485 MSIINSTALLCONTEXT_MACHINE
,
1486 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1487 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1488 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1489 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1491 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
1492 lstrcatA(keypath
, prod_squashed
);
1494 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
1495 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1497 /* user product key exists */
1499 lstrcpyA(value
, "aaa");
1500 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1501 MSIINSTALLCONTEXT_MACHINE
,
1502 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1503 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
1504 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1505 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1507 res
= RegCreateKeyA(prodkey
, "SourceList", &source
);
1508 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1510 /* SourceList key exists */
1512 lstrcpyA(value
, "aaa");
1513 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1514 MSIINSTALLCONTEXT_MACHINE
,
1515 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1516 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1517 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1518 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1520 res
= RegCreateKeyA(source
, "URL", &url
);
1521 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1523 /* URL key exists */
1525 lstrcpyA(value
, "aaa");
1526 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1527 MSIINSTALLCONTEXT_MACHINE
,
1528 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1529 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1530 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1531 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1533 res
= RegSetValueExA(url
, "1", 0, REG_SZ
, (LPBYTE
)"first", 6);
1534 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1538 lstrcpyA(value
, "aaa");
1539 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1540 MSIINSTALLCONTEXT_MACHINE
,
1541 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1542 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1543 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1544 ok(size
== 5, "Expected 5, got %d\n", size
);
1546 /* NULL szUserSid */
1548 lstrcpyA(value
, "aaa");
1549 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1550 MSIINSTALLCONTEXT_MACHINE
,
1551 MSICODE_PRODUCT
| MSISOURCETYPE_URL
, 0, value
, &size
);
1552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1553 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1554 ok(size
== 5, "Expected 5, got %d\n", size
);
1556 RegDeleteValueA(url
, "1");
1557 RegDeleteKeyA(url
, "");
1560 /* SourceList key exists */
1562 lstrcpyA(value
, "aaa");
1563 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1564 MSIINSTALLCONTEXT_MACHINE
,
1565 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1566 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1567 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1568 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1570 res
= RegCreateKeyA(source
, "Net", &net
);
1571 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1573 /* Net key exists */
1575 lstrcpyA(value
, "aaa");
1576 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1577 MSIINSTALLCONTEXT_MACHINE
,
1578 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1579 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
1580 ok(!lstrcmpA(value
, "aaa"), "Expected value to be unchanged, got %s\n", value
);
1581 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
1583 res
= RegSetValueExA(net
, "1", 0, REG_SZ
, (LPBYTE
)"first", 6);
1584 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1588 lstrcpyA(value
, "aaa");
1589 r
= pMsiSourceListEnumSourcesA(prodcode
, NULL
,
1590 MSIINSTALLCONTEXT_MACHINE
,
1591 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
, 0, value
, &size
);
1592 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1593 ok(!lstrcmpA(value
, "first"), "Expected \"first\", got %s\n", value
);
1594 ok(size
== 5, "Expected 5, got %d\n", size
);
1596 RegDeleteValueA(net
, "1");
1597 RegDeleteKeyA(net
, "");
1599 RegDeleteKeyA(source
, "");
1600 RegCloseKey(source
);
1601 RegDeleteKeyA(prodkey
, "");
1602 RegCloseKey(prodkey
);
1605 static void test_MsiSourceListSetInfo(void)
1607 CHAR prodcode
[MAX_PATH
];
1608 CHAR prod_squashed
[MAX_PATH
];
1609 CHAR keypath
[MAX_PATH
*2];
1610 HKEY prodkey
, userkey
;
1611 HKEY net
, url
, media
, source
;
1616 if (!pMsiSourceListSetInfoA
)
1618 skip("MsiSourceListSetInfoA is not available\n");
1622 create_test_guid(prodcode
, prod_squashed
);
1623 if (!get_user_sid(&usersid
))
1625 skip("User SID not available -> skipping MsiSourceListSetInfoA tests\n");
1629 /* GetLastError is not set by the function */
1631 /* NULL szProductCodeOrPatchCode */
1632 r
= pMsiSourceListSetInfoA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1633 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1634 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1635 ok(r
== ERROR_INVALID_PARAMETER
,
1636 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1638 /* empty szProductCodeOrPatchCode */
1639 r
= pMsiSourceListSetInfoA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1640 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1641 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1642 ok(r
== ERROR_INVALID_PARAMETER
,
1643 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1645 /* garbage szProductCodeOrPatchCode */
1646 r
= pMsiSourceListSetInfoA("garbage", usersid
,
1647 MSIINSTALLCONTEXT_USERUNMANAGED
,
1648 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1649 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1650 ok(r
== ERROR_INVALID_PARAMETER
,
1651 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1653 /* guid without brackets */
1654 r
= pMsiSourceListSetInfoA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
1655 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1656 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1657 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1658 ok(r
== ERROR_INVALID_PARAMETER
,
1659 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1661 /* guid with brackets */
1662 r
= pMsiSourceListSetInfoA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
1663 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
1664 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1665 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1666 ok(r
== ERROR_UNKNOWN_PRODUCT
,
1667 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1669 /* dwOptions is MSICODE_PRODUCT */
1670 r
= pMsiSourceListSetInfoA(prodcode
, usersid
,
1671 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1672 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1673 ok(r
== ERROR_UNKNOWN_PRODUCT
,
1674 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1676 /* dwOptions is MSICODE_PATCH */
1677 r
= pMsiSourceListSetInfoA(prodcode
, usersid
,
1678 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PATCH
,
1679 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1680 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
1682 /* dwOptions is both MSICODE_PRODUCT and MSICODE_PATCH */
1683 r
= pMsiSourceListSetInfoA(prodcode
, usersid
,
1684 MSIINSTALLCONTEXT_USERUNMANAGED
,
1685 MSICODE_PRODUCT
| MSICODE_PATCH
| MSISOURCETYPE_URL
,
1686 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1687 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
1689 /* dwOptions has both MSISOURCETYPE_NETWORK and MSISOURCETYPE_URL */
1690 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1691 MSIINSTALLCONTEXT_USERUNMANAGED
,
1692 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
| MSISOURCETYPE_URL
,
1693 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1694 ok(r
== ERROR_UNKNOWN_PRODUCT
,
1695 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1697 /* LastUsedSource and dwOptions has both
1698 * MSISOURCETYPE_NETWORK and MSISOURCETYPE_URL
1700 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1701 MSIINSTALLCONTEXT_USERUNMANAGED
,
1702 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
| MSISOURCETYPE_URL
,
1703 INSTALLPROPERTY_LASTUSEDSOURCE
, "path");
1704 ok(r
== ERROR_UNKNOWN_PRODUCT
,
1705 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1707 /* LastUsedSource and dwOptions has no source type */
1708 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1709 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1710 INSTALLPROPERTY_LASTUSEDSOURCE
, "path");
1711 ok(r
== ERROR_UNKNOWN_PRODUCT
,
1712 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
1714 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1716 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
1717 lstrcatA(keypath
, prod_squashed
);
1719 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
1720 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1722 /* user product key exists */
1723 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1724 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1725 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1726 ok(r
== ERROR_BAD_CONFIGURATION
,
1727 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
1729 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
1730 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1732 /* SourceList key exists, no source type */
1733 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1734 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1735 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1736 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1738 /* Media key is created by MsiSourceListSetInfo */
1739 res
= RegOpenKeyA(source
, "Media", &media
);
1740 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1741 CHECK_REG_STR(media
, "MediaPackage", "path");
1743 /* set the info again */
1744 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1745 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1746 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path2");
1747 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1748 CHECK_REG_STR(media
, "MediaPackage", "path2");
1750 /* NULL szProperty */
1751 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1752 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1754 ok(r
== ERROR_INVALID_PARAMETER
,
1755 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1757 /* empty szProperty */
1758 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1759 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1761 ok(r
== ERROR_UNKNOWN_PROPERTY
,
1762 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
1765 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1766 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1767 INSTALLPROPERTY_MEDIAPACKAGEPATH
, NULL
);
1768 ok(r
== ERROR_UNKNOWN_PROPERTY
,
1769 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
1772 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1773 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1774 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "");
1775 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1776 CHECK_REG_STR(media
, "MediaPackage", "");
1778 /* INSTALLPROPERTY_MEDIAPACKAGEPATH, MSISOURCETYPE_NETWORK */
1779 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1780 MSIINSTALLCONTEXT_USERUNMANAGED
,
1781 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1782 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1783 ok(r
== ERROR_INVALID_PARAMETER
,
1784 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1786 /* INSTALLPROPERTY_MEDIAPACKAGEPATH, MSISOURCETYPE_URL */
1787 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1788 MSIINSTALLCONTEXT_USERUNMANAGED
,
1789 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
1790 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1791 ok(r
== ERROR_INVALID_PARAMETER
,
1792 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1794 /* INSTALLPROPERTY_DISKPROMPT */
1795 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1796 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1797 INSTALLPROPERTY_DISKPROMPT
, "prompt");
1798 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1799 CHECK_REG_STR(media
, "DiskPrompt", "prompt");
1801 /* INSTALLPROPERTY_DISKPROMPT, MSISOURCETYPE_NETWORK */
1802 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1803 MSIINSTALLCONTEXT_USERUNMANAGED
,
1804 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1805 INSTALLPROPERTY_DISKPROMPT
, "prompt");
1806 ok(r
== ERROR_INVALID_PARAMETER
,
1807 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1809 /* INSTALLPROPERTY_DISKPROMPT, MSISOURCETYPE_URL */
1810 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1811 MSIINSTALLCONTEXT_USERUNMANAGED
,
1812 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
1813 INSTALLPROPERTY_DISKPROMPT
, "prompt");
1814 ok(r
== ERROR_INVALID_PARAMETER
,
1815 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1817 /* INSTALLPROPERTY_LASTUSEDSOURCE */
1818 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1819 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1820 INSTALLPROPERTY_LASTUSEDSOURCE
, "source");
1821 ok(r
== ERROR_INVALID_PARAMETER
,
1822 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1824 /* INSTALLPROPERTY_LASTUSEDSOURCE, MSISOURCETYPE_NETWORK */
1825 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1826 MSIINSTALLCONTEXT_USERUNMANAGED
,
1827 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1828 INSTALLPROPERTY_LASTUSEDSOURCE
, "source");
1829 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1831 /* Net key is created by MsiSourceListSetInfo */
1832 res
= RegOpenKeyA(source
, "Net", &net
);
1833 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1834 CHECK_REG_STR(net
, "1", "source\\")
1835 CHECK_REG_STR(source
, "LastUsedSource", "n;1;source");
1837 /* source has forward slash */
1838 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1839 MSIINSTALLCONTEXT_USERUNMANAGED
,
1840 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1841 INSTALLPROPERTY_LASTUSEDSOURCE
, "source/");
1842 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1843 CHECK_REG_STR(net
, "1", "source\\");
1844 CHECK_REG_STR(net
, "2", "source/\\");
1845 CHECK_REG_STR(source
, "LastUsedSource", "n;2;source/");
1847 /* INSTALLPROPERTY_LASTUSEDSOURCE, MSISOURCETYPE_URL */
1848 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1849 MSIINSTALLCONTEXT_USERUNMANAGED
,
1850 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
1851 INSTALLPROPERTY_LASTUSEDSOURCE
, "source");
1852 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1854 /* URL key is created by MsiSourceListSetInfo */
1855 res
= RegOpenKeyA(source
, "URL", &url
);
1856 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1857 CHECK_REG_STR(url
, "1", "source/");
1858 CHECK_REG_STR(source
, "LastUsedSource", "u;1;source");
1860 /* source has backslash */
1861 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1862 MSIINSTALLCONTEXT_USERUNMANAGED
,
1863 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
1864 INSTALLPROPERTY_LASTUSEDSOURCE
, "source\\");
1865 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1866 CHECK_REG_STR(url
, "1", "source/");
1867 CHECK_REG_STR(url
, "2", "source\\/");
1868 CHECK_REG_STR(source
, "LastUsedSource", "u;2;source\\");
1870 /* INSTALLPROPERTY_LASTUSEDSOURCE, MSISOURCETYPE_MEDIA */
1871 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1872 MSIINSTALLCONTEXT_USERUNMANAGED
,
1873 MSICODE_PRODUCT
| MSISOURCETYPE_MEDIA
,
1874 INSTALLPROPERTY_LASTUSEDSOURCE
, "source");
1875 ok(r
== ERROR_INVALID_PARAMETER
,
1876 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1878 /* INSTALLPROPERTY_PACKAGENAME */
1879 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1880 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1881 INSTALLPROPERTY_PACKAGENAME
, "name");
1882 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1883 CHECK_REG_STR(source
, "PackageName", "name");
1885 /* INSTALLPROPERTY_PACKAGENAME, MSISOURCETYPE_NETWORK */
1886 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1887 MSIINSTALLCONTEXT_USERUNMANAGED
,
1888 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
1889 INSTALLPROPERTY_PACKAGENAME
, "name");
1890 ok(r
== ERROR_INVALID_PARAMETER
,
1891 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1893 /* INSTALLPROPERTY_PACKAGENAME, MSISOURCETYPE_URL */
1894 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1895 MSIINSTALLCONTEXT_USERUNMANAGED
,
1896 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
1897 INSTALLPROPERTY_PACKAGENAME
, "name");
1898 ok(r
== ERROR_INVALID_PARAMETER
,
1899 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1901 /* INSTALLPROPERTY_LASTUSEDTYPE */
1902 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1903 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1904 INSTALLPROPERTY_LASTUSEDTYPE
, "type");
1905 ok(r
== ERROR_UNKNOWN_PROPERTY
,
1906 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
1908 /* definitely unknown property */
1909 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1910 MSIINSTALLCONTEXT_USERUNMANAGED
, MSICODE_PRODUCT
,
1912 ok(r
== ERROR_UNKNOWN_PROPERTY
,
1913 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
1915 RegDeleteValueA(net
, "1");
1916 RegDeleteKeyA(net
, "");
1918 RegDeleteValueA(url
, "1");
1919 RegDeleteKeyA(url
, "");
1921 RegDeleteValueA(media
, "MediaPackage");
1922 RegDeleteValueA(media
, "DiskPrompt");
1923 RegDeleteKeyA(media
, "");
1925 RegDeleteValueA(source
, "PackageName");
1926 RegDeleteKeyA(source
, "");
1927 RegCloseKey(source
);
1928 RegDeleteKeyA(userkey
, "");
1929 RegCloseKey(userkey
);
1931 /* MSIINSTALLCONTEXT_USERMANAGED */
1933 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1934 lstrcatA(keypath
, usersid
);
1935 lstrcatA(keypath
, "\\Installer\\Products\\");
1936 lstrcatA(keypath
, prod_squashed
);
1938 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &userkey
);
1939 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1941 /* user product key exists */
1942 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1943 MSIINSTALLCONTEXT_USERMANAGED
, MSICODE_PRODUCT
,
1944 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1945 ok(r
== ERROR_BAD_CONFIGURATION
,
1946 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
1948 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
1949 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1951 /* SourceList key exists, no source type */
1952 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1953 MSIINSTALLCONTEXT_USERMANAGED
, MSICODE_PRODUCT
,
1954 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1955 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1957 /* Media key is created by MsiSourceListSetInfo */
1958 res
= RegOpenKeyA(source
, "Media", &media
);
1959 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1960 CHECK_REG_STR(media
, "MediaPackage", "path");
1962 RegDeleteValueA(media
, "MediaPackage");
1963 RegDeleteKeyA(media
, "");
1965 RegDeleteKeyA(source
, "");
1966 RegCloseKey(source
);
1967 RegDeleteKeyA(userkey
, "");
1968 RegCloseKey(userkey
);
1970 /* MSIINSTALLCONTEXT_MACHINE */
1972 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
1973 lstrcatA(keypath
, prod_squashed
);
1975 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
1976 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1978 /* user product key exists */
1979 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1980 MSIINSTALLCONTEXT_MACHINE
, MSICODE_PRODUCT
,
1981 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1982 ok(r
== ERROR_BAD_CONFIGURATION
,
1983 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
1985 res
= RegCreateKeyA(prodkey
, "SourceList", &source
);
1986 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1988 /* SourceList key exists, no source type */
1989 r
= pMsiSourceListSetInfoA(prodcode
, NULL
,
1990 MSIINSTALLCONTEXT_MACHINE
, MSICODE_PRODUCT
,
1991 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
1992 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1994 /* Media key is created by MsiSourceListSetInfo */
1995 res
= RegOpenKeyA(source
, "Media", &media
);
1996 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1997 CHECK_REG_STR(media
, "MediaPackage", "path");
1999 /* szUserSid is non-NULL */
2000 r
= pMsiSourceListSetInfoA(prodcode
, usersid
,
2001 MSIINSTALLCONTEXT_MACHINE
, MSICODE_PRODUCT
,
2002 INSTALLPROPERTY_MEDIAPACKAGEPATH
, "path");
2003 ok(r
== ERROR_INVALID_PARAMETER
,
2004 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2006 RegDeleteValueA(media
, "MediaPackage");
2007 RegDeleteKeyA(media
, "");
2009 RegDeleteKeyA(source
, "");
2010 RegCloseKey(source
);
2011 RegDeleteKeyA(prodkey
, "");
2012 RegCloseKey(prodkey
);
2015 static void test_MsiSourceListAddMediaDisk(void)
2017 CHAR prodcode
[MAX_PATH
];
2018 CHAR prod_squashed
[MAX_PATH
];
2019 CHAR keypath
[MAX_PATH
*2];
2020 HKEY prodkey
, userkey
;
2026 if (!pMsiSourceListAddMediaDiskA
)
2028 skip("MsiSourceListAddMediaDiskA is not available\n");
2032 create_test_guid(prodcode
, prod_squashed
);
2033 if (!get_user_sid(&usersid
))
2035 skip("User SID not available -> skipping MsiSourceListAddMediaDiskA tests\n");
2039 /* GetLastError is not set by the function */
2041 /* NULL szProductCodeOrPatchCode */
2042 r
= pMsiSourceListAddMediaDiskA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2043 MSICODE_PRODUCT
, 1, "label", "prompt");
2044 ok(r
== ERROR_INVALID_PARAMETER
,
2045 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2047 /* empty szProductCodeOrPatchCode */
2048 r
= pMsiSourceListAddMediaDiskA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2049 MSICODE_PRODUCT
, 1, "label", "prompt");
2050 ok(r
== ERROR_INVALID_PARAMETER
,
2051 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2053 /* garbage szProductCodeOrPatchCode */
2054 r
= pMsiSourceListAddMediaDiskA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2055 MSICODE_PRODUCT
, 1, "label", "prompt");
2056 ok(r
== ERROR_INVALID_PARAMETER
,
2057 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2059 /* guid without brackets */
2060 r
= pMsiSourceListAddMediaDiskA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
2061 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2062 MSICODE_PRODUCT
, 1, "label", "prompt");
2063 ok(r
== ERROR_INVALID_PARAMETER
,
2064 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2066 /* guid with brackets */
2067 r
= pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2068 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2069 MSICODE_PRODUCT
, 1, "label", "prompt");
2070 ok(r
== ERROR_UNKNOWN_PRODUCT
,
2071 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2073 /* dwOptions has MSISOURCETYPE_NETWORK */
2074 r
= pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2075 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2076 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
2077 1, "label", "prompt");
2078 ok(r
== ERROR_INVALID_PARAMETER
,
2079 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2081 /* dwOptions has MSISOURCETYPE_URL */
2082 r
= pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2083 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2084 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
2085 1, "label", "prompt");
2086 ok(r
== ERROR_INVALID_PARAMETER
,
2087 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2089 /* dwOptions has MSISOURCETYPE_MEDIA */
2090 r
= pMsiSourceListAddMediaDiskA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2091 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2092 MSICODE_PRODUCT
| MSISOURCETYPE_MEDIA
,
2093 1, "label", "prompt");
2094 ok(r
== ERROR_INVALID_PARAMETER
,
2095 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2097 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2099 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
2100 lstrcatA(keypath
, prod_squashed
);
2102 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
2103 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2105 /* user product key exists */
2106 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2107 MSIINSTALLCONTEXT_USERUNMANAGED
,
2108 MSICODE_PRODUCT
, 1, "label", "prompt");
2109 ok(r
== ERROR_BAD_CONFIGURATION
,
2110 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
2112 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
2113 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2115 /* SourceList key exists */
2116 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2117 MSIINSTALLCONTEXT_USERUNMANAGED
,
2118 MSICODE_PRODUCT
, 1, "label", "prompt");
2119 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2121 /* Media subkey is created by MsiSourceListAddMediaDisk */
2122 res
= RegOpenKeyA(source
, "Media", &media
);
2123 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2125 CHECK_REG_STR(media
, "1", "label;prompt");
2127 /* dwDiskId is random */
2128 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2129 MSIINSTALLCONTEXT_USERUNMANAGED
,
2130 MSICODE_PRODUCT
, 42, "label42", "prompt42");
2131 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2133 CHECK_REG_STR(media
, "1", "label;prompt");
2134 CHECK_REG_STR(media
, "42", "label42;prompt42");
2137 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2138 MSIINSTALLCONTEXT_USERUNMANAGED
,
2139 MSICODE_PRODUCT
, 0, "label0", "prompt0");
2140 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2142 CHECK_REG_STR(media
, "0", "label0;prompt0");
2143 CHECK_REG_STR(media
, "1", "label;prompt");
2144 CHECK_REG_STR(media
, "42", "label42;prompt42");
2146 /* dwDiskId is < 0 */
2147 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2148 MSIINSTALLCONTEXT_USERUNMANAGED
,
2149 MSICODE_PRODUCT
, -1, "label-1", "prompt-1");
2150 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2152 CHECK_REG_STR(media
, "-1", "label-1;prompt-1");
2153 CHECK_REG_STR(media
, "0", "label0;prompt0");
2154 CHECK_REG_STR(media
, "1", "label;prompt");
2155 CHECK_REG_STR(media
, "42", "label42;prompt42");
2157 /* update dwDiskId 1 */
2158 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2159 MSIINSTALLCONTEXT_USERUNMANAGED
,
2160 MSICODE_PRODUCT
, 1, "newlabel", "newprompt");
2161 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2163 CHECK_REG_STR(media
, "-1", "label-1;prompt-1");
2164 CHECK_REG_STR(media
, "0", "label0;prompt0");
2165 CHECK_REG_STR(media
, "1", "newlabel;newprompt");
2166 CHECK_REG_STR(media
, "42", "label42;prompt42");
2168 /* update dwDiskId 1, szPrompt is NULL */
2169 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2170 MSIINSTALLCONTEXT_USERUNMANAGED
,
2171 MSICODE_PRODUCT
, 1, "etiqueta", NULL
);
2172 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2174 CHECK_REG_STR(media
, "-1", "label-1;prompt-1");
2175 CHECK_REG_STR(media
, "0", "label0;prompt0");
2176 CHECK_REG_STR(media
, "1", "etiqueta;");
2177 CHECK_REG_STR(media
, "42", "label42;prompt42");
2179 /* update dwDiskId 1, szPrompt is empty */
2180 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2181 MSIINSTALLCONTEXT_USERUNMANAGED
,
2182 MSICODE_PRODUCT
, 1, "etikett", "");
2183 ok(r
== ERROR_INVALID_PARAMETER
,
2184 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2186 /* update dwDiskId 1, szVolumeLabel is NULL */
2187 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2188 MSIINSTALLCONTEXT_USERUNMANAGED
,
2189 MSICODE_PRODUCT
, 1, NULL
, "provocar");
2190 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2192 CHECK_REG_STR(media
, "-1", "label-1;prompt-1");
2193 CHECK_REG_STR(media
, "0", "label0;prompt0");
2194 CHECK_REG_STR(media
, "1", ";provocar");
2195 CHECK_REG_STR(media
, "42", "label42;prompt42");
2197 /* update dwDiskId 1, szVolumeLabel is empty */
2198 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2199 MSIINSTALLCONTEXT_USERUNMANAGED
,
2200 MSICODE_PRODUCT
, 1, "", "provoquer");
2201 ok(r
== ERROR_INVALID_PARAMETER
,
2202 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2204 /* szUserSid is NULL */
2205 r
= pMsiSourceListAddMediaDiskA(prodcode
, NULL
,
2206 MSIINSTALLCONTEXT_USERUNMANAGED
,
2207 MSICODE_PRODUCT
, 1, NULL
, "provoquer");
2208 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2210 CHECK_REG_STR(media
, "-1", "label-1;prompt-1");
2211 CHECK_REG_STR(media
, "0", "label0;prompt0");
2212 CHECK_REG_STR(media
, "1", ";provoquer");
2213 CHECK_REG_STR(media
, "42", "label42;prompt42");
2215 RegDeleteValueA(media
, "-1");
2216 RegDeleteValueA(media
, "0");
2217 RegDeleteValueA(media
, "1");
2218 RegDeleteValueA(media
, "42");
2219 RegDeleteKeyA(media
, "");
2221 RegDeleteKeyA(source
, "");
2222 RegCloseKey(source
);
2223 RegDeleteKeyA(userkey
, "");
2224 RegCloseKey(userkey
);
2226 /* MSIINSTALLCONTEXT_USERMANAGED */
2228 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2229 lstrcatA(keypath
, usersid
);
2230 lstrcatA(keypath
, "\\Installer\\Products\\");
2231 lstrcatA(keypath
, prod_squashed
);
2233 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &userkey
);
2234 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2236 /* user product key exists */
2237 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2238 MSIINSTALLCONTEXT_USERMANAGED
,
2239 MSICODE_PRODUCT
, 1, "label", "prompt");
2240 ok(r
== ERROR_BAD_CONFIGURATION
,
2241 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
2243 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
2244 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2246 /* SourceList key exists */
2247 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2248 MSIINSTALLCONTEXT_USERMANAGED
,
2249 MSICODE_PRODUCT
, 1, "label", "prompt");
2250 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2252 /* Media subkey is created by MsiSourceListAddMediaDisk */
2253 res
= RegOpenKeyA(source
, "Media", &media
);
2254 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2256 CHECK_REG_STR(media
, "1", "label;prompt");
2258 RegDeleteValueA(media
, "1");
2259 RegDeleteKeyA(media
, "");
2261 RegDeleteKeyA(source
, "");
2262 RegCloseKey(source
);
2263 RegDeleteKeyA(userkey
, "");
2264 RegCloseKey(userkey
);
2266 /* MSIINSTALLCONTEXT_MACHINE */
2268 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
2269 lstrcatA(keypath
, prod_squashed
);
2271 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
2272 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2274 /* machine product key exists */
2275 r
= pMsiSourceListAddMediaDiskA(prodcode
, NULL
,
2276 MSIINSTALLCONTEXT_MACHINE
,
2277 MSICODE_PRODUCT
, 1, "label", "prompt");
2278 ok(r
== ERROR_BAD_CONFIGURATION
,
2279 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
2281 res
= RegCreateKeyA(prodkey
, "SourceList", &source
);
2282 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2284 /* SourceList key exists */
2285 r
= pMsiSourceListAddMediaDiskA(prodcode
, NULL
,
2286 MSIINSTALLCONTEXT_MACHINE
,
2287 MSICODE_PRODUCT
, 1, "label", "prompt");
2288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2290 /* Media subkey is created by MsiSourceListAddMediaDisk */
2291 res
= RegOpenKeyA(source
, "Media", &media
);
2292 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2294 CHECK_REG_STR(media
, "1", "label;prompt");
2296 /* szUserSid is non-NULL */
2297 r
= pMsiSourceListAddMediaDiskA(prodcode
, usersid
,
2298 MSIINSTALLCONTEXT_MACHINE
,
2299 MSICODE_PRODUCT
, 1, "label", "prompt");
2300 ok(r
== ERROR_INVALID_PARAMETER
,
2301 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2303 RegDeleteValueA(media
, "1");
2304 RegDeleteKeyA(media
, "");
2306 RegDeleteKeyA(source
, "");
2307 RegCloseKey(source
);
2308 RegDeleteKeyA(prodkey
, "");
2309 RegCloseKey(prodkey
);
2312 static void test_MsiSourceListEnumMediaDisks(void)
2314 CHAR prodcode
[MAX_PATH
];
2315 CHAR prod_squashed
[MAX_PATH
];
2316 CHAR keypath
[MAX_PATH
*2];
2317 CHAR label
[MAX_PATH
];
2318 CHAR prompt
[MAX_PATH
];
2319 HKEY prodkey
, userkey
;
2321 DWORD labelsz
, promptsz
;
2328 if (!pMsiSourceListEnumMediaDisksA
)
2330 skip("MsiSourceListEnumMediaDisksA is not available\n");
2334 create_test_guid(prodcode
, prod_squashed
);
2335 if (!get_user_sid(&usersid
))
2337 skip("User SID not available -> skipping MsiSourceListEnumMediaDisksA tests\n");
2341 /* GetLastError is not set by the function */
2343 /* NULL szProductCodeOrPatchCode */
2344 labelsz
= sizeof(label
);
2345 promptsz
= sizeof(prompt
);
2346 r
= pMsiSourceListEnumMediaDisksA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2347 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2349 ok(r
== ERROR_INVALID_PARAMETER
,
2350 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2352 /* empty szProductCodeOrPatchCode */
2353 labelsz
= sizeof(label
);
2354 promptsz
= sizeof(prompt
);
2355 r
= pMsiSourceListEnumMediaDisksA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2356 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2358 ok(r
== ERROR_INVALID_PARAMETER
,
2359 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2361 /* garbage szProductCodeOrPatchCode */
2362 labelsz
= sizeof(label
);
2363 promptsz
= sizeof(prompt
);
2364 r
= pMsiSourceListEnumMediaDisksA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2365 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2367 ok(r
== ERROR_INVALID_PARAMETER
,
2368 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2370 /* guid without brackets */
2371 labelsz
= sizeof(label
);
2372 promptsz
= sizeof(prompt
);
2373 r
= pMsiSourceListEnumMediaDisksA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA",
2374 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2375 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2377 ok(r
== ERROR_INVALID_PARAMETER
,
2378 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2380 /* guid with brackets */
2381 labelsz
= sizeof(label
);
2382 promptsz
= sizeof(prompt
);
2383 r
= pMsiSourceListEnumMediaDisksA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}",
2384 usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2385 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2387 ok(r
== ERROR_UNKNOWN_PRODUCT
,
2388 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2390 /* dwOptions has MSISOURCETYPE_NETWORK */
2391 labelsz
= sizeof(label
);
2392 promptsz
= sizeof(prompt
);
2393 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2394 MSICODE_PRODUCT
| MSISOURCETYPE_NETWORK
,
2395 0, &id
, label
, &labelsz
,
2397 ok(r
== ERROR_INVALID_PARAMETER
,
2398 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2400 /* dwOptions has MSISOURCETYPE_URL */
2401 labelsz
= sizeof(label
);
2402 promptsz
= sizeof(prompt
);
2403 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2404 MSICODE_PRODUCT
| MSISOURCETYPE_URL
,
2405 0, &id
, label
, &labelsz
,
2407 ok(r
== ERROR_INVALID_PARAMETER
,
2408 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2410 /* dwIndex is non-zero */
2411 labelsz
= sizeof(label
);
2412 promptsz
= sizeof(prompt
);
2413 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2414 MSICODE_PRODUCT
, 1, &id
, label
, &labelsz
,
2416 ok(r
== ERROR_INVALID_PARAMETER
,
2417 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2419 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2421 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
2422 lstrcatA(keypath
, prod_squashed
);
2424 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
2425 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2427 /* user product key exists */
2428 labelsz
= sizeof(label
);
2429 promptsz
= sizeof(prompt
);
2430 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2431 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2433 ok(r
== ERROR_BAD_CONFIGURATION
,
2434 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
2436 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
2437 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2439 /* SourceList key exists */
2441 lstrcpyA(label
, "aaa");
2442 labelsz
= 0xdeadbeef;
2443 lstrcpyA(prompt
, "bbb");
2444 promptsz
= 0xdeadbeef;
2445 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2446 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2448 ok(r
== ERROR_NO_MORE_ITEMS
,
2449 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
2450 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2451 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2452 ok(labelsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz
);
2453 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2454 ok(promptsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz
);
2456 res
= RegCreateKeyA(source
, "Media", &media
);
2457 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2459 /* Media key exists */
2461 lstrcpyA(label
, "aaa");
2462 labelsz
= 0xdeadbeef;
2463 lstrcpyA(prompt
, "bbb");
2464 promptsz
= 0xdeadbeef;
2465 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2466 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2468 ok(r
== ERROR_NO_MORE_ITEMS
,
2469 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
2470 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2471 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2472 ok(labelsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz
);
2473 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2474 ok(promptsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz
);
2476 res
= RegSetValueExA(media
, "1", 0, REG_SZ
, (LPBYTE
)"label;prompt", 13);
2477 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2481 lstrcpyA(label
, "aaa");
2483 lstrcpyA(prompt
, "bbb");
2484 promptsz
= MAX_PATH
;
2485 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2486 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2488 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2489 ok(id
== 1, "Expected 1, got %d\n", id
);
2490 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2491 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2492 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2493 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2495 res
= RegSetValueExA(media
, "2", 0, REG_SZ
, (LPBYTE
)"one;two", 8);
2496 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2498 /* now disk 2 exists, get the sizes */
2501 promptsz
= MAX_PATH
;
2502 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2503 MSICODE_PRODUCT
, 1, &id
, NULL
, &labelsz
,
2505 ok(r
== ERROR_SUCCESS
|| r
== ERROR_INVALID_PARAMETER
,
2506 "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r
);
2507 if (r
== ERROR_SUCCESS
)
2509 ok(id
== 2, "Expected 2, got %d\n", id
);
2510 ok(labelsz
== 3, "Expected 3, got %d\n", labelsz
);
2511 ok(promptsz
== 3, "Expected 3, got %d\n", promptsz
);
2514 /* now fill in the values */
2516 lstrcpyA(label
, "aaa");
2518 lstrcpyA(prompt
, "bbb");
2519 promptsz
= MAX_PATH
;
2520 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2521 MSICODE_PRODUCT
, 1, &id
, label
, &labelsz
,
2523 ok(r
== ERROR_SUCCESS
|| r
== ERROR_INVALID_PARAMETER
,
2524 "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r
);
2525 if (r
== ERROR_SUCCESS
)
2527 ok(id
== 2, "Expected 2, got %d\n", id
);
2528 ok(!lstrcmpA(label
, "one"), "Expected \"one\", got \"%s\"\n", label
);
2529 ok(labelsz
== 3, "Expected 3, got %d\n", labelsz
);
2530 ok(!lstrcmpA(prompt
, "two"), "Expected \"two\", got \"%s\"\n", prompt
);
2531 ok(promptsz
== 3, "Expected 3, got %d\n", promptsz
);
2533 else if (r
== ERROR_INVALID_PARAMETER
)
2535 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2536 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2537 ok(labelsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", labelsz
);
2538 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2539 ok(promptsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", promptsz
);
2542 res
= RegSetValueExA(media
, "4", 0, REG_SZ
, (LPBYTE
)"three;four", 11);
2543 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2545 /* disks 1, 2, 4 exist, reset the enumeration */
2547 lstrcpyA(label
, "aaa");
2549 lstrcpyA(prompt
, "bbb");
2550 promptsz
= MAX_PATH
;
2551 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2552 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2554 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2555 ok(id
== 1, "Expected 1, got %d\n", id
);
2556 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2557 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2558 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2559 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2561 /* disks 1, 2, 4 exist, index 1 */
2563 lstrcpyA(label
, "aaa");
2565 lstrcpyA(prompt
, "bbb");
2566 promptsz
= MAX_PATH
;
2567 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2568 MSICODE_PRODUCT
, 1, &id
, label
, &labelsz
,
2570 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2571 ok(id
== 2, "Expected 2, got %d\n", id
);
2572 ok(!lstrcmpA(label
, "one"), "Expected \"one\", got \"%s\"\n", label
);
2573 ok(labelsz
== 3, "Expected 3, got %d\n", labelsz
);
2574 ok(!lstrcmpA(prompt
, "two"), "Expected \"two\", got \"%s\"\n", prompt
);
2575 ok(promptsz
== 3, "Expected 3, got %d\n", promptsz
);
2577 /* disks 1, 2, 4 exist, index 2 */
2579 lstrcpyA(label
, "aaa");
2581 lstrcpyA(prompt
, "bbb");
2582 promptsz
= MAX_PATH
;
2583 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2584 MSICODE_PRODUCT
, 2, &id
, label
, &labelsz
,
2586 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2587 ok(id
== 4, "Expected 4, got %d\n", id
);
2588 ok(!lstrcmpA(label
, "three"), "Expected \"three\", got \"%s\"\n", label
);
2589 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2590 ok(!lstrcmpA(prompt
, "four"), "Expected \"four\", got \"%s\"\n", prompt
);
2591 ok(promptsz
== 4, "Expected 4, got %d\n", promptsz
);
2593 /* disks 1, 2, 4 exist, index 3, invalid */
2595 lstrcpyA(label
, "aaa");
2597 lstrcpyA(prompt
, "bbb");
2598 promptsz
= MAX_PATH
;
2599 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2600 MSICODE_PRODUCT
, 3, &id
, label
, &labelsz
,
2602 ok(r
== ERROR_NO_MORE_ITEMS
,
2603 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
2604 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2605 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2606 ok(labelsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", labelsz
);
2607 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2608 ok(promptsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", promptsz
);
2610 /* disks 1, 2, 4 exist, reset the enumeration */
2612 lstrcpyA(label
, "aaa");
2614 lstrcpyA(prompt
, "bbb");
2615 promptsz
= MAX_PATH
;
2616 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2617 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2619 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2620 ok(id
== 1, "Expected 1, got %d\n", id
);
2621 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2622 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2623 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2624 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2626 /* try index 0 again */
2628 lstrcpyA(label
, "aaa");
2630 lstrcpyA(prompt
, "bbb");
2631 promptsz
= MAX_PATH
;
2632 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2633 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2635 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2636 ok(id
== 1, "Expected 1, got %d\n", id
);
2637 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2638 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2639 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2640 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2642 /* jump to index 2 */
2644 lstrcpyA(label
, "aaa");
2646 lstrcpyA(prompt
, "bbb");
2647 promptsz
= MAX_PATH
;
2648 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2649 MSICODE_PRODUCT
, 2, &id
, label
, &labelsz
,
2651 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2652 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2653 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2654 ok(labelsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", labelsz
);
2655 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2656 ok(promptsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", promptsz
);
2658 /* after error, try index 1 */
2660 lstrcpyA(label
, "aaa");
2662 lstrcpyA(prompt
, "bbb");
2663 promptsz
= MAX_PATH
;
2664 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2665 MSICODE_PRODUCT
, 1, &id
, label
, &labelsz
,
2667 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2668 ok(id
== 2, "Expected 2, got %d\n", id
);
2669 ok(!lstrcmpA(label
, "one"), "Expected \"one\", got \"%s\"\n", label
);
2670 ok(labelsz
== 3, "Expected 3, got %d\n", labelsz
);
2671 ok(!lstrcmpA(prompt
, "two"), "Expected \"two\", got \"%s\"\n", prompt
);
2672 ok(promptsz
== 3, "Expected 3, got %d\n", promptsz
);
2674 /* try index 1 again */
2676 lstrcpyA(label
, "aaa");
2678 lstrcpyA(prompt
, "bbb");
2679 promptsz
= MAX_PATH
;
2680 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2681 MSICODE_PRODUCT
, 1, &id
, label
, &labelsz
,
2683 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2684 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2685 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2686 ok(labelsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", labelsz
);
2687 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2688 ok(promptsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", promptsz
);
2690 /* NULL pdwDiskId */
2691 lstrcpyA(label
, "aaa");
2693 lstrcpyA(prompt
, "bbb");
2694 promptsz
= MAX_PATH
;
2695 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2696 MSICODE_PRODUCT
, 0, NULL
, label
, &labelsz
,
2698 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2699 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2700 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2701 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2702 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2704 /* szVolumeLabel is NULL */
2707 lstrcpyA(prompt
, "bbb");
2708 promptsz
= MAX_PATH
;
2709 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2710 MSICODE_PRODUCT
, 0, &id
, NULL
, &labelsz
,
2712 ok(r
== ERROR_SUCCESS
|| r
== ERROR_INVALID_PARAMETER
,
2713 "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r
);
2714 if (r
== ERROR_SUCCESS
)
2716 ok(id
== 1, "Expected 1, got %d\n", id
);
2717 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2718 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2719 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2722 /* szVolumeLabel and pcchVolumeLabel are NULL */
2724 lstrcpyA(prompt
, "bbb");
2725 promptsz
= MAX_PATH
;
2726 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2727 MSICODE_PRODUCT
, 0, &id
, NULL
, NULL
,
2729 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2730 ok(id
== 1, "Expected 1, got %d\n", id
);
2731 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2732 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2734 /* szVolumeLabel is non-NULL while pcchVolumeLabel is NULL */
2736 lstrcpyA(label
, "aaa");
2737 lstrcpyA(prompt
, "bbb");
2738 promptsz
= MAX_PATH
;
2739 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2740 MSICODE_PRODUCT
, 0, &id
, label
, NULL
,
2742 ok(r
== ERROR_SUCCESS
|| r
== ERROR_INVALID_PARAMETER
,
2743 "Expected ERROR_SUCCESS or ERROR_INVALID_PARAMETER, got %d\n", r
);
2744 if (r
== ERROR_SUCCESS
)
2746 ok(id
== 1, "Expected 1, got %d\n", id
);
2747 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2748 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2749 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2752 /* szDiskPrompt is NULL */
2754 lstrcpyA(label
, "aaa");
2756 promptsz
= MAX_PATH
;
2757 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2758 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2760 ok(r
== ERROR_SUCCESS
|| r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_SUCCESS, got %d\n", r
);
2761 if (r
== ERROR_SUCCESS
)
2763 ok(id
== 1, "Expected 1, got %d\n", id
);
2764 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2765 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2766 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2769 /* szDiskPrompt and pcchDiskPrompt are NULL */
2771 lstrcpyA(label
, "aaa");
2773 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2774 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2776 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2777 ok(id
== 1, "Expected 1, got %d\n", id
);
2778 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2779 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2781 /* szDiskPrompt is non-NULL while pcchDiskPrompt is NULL */
2783 lstrcpyA(label
, "aaa");
2785 lstrcpyA(prompt
, "bbb");
2786 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2787 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2789 ok(r
== ERROR_INVALID_PARAMETER
,
2790 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2791 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2792 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2793 ok(labelsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", labelsz
);
2794 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2796 /* pcchVolumeLabel is exactly 5 */
2797 lstrcpyA(label
, "aaa");
2799 lstrcpyA(prompt
, "bbb");
2800 promptsz
= MAX_PATH
;
2801 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2802 MSICODE_PRODUCT
, 0, NULL
, label
, &labelsz
,
2804 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
2805 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2806 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2807 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2808 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2810 /* pcchDiskPrompt is exactly 6 */
2811 lstrcpyA(label
, "aaa");
2813 lstrcpyA(prompt
, "bbb");
2815 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2816 MSICODE_PRODUCT
, 0, NULL
, label
, &labelsz
,
2818 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
2819 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2820 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2821 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2822 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2824 res
= RegSetValueExA(media
, "1", 0, REG_SZ
, (LPBYTE
)"label", 13);
2825 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2829 lstrcpyA(label
, "aaa");
2831 lstrcpyA(prompt
, "bbb");
2832 promptsz
= MAX_PATH
;
2833 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2834 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2836 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2837 ok(id
== 1, "Expected 1, got %d\n", id
);
2838 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2839 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2840 ok(!lstrcmpA(prompt
, "label"), "Expected \"label\", got \"%s\"\n", prompt
);
2841 ok(promptsz
== 5, "Expected 5, got %d\n", promptsz
);
2843 res
= RegSetValueExA(media
, "1", 0, REG_SZ
, (LPBYTE
)"label;", 13);
2844 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2846 /* semicolon, no disk prompt */
2848 lstrcpyA(label
, "aaa");
2850 lstrcpyA(prompt
, "bbb");
2851 promptsz
= MAX_PATH
;
2852 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2853 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2855 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2856 ok(id
== 1, "Expected 1, got %d\n", id
);
2857 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
2858 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
2859 ok(!lstrcmpA(prompt
, ""), "Expected \"\", got \"%s\"\n", prompt
);
2860 ok(promptsz
== 0, "Expected 0, got %d\n", promptsz
);
2862 res
= RegSetValueExA(media
, "1", 0, REG_SZ
, (LPBYTE
)";prompt", 13);
2863 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2865 /* semicolon, label doesn't exist */
2867 lstrcpyA(label
, "aaa");
2869 lstrcpyA(prompt
, "bbb");
2870 promptsz
= MAX_PATH
;
2871 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2872 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2874 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2875 ok(id
== 1, "Expected 1, got %d\n", id
);
2876 ok(!lstrcmpA(label
, ""), "Expected \"\", got \"%s\"\n", label
);
2877 ok(labelsz
== 0, "Expected 0, got %d\n", labelsz
);
2878 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
2879 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
2881 res
= RegSetValueExA(media
, "1", 0, REG_SZ
, (LPBYTE
)";", 13);
2882 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2884 /* semicolon, neither label nor disk prompt exist */
2886 lstrcpyA(label
, "aaa");
2888 lstrcpyA(prompt
, "bbb");
2889 promptsz
= MAX_PATH
;
2890 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2891 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2893 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2894 ok(id
== 1, "Expected 1, got %d\n", id
);
2895 ok(!lstrcmpA(label
, ""), "Expected \"\", got \"%s\"\n", label
);
2896 ok(labelsz
== 0, "Expected 0, got %d\n", labelsz
);
2897 ok(!lstrcmpA(prompt
, ""), "Expected \"\", got \"%s\"\n", prompt
);
2898 ok(promptsz
== 0, "Expected 0, got %d\n", promptsz
);
2901 res
= RegSetValueExA(media
, "1", 0, REG_DWORD
, (LPBYTE
)&val
, sizeof(DWORD
));
2902 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2904 /* type is REG_DWORD */
2906 lstrcpyA(label
, "aaa");
2908 lstrcpyA(prompt
, "bbb");
2909 promptsz
= MAX_PATH
;
2910 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
2911 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2913 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2914 ok(id
== 1, "Expected 1, got %d\n", id
);
2915 ok(!lstrcmpA(label
, "#42"), "Expected \"#42\", got \"%s\"\n", label
);
2916 ok(labelsz
== 3, "Expected 3, got %d\n", labelsz
);
2917 ok(!lstrcmpA(prompt
, "#42"), "Expected \"#42\", got \"%s\"\n", prompt
);
2918 ok(promptsz
== 3, "Expected 3, got %d\n", promptsz
);
2920 RegDeleteValueA(media
, "1");
2921 RegDeleteValueA(media
, "2");
2922 RegDeleteValueA(media
, "4");
2923 RegDeleteKeyA(media
, "");
2925 RegDeleteKeyA(source
, "");
2926 RegCloseKey(source
);
2927 RegDeleteKeyA(userkey
, "");
2928 RegCloseKey(userkey
);
2930 /* MSIINSTALLCONTEXT_USERMANAGED */
2932 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2933 lstrcatA(keypath
, usersid
);
2934 lstrcatA(keypath
, "\\Installer\\Products\\");
2935 lstrcatA(keypath
, prod_squashed
);
2937 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &userkey
);
2938 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2940 /* user product key exists */
2941 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
2942 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2944 ok(r
== ERROR_BAD_CONFIGURATION
,
2945 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
2947 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
2948 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2950 /* SourceList key exists */
2952 lstrcpyA(label
, "aaa");
2953 labelsz
= 0xdeadbeef;
2954 lstrcpyA(prompt
, "bbb");
2955 promptsz
= 0xdeadbeef;
2956 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
2957 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2959 ok(r
== ERROR_NO_MORE_ITEMS
,
2960 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
2961 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2962 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2963 ok(labelsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz
);
2964 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2965 ok(promptsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz
);
2967 res
= RegCreateKeyA(source
, "Media", &media
);
2968 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2970 /* Media key exists */
2972 lstrcpyA(label
, "aaa");
2973 labelsz
= 0xdeadbeef;
2974 lstrcpyA(prompt
, "bbb");
2975 promptsz
= 0xdeadbeef;
2976 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
2977 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2979 ok(r
== ERROR_NO_MORE_ITEMS
,
2980 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
2981 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
2982 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
2983 ok(labelsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz
);
2984 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
2985 ok(promptsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz
);
2987 res
= RegSetValueExA(media
, "2", 0, REG_SZ
, (LPBYTE
)"label;prompt", 13);
2988 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2990 /* disk exists, but no id 1 */
2992 lstrcpyA(label
, "aaa");
2994 lstrcpyA(prompt
, "bbb");
2995 promptsz
= MAX_PATH
;
2996 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
2997 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
2999 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3000 ok(id
== 2, "Expected 2, got %d\n", id
);
3001 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
3002 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
3003 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
3004 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
3006 RegDeleteValueA(media
, "2");
3007 RegDeleteKeyA(media
, "");
3009 RegDeleteKeyA(source
, "");
3010 RegCloseKey(source
);
3011 RegDeleteKeyA(userkey
, "");
3012 RegCloseKey(userkey
);
3014 /* MSIINSTALLCONTEXT_MACHINE */
3016 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3017 lstrcatA(keypath
, prod_squashed
);
3019 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
3020 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3022 /* machine product key exists */
3023 r
= pMsiSourceListEnumMediaDisksA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3024 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
3026 ok(r
== ERROR_BAD_CONFIGURATION
,
3027 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
3029 res
= RegCreateKeyA(prodkey
, "SourceList", &source
);
3030 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3032 /* SourceList key exists */
3034 lstrcpyA(label
, "aaa");
3035 labelsz
= 0xdeadbeef;
3036 lstrcpyA(prompt
, "bbb");
3037 promptsz
= 0xdeadbeef;
3038 r
= pMsiSourceListEnumMediaDisksA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3039 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
3041 ok(r
== ERROR_NO_MORE_ITEMS
,
3042 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
3043 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
3044 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
3045 ok(labelsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz
);
3046 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
3047 ok(promptsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz
);
3049 res
= RegCreateKeyA(source
, "Media", &media
);
3050 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3052 /* Media key exists */
3054 lstrcpyA(label
, "aaa");
3055 labelsz
= 0xdeadbeef;
3056 lstrcpyA(prompt
, "bbb");
3057 promptsz
= 0xdeadbeef;
3058 r
= pMsiSourceListEnumMediaDisksA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3059 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
3061 ok(r
== ERROR_NO_MORE_ITEMS
,
3062 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
3063 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
3064 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
3065 ok(labelsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", labelsz
);
3066 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
3067 ok(promptsz
== 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", promptsz
);
3069 res
= RegSetValueExA(media
, "2", 0, REG_SZ
, (LPBYTE
)"label;prompt", 13);
3070 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3072 /* disk exists, but no id 1 */
3074 lstrcpyA(label
, "aaa");
3076 lstrcpyA(prompt
, "bbb");
3077 promptsz
= MAX_PATH
;
3078 r
= pMsiSourceListEnumMediaDisksA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
3079 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
3081 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3082 ok(id
== 2, "Expected 2, got %d\n", id
);
3083 ok(!lstrcmpA(label
, "label"), "Expected \"label\", got \"%s\"\n", label
);
3084 ok(labelsz
== 5, "Expected 5, got %d\n", labelsz
);
3085 ok(!lstrcmpA(prompt
, "prompt"), "Expected \"prompt\", got \"%s\"\n", prompt
);
3086 ok(promptsz
== 6, "Expected 6, got %d\n", promptsz
);
3088 /* szUserSid is non-NULL */
3090 lstrcpyA(label
, "aaa");
3092 lstrcpyA(prompt
, "bbb");
3093 promptsz
= MAX_PATH
;
3094 r
= pMsiSourceListEnumMediaDisksA(prodcode
, usersid
, MSIINSTALLCONTEXT_MACHINE
,
3095 MSICODE_PRODUCT
, 0, &id
, label
, &labelsz
,
3097 ok(r
== ERROR_INVALID_PARAMETER
,
3098 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3099 ok(id
== 0xbeef, "Expected 0xbeef, got %d\n", id
);
3100 ok(!lstrcmpA(label
, "aaa"), "Expected \"aaa\", got \"%s\"\n", label
);
3101 ok(labelsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", labelsz
);
3102 ok(!lstrcmpA(prompt
, "bbb"), "Expected \"bbb\", got \"%s\"\n", prompt
);
3103 ok(promptsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", promptsz
);
3105 RegDeleteValueA(media
, "2");
3106 RegDeleteKeyA(media
, "");
3108 RegDeleteKeyA(source
, "");
3109 RegCloseKey(source
);
3110 RegDeleteKeyA(prodkey
, "");
3111 RegCloseKey(prodkey
);
3114 static void test_MsiSourceListAddSource(void)
3116 CHAR prodcode
[MAX_PATH
];
3117 CHAR prod_squashed
[MAX_PATH
];
3118 CHAR keypath
[MAX_PATH
*2];
3119 CHAR username
[MAX_PATH
];
3123 HKEY prodkey
, userkey
;
3127 if (!pMsiSourceListAddSourceA
)
3129 skip("Skipping MsiSourceListAddSourceA tests\n");
3133 create_test_guid(prodcode
, prod_squashed
);
3134 if (!get_user_sid(&usersid
))
3136 skip("User SID not available -> skipping MsiSourceListAddSourceA tests\n");
3140 /* MACHINENAME\username */
3142 GetComputerNameA(username
, &size
);
3143 lstrcatA(username
, "\\");
3144 ptr
= username
+ lstrlenA(username
);
3146 GetUserNameA(ptr
, &size
);
3148 /* GetLastError is not set by the function */
3150 /* NULL szProduct */
3151 r
= pMsiSourceListAddSourceA(NULL
, username
, 0, "source");
3152 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3154 /* empty szProduct */
3155 r
= pMsiSourceListAddSourceA("", username
, 0, "source");
3156 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3158 /* garbage szProduct */
3159 r
= pMsiSourceListAddSourceA("garbage", username
, 0, "source");
3160 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3162 /* guid without brackets */
3163 r
= pMsiSourceListAddSourceA("51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA", username
, 0, "source");
3164 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3166 /* guid with brackets */
3167 r
= pMsiSourceListAddSourceA("{51CD2AD5-0482-4C46-8DDD-0ED1022AA1AA}", username
, 0, "source");
3168 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
3170 /* dwReserved is not 0 */
3171 r
= pMsiSourceListAddSourceA(prodcode
, username
, 42, "source");
3172 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3174 /* szSource is NULL */
3175 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, NULL
);
3176 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3178 /* szSource is empty */
3179 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "");
3180 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3182 /* MSIINSTALLCONTEXT_USERMANAGED */
3184 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3185 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
3187 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
3188 lstrcatA(keypath
, usersid
);
3189 lstrcatA(keypath
, "\\Installer\\Products\\");
3190 lstrcatA(keypath
, prod_squashed
);
3192 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &userkey
);
3193 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3195 /* user product key exists */
3196 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3197 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
3199 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
3200 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3202 /* SourceList key exists */
3203 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3204 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3206 /* Net key is created */
3207 res
= RegOpenKeyA(source
, "Net", &net
);
3208 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3210 /* LastUsedSource does not exist and it is not created */
3211 res
= RegQueryValueExA(source
, "LastUsedSource", 0, NULL
, NULL
, NULL
);
3212 ok(res
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res
);
3214 CHECK_REG_STR(net
, "1", "source\\");
3216 RegDeleteValueA(net
, "1");
3217 RegDeleteKeyA(net
, "");
3220 res
= RegSetValueExA(source
, "LastUsedSource", 0, REG_SZ
, (LPBYTE
)"blah", 5);
3221 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3223 /* LastUsedSource value exists */
3224 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3225 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3227 /* Net key is created */
3228 res
= RegOpenKeyA(source
, "Net", &net
);
3229 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3231 CHECK_REG_STR(source
, "LastUsedSource", "blah");
3232 CHECK_REG_STR(net
, "1", "source\\");
3234 RegDeleteValueA(net
, "1");
3235 RegDeleteKeyA(net
, "");
3238 res
= RegSetValueExA(source
, "LastUsedSource", 0, REG_SZ
, (LPBYTE
)"5", 2);
3239 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3241 /* LastUsedSource is an integer */
3242 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3243 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3245 /* Net key is created */
3246 res
= RegOpenKeyA(source
, "Net", &net
);
3247 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3249 CHECK_REG_STR(source
, "LastUsedSource", "5");
3250 CHECK_REG_STR(net
, "1", "source\\");
3252 /* Add a second source, has trailing backslash */
3253 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "another\\");
3254 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3256 CHECK_REG_STR(source
, "LastUsedSource", "5");
3257 CHECK_REG_STR(net
, "1", "source\\");
3258 CHECK_REG_STR(net
, "2", "another\\");
3260 res
= RegSetValueExA(source
, "LastUsedSource", 0, REG_SZ
, (LPBYTE
)"2", 2);
3261 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3263 /* LastUsedSource is in the source list */
3264 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "third/");
3265 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3267 CHECK_REG_STR(source
, "LastUsedSource", "2");
3268 CHECK_REG_STR(net
, "1", "source\\");
3269 CHECK_REG_STR(net
, "2", "another\\");
3270 CHECK_REG_STR(net
, "3", "third/\\");
3272 RegDeleteValueA(net
, "1");
3273 RegDeleteValueA(net
, "2");
3274 RegDeleteValueA(net
, "3");
3275 RegDeleteKeyA(net
, "");
3277 RegDeleteKeyA(source
, "");
3278 RegCloseKey(source
);
3279 RegDeleteKeyA(userkey
, "");
3280 RegCloseKey(userkey
);
3282 /* MSIINSTALLCONTEXT_USERUNMANAGED */
3284 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3285 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
3287 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3288 lstrcatA(keypath
, prod_squashed
);
3290 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
3291 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3293 /* user product key exists */
3294 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3295 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
3297 res
= RegCreateKeyA(userkey
, "SourceList", &source
);
3298 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3300 /* SourceList key exists */
3301 r
= pMsiSourceListAddSourceA(prodcode
, username
, 0, "source");
3302 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3304 /* Net key is created */
3305 res
= RegOpenKeyA(source
, "Net", &net
);
3306 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3308 CHECK_REG_STR(net
, "1", "source\\");
3310 RegDeleteValueA(net
, "1");
3311 RegDeleteKeyA(net
, "");
3313 RegDeleteKeyA(source
, "");
3314 RegCloseKey(source
);
3315 RegDeleteKeyA(userkey
, "");
3316 RegCloseKey(userkey
);
3318 /* MSIINSTALLCONTEXT_MACHINE */
3320 r
= pMsiSourceListAddSourceA(prodcode
, NULL
, 0, "source");
3321 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
3323 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3324 lstrcatA(keypath
, prod_squashed
);
3326 res
= RegCreateKeyA(HKEY_LOCAL_MACHINE
, keypath
, &prodkey
);
3327 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3329 /* machine product key exists */
3330 r
= pMsiSourceListAddSourceA(prodcode
, NULL
, 0, "source");
3331 ok(r
== ERROR_BAD_CONFIGURATION
, "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
3333 res
= RegCreateKeyA(prodkey
, "SourceList", &source
);
3334 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3336 /* SourceList key exists */
3337 r
= pMsiSourceListAddSourceA(prodcode
, NULL
, 0, "source");
3338 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3340 /* Net key is created */
3341 res
= RegOpenKeyA(source
, "Net", &net
);
3342 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3344 CHECK_REG_STR(net
, "1", "source\\");
3346 /* empty szUserName */
3347 r
= pMsiSourceListAddSourceA(prodcode
, "", 0, "another");
3348 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3350 CHECK_REG_STR(net
, "1", "source\\");
3351 CHECK_REG_STR(net
, "2", "another\\");
3353 RegDeleteValueA(net
, "2");
3354 RegDeleteValueA(net
, "1");
3355 RegDeleteKeyA(net
, "");
3357 RegDeleteKeyA(source
, "");
3358 RegCloseKey(source
);
3359 RegDeleteKeyA(prodkey
, "");
3360 RegCloseKey(prodkey
);
3365 init_functionpointers();
3367 test_MsiSourceListGetInfo();
3368 test_MsiSourceListAddSourceEx();
3369 test_MsiSourceListEnumSources();
3370 test_MsiSourceListSetInfo();
3371 test_MsiSourceListAddMediaDisk();
3372 test_MsiSourceListEnumMediaDisks();
3373 test_MsiSourceListAddSource();