gdiplus: Implement GdipBeginContainer.
[wine.git] / dlls / msi / tests / msi.c
blobfeeb1ff8e72da118b3398e3cba98aa460a158c35
1 /*
2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
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
22 #define COBJMACROS
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msi.h>
27 #include <msiquery.h>
28 #include <msidefs.h>
29 #include <sddl.h>
30 #include <fci.h>
31 #include <shellapi.h>
32 #include <objidl.h>
34 #include "wine/test.h"
36 static BOOL is_wow64;
37 static const char msifile[] = "winetest.msi";
38 static const WCHAR msifileW[] = {'w','i','n','e','t','e','s','t','.','m','s','i',0};
39 static char CURR_DIR[MAX_PATH];
40 static char PROG_FILES_DIR[MAX_PATH];
41 static char PROG_FILES_DIR_NATIVE[MAX_PATH];
42 static char COMMON_FILES_DIR[MAX_PATH];
43 static char WINDOWS_DIR[MAX_PATH];
45 static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL);
46 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
47 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
48 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
49 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
51 static INSTALLSTATE (WINAPI *pMsiGetComponentPathA)
52 (LPCSTR, LPCSTR, LPSTR, DWORD*);
53 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)
54 (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
55 static INSTALLSTATE (WINAPI *pMsiProvideComponentA)
56 (LPCSTR, LPCSTR, LPCSTR, DWORD, LPSTR, LPDWORD);
57 static INSTALLSTATE (WINAPI *pMsiProvideComponentW)
58 (LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPWSTR, LPDWORD);
59 static UINT (WINAPI *pMsiGetFileHashA)
60 (LPCSTR, DWORD, PMSIFILEHASHINFO);
61 static UINT (WINAPI *pMsiGetProductInfoExA)
62 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, LPDWORD);
63 static UINT (WINAPI *pMsiOpenPackageExA)
64 (LPCSTR, DWORD, MSIHANDLE*);
65 static UINT (WINAPI *pMsiOpenPackageExW)
66 (LPCWSTR, DWORD, MSIHANDLE*);
67 static UINT (WINAPI *pMsiEnumPatchesExA)
68 (LPCSTR, LPCSTR, DWORD, DWORD, DWORD, LPSTR, LPSTR,
69 MSIINSTALLCONTEXT*, LPSTR, LPDWORD);
70 static UINT (WINAPI *pMsiQueryComponentStateA)
71 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
72 static INSTALLSTATE (WINAPI *pMsiUseFeatureExA)
73 (LPCSTR, LPCSTR ,DWORD, DWORD);
74 static UINT (WINAPI *pMsiGetPatchInfoExA)
75 (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, DWORD *);
76 static UINT (WINAPI *pMsiEnumProductsExA)
77 (LPCSTR, LPCSTR, DWORD, DWORD, CHAR[39], MSIINSTALLCONTEXT *, LPSTR, LPDWORD);
78 static UINT (WINAPI *pMsiEnumComponentsExA)
79 (LPCSTR, DWORD, DWORD, CHAR[39], MSIINSTALLCONTEXT *, LPSTR, LPDWORD);
80 static UINT (WINAPI *pMsiSetExternalUIRecord)
81 (INSTALLUI_HANDLER_RECORD, DWORD, LPVOID, PINSTALLUI_HANDLER_RECORD);
82 static UINT (WINAPI *pMsiSourceListGetInfoA)
83 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
85 static void init_functionpointers(void)
87 HMODULE hmsi = GetModuleHandleA("msi.dll");
88 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
89 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
91 #define GET_PROC(dll, func) \
92 p ## func = (void *)GetProcAddress(dll, #func); \
93 if(!p ## func) \
94 trace("GetProcAddress(%s) failed\n", #func);
96 GET_PROC(hmsi, MsiGetComponentPathA)
97 GET_PROC(hmsi, MsiGetComponentPathExA);
98 GET_PROC(hmsi, MsiProvideComponentA)
99 GET_PROC(hmsi, MsiProvideComponentW)
100 GET_PROC(hmsi, MsiGetFileHashA)
101 GET_PROC(hmsi, MsiGetProductInfoExA)
102 GET_PROC(hmsi, MsiOpenPackageExA)
103 GET_PROC(hmsi, MsiOpenPackageExW)
104 GET_PROC(hmsi, MsiEnumPatchesExA)
105 GET_PROC(hmsi, MsiQueryComponentStateA)
106 GET_PROC(hmsi, MsiSetExternalUIRecord)
107 GET_PROC(hmsi, MsiUseFeatureExA)
108 GET_PROC(hmsi, MsiGetPatchInfoExA)
109 GET_PROC(hmsi, MsiEnumProductsExA)
110 GET_PROC(hmsi, MsiEnumComponentsExA)
111 GET_PROC(hmsi, MsiSourceListGetInfoA)
113 GET_PROC(hadvapi32, CheckTokenMembership);
114 GET_PROC(hadvapi32, ConvertSidToStringSidA)
115 GET_PROC(hadvapi32, OpenProcessToken);
116 GET_PROC(hadvapi32, RegDeleteKeyExA)
117 GET_PROC(hkernel32, IsWow64Process)
119 #undef GET_PROC
122 static BOOL get_system_dirs(void)
124 HKEY hkey;
125 DWORD type, size;
127 if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
128 return FALSE;
130 size = MAX_PATH;
131 if (RegQueryValueExA(hkey, "ProgramFilesDir (x86)", 0, &type, (LPBYTE)PROG_FILES_DIR, &size) &&
132 RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR, &size))
134 RegCloseKey(hkey);
135 return FALSE;
137 size = MAX_PATH;
138 if (RegQueryValueExA(hkey, "CommonFilesDir (x86)", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size) &&
139 RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)COMMON_FILES_DIR, &size))
141 RegCloseKey(hkey);
142 return FALSE;
144 size = MAX_PATH;
145 if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)PROG_FILES_DIR_NATIVE, &size))
147 RegCloseKey(hkey);
148 return FALSE;
150 RegCloseKey(hkey);
151 if (!GetWindowsDirectoryA(WINDOWS_DIR, MAX_PATH)) return FALSE;
152 return TRUE;
155 static BOOL file_exists(const char *file)
157 return GetFileAttributesA(file) != INVALID_FILE_ATTRIBUTES;
160 static BOOL pf_exists(const char *file)
162 char path[MAX_PATH];
164 lstrcpyA(path, PROG_FILES_DIR);
165 lstrcatA(path, "\\");
166 lstrcatA(path, file);
167 return file_exists(path);
170 static BOOL delete_pf(const char *rel_path, BOOL is_file)
172 char path[MAX_PATH];
174 lstrcpyA(path, PROG_FILES_DIR);
175 lstrcatA(path, "\\");
176 lstrcatA(path, rel_path);
178 if (is_file)
179 return DeleteFileA(path);
180 else
181 return RemoveDirectoryA(path);
184 static BOOL is_process_limited(void)
186 SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
187 PSID Group = NULL;
188 BOOL IsInGroup;
189 HANDLE token;
191 if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE;
193 if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
194 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) ||
195 !pCheckTokenMembership(NULL, Group, &IsInGroup))
197 trace("Could not check if the current user is an administrator\n");
198 FreeSid(Group);
199 return FALSE;
201 FreeSid(Group);
203 if (!IsInGroup)
205 /* Only administrators have enough privileges for these tests */
206 return TRUE;
209 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
211 BOOL ret;
212 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
213 DWORD size;
215 ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
216 CloseHandle(token);
217 return (ret && type == TokenElevationTypeLimited);
219 return FALSE;
222 /* cabinet definitions */
224 /* make the max size large so there is only one cab file */
225 #define MEDIA_SIZE 0x7FFFFFFF
226 #define FOLDER_THRESHOLD 900000
228 /* the FCI callbacks */
230 static void * CDECL mem_alloc(ULONG cb)
232 return HeapAlloc(GetProcessHeap(), 0, cb);
235 static void CDECL mem_free(void *memory)
237 HeapFree(GetProcessHeap(), 0, memory);
240 static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
242 sprintf(pccab->szCab, pv, pccab->iCab);
243 return TRUE;
246 static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
248 return 0;
251 static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
252 BOOL fContinuation, void *pv)
254 return 0;
257 static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
259 HANDLE handle;
260 DWORD dwAccess = 0;
261 DWORD dwShareMode = 0;
262 DWORD dwCreateDisposition = OPEN_EXISTING;
264 dwAccess = GENERIC_READ | GENERIC_WRITE;
265 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
266 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
268 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
269 dwCreateDisposition = OPEN_EXISTING;
270 else
271 dwCreateDisposition = CREATE_NEW;
273 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
274 dwCreateDisposition, 0, NULL);
276 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
278 return (INT_PTR)handle;
281 static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
283 HANDLE handle = (HANDLE)hf;
284 DWORD dwRead;
285 BOOL res;
287 res = ReadFile(handle, memory, cb, &dwRead, NULL);
288 ok(res, "Failed to ReadFile\n");
290 return dwRead;
293 static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
295 HANDLE handle = (HANDLE)hf;
296 DWORD dwWritten;
297 BOOL res;
299 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
300 ok(res, "Failed to WriteFile\n");
302 return dwWritten;
305 static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
307 HANDLE handle = (HANDLE)hf;
308 ok(CloseHandle(handle), "Failed to CloseHandle\n");
310 return 0;
313 static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
315 HANDLE handle = (HANDLE)hf;
316 DWORD ret;
318 ret = SetFilePointer(handle, dist, NULL, seektype);
319 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
321 return ret;
324 static int CDECL fci_delete(char *pszFile, int *err, void *pv)
326 BOOL ret = DeleteFileA(pszFile);
327 ok(ret, "Failed to DeleteFile %s\n", pszFile);
329 return 0;
332 static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
334 LPSTR tempname;
336 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
337 GetTempFileNameA(".", "xx", 0, tempname);
339 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
341 lstrcpyA(pszTempName, tempname);
342 HeapFree(GetProcessHeap(), 0, tempname);
343 return TRUE;
346 HeapFree(GetProcessHeap(), 0, tempname);
348 return FALSE;
351 static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
352 USHORT *pattribs, int *err, void *pv)
354 BY_HANDLE_FILE_INFORMATION finfo;
355 FILETIME filetime;
356 HANDLE handle;
357 DWORD attrs;
358 BOOL res;
360 handle = CreateFileA(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
361 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
362 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
364 res = GetFileInformationByHandle(handle, &finfo);
365 ok(res, "Expected GetFileInformationByHandle to succeed\n");
367 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
368 FileTimeToDosDateTime(&filetime, pdate, ptime);
370 attrs = GetFileAttributesA(pszName);
371 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
373 return (INT_PTR)handle;
376 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
378 char path[MAX_PATH];
379 char filename[MAX_PATH];
381 lstrcpyA(path, CURR_DIR);
382 lstrcatA(path, "\\");
383 lstrcatA(path, file);
385 lstrcpyA(filename, file);
387 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
388 progress, get_open_info, compress);
391 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
393 ZeroMemory(pCabParams, sizeof(CCAB));
395 pCabParams->cb = max_size;
396 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
397 pCabParams->setID = 0xbeef;
398 pCabParams->iCab = 1;
399 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
400 lstrcatA(pCabParams->szCabPath, "\\");
401 lstrcpyA(pCabParams->szCab, name);
404 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
406 CCAB cabParams;
407 LPCSTR ptr;
408 HFCI hfci;
409 ERF erf;
410 BOOL res;
412 set_cab_parameters(&cabParams, name, max_size);
414 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
415 fci_read, fci_write, fci_close, fci_seek, fci_delete,
416 get_temp_file, &cabParams, NULL);
418 ok(hfci != NULL, "Failed to create an FCI context\n");
420 ptr = files;
421 while (*ptr)
423 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
424 ok(res, "Failed to add file: %s\n", ptr);
425 ptr += lstrlenA(ptr) + 1;
428 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
429 ok(res, "Failed to flush the cabinet\n");
431 res = FCIDestroy(hfci);
432 ok(res, "Failed to destroy the cabinet\n");
435 static BOOL add_cabinet_storage(LPCSTR db, LPCSTR cabinet)
437 WCHAR dbW[MAX_PATH], cabinetW[MAX_PATH];
438 IStorage *stg;
439 IStream *stm;
440 HRESULT hr;
441 HANDLE handle;
443 MultiByteToWideChar(CP_ACP, 0, db, -1, dbW, MAX_PATH);
444 hr = StgOpenStorage(dbW, NULL, STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
445 if (FAILED(hr))
446 return FALSE;
448 MultiByteToWideChar(CP_ACP, 0, cabinet, -1, cabinetW, MAX_PATH);
449 hr = IStorage_CreateStream(stg, cabinetW, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
450 if (FAILED(hr))
452 IStorage_Release(stg);
453 return FALSE;
456 handle = CreateFileW(cabinetW, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
457 if (handle != INVALID_HANDLE_VALUE)
459 DWORD count;
460 char buffer[1024];
461 if (ReadFile(handle, buffer, sizeof(buffer), &count, NULL))
462 IStream_Write(stm, buffer, count, &count);
463 CloseHandle(handle);
466 IStream_Release(stm);
467 IStorage_Release(stg);
469 return TRUE;
472 static void delete_cab_files(void)
474 SHFILEOPSTRUCTA shfl;
475 CHAR path[MAX_PATH+10];
477 lstrcpyA(path, CURR_DIR);
478 lstrcatA(path, "\\*.cab");
479 path[strlen(path) + 1] = '\0';
481 shfl.hwnd = NULL;
482 shfl.wFunc = FO_DELETE;
483 shfl.pFrom = path;
484 shfl.pTo = NULL;
485 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
487 SHFileOperationA(&shfl);
490 /* msi database data */
492 static const char directory_dat[] =
493 "Directory\tDirectory_Parent\tDefaultDir\n"
494 "s72\tS72\tl255\n"
495 "Directory\tDirectory\n"
496 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
497 "ProgramFilesFolder\tTARGETDIR\t.\n"
498 "TARGETDIR\t\tSourceDir";
500 static const char component_dat[] =
501 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
502 "s72\tS38\ts72\ti2\tS255\tS72\n"
503 "Component\tComponent\n"
504 "One\t{8F5BAEEF-DD92-40AC-9397-BE3CF9F97C81}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n";
506 static const char feature_dat[] =
507 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
508 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
509 "Feature\tFeature\n"
510 "One\t\tOne\tOne\t1\t3\tMSITESTDIR\t0\n"
511 "Two\t\t\t\t2\t1\tTARGETDIR\t0\n";
513 static const char feature_comp_dat[] =
514 "Feature_\tComponent_\n"
515 "s38\ts72\n"
516 "FeatureComponents\tFeature_\tComponent_\n"
517 "One\tOne\n";
519 static const char file_dat[] =
520 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
521 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
522 "File\tFile\n"
523 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n";
525 static const char install_exec_seq_dat[] =
526 "Action\tCondition\tSequence\n"
527 "s72\tS255\tI2\n"
528 "InstallExecuteSequence\tAction\n"
529 "ValidateProductID\t\t700\n"
530 "CostInitialize\t\t800\n"
531 "FileCost\t\t900\n"
532 "CostFinalize\t\t1000\n"
533 "InstallValidate\t\t1400\n"
534 "InstallInitialize\t\t1500\n"
535 "ProcessComponents\t\t1600\n"
536 "UnpublishFeatures\t\t1800\n"
537 "RemoveFiles\t\t3500\n"
538 "InstallFiles\t\t4000\n"
539 "RegisterProduct\t\t6100\n"
540 "PublishFeatures\t\t6300\n"
541 "PublishProduct\t\t6400\n"
542 "InstallFinalize\t\t6600";
544 static const char media_dat[] =
545 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
546 "i2\ti4\tL64\tS255\tS32\tS72\n"
547 "Media\tDiskId\n"
548 "1\t1\t\t\tDISK1\t\n";
550 static const char property_dat[] =
551 "Property\tValue\n"
552 "s72\tl0\n"
553 "Property\tProperty\n"
554 "INSTALLLEVEL\t3\n"
555 "Manufacturer\tWine\n"
556 "ProductCode\t{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}\n"
557 "ProductName\tMSITEST\n"
558 "ProductVersion\t1.1.1\n"
559 "UpgradeCode\t{9574448F-9B86-4E07-B6F6-8D199DA12127}\n"
560 "MSIFASTINSTALL\t1\n";
562 static const char mcp_component_dat[] =
563 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
564 "s72\tS38\ts72\ti2\tS255\tS72\n"
565 "Component\tComponent\n"
566 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
567 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
568 "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";
570 static const char mcp_feature_dat[] =
571 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
572 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
573 "Feature\tFeature\n"
574 "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
575 "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
576 "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";
578 static const char mcp_feature_comp_dat[] =
579 "Feature_\tComponent_\n"
580 "s38\ts72\n"
581 "FeatureComponents\tFeature_\tComponent_\n"
582 "hydroxyl\thydrogen\n"
583 "heliox\thelium\n"
584 "lithia\tlithium";
586 static const char mcp_file_dat[] =
587 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
588 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
589 "File\tFile\n"
590 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
591 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
592 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
594 static const char lus_component_dat[] =
595 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
596 "s72\tS38\ts72\ti2\tS255\tS72\n"
597 "Component\tComponent\n"
598 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
600 static const char lus_feature_dat[] =
601 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
602 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
603 "Feature\tFeature\n"
604 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
605 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
607 static const char lus_file_dat[] =
608 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
609 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
610 "File\tFile\n"
611 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
613 static const char lus_feature_comp_dat[] =
614 "Feature_\tComponent_\n"
615 "s38\ts72\n"
616 "FeatureComponents\tFeature_\tComponent_\n"
617 "feature\tmaximus\n"
618 "montecristo\tmaximus";
620 static const char lus_install_exec_seq_dat[] =
621 "Action\tCondition\tSequence\n"
622 "s72\tS255\tI2\n"
623 "InstallExecuteSequence\tAction\n"
624 "ValidateProductID\t\t700\n"
625 "CostInitialize\t\t800\n"
626 "FileCost\t\t900\n"
627 "CostFinalize\t\t1000\n"
628 "InstallValidate\t\t1400\n"
629 "InstallInitialize\t\t1500\n"
630 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
631 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
632 "RemoveFiles\t\t3500\n"
633 "InstallFiles\t\t4000\n"
634 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
635 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
636 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
637 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
638 "InstallFinalize\t\t6600";
640 static const char lus0_media_dat[] =
641 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
642 "i2\ti4\tL64\tS255\tS32\tS72\n"
643 "Media\tDiskId\n"
644 "1\t1\t\t\tDISK1\t\n";
646 static const char lus1_media_dat[] =
647 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
648 "i2\ti4\tL64\tS255\tS32\tS72\n"
649 "Media\tDiskId\n"
650 "1\t1\t\ttest1.cab\tDISK1\t\n";
652 static const char lus2_media_dat[] =
653 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
654 "i2\ti4\tL64\tS255\tS32\tS72\n"
655 "Media\tDiskId\n"
656 "1\t1\t\t#test1.cab\tDISK1\t\n";
658 static const char spf_custom_action_dat[] =
659 "Action\tType\tSource\tTarget\tISComments\n"
660 "s72\ti2\tS64\tS0\tS255\n"
661 "CustomAction\tAction\n"
662 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
664 static const char spf_install_exec_seq_dat[] =
665 "Action\tCondition\tSequence\n"
666 "s72\tS255\tI2\n"
667 "InstallExecuteSequence\tAction\n"
668 "CostFinalize\t\t1000\n"
669 "CostInitialize\t\t800\n"
670 "FileCost\t\t900\n"
671 "SetFolderProp\t\t950\n"
672 "InstallFiles\t\t4000\n"
673 "InstallServices\t\t5000\n"
674 "InstallFinalize\t\t6600\n"
675 "InstallInitialize\t\t1500\n"
676 "InstallValidate\t\t1400\n"
677 "LaunchConditions\t\t100";
679 static const char spf_install_ui_seq_dat[] =
680 "Action\tCondition\tSequence\n"
681 "s72\tS255\tI2\n"
682 "InstallUISequence\tAction\n"
683 "CostInitialize\t\t800\n"
684 "FileCost\t\t900\n"
685 "CostFinalize\t\t1000\n"
686 "ExecuteAction\t\t1100\n";
688 static const char sd_file_dat[] =
689 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
690 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
691 "File\tFile\n"
692 "sourcedir.txt\tsourcedir\tsourcedir.txt\t1000\t\t\t8192\t1\n";
694 static const char sd_feature_dat[] =
695 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
696 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
697 "Feature\tFeature\n"
698 "sourcedir\t\t\tsourcedir feature\t1\t2\tMSITESTDIR\t0\n";
700 static const char sd_feature_comp_dat[] =
701 "Feature_\tComponent_\n"
702 "s38\ts72\n"
703 "FeatureComponents\tFeature_\tComponent_\n"
704 "sourcedir\tsourcedir\n";
706 static const char sd_component_dat[] =
707 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
708 "s72\tS38\ts72\ti2\tS255\tS72\n"
709 "Component\tComponent\n"
710 "sourcedir\t{DD422F92-3ED8-49B5-A0B7-F266F98357DF}\tMSITESTDIR\t0\t\tsourcedir.txt\n";
712 static const char sd_install_ui_seq_dat[] =
713 "Action\tCondition\tSequence\n"
714 "s72\tS255\tI2\n"
715 "InstallUISequence\tAction\n"
716 "TestSourceDirProp1\tnot SourceDir and not SOURCEDIR and not Installed\t99\n"
717 "AppSearch\t\t100\n"
718 "TestSourceDirProp2\tnot SourceDir and not SOURCEDIR and not Installed\t101\n"
719 "LaunchConditions\tnot Installed \t110\n"
720 "TestSourceDirProp3\tnot SourceDir and not SOURCEDIR and not Installed\t111\n"
721 "FindRelatedProducts\t\t120\n"
722 "TestSourceDirProp4\tnot SourceDir and not SOURCEDIR and not Installed\t121\n"
723 "CCPSearch\t\t130\n"
724 "TestSourceDirProp5\tnot SourceDir and not SOURCEDIR and not Installed\t131\n"
725 "RMCCPSearch\t\t140\n"
726 "TestSourceDirProp6\tnot SourceDir and not SOURCEDIR and not Installed\t141\n"
727 "ValidateProductID\t\t150\n"
728 "TestSourceDirProp7\tnot SourceDir and not SOURCEDIR and not Installed\t151\n"
729 "CostInitialize\t\t800\n"
730 "TestSourceDirProp8\tnot SourceDir and not SOURCEDIR and not Installed\t801\n"
731 "FileCost\t\t900\n"
732 "TestSourceDirProp9\tnot SourceDir and not SOURCEDIR and not Installed\t901\n"
733 "IsolateComponents\t\t1000\n"
734 "TestSourceDirProp10\tnot SourceDir and not SOURCEDIR and not Installed\t1001\n"
735 "CostFinalize\t\t1100\n"
736 "TestSourceDirProp11\tnot SourceDir and not SOURCEDIR and not Installed\t1101\n"
737 "MigrateFeatureStates\t\t1200\n"
738 "TestSourceDirProp12\tnot SourceDir and not SOURCEDIR and not Installed\t1201\n"
739 "ExecuteAction\t\t1300\n"
740 "TestSourceDirProp13\tnot SourceDir and not SOURCEDIR and not Installed\t1301\n";
742 static const char sd_install_exec_seq_dat[] =
743 "Action\tCondition\tSequence\n"
744 "s72\tS255\tI2\n"
745 "InstallExecuteSequence\tAction\n"
746 "TestSourceDirProp14\tSourceDir and SOURCEDIR and not Installed\t99\n"
747 "LaunchConditions\t\t100\n"
748 "TestSourceDirProp15\tSourceDir and SOURCEDIR and not Installed\t101\n"
749 "ValidateProductID\t\t700\n"
750 "TestSourceDirProp16\tSourceDir and SOURCEDIR and not Installed\t701\n"
751 "CostInitialize\t\t800\n"
752 "TestSourceDirProp17\tSourceDir and SOURCEDIR and not Installed\t801\n"
753 "ResolveSource\tResolveSource and not Installed\t850\n"
754 "TestSourceDirProp18\tResolveSource and not SourceDir and not SOURCEDIR and not Installed\t851\n"
755 "TestSourceDirProp19\tnot ResolveSource and SourceDir and SOURCEDIR and not Installed\t852\n"
756 "FileCost\t\t900\n"
757 "TestSourceDirProp20\tSourceDir and SOURCEDIR and not Installed\t901\n"
758 "IsolateComponents\t\t1000\n"
759 "TestSourceDirProp21\tSourceDir and SOURCEDIR and not Installed\t1001\n"
760 "CostFinalize\t\t1100\n"
761 "TestSourceDirProp22\tSourceDir and SOURCEDIR and not Installed\t1101\n"
762 "MigrateFeatureStates\t\t1200\n"
763 "TestSourceDirProp23\tSourceDir and SOURCEDIR and not Installed\t1201\n"
764 "InstallValidate\t\t1400\n"
765 "TestSourceDirProp24\tSourceDir and SOURCEDIR and not Installed\t1401\n"
766 "InstallInitialize\t\t1500\n"
767 "TestSourceDirProp25\tSourceDir and SOURCEDIR and not Installed\t1501\n"
768 "ProcessComponents\t\t1600\n"
769 "TestSourceDirProp26\tnot SourceDir and not SOURCEDIR and not Installed\t1601\n"
770 "UnpublishFeatures\t\t1800\n"
771 "TestSourceDirProp27\tnot SourceDir and not SOURCEDIR and not Installed\t1801\n"
772 "RemoveFiles\t\t3500\n"
773 "TestSourceDirProp28\tnot SourceDir and not SOURCEDIR and not Installed\t3501\n"
774 "InstallFiles\t\t4000\n"
775 "TestSourceDirProp29\tnot SourceDir and not SOURCEDIR and not Installed\t4001\n"
776 "RegisterUser\t\t6000\n"
777 "TestSourceDirProp30\tnot SourceDir and not SOURCEDIR and not Installed\t6001\n"
778 "RegisterProduct\t\t6100\n"
779 "TestSourceDirProp31\tnot SourceDir and not SOURCEDIR and not Installed\t6101\n"
780 "PublishFeatures\t\t6300\n"
781 "TestSourceDirProp32\tnot SourceDir and not SOURCEDIR and not Installed\t6301\n"
782 "PublishProduct\t\t6400\n"
783 "TestSourceDirProp33\tnot SourceDir and not SOURCEDIR and not Installed\t6401\n"
784 "InstallExecute\t\t6500\n"
785 "TestSourceDirProp34\tnot SourceDir and not SOURCEDIR and not Installed\t6501\n"
786 "InstallFinalize\t\t6600\n"
787 "TestSourceDirProp35\tnot SourceDir and not SOURCEDIR and not Installed\t6601\n";
789 static const char sd_custom_action_dat[] =
790 "Action\tType\tSource\tTarget\tISComments\n"
791 "s72\ti2\tS64\tS0\tS255\n"
792 "CustomAction\tAction\n"
793 "TestSourceDirProp1\t19\t\tTest 1 failed\t\n"
794 "TestSourceDirProp2\t19\t\tTest 2 failed\t\n"
795 "TestSourceDirProp3\t19\t\tTest 3 failed\t\n"
796 "TestSourceDirProp4\t19\t\tTest 4 failed\t\n"
797 "TestSourceDirProp5\t19\t\tTest 5 failed\t\n"
798 "TestSourceDirProp6\t19\t\tTest 6 failed\t\n"
799 "TestSourceDirProp7\t19\t\tTest 7 failed\t\n"
800 "TestSourceDirProp8\t19\t\tTest 8 failed\t\n"
801 "TestSourceDirProp9\t19\t\tTest 9 failed\t\n"
802 "TestSourceDirProp10\t19\t\tTest 10 failed\t\n"
803 "TestSourceDirProp11\t19\t\tTest 11 failed\t\n"
804 "TestSourceDirProp12\t19\t\tTest 12 failed\t\n"
805 "TestSourceDirProp13\t19\t\tTest 13 failed\t\n"
806 "TestSourceDirProp14\t19\t\tTest 14 failed\t\n"
807 "TestSourceDirProp15\t19\t\tTest 15 failed\t\n"
808 "TestSourceDirProp16\t19\t\tTest 16 failed\t\n"
809 "TestSourceDirProp17\t19\t\tTest 17 failed\t\n"
810 "TestSourceDirProp18\t19\t\tTest 18 failed\t\n"
811 "TestSourceDirProp19\t19\t\tTest 19 failed\t\n"
812 "TestSourceDirProp20\t19\t\tTest 20 failed\t\n"
813 "TestSourceDirProp21\t19\t\tTest 21 failed\t\n"
814 "TestSourceDirProp22\t19\t\tTest 22 failed\t\n"
815 "TestSourceDirProp23\t19\t\tTest 23 failed\t\n"
816 "TestSourceDirProp24\t19\t\tTest 24 failed\t\n"
817 "TestSourceDirProp25\t19\t\tTest 25 failed\t\n"
818 "TestSourceDirProp26\t19\t\tTest 26 failed\t\n"
819 "TestSourceDirProp27\t19\t\tTest 27 failed\t\n"
820 "TestSourceDirProp28\t19\t\tTest 28 failed\t\n"
821 "TestSourceDirProp29\t19\t\tTest 29 failed\t\n"
822 "TestSourceDirProp30\t19\t\tTest 30 failed\t\n"
823 "TestSourceDirProp31\t19\t\tTest 31 failed\t\n"
824 "TestSourceDirProp32\t19\t\tTest 32 failed\t\n"
825 "TestSourceDirProp33\t19\t\tTest 33 failed\t\n"
826 "TestSourceDirProp34\t19\t\tTest 34 failed\t\n"
827 "TestSourceDirProp35\t19\t\tTest 35 failed\t\n";
829 static const char ci_install_exec_seq_dat[] =
830 "Action\tCondition\tSequence\n"
831 "s72\tS255\tI2\n"
832 "InstallExecuteSequence\tAction\n"
833 "CostFinalize\t\t1000\n"
834 "CostInitialize\t\t800\n"
835 "FileCost\t\t900\n"
836 "InstallFiles\t\t4000\n"
837 "InstallServices\t\t5000\n"
838 "InstallFinalize\t\t6600\n"
839 "InstallInitialize\t\t1500\n"
840 "RunInstall\t\t1600\n"
841 "InstallValidate\t\t1400\n"
842 "LaunchConditions\t\t100";
844 static const char ci_custom_action_dat[] =
845 "Action\tType\tSource\tTarget\tISComments\n"
846 "s72\ti2\tS64\tS0\tS255\n"
847 "CustomAction\tAction\n"
848 "RunInstall\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
850 static const char ci_component_dat[] =
851 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
852 "s72\tS38\ts72\ti2\tS255\tS72\n"
853 "Component\tComponent\n"
854 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
856 static const char ci2_component_dat[] =
857 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
858 "s72\tS38\ts72\ti2\tS255\tS72\n"
859 "Component\tComponent\n"
860 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
862 static const char ci2_feature_comp_dat[] =
863 "Feature_\tComponent_\n"
864 "s38\ts72\n"
865 "FeatureComponents\tFeature_\tComponent_\n"
866 "feature\taugustus";
868 static const char ci2_file_dat[] =
869 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
870 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
871 "File\tFile\n"
872 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
874 static const char cl_custom_action_dat[] =
875 "Action\tType\tSource\tTarget\tISComments\n"
876 "s72\ti2\tS64\tS0\tS255\n"
877 "CustomAction\tAction\n"
878 "TestCommandlineProp\t19\t\tTest1\t\n";
880 static const char cl_install_exec_seq_dat[] =
881 "Action\tCondition\tSequence\n"
882 "s72\tS255\tI2\n"
883 "InstallExecuteSequence\tAction\n"
884 "LaunchConditions\t\t100\n"
885 "ValidateProductID\t\t700\n"
886 "CostInitialize\t\t800\n"
887 "FileCost\t\t900\n"
888 "CostFinalize\t\t1000\n"
889 "TestCommandlineProp\tP=\"one\"\t1100\n"
890 "InstallInitialize\t\t1500\n"
891 "ProcessComponents\t\t1600\n"
892 "InstallValidate\t\t1400\n"
893 "InstallFinalize\t\t5000\n";
895 typedef struct _msi_table
897 const CHAR *filename;
898 const CHAR *data;
899 int size;
900 } msi_table;
902 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
904 static const msi_table tables[] =
906 ADD_TABLE(directory),
907 ADD_TABLE(component),
908 ADD_TABLE(feature),
909 ADD_TABLE(feature_comp),
910 ADD_TABLE(file),
911 ADD_TABLE(install_exec_seq),
912 ADD_TABLE(media),
913 ADD_TABLE(property),
916 static const msi_table mcp_tables[] =
918 ADD_TABLE(directory),
919 ADD_TABLE(mcp_component),
920 ADD_TABLE(mcp_feature),
921 ADD_TABLE(mcp_feature_comp),
922 ADD_TABLE(mcp_file),
923 ADD_TABLE(install_exec_seq),
924 ADD_TABLE(media),
925 ADD_TABLE(property)
928 static const msi_table lus0_tables[] =
930 ADD_TABLE(lus_component),
931 ADD_TABLE(directory),
932 ADD_TABLE(lus_feature),
933 ADD_TABLE(lus_feature_comp),
934 ADD_TABLE(lus_file),
935 ADD_TABLE(lus_install_exec_seq),
936 ADD_TABLE(lus0_media),
937 ADD_TABLE(property)
940 static const msi_table lus1_tables[] =
942 ADD_TABLE(lus_component),
943 ADD_TABLE(directory),
944 ADD_TABLE(lus_feature),
945 ADD_TABLE(lus_feature_comp),
946 ADD_TABLE(lus_file),
947 ADD_TABLE(lus_install_exec_seq),
948 ADD_TABLE(lus1_media),
949 ADD_TABLE(property)
952 static const msi_table lus2_tables[] =
954 ADD_TABLE(lus_component),
955 ADD_TABLE(directory),
956 ADD_TABLE(lus_feature),
957 ADD_TABLE(lus_feature_comp),
958 ADD_TABLE(lus_file),
959 ADD_TABLE(lus_install_exec_seq),
960 ADD_TABLE(lus2_media),
961 ADD_TABLE(property)
964 static const msi_table spf_tables[] =
966 ADD_TABLE(lus_component),
967 ADD_TABLE(directory),
968 ADD_TABLE(lus_feature),
969 ADD_TABLE(lus_feature_comp),
970 ADD_TABLE(lus_file),
971 ADD_TABLE(lus0_media),
972 ADD_TABLE(property),
973 ADD_TABLE(spf_custom_action),
974 ADD_TABLE(spf_install_exec_seq),
975 ADD_TABLE(spf_install_ui_seq)
978 static const msi_table sd_tables[] =
980 ADD_TABLE(directory),
981 ADD_TABLE(sd_component),
982 ADD_TABLE(sd_feature),
983 ADD_TABLE(sd_feature_comp),
984 ADD_TABLE(sd_file),
985 ADD_TABLE(sd_install_exec_seq),
986 ADD_TABLE(sd_install_ui_seq),
987 ADD_TABLE(sd_custom_action),
988 ADD_TABLE(media),
989 ADD_TABLE(property)
992 static const msi_table ci_tables[] =
994 ADD_TABLE(ci_component),
995 ADD_TABLE(directory),
996 ADD_TABLE(lus_feature),
997 ADD_TABLE(lus_feature_comp),
998 ADD_TABLE(lus_file),
999 ADD_TABLE(ci_install_exec_seq),
1000 ADD_TABLE(lus0_media),
1001 ADD_TABLE(property),
1002 ADD_TABLE(ci_custom_action),
1005 static const msi_table ci2_tables[] =
1007 ADD_TABLE(ci2_component),
1008 ADD_TABLE(directory),
1009 ADD_TABLE(lus_feature),
1010 ADD_TABLE(ci2_feature_comp),
1011 ADD_TABLE(ci2_file),
1012 ADD_TABLE(install_exec_seq),
1013 ADD_TABLE(lus0_media),
1014 ADD_TABLE(property),
1017 static const msi_table cl_tables[] =
1019 ADD_TABLE(component),
1020 ADD_TABLE(directory),
1021 ADD_TABLE(feature),
1022 ADD_TABLE(feature_comp),
1023 ADD_TABLE(file),
1024 ADD_TABLE(cl_custom_action),
1025 ADD_TABLE(cl_install_exec_seq),
1026 ADD_TABLE(media),
1027 ADD_TABLE(property)
1030 static void write_file(const CHAR *filename, const char *data, int data_size)
1032 DWORD size;
1034 HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL,
1035 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1036 WriteFile(hf, data, data_size, &size, NULL);
1037 CloseHandle(hf);
1040 static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount, const char *template)
1042 MSIHANDLE summary;
1043 UINT r;
1045 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1046 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1048 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, template);
1049 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1051 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1052 "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}");
1053 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1055 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, version, NULL, NULL);
1056 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1058 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, wordcount, NULL, NULL);
1059 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1061 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1064 /* write the summary changes back to the stream */
1065 r = MsiSummaryInfoPersist(summary);
1066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1068 MsiCloseHandle(summary);
1071 #define create_database(name, tables, num_tables) \
1072 create_database_wordcount(name, tables, num_tables, 100, 0, ";1033");
1074 #define create_database_template(name, tables, num_tables, version, template) \
1075 create_database_wordcount(name, tables, num_tables, version, 0, template);
1077 static void create_database_wordcount(const CHAR *name, const msi_table *tables,
1078 int num_tables, INT version, INT wordcount,
1079 const char *template)
1081 MSIHANDLE db;
1082 UINT r;
1083 WCHAR *nameW;
1084 int j, len;
1086 len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
1087 if (!(nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return;
1088 MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, len );
1090 r = MsiOpenDatabaseW(nameW, MSIDBOPEN_CREATE, &db);
1091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1093 /* import the tables into the database */
1094 for (j = 0; j < num_tables; j++)
1096 const msi_table *table = &tables[j];
1098 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1100 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1103 DeleteFileA(table->filename);
1106 write_msi_summary_info(db, version, wordcount, template);
1108 r = MsiDatabaseCommit(db);
1109 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1111 MsiCloseHandle(db);
1112 HeapFree( GetProcessHeap(), 0, nameW );
1115 static UINT run_query(MSIHANDLE hdb, const char *query)
1117 MSIHANDLE hview = 0;
1118 UINT r;
1120 r = MsiDatabaseOpenViewA(hdb, query, &hview);
1121 if (r != ERROR_SUCCESS)
1122 return r;
1124 r = MsiViewExecute(hview, 0);
1125 if (r == ERROR_SUCCESS)
1126 r = MsiViewClose(hview);
1127 MsiCloseHandle(hview);
1128 return r;
1131 static UINT set_summary_info(MSIHANDLE hdb, LPSTR prodcode)
1133 UINT res;
1134 MSIHANDLE suminfo;
1136 /* build summary info */
1137 res = MsiGetSummaryInformationA(hdb, NULL, 7, &suminfo);
1138 ok(res == ERROR_SUCCESS, "Failed to open summaryinfo\n");
1140 res = MsiSummaryInfoSetPropertyA(suminfo, 2, VT_LPSTR, 0, NULL,
1141 "Installation Database");
1142 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1144 res = MsiSummaryInfoSetPropertyA(suminfo, 3, VT_LPSTR, 0, NULL,
1145 "Installation Database");
1146 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1148 res = MsiSummaryInfoSetPropertyA(suminfo, 4, VT_LPSTR, 0, NULL,
1149 "Wine Hackers");
1150 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1152 res = MsiSummaryInfoSetPropertyA(suminfo, 7, VT_LPSTR, 0, NULL,
1153 ";1033");
1154 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1156 res = MsiSummaryInfoSetPropertyA(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1157 "{A2078D65-94D6-4205-8DEE-F68D6FD622AA}");
1158 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1160 res = MsiSummaryInfoSetPropertyA(suminfo, 14, VT_I4, 100, NULL, NULL);
1161 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1163 res = MsiSummaryInfoSetPropertyA(suminfo, 15, VT_I4, 0, NULL, NULL);
1164 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
1166 res = MsiSummaryInfoPersist(suminfo);
1167 ok(res == ERROR_SUCCESS, "Failed to make summary info persist\n");
1169 res = MsiCloseHandle(suminfo);
1170 ok(res == ERROR_SUCCESS, "Failed to close suminfo\n");
1172 return res;
1175 static MSIHANDLE create_package_db(LPSTR prodcode)
1177 MSIHANDLE hdb = 0;
1178 CHAR query[MAX_PATH];
1179 UINT res;
1181 DeleteFileA(msifile);
1183 /* create an empty database */
1184 res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
1185 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
1186 if (res != ERROR_SUCCESS)
1187 return hdb;
1189 res = MsiDatabaseCommit(hdb);
1190 ok(res == ERROR_SUCCESS, "Failed to commit database\n");
1192 set_summary_info(hdb, prodcode);
1194 res = run_query(hdb,
1195 "CREATE TABLE `Directory` ( "
1196 "`Directory` CHAR(255) NOT NULL, "
1197 "`Directory_Parent` CHAR(255), "
1198 "`DefaultDir` CHAR(255) NOT NULL "
1199 "PRIMARY KEY `Directory`)");
1200 ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
1202 res = run_query(hdb,
1203 "CREATE TABLE `Property` ( "
1204 "`Property` CHAR(72) NOT NULL, "
1205 "`Value` CHAR(255) "
1206 "PRIMARY KEY `Property`)");
1207 ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
1209 sprintf(query, "INSERT INTO `Property` "
1210 "(`Property`, `Value`) "
1211 "VALUES( 'ProductCode', '%s' )", prodcode);
1212 res = run_query(hdb, query);
1213 ok(res == ERROR_SUCCESS , "Failed\n");
1215 res = MsiDatabaseCommit(hdb);
1216 ok(res == ERROR_SUCCESS, "Failed to commit database\n");
1218 return hdb;
1221 static void test_usefeature(void)
1223 INSTALLSTATE r;
1225 if (!pMsiUseFeatureExA)
1227 win_skip("MsiUseFeatureExA not implemented\n");
1228 return;
1231 r = MsiQueryFeatureStateA(NULL, NULL);
1232 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1234 r = MsiQueryFeatureStateA("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL);
1235 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1237 r = pMsiUseFeatureExA(NULL,NULL,0,0);
1238 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1240 r = pMsiUseFeatureExA(NULL, "WORDVIEWFiles", -2, 1 );
1241 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1243 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
1244 NULL, -2, 0 );
1245 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1247 r = pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
1248 "WORDVIEWFiles", -2, 0 );
1249 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1251 r = pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
1252 "WORDVIEWFiles", -2, 0 );
1253 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1255 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
1256 "WORDVIEWFiles", -2, 1 );
1257 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
1260 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
1262 if (pRegDeleteKeyExA)
1263 return pRegDeleteKeyExA( key, subkey, access, 0 );
1264 return RegDeleteKeyA( key, subkey );
1267 static void test_null(void)
1269 MSIHANDLE hpkg;
1270 UINT r;
1271 HKEY hkey;
1272 DWORD dwType, cbData;
1273 LPBYTE lpData = NULL;
1274 INSTALLSTATE state;
1275 REGSAM access = KEY_ALL_ACCESS;
1277 if (is_wow64)
1278 access |= KEY_WOW64_64KEY;
1280 r = pMsiOpenPackageExW(NULL, 0, &hpkg);
1281 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
1283 state = MsiQueryProductStateW(NULL);
1284 ok( state == INSTALLSTATE_INVALIDARG, "wrong return\n");
1286 r = MsiEnumFeaturesW(NULL,0,NULL,NULL);
1287 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
1289 r = MsiConfigureFeatureW(NULL, NULL, 0);
1290 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
1292 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL, 0);
1293 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
1295 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000001}", "foo", 0);
1296 ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
1298 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000002}", "foo", INSTALLSTATE_DEFAULT);
1299 ok( r == ERROR_UNKNOWN_PRODUCT, "wrong error %d\n", r);
1301 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
1302 * necessary registry values */
1304 /* empty product string */
1305 r = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, access, &hkey);
1306 if (r == ERROR_ACCESS_DENIED)
1308 skip("Not enough rights to perform tests\n");
1309 return;
1311 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1313 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
1314 ok ( r == ERROR_SUCCESS || r == ERROR_FILE_NOT_FOUND, "wrong error %d\n", r);
1315 if ( r == ERROR_SUCCESS )
1317 lpData = HeapAlloc(GetProcessHeap(), 0, cbData);
1318 if (!lpData)
1319 skip("Out of memory\n");
1320 else
1322 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
1323 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
1327 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
1328 if (r == ERROR_ACCESS_DENIED)
1330 skip("Not enough rights to perform tests\n");
1331 HeapFree(GetProcessHeap(), 0, lpData);
1332 RegCloseKey(hkey);
1333 return;
1335 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1337 r = MsiGetProductInfoA("", "", NULL, NULL);
1338 ok ( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
1340 if (lpData)
1342 r = RegSetValueExA(hkey, NULL, 0, dwType, lpData, cbData);
1343 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
1345 HeapFree(GetProcessHeap(), 0, lpData);
1347 else
1349 r = RegDeleteValueA(hkey, NULL);
1350 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
1353 r = RegCloseKey(hkey);
1354 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1356 /* empty attribute */
1357 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1358 0, NULL, 0, access, NULL, &hkey, NULL);
1359 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1361 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
1362 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1364 r = MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL, NULL);
1365 ok ( r == ERROR_UNKNOWN_PROPERTY, "wrong error %d\n", r);
1367 r = RegCloseKey(hkey);
1368 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1370 r = delete_key(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1371 access & KEY_WOW64_64KEY);
1372 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1375 static void test_getcomponentpath(void)
1377 INSTALLSTATE r;
1378 char buffer[0x100];
1379 DWORD sz;
1381 if(!pMsiGetComponentPathA)
1382 return;
1384 r = pMsiGetComponentPathA( NULL, NULL, NULL, NULL );
1385 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1387 r = pMsiGetComponentPathA( "bogus", "bogus", NULL, NULL );
1388 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1390 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL, NULL );
1391 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1393 sz = sizeof buffer;
1394 buffer[0]=0;
1395 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer, &sz );
1396 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1398 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
1399 "{00000000-0000-0000-0000-000000000000}", buffer, &sz );
1400 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
1402 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1403 "{00000000-0000-0000-0000-00000000}", buffer, &sz );
1404 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1406 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1407 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer, &sz );
1408 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1410 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
1411 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer, &sz );
1412 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
1415 static void create_file(LPCSTR name, LPCSTR data, DWORD size)
1417 HANDLE file;
1418 DWORD written;
1420 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1421 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1422 WriteFile(file, data, strlen(data), &written, NULL);
1424 if (size)
1426 SetFilePointer(file, size, NULL, FILE_BEGIN);
1427 SetEndOfFile(file);
1430 CloseHandle(file);
1433 static void create_test_files(void)
1435 CreateDirectoryA("msitest", NULL);
1436 create_file("msitest\\one.txt", "msitest\\one.txt", 100);
1437 CreateDirectoryA("msitest\\first", NULL);
1438 create_file("msitest\\first\\two.txt", "msitest\\first\\two.txt", 100);
1439 CreateDirectoryA("msitest\\second", NULL);
1440 create_file("msitest\\second\\three.txt", "msitest\\second\\three.txt", 100);
1442 create_file("four.txt", "four.txt", 100);
1443 create_file("five.txt", "five.txt", 100);
1444 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1446 create_file("msitest\\filename", "msitest\\filename", 100);
1447 create_file("msitest\\service.exe", "msitest\\service.exe", 100);
1449 DeleteFileA("four.txt");
1450 DeleteFileA("five.txt");
1453 static void delete_test_files(void)
1455 DeleteFileA("msitest.msi");
1456 DeleteFileA("msitest.cab");
1457 DeleteFileA("msitest\\second\\three.txt");
1458 DeleteFileA("msitest\\first\\two.txt");
1459 DeleteFileA("msitest\\one.txt");
1460 DeleteFileA("msitest\\service.exe");
1461 DeleteFileA("msitest\\filename");
1462 RemoveDirectoryA("msitest\\second");
1463 RemoveDirectoryA("msitest\\first");
1464 RemoveDirectoryA("msitest");
1467 #define HASHSIZE sizeof(MSIFILEHASHINFO)
1469 static const struct
1471 LPCSTR data;
1472 DWORD size;
1473 MSIFILEHASHINFO hash;
1474 } hash_data[] =
1476 { "", 0,
1477 { HASHSIZE,
1478 { 0, 0, 0, 0 },
1482 { "abc", 0,
1483 { HASHSIZE,
1484 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
1488 { "C:\\Program Files\\msitest\\caesar\n", 0,
1489 { HASHSIZE,
1490 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
1494 { "C:\\Program Files\\msitest\\caesar\n", 500,
1495 { HASHSIZE,
1496 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
1501 static void test_MsiGetFileHash(void)
1503 const char name[] = "msitest.bin";
1504 UINT r;
1505 MSIFILEHASHINFO hash;
1506 DWORD i;
1508 if (!pMsiGetFileHashA)
1510 win_skip("MsiGetFileHash not implemented\n");
1511 return;
1514 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
1516 /* szFilePath is NULL */
1517 r = pMsiGetFileHashA(NULL, 0, &hash);
1518 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1520 /* szFilePath is empty */
1521 r = pMsiGetFileHashA("", 0, &hash);
1522 ok(r == ERROR_PATH_NOT_FOUND || r == ERROR_BAD_PATHNAME,
1523 "Expected ERROR_PATH_NOT_FOUND or ERROR_BAD_PATHNAME, got %d\n", r);
1525 /* szFilePath is nonexistent */
1526 r = pMsiGetFileHashA(name, 0, &hash);
1527 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1529 /* dwOptions is non-zero */
1530 r = pMsiGetFileHashA(name, 1, &hash);
1531 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1533 /* pHash.dwFileHashInfoSize is not correct */
1534 hash.dwFileHashInfoSize = 0;
1535 r = pMsiGetFileHashA(name, 0, &hash);
1536 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1538 /* pHash is NULL */
1539 r = pMsiGetFileHashA(name, 0, NULL);
1540 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1542 for (i = 0; i < sizeof(hash_data) / sizeof(hash_data[0]); i++)
1544 int ret;
1546 create_file(name, hash_data[i].data, hash_data[i].size);
1548 memset(&hash, 0, sizeof(MSIFILEHASHINFO));
1549 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
1551 r = pMsiGetFileHashA(name, 0, &hash);
1552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1554 ret = memcmp(&hash, &hash_data[i].hash, HASHSIZE);
1555 ok(!ret, "Hash incorrect\n");
1557 DeleteFileA(name);
1561 /* copied from dlls/msi/registry.c */
1562 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
1564 DWORD i,n=1;
1565 GUID guid;
1567 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
1568 return FALSE;
1570 for(i=0; i<8; i++)
1571 out[7-i] = in[n++];
1572 n++;
1573 for(i=0; i<4; i++)
1574 out[11-i] = in[n++];
1575 n++;
1576 for(i=0; i<4; i++)
1577 out[15-i] = in[n++];
1578 n++;
1579 for(i=0; i<2; i++)
1581 out[17+i*2] = in[n++];
1582 out[16+i*2] = in[n++];
1584 n++;
1585 for( ; i<8; i++)
1587 out[17+i*2] = in[n++];
1588 out[16+i*2] = in[n++];
1590 out[32]=0;
1591 return TRUE;
1594 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
1596 WCHAR guidW[MAX_PATH];
1597 WCHAR squashedW[MAX_PATH];
1598 GUID guid;
1599 HRESULT hr;
1600 int size;
1602 hr = CoCreateGuid(&guid);
1603 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
1605 size = StringFromGUID2(&guid, guidW, MAX_PATH);
1606 ok(size == 39, "Expected 39, got %d\n", hr);
1608 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
1609 if (squashed)
1611 squash_guid(guidW, squashedW);
1612 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
1616 static char *get_user_sid(void)
1618 HANDLE token;
1619 DWORD size = 0;
1620 TOKEN_USER *user;
1621 char *usersid = NULL;
1623 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
1624 GetTokenInformation(token, TokenUser, NULL, size, &size);
1626 user = HeapAlloc(GetProcessHeap(), 0, size);
1627 GetTokenInformation(token, TokenUser, user, size, &size);
1628 pConvertSidToStringSidA(user->User.Sid, &usersid);
1629 HeapFree(GetProcessHeap(), 0, user);
1631 CloseHandle(token);
1632 return usersid;
1635 static void test_MsiQueryProductState(void)
1637 CHAR prodcode[MAX_PATH];
1638 CHAR prod_squashed[MAX_PATH];
1639 CHAR keypath[MAX_PATH*2];
1640 LPSTR usersid;
1641 INSTALLSTATE state;
1642 LONG res;
1643 HKEY userkey, localkey, props;
1644 HKEY prodkey;
1645 DWORD data, error;
1646 REGSAM access = KEY_ALL_ACCESS;
1648 create_test_guid(prodcode, prod_squashed);
1649 usersid = get_user_sid();
1651 if (is_wow64)
1652 access |= KEY_WOW64_64KEY;
1654 /* NULL prodcode */
1655 SetLastError(0xdeadbeef);
1656 state = MsiQueryProductStateA(NULL);
1657 error = GetLastError();
1658 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1659 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1661 /* empty prodcode */
1662 SetLastError(0xdeadbeef);
1663 state = MsiQueryProductStateA("");
1664 error = GetLastError();
1665 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1666 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1668 /* garbage prodcode */
1669 SetLastError(0xdeadbeef);
1670 state = MsiQueryProductStateA("garbage");
1671 error = GetLastError();
1672 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1673 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1675 /* guid without brackets */
1676 SetLastError(0xdeadbeef);
1677 state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
1678 error = GetLastError();
1679 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1680 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1682 /* guid with brackets */
1683 SetLastError(0xdeadbeef);
1684 state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
1685 error = GetLastError();
1686 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1687 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1688 "expected ERROR_SUCCESS, got %u\n", error);
1690 /* same length as guid, but random */
1691 SetLastError(0xdeadbeef);
1692 state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
1693 error = GetLastError();
1694 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1695 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1697 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1699 SetLastError(0xdeadbeef);
1700 state = MsiQueryProductStateA(prodcode);
1701 error = GetLastError();
1702 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1703 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1704 "expected ERROR_SUCCESS, got %u\n", error);
1706 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1707 lstrcatA(keypath, prod_squashed);
1709 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
1710 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1712 /* user product key exists */
1713 SetLastError(0xdeadbeef);
1714 state = MsiQueryProductStateA(prodcode);
1715 error = GetLastError();
1716 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1717 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1718 "expected ERROR_SUCCESS, got %u\n", error);
1720 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
1721 lstrcatA(keypath, prodcode);
1723 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1724 if (res == ERROR_ACCESS_DENIED)
1726 skip("Not enough rights to perform tests\n");
1727 RegDeleteKeyA(userkey, "");
1728 RegCloseKey(userkey);
1729 LocalFree(usersid);
1730 return;
1732 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1734 /* local uninstall key exists */
1735 SetLastError(0xdeadbeef);
1736 state = MsiQueryProductStateA(prodcode);
1737 error = GetLastError();
1738 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1739 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1740 "expected ERROR_SUCCESS, got %u\n", error);
1742 data = 1;
1743 res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1744 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1746 /* WindowsInstaller value exists */
1747 SetLastError(0xdeadbeef);
1748 state = MsiQueryProductStateA(prodcode);
1749 error = GetLastError();
1750 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1751 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1752 "expected ERROR_SUCCESS, got %u\n", error);
1754 RegDeleteValueA(localkey, "WindowsInstaller");
1755 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1757 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1758 lstrcatA(keypath, usersid);
1759 lstrcatA(keypath, "\\Products\\");
1760 lstrcatA(keypath, prod_squashed);
1762 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1763 if (res == ERROR_ACCESS_DENIED)
1765 skip("Not enough rights to perform tests\n");
1766 RegDeleteKeyA(userkey, "");
1767 RegCloseKey(userkey);
1768 LocalFree(usersid);
1769 return;
1771 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1773 /* local product key exists */
1774 SetLastError(0xdeadbeef);
1775 state = MsiQueryProductStateA(prodcode);
1776 error = GetLastError();
1777 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1778 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1779 "expected ERROR_SUCCESS, got %u\n", error);
1781 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
1782 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1784 /* install properties key exists */
1785 SetLastError(0xdeadbeef);
1786 state = MsiQueryProductStateA(prodcode);
1787 error = GetLastError();
1788 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1789 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1790 "expected ERROR_SUCCESS, got %u\n", error);
1792 data = 1;
1793 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1794 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1796 /* WindowsInstaller value exists */
1797 SetLastError(0xdeadbeef);
1798 state = MsiQueryProductStateA(prodcode);
1799 error = GetLastError();
1800 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1801 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1802 "expected ERROR_SUCCESS, got %u\n", error);
1804 data = 2;
1805 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1806 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1808 /* WindowsInstaller value is not 1 */
1809 SetLastError(0xdeadbeef);
1810 state = MsiQueryProductStateA(prodcode);
1811 error = GetLastError();
1812 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1813 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1814 "expected ERROR_SUCCESS, got %u\n", error);
1816 RegDeleteKeyA(userkey, "");
1818 /* user product key does not exist */
1819 SetLastError(0xdeadbeef);
1820 state = MsiQueryProductStateA(prodcode);
1821 error = GetLastError();
1822 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1823 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
1824 "expected ERROR_SUCCESS, got %u\n", error);
1826 RegDeleteValueA(props, "WindowsInstaller");
1827 delete_key(props, "", access & KEY_WOW64_64KEY);
1828 RegCloseKey(props);
1829 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1830 RegCloseKey(localkey);
1831 RegDeleteKeyA(userkey, "");
1832 RegCloseKey(userkey);
1834 /* MSIINSTALLCONTEXT_USERMANAGED */
1836 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1837 lstrcatA(keypath, usersid);
1838 lstrcatA(keypath, "\\Installer\\Products\\");
1839 lstrcatA(keypath, prod_squashed);
1841 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
1842 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1844 state = MsiQueryProductStateA(prodcode);
1845 ok(state == INSTALLSTATE_ADVERTISED,
1846 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1848 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1849 lstrcatA(keypath, usersid);
1850 lstrcatA(keypath, "\\Products\\");
1851 lstrcatA(keypath, prod_squashed);
1853 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1854 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1856 state = MsiQueryProductStateA(prodcode);
1857 ok(state == INSTALLSTATE_ADVERTISED,
1858 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1860 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
1861 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1863 state = MsiQueryProductStateA(prodcode);
1864 ok(state == INSTALLSTATE_ADVERTISED,
1865 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1867 data = 1;
1868 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1869 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1871 /* WindowsInstaller value exists */
1872 state = MsiQueryProductStateA(prodcode);
1873 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1875 RegDeleteValueA(props, "WindowsInstaller");
1876 delete_key(props, "", access & KEY_WOW64_64KEY);
1877 RegCloseKey(props);
1878 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1879 RegCloseKey(localkey);
1880 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
1881 RegCloseKey(prodkey);
1883 /* MSIINSTALLCONTEXT_MACHINE */
1885 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1886 lstrcatA(keypath, prod_squashed);
1888 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
1889 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1891 state = MsiQueryProductStateA(prodcode);
1892 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1894 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1895 lstrcatA(keypath, "S-1-5-18\\Products\\");
1896 lstrcatA(keypath, prod_squashed);
1898 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1899 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1901 state = MsiQueryProductStateA(prodcode);
1902 ok(state == INSTALLSTATE_ADVERTISED,
1903 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1905 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
1906 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1908 state = MsiQueryProductStateA(prodcode);
1909 ok(state == INSTALLSTATE_ADVERTISED,
1910 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1912 data = 1;
1913 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1914 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1916 /* WindowsInstaller value exists */
1917 state = MsiQueryProductStateA(prodcode);
1918 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1920 RegDeleteValueA(props, "WindowsInstaller");
1921 delete_key(props, "", access & KEY_WOW64_64KEY);
1922 RegCloseKey(props);
1923 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1924 RegCloseKey(localkey);
1925 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
1926 RegCloseKey(prodkey);
1928 LocalFree(usersid);
1931 static const char table_enc85[] =
1932 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
1933 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
1934 "yz{}~";
1937 * Encodes a base85 guid given a GUID pointer
1938 * Caller should provide a 21 character buffer for the encoded string.
1940 static void encode_base85_guid( GUID *guid, LPWSTR str )
1942 unsigned int x, *p, i;
1944 p = (unsigned int*) guid;
1945 for( i=0; i<4; i++ )
1947 x = p[i];
1948 *str++ = table_enc85[x%85];
1949 x = x/85;
1950 *str++ = table_enc85[x%85];
1951 x = x/85;
1952 *str++ = table_enc85[x%85];
1953 x = x/85;
1954 *str++ = table_enc85[x%85];
1955 x = x/85;
1956 *str++ = table_enc85[x%85];
1958 *str = 0;
1961 static void compose_base85_guid(LPSTR component, LPSTR comp_base85, LPSTR squashed)
1963 WCHAR guidW[MAX_PATH];
1964 WCHAR base85W[MAX_PATH];
1965 WCHAR squashedW[MAX_PATH];
1966 GUID guid;
1967 HRESULT hr;
1968 int size;
1970 hr = CoCreateGuid(&guid);
1971 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
1973 size = StringFromGUID2(&guid, guidW, MAX_PATH);
1974 ok(size == 39, "Expected 39, got %d\n", hr);
1976 WideCharToMultiByte(CP_ACP, 0, guidW, size, component, MAX_PATH, NULL, NULL);
1977 encode_base85_guid(&guid, base85W);
1978 WideCharToMultiByte(CP_ACP, 0, base85W, -1, comp_base85, MAX_PATH, NULL, NULL);
1979 squash_guid(guidW, squashedW);
1980 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
1983 static void test_MsiQueryFeatureState(void)
1985 HKEY userkey, localkey, compkey, compkey2;
1986 CHAR prodcode[MAX_PATH];
1987 CHAR prod_squashed[MAX_PATH];
1988 CHAR component[MAX_PATH];
1989 CHAR comp_base85[MAX_PATH];
1990 CHAR comp_squashed[MAX_PATH], comp_squashed2[MAX_PATH];
1991 CHAR keypath[MAX_PATH*2];
1992 INSTALLSTATE state;
1993 LPSTR usersid;
1994 LONG res;
1995 REGSAM access = KEY_ALL_ACCESS;
1996 DWORD error;
1998 create_test_guid(prodcode, prod_squashed);
1999 compose_base85_guid(component, comp_base85, comp_squashed);
2000 compose_base85_guid(component, comp_base85 + 20, comp_squashed2);
2001 usersid = get_user_sid();
2003 if (is_wow64)
2004 access |= KEY_WOW64_64KEY;
2006 /* NULL prodcode */
2007 SetLastError(0xdeadbeef);
2008 state = MsiQueryFeatureStateA(NULL, "feature");
2009 error = GetLastError();
2010 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2011 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2013 /* empty prodcode */
2014 SetLastError(0xdeadbeef);
2015 state = MsiQueryFeatureStateA("", "feature");
2016 error = GetLastError();
2017 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2018 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2020 /* garbage prodcode */
2021 SetLastError(0xdeadbeef);
2022 state = MsiQueryFeatureStateA("garbage", "feature");
2023 error = GetLastError();
2024 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2025 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2027 /* guid without brackets */
2028 SetLastError(0xdeadbeef);
2029 state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
2030 error = GetLastError();
2031 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2032 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2034 /* guid with brackets */
2035 SetLastError(0xdeadbeef);
2036 state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
2037 error = GetLastError();
2038 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2039 ok(error == ERROR_SUCCESS || broken(error == ERROR_ALREADY_EXISTS) /* win2k */,
2040 "expected ERROR_SUCCESS, got %u\n", error);
2042 /* same length as guid, but random */
2043 SetLastError(0xdeadbeef);
2044 state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
2045 error = GetLastError();
2046 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2047 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2049 /* NULL szFeature */
2050 SetLastError(0xdeadbeef);
2051 state = MsiQueryFeatureStateA(prodcode, NULL);
2052 error = GetLastError();
2053 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2054 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2056 /* empty szFeature */
2057 SetLastError(0xdeadbeef);
2058 state = MsiQueryFeatureStateA(prodcode, "");
2059 error = GetLastError();
2060 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2061 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2062 "expected ERROR_SUCCESS, got %u\n", error);
2064 /* feature key does not exist yet */
2065 SetLastError(0xdeadbeef);
2066 state = MsiQueryFeatureStateA(prodcode, "feature");
2067 error = GetLastError();
2068 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2069 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2070 "expected ERROR_SUCCESS, got %u\n", error);
2072 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2074 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Features\\");
2075 lstrcatA(keypath, prod_squashed);
2077 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
2078 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2080 /* feature key exists */
2081 SetLastError(0xdeadbeef);
2082 state = MsiQueryFeatureStateA(prodcode, "feature");
2083 error = GetLastError();
2084 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2085 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2086 "expected ERROR_SUCCESS, got %u\n", error);
2088 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
2089 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2091 /* feature value exists */
2092 SetLastError(0xdeadbeef);
2093 state = MsiQueryFeatureStateA(prodcode, "feature");
2094 error = GetLastError();
2095 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2096 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2097 "expected ERROR_SUCCESS, got %u\n", error);
2099 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2100 lstrcatA(keypath, usersid);
2101 lstrcatA(keypath, "\\Products\\");
2102 lstrcatA(keypath, prod_squashed);
2103 lstrcatA(keypath, "\\Features");
2105 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
2106 if (res == ERROR_ACCESS_DENIED)
2108 skip("Not enough rights to perform tests\n");
2109 RegDeleteKeyA(userkey, "");
2110 RegCloseKey(userkey);
2111 LocalFree(usersid);
2112 return;
2114 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2116 /* userdata features key exists */
2117 SetLastError(0xdeadbeef);
2118 state = MsiQueryFeatureStateA(prodcode, "feature");
2119 error = GetLastError();
2120 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2121 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2122 "expected ERROR_SUCCESS, got %u\n", error);
2124 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
2125 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2127 SetLastError(0xdeadbeef);
2128 state = MsiQueryFeatureStateA(prodcode, "feature");
2129 error = GetLastError();
2130 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
2131 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2132 "expected ERROR_SUCCESS, got %u\n", error);
2134 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
2135 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2137 SetLastError(0xdeadbeef);
2138 state = MsiQueryFeatureStateA(prodcode, "feature");
2139 error = GetLastError();
2140 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2141 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2142 "expected ERROR_SUCCESS, got %u\n", error);
2144 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
2145 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2147 SetLastError(0xdeadbeef);
2148 state = MsiQueryFeatureStateA(prodcode, "feature");
2149 error = GetLastError();
2150 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2151 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2152 "expected ERROR_SUCCESS, got %u\n", error);
2154 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
2155 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2157 SetLastError(0xdeadbeef);
2158 state = MsiQueryFeatureStateA(prodcode, "feature");
2159 error = GetLastError();
2160 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2161 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2162 "expected ERROR_SUCCESS, got %u\n", error);
2164 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2165 lstrcatA(keypath, usersid);
2166 lstrcatA(keypath, "\\Components\\");
2167 lstrcatA(keypath, comp_squashed);
2169 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2170 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2172 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2173 lstrcatA(keypath, usersid);
2174 lstrcatA(keypath, "\\Components\\");
2175 lstrcatA(keypath, comp_squashed2);
2177 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
2178 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2180 SetLastError(0xdeadbeef);
2181 state = MsiQueryFeatureStateA(prodcode, "feature");
2182 error = GetLastError();
2183 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2184 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2185 "expected ERROR_SUCCESS, got %u\n", error);
2187 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
2188 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2190 SetLastError(0xdeadbeef);
2191 state = MsiQueryFeatureStateA(prodcode, "feature");
2192 error = GetLastError();
2193 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2194 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2195 "expected ERROR_SUCCESS, got %u\n", error);
2197 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
2198 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2200 SetLastError(0xdeadbeef);
2201 state = MsiQueryFeatureStateA(prodcode, "feature");
2202 error = GetLastError();
2203 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2204 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2205 "expected ERROR_SUCCESS, got %u\n", error);
2207 res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
2208 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2210 /* INSTALLSTATE_LOCAL */
2211 SetLastError(0xdeadbeef);
2212 state = MsiQueryFeatureStateA(prodcode, "feature");
2213 error = GetLastError();
2214 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2215 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2216 "expected ERROR_SUCCESS, got %u\n", error);
2218 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
2219 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2221 /* INSTALLSTATE_SOURCE */
2222 SetLastError(0xdeadbeef);
2223 state = MsiQueryFeatureStateA(prodcode, "feature");
2224 error = GetLastError();
2225 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
2226 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2227 "expected ERROR_SUCCESS, got %u\n", error);
2229 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
2230 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2232 /* bad INSTALLSTATE_SOURCE */
2233 SetLastError(0xdeadbeef);
2234 state = MsiQueryFeatureStateA(prodcode, "feature");
2235 error = GetLastError();
2236 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2237 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2238 "expected ERROR_SUCCESS, got %u\n", error);
2240 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
2241 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2243 /* INSTALLSTATE_SOURCE */
2244 SetLastError(0xdeadbeef);
2245 state = MsiQueryFeatureStateA(prodcode, "feature");
2246 error = GetLastError();
2247 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
2248 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2249 "expected ERROR_SUCCESS, got %u\n", error);
2251 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
2252 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2254 /* bad INSTALLSTATE_SOURCE */
2255 SetLastError(0xdeadbeef);
2256 state = MsiQueryFeatureStateA(prodcode, "feature");
2257 error = GetLastError();
2258 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2259 ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
2260 "expected ERROR_SUCCESS, got %u\n", error);
2262 RegDeleteValueA(compkey, prod_squashed);
2263 RegDeleteValueA(compkey2, prod_squashed);
2264 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2265 delete_key(compkey2, "", access & KEY_WOW64_64KEY);
2266 RegDeleteValueA(localkey, "feature");
2267 RegDeleteValueA(userkey, "feature");
2268 RegDeleteKeyA(userkey, "");
2269 RegCloseKey(compkey);
2270 RegCloseKey(compkey2);
2271 RegCloseKey(localkey);
2272 RegCloseKey(userkey);
2274 /* MSIINSTALLCONTEXT_USERMANAGED */
2276 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2277 lstrcatA(keypath, usersid);
2278 lstrcatA(keypath, "\\Installer\\Features\\");
2279 lstrcatA(keypath, prod_squashed);
2281 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
2282 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2284 /* feature key exists */
2285 state = MsiQueryFeatureStateA(prodcode, "feature");
2286 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2288 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 1);
2289 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2291 /* feature value exists */
2292 state = MsiQueryFeatureStateA(prodcode, "feature");
2293 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2295 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2296 lstrcatA(keypath, usersid);
2297 lstrcatA(keypath, "\\Products\\");
2298 lstrcatA(keypath, prod_squashed);
2299 lstrcatA(keypath, "\\Features");
2301 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
2302 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2304 /* userdata features key exists */
2305 state = MsiQueryFeatureStateA(prodcode, "feature");
2306 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2308 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
2309 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2311 state = MsiQueryFeatureStateA(prodcode, "feature");
2312 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
2314 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
2315 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2317 state = MsiQueryFeatureStateA(prodcode, "feature");
2318 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2320 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
2321 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2323 state = MsiQueryFeatureStateA(prodcode, "feature");
2324 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2326 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
2327 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2329 state = MsiQueryFeatureStateA(prodcode, "feature");
2330 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2332 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2333 lstrcatA(keypath, usersid);
2334 lstrcatA(keypath, "\\Components\\");
2335 lstrcatA(keypath, comp_squashed);
2337 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2338 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2340 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2341 lstrcatA(keypath, usersid);
2342 lstrcatA(keypath, "\\Components\\");
2343 lstrcatA(keypath, comp_squashed2);
2345 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
2346 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2348 state = MsiQueryFeatureStateA(prodcode, "feature");
2349 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2351 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
2352 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2354 state = MsiQueryFeatureStateA(prodcode, "feature");
2355 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2357 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
2358 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2360 state = MsiQueryFeatureStateA(prodcode, "feature");
2361 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2363 res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
2364 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2366 state = MsiQueryFeatureStateA(prodcode, "feature");
2367 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2369 RegDeleteValueA(compkey, prod_squashed);
2370 RegDeleteValueA(compkey2, prod_squashed);
2371 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2372 delete_key(compkey2, "", access & KEY_WOW64_64KEY);
2373 RegDeleteValueA(localkey, "feature");
2374 RegDeleteValueA(userkey, "feature");
2375 delete_key(userkey, "", access & KEY_WOW64_64KEY);
2376 RegCloseKey(compkey);
2377 RegCloseKey(compkey2);
2378 RegCloseKey(localkey);
2379 RegCloseKey(userkey);
2381 /* MSIINSTALLCONTEXT_MACHINE */
2383 lstrcpyA(keypath, "Software\\Classes\\Installer\\Features\\");
2384 lstrcatA(keypath, prod_squashed);
2386 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
2387 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2389 /* feature key exists */
2390 state = MsiQueryFeatureStateA(prodcode, "feature");
2391 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2393 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 1);
2394 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2396 /* feature value exists */
2397 state = MsiQueryFeatureStateA(prodcode, "feature");
2398 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2400 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2401 lstrcatA(keypath, "S-1-5-18\\Products\\");
2402 lstrcatA(keypath, prod_squashed);
2403 lstrcatA(keypath, "\\Features");
2405 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
2406 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2408 /* userdata features key exists */
2409 state = MsiQueryFeatureStateA(prodcode, "feature");
2410 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2412 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
2413 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2415 state = MsiQueryFeatureStateA(prodcode, "feature");
2416 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
2418 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
2419 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2421 state = MsiQueryFeatureStateA(prodcode, "feature");
2422 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2424 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
2425 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2427 state = MsiQueryFeatureStateA(prodcode, "feature");
2428 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2430 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
2431 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2433 state = MsiQueryFeatureStateA(prodcode, "feature");
2434 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2436 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2437 lstrcatA(keypath, "S-1-5-18\\Components\\");
2438 lstrcatA(keypath, comp_squashed);
2440 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2441 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2443 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2444 lstrcatA(keypath, "S-1-5-18\\Components\\");
2445 lstrcatA(keypath, comp_squashed2);
2447 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
2448 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2450 state = MsiQueryFeatureStateA(prodcode, "feature");
2451 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2453 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
2454 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2456 state = MsiQueryFeatureStateA(prodcode, "feature");
2457 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2459 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
2460 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2462 state = MsiQueryFeatureStateA(prodcode, "feature");
2463 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2465 res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
2466 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2468 state = MsiQueryFeatureStateA(prodcode, "feature");
2469 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2471 RegDeleteValueA(compkey, prod_squashed);
2472 RegDeleteValueA(compkey2, prod_squashed);
2473 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2474 delete_key(compkey2, "", access & KEY_WOW64_64KEY);
2475 RegDeleteValueA(localkey, "feature");
2476 RegDeleteValueA(userkey, "feature");
2477 delete_key(userkey, "", access & KEY_WOW64_64KEY);
2478 RegCloseKey(compkey);
2479 RegCloseKey(compkey2);
2480 RegCloseKey(localkey);
2481 RegCloseKey(userkey);
2482 LocalFree(usersid);
2485 static void test_MsiQueryComponentState(void)
2487 HKEY compkey, prodkey;
2488 CHAR prodcode[MAX_PATH];
2489 CHAR prod_squashed[MAX_PATH];
2490 CHAR component[MAX_PATH];
2491 CHAR comp_base85[MAX_PATH];
2492 CHAR comp_squashed[MAX_PATH];
2493 CHAR keypath[MAX_PATH];
2494 INSTALLSTATE state;
2495 LPSTR usersid;
2496 LONG res;
2497 UINT r;
2498 REGSAM access = KEY_ALL_ACCESS;
2499 DWORD error;
2501 static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef;
2503 if (!pMsiQueryComponentStateA)
2505 win_skip("MsiQueryComponentStateA not implemented\n");
2506 return;
2509 create_test_guid(prodcode, prod_squashed);
2510 compose_base85_guid(component, comp_base85, comp_squashed);
2511 usersid = get_user_sid();
2513 if (is_wow64)
2514 access |= KEY_WOW64_64KEY;
2516 /* NULL szProductCode */
2517 state = MAGIC_ERROR;
2518 SetLastError(0xdeadbeef);
2519 r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2520 error = GetLastError();
2521 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2522 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2523 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2525 /* empty szProductCode */
2526 state = MAGIC_ERROR;
2527 SetLastError(0xdeadbeef);
2528 r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2529 error = GetLastError();
2530 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2531 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2532 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2534 /* random szProductCode */
2535 state = MAGIC_ERROR;
2536 SetLastError(0xdeadbeef);
2537 r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2538 error = GetLastError();
2539 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2540 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2541 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2543 /* GUID-length szProductCode */
2544 state = MAGIC_ERROR;
2545 SetLastError(0xdeadbeef);
2546 r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2547 error = GetLastError();
2548 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2549 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2550 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2552 /* GUID-length with brackets */
2553 state = MAGIC_ERROR;
2554 SetLastError(0xdeadbeef);
2555 r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2556 error = GetLastError();
2557 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2558 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2559 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2561 /* actual GUID */
2562 state = MAGIC_ERROR;
2563 SetLastError(0xdeadbeef);
2564 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2565 error = GetLastError();
2566 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2567 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2568 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2570 state = MAGIC_ERROR;
2571 SetLastError(0xdeadbeef);
2572 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2573 error = GetLastError();
2574 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2575 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2576 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2578 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2579 lstrcatA(keypath, prod_squashed);
2581 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2582 if (res == ERROR_ACCESS_DENIED)
2584 skip("Not enough rights to perform tests\n");
2585 LocalFree(usersid);
2586 return;
2588 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2590 state = MAGIC_ERROR;
2591 SetLastError(0xdeadbeef);
2592 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2593 error = GetLastError();
2594 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2595 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2596 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2598 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2599 RegCloseKey(prodkey);
2601 /* create local system product key */
2602 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
2603 lstrcatA(keypath, prod_squashed);
2604 lstrcatA(keypath, "\\InstallProperties");
2606 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2607 if (res == ERROR_ACCESS_DENIED)
2609 skip("Not enough rights to perform tests\n");
2610 LocalFree(usersid);
2611 return;
2613 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2615 /* local system product key exists */
2616 state = MAGIC_ERROR;
2617 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2618 error = GetLastError();
2619 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2620 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2621 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2623 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
2624 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2626 /* LocalPackage value exists */
2627 state = MAGIC_ERROR;
2628 SetLastError(0xdeadbeef);
2629 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2630 error = GetLastError();
2631 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2632 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2633 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2635 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
2636 lstrcatA(keypath, comp_squashed);
2638 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2639 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2641 /* component key exists */
2642 state = MAGIC_ERROR;
2643 SetLastError(0xdeadbeef);
2644 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2645 error = GetLastError();
2646 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2647 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2648 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2650 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
2651 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2653 /* component\product exists */
2654 state = MAGIC_ERROR;
2655 SetLastError(0xdeadbeef);
2656 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2657 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2658 error = GetLastError();
2659 ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
2660 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
2661 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2663 /* NULL component, product exists */
2664 state = MAGIC_ERROR;
2665 SetLastError(0xdeadbeef);
2666 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &state);
2667 error = GetLastError();
2668 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2669 ok(state == MAGIC_ERROR, "Expected state not changed, got %d\n", state);
2670 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2672 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
2673 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2675 /* INSTALLSTATE_LOCAL */
2676 state = MAGIC_ERROR;
2677 SetLastError(0xdeadbeef);
2678 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2679 error = GetLastError();
2680 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2681 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2682 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2684 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
2685 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2687 /* INSTALLSTATE_SOURCE */
2688 state = MAGIC_ERROR;
2689 SetLastError(0xdeadbeef);
2690 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2691 error = GetLastError();
2692 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2693 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
2694 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2696 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
2697 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2699 /* bad INSTALLSTATE_SOURCE */
2700 state = MAGIC_ERROR;
2701 SetLastError(0xdeadbeef);
2702 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2703 error = GetLastError();
2704 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2705 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2706 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2708 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
2709 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2711 /* INSTALLSTATE_SOURCE */
2712 state = MAGIC_ERROR;
2713 SetLastError(0xdeadbeef);
2714 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2715 error = GetLastError();
2716 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2717 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
2718 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2720 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01:", 4);
2721 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2723 /* registry component */
2724 state = MAGIC_ERROR;
2725 SetLastError(0xdeadbeef);
2726 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2727 error = GetLastError();
2728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2729 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2730 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2732 RegDeleteValueA(prodkey, "LocalPackage");
2733 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2734 RegDeleteValueA(compkey, prod_squashed);
2735 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2736 RegCloseKey(prodkey);
2737 RegCloseKey(compkey);
2739 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2741 state = MAGIC_ERROR;
2742 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2743 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2744 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2746 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2747 lstrcatA(keypath, prod_squashed);
2749 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2750 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2752 state = MAGIC_ERROR;
2753 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2754 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2755 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2757 RegDeleteKeyA(prodkey, "");
2758 RegCloseKey(prodkey);
2760 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2761 lstrcatA(keypath, usersid);
2762 lstrcatA(keypath, "\\Products\\");
2763 lstrcatA(keypath, prod_squashed);
2764 lstrcatA(keypath, "\\InstallProperties");
2766 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2767 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2769 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
2770 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2772 RegCloseKey(prodkey);
2774 state = MAGIC_ERROR;
2775 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2776 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2777 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2779 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2780 lstrcatA(keypath, usersid);
2781 lstrcatA(keypath, "\\Components\\");
2782 lstrcatA(keypath, comp_squashed);
2784 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2785 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2787 /* component key exists */
2788 state = MAGIC_ERROR;
2789 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2790 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2791 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2793 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
2794 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2796 /* component\product exists */
2797 state = MAGIC_ERROR;
2798 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2799 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2800 ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
2801 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
2803 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
2804 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2806 state = MAGIC_ERROR;
2807 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2809 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2811 /* MSIINSTALLCONTEXT_USERMANAGED */
2813 state = MAGIC_ERROR;
2814 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2815 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2816 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2818 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2819 lstrcatA(keypath, prod_squashed);
2821 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2822 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2824 state = MAGIC_ERROR;
2825 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2826 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2827 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2829 RegDeleteKeyA(prodkey, "");
2830 RegCloseKey(prodkey);
2832 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2833 lstrcatA(keypath, usersid);
2834 lstrcatA(keypath, "\\Installer\\Products\\");
2835 lstrcatA(keypath, prod_squashed);
2837 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2838 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2840 state = MAGIC_ERROR;
2841 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2842 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2843 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2845 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2846 RegCloseKey(prodkey);
2848 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2849 lstrcatA(keypath, usersid);
2850 lstrcatA(keypath, "\\Products\\");
2851 lstrcatA(keypath, prod_squashed);
2852 lstrcatA(keypath, "\\InstallProperties");
2854 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2855 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2857 res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
2858 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2860 state = MAGIC_ERROR;
2861 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2862 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2863 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2865 RegDeleteValueA(prodkey, "LocalPackage");
2866 RegDeleteValueA(prodkey, "ManagedLocalPackage");
2867 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2868 RegDeleteValueA(compkey, prod_squashed);
2869 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2870 RegCloseKey(prodkey);
2871 RegCloseKey(compkey);
2872 LocalFree(usersid);
2875 static void test_MsiGetComponentPath(void)
2877 HKEY compkey, prodkey, installprop;
2878 CHAR prodcode[MAX_PATH];
2879 CHAR prod_squashed[MAX_PATH];
2880 CHAR component[MAX_PATH];
2881 CHAR comp_base85[MAX_PATH];
2882 CHAR comp_squashed[MAX_PATH];
2883 CHAR keypath[MAX_PATH];
2884 CHAR path[MAX_PATH];
2885 INSTALLSTATE state;
2886 LPSTR usersid;
2887 DWORD size, val;
2888 REGSAM access = KEY_ALL_ACCESS;
2889 LONG res;
2891 create_test_guid(prodcode, prod_squashed);
2892 compose_base85_guid(component, comp_base85, comp_squashed);
2893 usersid = get_user_sid();
2895 if (is_wow64)
2896 access |= KEY_WOW64_64KEY;
2898 /* NULL szProduct */
2899 size = MAX_PATH;
2900 state = MsiGetComponentPathA(NULL, component, path, &size);
2901 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2902 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2904 /* NULL szComponent */
2905 size = MAX_PATH;
2906 state = MsiGetComponentPathA(prodcode, NULL, path, &size);
2907 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2908 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2910 size = MAX_PATH;
2911 state = MsiLocateComponentA(NULL, path, &size);
2912 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2913 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2915 /* NULL lpPathBuf */
2916 size = MAX_PATH;
2917 state = MsiGetComponentPathA(prodcode, component, NULL, &size);
2918 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2919 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2921 size = MAX_PATH;
2922 state = MsiLocateComponentA(component, NULL, &size);
2923 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2924 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2926 /* NULL pcchBuf */
2927 size = MAX_PATH;
2928 state = MsiGetComponentPathA(prodcode, component, path, NULL);
2929 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2930 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2932 size = MAX_PATH;
2933 state = MsiLocateComponentA(component, path, NULL);
2934 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2935 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2937 /* all params valid */
2938 size = MAX_PATH;
2939 state = MsiGetComponentPathA(prodcode, component, path, &size);
2940 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2941 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2943 size = MAX_PATH;
2944 state = MsiLocateComponentA(component, path, &size);
2945 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2946 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2948 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2949 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
2950 lstrcatA(keypath, comp_squashed);
2952 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2953 if (res == ERROR_ACCESS_DENIED)
2955 skip("Not enough rights to perform tests\n");
2956 LocalFree(usersid);
2957 return;
2959 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2961 /* local system component key exists */
2962 size = MAX_PATH;
2963 state = MsiGetComponentPathA(prodcode, component, path, &size);
2964 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2965 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2967 size = MAX_PATH;
2968 state = MsiLocateComponentA(component, path, &size);
2969 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2970 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2972 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2973 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2975 /* product value exists */
2976 path[0] = 0;
2977 size = MAX_PATH;
2978 state = MsiGetComponentPathA(prodcode, component, path, &size);
2979 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2980 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2981 ok(size == 10, "Expected 10, got %d\n", size);
2983 path[0] = 0;
2984 size = MAX_PATH;
2985 state = MsiLocateComponentA(component, path, &size);
2986 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2987 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2988 ok(size == 10, "Expected 10, got %d\n", size);
2990 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2991 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
2992 lstrcatA(keypath, prod_squashed);
2993 lstrcatA(keypath, "\\InstallProperties");
2995 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &installprop, NULL);
2996 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2998 val = 1;
2999 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
3000 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3002 /* install properties key exists */
3003 path[0] = 0;
3004 size = MAX_PATH;
3005 state = MsiGetComponentPathA(prodcode, component, path, &size);
3006 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3007 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3008 ok(size == 10, "Expected 10, got %d\n", size);
3010 path[0] = 0;
3011 size = MAX_PATH;
3012 state = MsiLocateComponentA(component, path, &size);
3013 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3014 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3015 ok(size == 10, "Expected 10, got %d\n", size);
3017 create_file("C:\\imapath", "C:\\imapath", 11);
3019 /* file exists */
3020 path[0] = 'a';
3021 size = 0;
3022 state = MsiGetComponentPathA(prodcode, component, path, &size);
3023 ok(state == INSTALLSTATE_MOREDATA, "Expected INSTALLSTATE_MOREDATA, got %d\n", state);
3024 ok(path[0] == 'a', "got %s\n", path);
3025 ok(size == 10, "Expected 10, got %d\n", size);
3027 path[0] = 0;
3028 size = MAX_PATH;
3029 state = MsiGetComponentPathA(prodcode, component, path, &size);
3030 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3031 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3032 ok(size == 10, "Expected 10, got %d\n", size);
3034 size = 0;
3035 path[0] = 'a';
3036 state = MsiLocateComponentA(component, path, &size);
3037 ok(state == INSTALLSTATE_MOREDATA, "Expected INSTALLSTATE_MOREDATA, got %d\n", state);
3038 ok(path[0] == 'a', "got %s\n", path);
3039 ok(size == 10, "Expected 10, got %d\n", size);
3041 path[0] = 0;
3042 size = MAX_PATH;
3043 state = MsiLocateComponentA(component, path, &size);
3044 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3045 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3046 ok(size == 10, "Expected 10, got %d\n", size);
3048 RegDeleteValueA(compkey, prod_squashed);
3049 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3050 RegDeleteValueA(installprop, "WindowsInstaller");
3051 delete_key(installprop, "", access & KEY_WOW64_64KEY);
3052 RegCloseKey(compkey);
3053 RegCloseKey(installprop);
3054 DeleteFileA("C:\\imapath");
3056 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3057 lstrcatA(keypath, "Installer\\UserData\\");
3058 lstrcatA(keypath, usersid);
3059 lstrcatA(keypath, "\\Components\\");
3060 lstrcatA(keypath, comp_squashed);
3062 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3063 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3065 /* user managed component key exists */
3066 size = MAX_PATH;
3067 state = MsiGetComponentPathA(prodcode, component, path, &size);
3068 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3069 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3071 size = MAX_PATH;
3072 state = MsiLocateComponentA(component, path, &size);
3073 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3074 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3076 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3079 /* product value exists */
3080 path[0] = 0;
3081 size = MAX_PATH;
3082 state = MsiGetComponentPathA(prodcode, component, path, &size);
3083 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3084 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3085 ok(size == 10, "Expected 10, got %d\n", size);
3087 path[0] = 0;
3088 size = MAX_PATH;
3089 state = MsiLocateComponentA(component, path, &size);
3090 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3091 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3092 ok(size == 10, "Expected 10, got %d\n", size);
3094 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3095 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
3096 lstrcatA(keypath, prod_squashed);
3097 lstrcatA(keypath, "\\InstallProperties");
3099 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &installprop, NULL);
3100 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3102 val = 1;
3103 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
3104 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3106 /* install properties key exists */
3107 path[0] = 0;
3108 size = MAX_PATH;
3109 state = MsiGetComponentPathA(prodcode, component, path, &size);
3110 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3111 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3112 ok(size == 10, "Expected 10, got %d\n", size);
3114 path[0] = 0;
3115 size = MAX_PATH;
3116 state = MsiLocateComponentA(component, path, &size);
3117 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3118 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3119 ok(size == 10, "Expected 10, got %d\n", size);
3121 create_file("C:\\imapath", "C:\\imapath", 11);
3123 /* file exists */
3124 path[0] = 0;
3125 size = MAX_PATH;
3126 state = MsiGetComponentPathA(prodcode, component, path, &size);
3127 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3128 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3129 ok(size == 10, "Expected 10, got %d\n", size);
3131 path[0] = 0;
3132 size = MAX_PATH;
3133 state = MsiLocateComponentA(component, path, &size);
3134 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3135 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3136 ok(size == 10, "Expected 10, got %d\n", size);
3138 RegDeleteValueA(compkey, prod_squashed);
3139 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3140 RegDeleteValueA(installprop, "WindowsInstaller");
3141 delete_key(installprop, "", access & KEY_WOW64_64KEY);
3142 RegCloseKey(compkey);
3143 RegCloseKey(installprop);
3144 DeleteFileA("C:\\imapath");
3146 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3147 lstrcatA(keypath, "Installer\\Managed\\");
3148 lstrcatA(keypath, usersid);
3149 lstrcatA(keypath, "\\Installer\\Products\\");
3150 lstrcatA(keypath, prod_squashed);
3152 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3153 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3155 /* user managed product key exists */
3156 size = MAX_PATH;
3157 state = MsiGetComponentPathA(prodcode, component, path, &size);
3158 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3159 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3161 size = MAX_PATH;
3162 state = MsiLocateComponentA(component, path, &size);
3163 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3164 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3166 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3167 lstrcatA(keypath, "Installer\\UserData\\");
3168 lstrcatA(keypath, usersid);
3169 lstrcatA(keypath, "\\Components\\");
3170 lstrcatA(keypath, comp_squashed);
3172 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3173 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3175 /* user managed component key exists */
3176 size = MAX_PATH;
3177 state = MsiGetComponentPathA(prodcode, component, path, &size);
3178 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3179 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3181 size = MAX_PATH;
3182 state = MsiLocateComponentA(component, path, &size);
3183 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3184 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3186 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3187 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3189 /* product value exists */
3190 path[0] = 0;
3191 size = MAX_PATH;
3192 state = MsiGetComponentPathA(prodcode, component, path, &size);
3193 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3194 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3195 ok(size == 10, "Expected 10, got %d\n", size);
3197 path[0] = 0;
3198 size = MAX_PATH;
3199 state = MsiLocateComponentA(component, path, &size);
3200 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3201 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3202 ok(size == 10, "Expected 10, got %d\n", size);
3204 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3205 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
3206 lstrcatA(keypath, prod_squashed);
3207 lstrcatA(keypath, "\\InstallProperties");
3209 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &installprop, NULL);
3210 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3212 val = 1;
3213 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
3214 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3216 /* install properties key exists */
3217 path[0] = 0;
3218 size = MAX_PATH;
3219 state = MsiGetComponentPathA(prodcode, component, path, &size);
3220 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3221 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3222 ok(size == 10, "Expected 10, got %d\n", size);
3224 path[0] = 0;
3225 size = MAX_PATH;
3226 state = MsiLocateComponentA(component, path, &size);
3227 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3228 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3229 ok(size == 10, "Expected 10, got %d\n", size);
3231 create_file("C:\\imapath", "C:\\imapath", 11);
3233 /* file exists */
3234 path[0] = 0;
3235 size = MAX_PATH;
3236 state = MsiGetComponentPathA(prodcode, component, path, &size);
3237 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3238 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3239 ok(size == 10, "Expected 10, got %d\n", size);
3241 path[0] = 0;
3242 size = MAX_PATH;
3243 state = MsiLocateComponentA(component, path, &size);
3244 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3245 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3246 ok(size == 10, "Expected 10, got %d\n", size);
3248 RegDeleteValueA(compkey, prod_squashed);
3249 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3250 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3251 RegDeleteValueA(installprop, "WindowsInstaller");
3252 delete_key(installprop, "", access & KEY_WOW64_64KEY);
3253 RegCloseKey(prodkey);
3254 RegCloseKey(compkey);
3255 RegCloseKey(installprop);
3256 DeleteFileA("C:\\imapath");
3258 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3259 lstrcatA(keypath, prod_squashed);
3261 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
3262 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3264 /* user unmanaged product key exists */
3265 size = MAX_PATH;
3266 state = MsiGetComponentPathA(prodcode, component, path, &size);
3267 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3268 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3270 size = MAX_PATH;
3271 state = MsiLocateComponentA(component, path, &size);
3272 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3273 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3275 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3276 lstrcatA(keypath, "Installer\\UserData\\");
3277 lstrcatA(keypath, usersid);
3278 lstrcatA(keypath, "\\Components\\");
3279 lstrcatA(keypath, comp_squashed);
3281 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3282 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3284 /* user unmanaged component key exists */
3285 size = MAX_PATH;
3286 state = MsiGetComponentPathA(prodcode, component, path, &size);
3287 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3288 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3290 size = MAX_PATH;
3291 state = MsiLocateComponentA(component, path, &size);
3292 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3293 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3295 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3296 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3298 /* product value exists */
3299 path[0] = 0;
3300 size = MAX_PATH;
3301 state = MsiGetComponentPathA(prodcode, component, path, &size);
3302 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3303 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3304 ok(size == 10, "Expected 10, got %d\n", size);
3306 path[0] = 0;
3307 size = MAX_PATH;
3308 state = MsiLocateComponentA(component, path, &size);
3309 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3310 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3311 ok(size == 10, "Expected 10, got %d\n", size);
3313 create_file("C:\\imapath", "C:\\imapath", 11);
3315 /* file exists */
3316 path[0] = 0;
3317 size = MAX_PATH;
3318 state = MsiGetComponentPathA(prodcode, component, path, &size);
3319 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3320 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3321 ok(size == 10, "Expected 10, got %d\n", size);
3323 path[0] = 0;
3324 size = MAX_PATH;
3325 state = MsiLocateComponentA(component, path, &size);
3326 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3327 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3328 ok(size == 10, "Expected 10, got %d\n", size);
3330 RegDeleteValueA(compkey, prod_squashed);
3331 RegDeleteKeyA(prodkey, "");
3332 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3333 RegCloseKey(prodkey);
3334 RegCloseKey(compkey);
3335 DeleteFileA("C:\\imapath");
3337 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3338 lstrcatA(keypath, prod_squashed);
3340 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3341 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3343 /* local classes product key exists */
3344 size = MAX_PATH;
3345 state = MsiGetComponentPathA(prodcode, component, path, &size);
3346 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3347 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3349 size = MAX_PATH;
3350 state = MsiLocateComponentA(component, path, &size);
3351 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3352 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3354 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3355 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
3356 lstrcatA(keypath, comp_squashed);
3358 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3359 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3361 /* local user component key exists */
3362 size = MAX_PATH;
3363 state = MsiGetComponentPathA(prodcode, component, path, &size);
3364 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3365 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3367 size = MAX_PATH;
3368 state = MsiLocateComponentA(component, path, &size);
3369 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3370 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3372 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3373 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3375 /* product value exists */
3376 path[0] = 0;
3377 size = MAX_PATH;
3378 state = MsiGetComponentPathA(prodcode, component, path, &size);
3379 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3380 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3381 ok(size == 10, "Expected 10, got %d\n", size);
3383 path[0] = 0;
3384 size = MAX_PATH;
3385 state = MsiLocateComponentA(component, path, &size);
3386 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3387 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3388 ok(size == 10, "Expected 10, got %d\n", size);
3390 create_file("C:\\imapath", "C:\\imapath", 11);
3392 /* file exists */
3393 path[0] = 0;
3394 size = MAX_PATH;
3395 state = MsiGetComponentPathA(prodcode, component, path, &size);
3396 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3397 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3398 ok(size == 10, "Expected 10, got %d\n", size);
3400 path[0] = 0;
3401 size = MAX_PATH;
3402 state = MsiLocateComponentA(component, path, &size);
3403 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3404 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3405 ok(size == 10, "Expected 10, got %d\n", size);
3407 RegDeleteValueA(compkey, prod_squashed);
3408 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3409 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3410 RegCloseKey(prodkey);
3411 RegCloseKey(compkey);
3412 DeleteFileA("C:\\imapath");
3413 LocalFree(usersid);
3416 static void test_MsiProvideComponent(void)
3418 static const WCHAR sourcedirW[] =
3419 {'s','o','u','r','c','e','d','i','r',0};
3420 static const WCHAR productW[] =
3421 {'{','3','8','8','4','7','3','3','8','-','1','B','B','C','-','4','1','0','4','-',
3422 '8','1','A','C','-','2','F','A','A','C','7','E','C','D','D','C','D','}',0};
3423 static const WCHAR componentW[] =
3424 {'{','D','D','4','2','2','F','9','2','-','3','E','D','8','-','4','9','B','5','-',
3425 'A','0','B','7','-','F','2','6','6','F','9','8','3','5','7','D','F','}',0};
3426 INSTALLSTATE state;
3427 char buf[0x100];
3428 WCHAR bufW[0x100];
3429 DWORD len, len2;
3430 UINT r;
3432 if (is_process_limited())
3434 skip("process is limited\n");
3435 return;
3438 create_test_files();
3439 create_file("msitest\\sourcedir.txt", "msitest\\sourcedir.txt", 1000);
3440 create_database(msifile, sd_tables, sizeof(sd_tables) / sizeof(msi_table));
3442 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3444 buf[0] = 0;
3445 len = sizeof(buf);
3446 r = pMsiProvideComponentA("{90120000-0070-0000-0000-4000000FF1CE}",
3447 "{17961602-C4E2-482E-800A-DF6E627549CF}",
3448 "ProductFiles", INSTALLMODE_NODETECTION, buf, &len);
3449 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
3451 r = MsiInstallProductA(msifile, NULL);
3452 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3454 state = MsiQueryFeatureStateA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir");
3455 ok(state == INSTALLSTATE_LOCAL, "got %d\n", state);
3457 buf[0] = 0;
3458 len = sizeof(buf);
3459 r = pMsiProvideComponentA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir",
3460 "{DD422F92-3ED8-49B5-A0B7-F266F98357DF}",
3461 INSTALLMODE_NODETECTION, buf, &len);
3462 ok(r == ERROR_SUCCESS, "got %u\n", r);
3463 ok(buf[0], "empty path\n");
3464 ok(len == lstrlenA(buf), "got %u\n", len);
3466 len2 = 0;
3467 r = pMsiProvideComponentA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir",
3468 "{DD422F92-3ED8-49B5-A0B7-F266F98357DF}",
3469 INSTALLMODE_NODETECTION, NULL, &len2);
3470 ok(r == ERROR_SUCCESS, "got %u\n", r);
3471 ok(len2 == len, "got %u\n", len2);
3473 len2 = 0;
3474 r = pMsiProvideComponentA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir",
3475 "{DD422F92-3ED8-49B5-A0B7-F266F98357DF}",
3476 INSTALLMODE_NODETECTION, buf, &len2);
3477 ok(r == ERROR_MORE_DATA, "got %u\n", r);
3478 ok(len2 == len, "got %u\n", len2);
3480 /* wide version */
3482 bufW[0] = 0;
3483 len = sizeof(buf);
3484 r = pMsiProvideComponentW(productW, sourcedirW, componentW,
3485 INSTALLMODE_NODETECTION, bufW, &len);
3486 ok(r == ERROR_SUCCESS, "got %u\n", r);
3487 ok(bufW[0], "empty path\n");
3488 ok(len == lstrlenW(bufW), "got %u\n", len);
3490 len2 = 0;
3491 r = pMsiProvideComponentW(productW, sourcedirW, componentW,
3492 INSTALLMODE_NODETECTION, NULL, &len2);
3493 ok(r == ERROR_SUCCESS, "got %u\n", r);
3494 ok(len2 == len, "got %u\n", len2);
3496 len2 = 0;
3497 r = pMsiProvideComponentW(productW, sourcedirW, componentW,
3498 INSTALLMODE_NODETECTION, bufW, &len2);
3499 ok(r == ERROR_MORE_DATA, "got %u\n", r);
3500 ok(len2 == len, "got %u\n", len2);
3502 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3503 ok(r == ERROR_SUCCESS, "got %u\n", r);
3505 DeleteFileA("msitest\\sourcedir.txt");
3506 delete_test_files();
3507 DeleteFileA(msifile);
3510 static void test_MsiGetProductCode(void)
3512 HKEY compkey, prodkey;
3513 CHAR prodcode[MAX_PATH];
3514 CHAR prod_squashed[MAX_PATH];
3515 CHAR prodcode2[MAX_PATH];
3516 CHAR prod2_squashed[MAX_PATH];
3517 CHAR component[MAX_PATH];
3518 CHAR comp_base85[MAX_PATH];
3519 CHAR comp_squashed[MAX_PATH];
3520 CHAR keypath[MAX_PATH];
3521 CHAR product[MAX_PATH];
3522 LPSTR usersid;
3523 LONG res;
3524 UINT r;
3525 REGSAM access = KEY_ALL_ACCESS;
3527 create_test_guid(prodcode, prod_squashed);
3528 create_test_guid(prodcode2, prod2_squashed);
3529 compose_base85_guid(component, comp_base85, comp_squashed);
3530 usersid = get_user_sid();
3532 if (is_wow64)
3533 access |= KEY_WOW64_64KEY;
3535 /* szComponent is NULL */
3536 lstrcpyA(product, "prod");
3537 r = MsiGetProductCodeA(NULL, product);
3538 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3539 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3541 /* szComponent is empty */
3542 lstrcpyA(product, "prod");
3543 r = MsiGetProductCodeA("", product);
3544 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3545 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3547 /* garbage szComponent */
3548 lstrcpyA(product, "prod");
3549 r = MsiGetProductCodeA("garbage", product);
3550 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3551 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3553 /* guid without brackets */
3554 lstrcpyA(product, "prod");
3555 r = MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product);
3556 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3557 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3559 /* guid with brackets */
3560 lstrcpyA(product, "prod");
3561 r = MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product);
3562 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3563 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3565 /* same length as guid, but random */
3566 lstrcpyA(product, "prod");
3567 r = MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product);
3568 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3569 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3571 /* all params correct, szComponent not published */
3572 lstrcpyA(product, "prod");
3573 r = MsiGetProductCodeA(component, product);
3574 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3575 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3577 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3578 lstrcatA(keypath, "Installer\\UserData\\");
3579 lstrcatA(keypath, usersid);
3580 lstrcatA(keypath, "\\Components\\");
3581 lstrcatA(keypath, comp_squashed);
3583 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3584 if (res == ERROR_ACCESS_DENIED)
3586 skip("Not enough rights to perform tests\n");
3587 LocalFree(usersid);
3588 return;
3590 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3592 /* user unmanaged component key exists */
3593 lstrcpyA(product, "prod");
3594 r = MsiGetProductCodeA(component, product);
3595 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3596 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3598 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3599 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3601 /* product value exists */
3602 lstrcpyA(product, "prod");
3603 r = MsiGetProductCodeA(component, product);
3604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3605 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3607 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3608 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3610 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3611 lstrcatA(keypath, "Installer\\Managed\\");
3612 lstrcatA(keypath, usersid);
3613 lstrcatA(keypath, "\\Installer\\Products\\");
3614 lstrcatA(keypath, prod_squashed);
3616 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3617 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3619 /* user managed product key of first product exists */
3620 lstrcpyA(product, "prod");
3621 r = MsiGetProductCodeA(component, product);
3622 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3623 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3625 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3626 RegCloseKey(prodkey);
3628 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3629 lstrcatA(keypath, prod_squashed);
3631 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
3632 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3634 /* user unmanaged product key exists */
3635 lstrcpyA(product, "prod");
3636 r = MsiGetProductCodeA(component, product);
3637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3638 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3640 RegDeleteKeyA(prodkey, "");
3641 RegCloseKey(prodkey);
3643 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3644 lstrcatA(keypath, prod_squashed);
3646 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3647 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3649 /* local classes product key exists */
3650 lstrcpyA(product, "prod");
3651 r = MsiGetProductCodeA(component, product);
3652 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3653 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3655 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3656 RegCloseKey(prodkey);
3658 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3659 lstrcatA(keypath, "Installer\\Managed\\");
3660 lstrcatA(keypath, usersid);
3661 lstrcatA(keypath, "\\Installer\\Products\\");
3662 lstrcatA(keypath, prod2_squashed);
3664 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3665 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3667 /* user managed product key of second product exists */
3668 lstrcpyA(product, "prod");
3669 r = MsiGetProductCodeA(component, product);
3670 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3671 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
3673 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3674 RegCloseKey(prodkey);
3675 RegDeleteValueA(compkey, prod_squashed);
3676 RegDeleteValueA(compkey, prod2_squashed);
3677 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3678 RegCloseKey(compkey);
3680 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3681 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
3682 lstrcatA(keypath, comp_squashed);
3684 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3685 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3687 /* local user component key exists */
3688 lstrcpyA(product, "prod");
3689 r = MsiGetProductCodeA(component, product);
3690 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3691 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3693 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3694 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3696 /* product value exists */
3697 lstrcpyA(product, "prod");
3698 r = MsiGetProductCodeA(component, product);
3699 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3700 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3702 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3703 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3705 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3706 lstrcatA(keypath, "Installer\\Managed\\");
3707 lstrcatA(keypath, usersid);
3708 lstrcatA(keypath, "\\Installer\\Products\\");
3709 lstrcatA(keypath, prod_squashed);
3711 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3712 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3714 /* user managed product key of first product exists */
3715 lstrcpyA(product, "prod");
3716 r = MsiGetProductCodeA(component, product);
3717 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3718 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3720 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3721 RegCloseKey(prodkey);
3723 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3724 lstrcatA(keypath, prod_squashed);
3726 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
3727 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3729 /* user unmanaged product key exists */
3730 lstrcpyA(product, "prod");
3731 r = MsiGetProductCodeA(component, product);
3732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3733 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3735 RegDeleteKeyA(prodkey, "");
3736 RegCloseKey(prodkey);
3738 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3739 lstrcatA(keypath, prod_squashed);
3741 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3742 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3744 /* local classes product key exists */
3745 lstrcpyA(product, "prod");
3746 r = MsiGetProductCodeA(component, product);
3747 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3748 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3750 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3751 RegCloseKey(prodkey);
3753 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3754 lstrcatA(keypath, "Installer\\Managed\\");
3755 lstrcatA(keypath, usersid);
3756 lstrcatA(keypath, "\\Installer\\Products\\");
3757 lstrcatA(keypath, prod2_squashed);
3759 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3760 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3762 /* user managed product key of second product exists */
3763 lstrcpyA(product, "prod");
3764 r = MsiGetProductCodeA(component, product);
3765 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3766 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
3768 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3769 RegCloseKey(prodkey);
3770 RegDeleteValueA(compkey, prod_squashed);
3771 RegDeleteValueA(compkey, prod2_squashed);
3772 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3773 RegCloseKey(compkey);
3774 LocalFree(usersid);
3777 static void test_MsiEnumClients(void)
3779 HKEY compkey;
3780 CHAR prodcode[MAX_PATH];
3781 CHAR prod_squashed[MAX_PATH];
3782 CHAR prodcode2[MAX_PATH];
3783 CHAR prod2_squashed[MAX_PATH];
3784 CHAR component[MAX_PATH];
3785 CHAR comp_base85[MAX_PATH];
3786 CHAR comp_squashed[MAX_PATH];
3787 CHAR product[MAX_PATH];
3788 CHAR keypath[MAX_PATH];
3789 LPSTR usersid;
3790 LONG res;
3791 UINT r;
3792 REGSAM access = KEY_ALL_ACCESS;
3794 create_test_guid(prodcode, prod_squashed);
3795 create_test_guid(prodcode2, prod2_squashed);
3796 compose_base85_guid(component, comp_base85, comp_squashed);
3797 usersid = get_user_sid();
3799 if (is_wow64)
3800 access |= KEY_WOW64_64KEY;
3802 /* NULL szComponent */
3803 product[0] = '\0';
3804 r = MsiEnumClientsA(NULL, 0, product);
3805 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3806 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3808 /* empty szComponent */
3809 product[0] = '\0';
3810 r = MsiEnumClientsA("", 0, product);
3811 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3812 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3814 /* NULL lpProductBuf */
3815 r = MsiEnumClientsA(component, 0, NULL);
3816 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3818 /* all params correct, component missing */
3819 product[0] = '\0';
3820 r = MsiEnumClientsA(component, 0, product);
3821 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3822 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3824 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3825 lstrcatA(keypath, "Installer\\UserData\\");
3826 lstrcatA(keypath, usersid);
3827 lstrcatA(keypath, "\\Components\\");
3828 lstrcatA(keypath, comp_squashed);
3830 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3831 if (res == ERROR_ACCESS_DENIED)
3833 skip("Not enough rights to perform tests\n");
3834 LocalFree(usersid);
3835 return;
3837 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3839 /* user unmanaged component key exists */
3840 product[0] = '\0';
3841 r = MsiEnumClientsA(component, 0, product);
3842 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3843 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3845 /* index > 0, no products exist */
3846 product[0] = '\0';
3847 r = MsiEnumClientsA(component, 1, product);
3848 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3849 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3851 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3852 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3854 /* product value exists */
3855 r = MsiEnumClientsA(component, 0, product);
3856 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3857 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3859 /* try index 0 again */
3860 product[0] = '\0';
3861 r = MsiEnumClientsA(component, 0, product);
3862 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3863 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3865 /* try index 1, second product value does not exist */
3866 product[0] = '\0';
3867 r = MsiEnumClientsA(component, 1, product);
3868 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3869 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3871 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3872 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3874 /* try index 1, second product value does exist */
3875 product[0] = '\0';
3876 r = MsiEnumClientsA(component, 1, product);
3877 todo_wine
3879 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3880 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3883 /* start the enumeration over */
3884 product[0] = '\0';
3885 r = MsiEnumClientsA(component, 0, product);
3886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3887 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
3888 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
3890 /* correctly query second product */
3891 product[0] = '\0';
3892 r = MsiEnumClientsA(component, 1, product);
3893 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3894 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
3895 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
3897 RegDeleteValueA(compkey, prod_squashed);
3898 RegDeleteValueA(compkey, prod2_squashed);
3899 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3900 RegCloseKey(compkey);
3902 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3903 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
3904 lstrcatA(keypath, comp_squashed);
3906 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3907 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3909 /* user local component key exists */
3910 product[0] = '\0';
3911 r = MsiEnumClientsA(component, 0, product);
3912 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3913 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3915 /* index > 0, no products exist */
3916 product[0] = '\0';
3917 r = MsiEnumClientsA(component, 1, product);
3918 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3919 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3921 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3922 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3924 /* product value exists */
3925 product[0] = '\0';
3926 r = MsiEnumClientsA(component, 0, product);
3927 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3928 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3930 /* try index 0 again */
3931 product[0] = '\0';
3932 r = MsiEnumClientsA(component, 0, product);
3933 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3935 /* try index 1, second product value does not exist */
3936 product[0] = '\0';
3937 r = MsiEnumClientsA(component, 1, product);
3938 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3939 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3941 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3942 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3944 /* try index 1, second product value does exist */
3945 product[0] = '\0';
3946 r = MsiEnumClientsA(component, 1, product);
3947 todo_wine
3949 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3950 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3953 /* start the enumeration over */
3954 product[0] = '\0';
3955 r = MsiEnumClientsA(component, 0, product);
3956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3957 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
3958 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
3960 /* correctly query second product */
3961 product[0] = '\0';
3962 r = MsiEnumClientsA(component, 1, product);
3963 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3964 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
3965 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
3967 RegDeleteValueA(compkey, prod_squashed);
3968 RegDeleteValueA(compkey, prod2_squashed);
3969 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3970 RegCloseKey(compkey);
3971 LocalFree(usersid);
3974 static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
3975 LPSTR *langcheck, LPDWORD langchecksz)
3977 LPSTR version;
3978 VS_FIXEDFILEINFO *ffi;
3979 DWORD size = GetFileVersionInfoSizeA(path, NULL);
3980 USHORT *lang;
3982 version = HeapAlloc(GetProcessHeap(), 0, size);
3983 GetFileVersionInfoA(path, 0, size, version);
3985 VerQueryValueA(version, "\\", (LPVOID *)&ffi, &size);
3986 *vercheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
3987 sprintf(*vercheck, "%d.%d.%d.%d", HIWORD(ffi->dwFileVersionMS),
3988 LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS),
3989 LOWORD(ffi->dwFileVersionLS));
3990 *verchecksz = lstrlenA(*vercheck);
3992 VerQueryValueA(version, "\\VarFileInfo\\Translation", (void **)&lang, &size);
3993 *langcheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
3994 sprintf(*langcheck, "%d", *lang);
3995 *langchecksz = lstrlenA(*langcheck);
3997 HeapFree(GetProcessHeap(), 0, version);
4000 static void test_MsiGetFileVersion(void)
4002 UINT r;
4003 DWORD versz, langsz;
4004 char version[MAX_PATH];
4005 char lang[MAX_PATH];
4006 char path[MAX_PATH];
4007 LPSTR vercheck, langcheck;
4008 DWORD verchecksz, langchecksz;
4010 /* NULL szFilePath */
4011 r = MsiGetFileVersionA(NULL, NULL, NULL, NULL, NULL);
4012 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4014 versz = MAX_PATH;
4015 langsz = MAX_PATH;
4016 lstrcpyA(version, "version");
4017 lstrcpyA(lang, "lang");
4018 r = MsiGetFileVersionA(NULL, version, &versz, lang, &langsz);
4019 ok(r == ERROR_INVALID_PARAMETER,
4020 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4021 ok(!lstrcmpA(version, "version"),
4022 "Expected version to be unchanged, got %s\n", version);
4023 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4024 ok(!lstrcmpA(lang, "lang"),
4025 "Expected lang to be unchanged, got %s\n", lang);
4026 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4028 /* empty szFilePath */
4029 r = MsiGetFileVersionA("", NULL, NULL, NULL, NULL);
4030 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4032 versz = MAX_PATH;
4033 langsz = MAX_PATH;
4034 lstrcpyA(version, "version");
4035 lstrcpyA(lang, "lang");
4036 r = MsiGetFileVersionA("", version, &versz, lang, &langsz);
4037 ok(r == ERROR_FILE_NOT_FOUND,
4038 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4039 ok(!lstrcmpA(version, "version"),
4040 "Expected version to be unchanged, got %s\n", version);
4041 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4042 ok(!lstrcmpA(lang, "lang"),
4043 "Expected lang to be unchanged, got %s\n", lang);
4044 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4046 /* nonexistent szFilePath */
4047 versz = MAX_PATH;
4048 langsz = MAX_PATH;
4049 lstrcpyA(version, "version");
4050 lstrcpyA(lang, "lang");
4051 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
4052 ok(r == ERROR_FILE_NOT_FOUND,
4053 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4054 ok(!lstrcmpA(version, "version"),
4055 "Expected version to be unchanged, got %s\n", version);
4056 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4057 ok(!lstrcmpA(lang, "lang"),
4058 "Expected lang to be unchanged, got %s\n", lang);
4059 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4061 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
4062 versz = MAX_PATH;
4063 langsz = MAX_PATH;
4064 lstrcpyA(version, "version");
4065 lstrcpyA(lang, "lang");
4066 r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
4067 ok(r == ERROR_INVALID_PARAMETER,
4068 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4069 ok(!lstrcmpA(version, "version"),
4070 "Expected version to be unchanged, got %s\n", version);
4071 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4072 ok(!lstrcmpA(lang, "lang"),
4073 "Expected lang to be unchanged, got %s\n", lang);
4074 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4076 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
4077 versz = MAX_PATH;
4078 langsz = MAX_PATH;
4079 lstrcpyA(version, "version");
4080 lstrcpyA(lang, "lang");
4081 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
4082 ok(r == ERROR_INVALID_PARAMETER,
4083 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4084 ok(!lstrcmpA(version, "version"),
4085 "Expected version to be unchanged, got %s\n", version);
4086 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4087 ok(!lstrcmpA(lang, "lang"),
4088 "Expected lang to be unchanged, got %s\n", lang);
4089 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4091 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
4092 versz = 0;
4093 langsz = MAX_PATH;
4094 lstrcpyA(version, "version");
4095 lstrcpyA(lang, "lang");
4096 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
4097 ok(r == ERROR_FILE_NOT_FOUND,
4098 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4099 ok(!lstrcmpA(version, "version"),
4100 "Expected version to be unchanged, got %s\n", version);
4101 ok(versz == 0, "Expected 0, got %d\n", versz);
4102 ok(!lstrcmpA(lang, "lang"),
4103 "Expected lang to be unchanged, got %s\n", lang);
4104 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4106 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
4107 versz = MAX_PATH;
4108 langsz = 0;
4109 lstrcpyA(version, "version");
4110 lstrcpyA(lang, "lang");
4111 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
4112 ok(r == ERROR_FILE_NOT_FOUND,
4113 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4114 ok(!lstrcmpA(version, "version"),
4115 "Expected version to be unchanged, got %s\n", version);
4116 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4117 ok(!lstrcmpA(lang, "lang"),
4118 "Expected lang to be unchanged, got %s\n", lang);
4119 ok(langsz == 0, "Expected 0, got %d\n", langsz);
4121 /* nonexistent szFilePath, rest NULL */
4122 r = MsiGetFileVersionA("nonexistent", NULL, NULL, NULL, NULL);
4123 ok(r == ERROR_FILE_NOT_FOUND,
4124 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4126 create_file("ver.txt", "ver.txt", 20);
4128 /* file exists, no version information */
4129 r = MsiGetFileVersionA("ver.txt", NULL, NULL, NULL, NULL);
4130 ok(r == ERROR_FILE_INVALID, "Expected ERROR_FILE_INVALID, got %d\n", r);
4132 versz = MAX_PATH;
4133 langsz = MAX_PATH;
4134 lstrcpyA(version, "version");
4135 lstrcpyA(lang, "lang");
4136 r = MsiGetFileVersionA("ver.txt", version, &versz, lang, &langsz);
4137 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4138 ok(!lstrcmpA(version, "version"),
4139 "Expected version to be unchanged, got %s\n", version);
4140 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4141 ok(!lstrcmpA(lang, "lang"),
4142 "Expected lang to be unchanged, got %s\n", lang);
4143 ok(r == ERROR_FILE_INVALID,
4144 "Expected ERROR_FILE_INVALID, got %d\n", r);
4146 DeleteFileA("ver.txt");
4148 /* relative path, has version information */
4149 versz = MAX_PATH;
4150 langsz = MAX_PATH;
4151 lstrcpyA(version, "version");
4152 lstrcpyA(lang, "lang");
4153 r = MsiGetFileVersionA("kernel32.dll", version, &versz, lang, &langsz);
4154 todo_wine
4156 ok(r == ERROR_FILE_NOT_FOUND,
4157 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4158 ok(!lstrcmpA(version, "version"),
4159 "Expected version to be unchanged, got %s\n", version);
4160 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4161 ok(!lstrcmpA(lang, "lang"),
4162 "Expected lang to be unchanged, got %s\n", lang);
4163 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4166 GetSystemDirectoryA(path, MAX_PATH);
4167 lstrcatA(path, "\\kernel32.dll");
4169 get_version_info(path, &vercheck, &verchecksz, &langcheck, &langchecksz);
4171 /* absolute path, has version information */
4172 versz = MAX_PATH;
4173 langsz = MAX_PATH;
4174 lstrcpyA(version, "version");
4175 lstrcpyA(lang, "lang");
4176 r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
4177 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4178 if (langchecksz && !langsz)
4180 win_skip("broken MsiGetFileVersionA detected\n");
4181 HeapFree(GetProcessHeap(), 0, vercheck);
4182 HeapFree(GetProcessHeap(), 0, langcheck);
4183 return;
4185 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4186 ok(strstr(lang, langcheck) != NULL, "Expected \"%s\" in \"%s\"\n", langcheck, lang);
4187 ok(!lstrcmpA(version, vercheck),
4188 "Expected %s, got %s\n", vercheck, version);
4190 /* only check version */
4191 versz = MAX_PATH;
4192 lstrcpyA(version, "version");
4193 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
4194 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4195 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4196 ok(!lstrcmpA(version, vercheck),
4197 "Expected %s, got %s\n", vercheck, version);
4199 /* only check language */
4200 langsz = MAX_PATH;
4201 lstrcpyA(lang, "lang");
4202 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
4203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4204 ok(strstr(lang, langcheck) != NULL, "Expected \"%s\" in \"%s\"\n", langcheck, lang);
4206 /* check neither version nor language */
4207 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
4208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4210 /* get pcchVersionBuf */
4211 versz = MAX_PATH;
4212 r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
4213 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4214 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4216 /* get pcchLangBuf */
4217 langsz = MAX_PATH;
4218 r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
4219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4220 ok(langsz >= langchecksz, "Expected %d >= %d\n", langsz, langchecksz);
4222 /* pcchVersionBuf not big enough */
4223 versz = 5;
4224 lstrcpyA(version, "version");
4225 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
4226 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4227 ok(!strncmp(version, vercheck, 4),
4228 "Expected first 4 characters of \"%s\", got \"%s\"\n", vercheck, version);
4229 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4231 /* pcchLangBuf not big enough */
4232 langsz = 4;
4233 lstrcpyA(lang, "lang");
4234 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
4235 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4236 ok(lstrcmpA(lang, "lang"), "lang not set\n");
4237 ok(langsz >= langchecksz, "Expected %d >= %d\n", langsz, langchecksz);
4239 /* pcchVersionBuf big enough, pcchLangBuf not big enough */
4240 versz = MAX_PATH;
4241 langsz = 0;
4242 lstrcpyA(version, "version");
4243 r = MsiGetFileVersionA(path, version, &versz, NULL, &langsz);
4244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4245 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4246 ok(!lstrcmpA(version, vercheck), "Expected \"%s\", got \"%s\"\n", vercheck, version);
4247 ok(langsz >= langchecksz && langsz < MAX_PATH, "Expected %d >= %d\n", langsz, langchecksz);
4249 /* pcchVersionBuf not big enough, pcchLangBuf big enough */
4250 versz = 5;
4251 langsz = MAX_PATH;
4252 lstrcpyA(lang, "lang");
4253 r = MsiGetFileVersionA(path, NULL, &versz, lang, &langsz);
4254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4255 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4256 ok(langsz >= langchecksz && langsz < MAX_PATH, "Expected %d >= %d\n", langsz, langchecksz);
4257 ok(strstr(lang, langcheck) != NULL, "expected %s in %s\n", langcheck, lang);
4259 /* NULL pcchVersionBuf and pcchLangBuf */
4260 r = MsiGetFileVersionA(path, version, NULL, lang, NULL);
4261 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4263 /* All NULL except szFilePath */
4264 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
4265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4267 HeapFree(GetProcessHeap(), 0, vercheck);
4268 HeapFree(GetProcessHeap(), 0, langcheck);
4271 static void test_MsiGetProductInfo(void)
4273 UINT r;
4274 LONG res;
4275 HKEY propkey, source;
4276 HKEY prodkey, localkey;
4277 CHAR prodcode[MAX_PATH];
4278 CHAR prod_squashed[MAX_PATH];
4279 CHAR packcode[MAX_PATH];
4280 CHAR pack_squashed[MAX_PATH];
4281 CHAR buf[MAX_PATH];
4282 CHAR keypath[MAX_PATH];
4283 LPSTR usersid;
4284 DWORD sz, val = 42;
4285 REGSAM access = KEY_ALL_ACCESS;
4287 create_test_guid(prodcode, prod_squashed);
4288 create_test_guid(packcode, pack_squashed);
4289 usersid = get_user_sid();
4291 if (is_wow64)
4292 access |= KEY_WOW64_64KEY;
4294 /* NULL szProduct */
4295 sz = MAX_PATH;
4296 lstrcpyA(buf, "apple");
4297 r = MsiGetProductInfoA(NULL, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4298 ok(r == ERROR_INVALID_PARAMETER,
4299 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4300 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4301 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4303 /* empty szProduct */
4304 sz = MAX_PATH;
4305 lstrcpyA(buf, "apple");
4306 r = MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINKA, buf, &sz);
4307 ok(r == ERROR_INVALID_PARAMETER,
4308 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4309 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4310 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4312 /* garbage szProduct */
4313 sz = MAX_PATH;
4314 lstrcpyA(buf, "apple");
4315 r = MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINKA, buf, &sz);
4316 ok(r == ERROR_INVALID_PARAMETER,
4317 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4318 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4319 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4321 /* guid without brackets */
4322 sz = MAX_PATH;
4323 lstrcpyA(buf, "apple");
4324 r = MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
4325 INSTALLPROPERTY_HELPLINKA, buf, &sz);
4326 ok(r == ERROR_INVALID_PARAMETER,
4327 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4328 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4329 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4331 /* guid with brackets */
4332 sz = MAX_PATH;
4333 lstrcpyA(buf, "apple");
4334 r = MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
4335 INSTALLPROPERTY_HELPLINKA, buf, &sz);
4336 ok(r == ERROR_UNKNOWN_PRODUCT,
4337 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4338 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4339 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4341 /* same length as guid, but random */
4342 sz = MAX_PATH;
4343 lstrcpyA(buf, "apple");
4344 r = MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
4345 INSTALLPROPERTY_HELPLINKA, buf, &sz);
4346 ok(r == ERROR_INVALID_PARAMETER,
4347 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4348 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4349 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4351 /* not installed, NULL szAttribute */
4352 sz = MAX_PATH;
4353 lstrcpyA(buf, "apple");
4354 r = MsiGetProductInfoA(prodcode, NULL, buf, &sz);
4355 ok(r == ERROR_INVALID_PARAMETER,
4356 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4357 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4358 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4360 /* not installed, NULL lpValueBuf */
4361 sz = MAX_PATH;
4362 lstrcpyA(buf, "apple");
4363 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, &sz);
4364 ok(r == ERROR_UNKNOWN_PRODUCT,
4365 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4366 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4367 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4369 /* not installed, NULL pcchValueBuf */
4370 sz = MAX_PATH;
4371 lstrcpyA(buf, "apple");
4372 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, NULL);
4373 ok(r == ERROR_INVALID_PARAMETER,
4374 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4375 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4376 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4378 /* created guid cannot possibly be an installed product code */
4379 sz = MAX_PATH;
4380 lstrcpyA(buf, "apple");
4381 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4382 ok(r == ERROR_UNKNOWN_PRODUCT,
4383 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4384 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4385 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4387 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4388 lstrcatA(keypath, usersid);
4389 lstrcatA(keypath, "\\Installer\\Products\\");
4390 lstrcatA(keypath, prod_squashed);
4392 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
4393 if (res == ERROR_ACCESS_DENIED)
4395 skip("Not enough rights to perform tests\n");
4396 LocalFree(usersid);
4397 return;
4399 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4401 /* managed product code exists */
4402 sz = MAX_PATH;
4403 lstrcpyA(buf, "apple");
4404 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4405 ok(r == ERROR_UNKNOWN_PROPERTY,
4406 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4407 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4408 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4410 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
4411 RegCloseKey(prodkey);
4413 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4414 lstrcatA(keypath, usersid);
4415 lstrcatA(keypath, "\\Products\\");
4416 lstrcatA(keypath, prod_squashed);
4418 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4419 if (res == ERROR_ACCESS_DENIED)
4421 skip("Not enough rights to perform tests\n");
4422 LocalFree(usersid);
4423 return;
4425 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4427 /* local user product code exists */
4428 sz = MAX_PATH;
4429 lstrcpyA(buf, "apple");
4430 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4431 ok(r == ERROR_UNKNOWN_PRODUCT,
4432 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4433 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4434 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4436 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4437 lstrcatA(keypath, usersid);
4438 lstrcatA(keypath, "\\Installer\\Products\\");
4439 lstrcatA(keypath, prod_squashed);
4441 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
4442 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4444 /* both local and managed product code exist */
4445 sz = MAX_PATH;
4446 lstrcpyA(buf, "apple");
4447 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4448 ok(r == ERROR_UNKNOWN_PROPERTY,
4449 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4450 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4451 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4453 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4454 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4456 /* InstallProperties key exists */
4457 sz = MAX_PATH;
4458 lstrcpyA(buf, "apple");
4459 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4460 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4461 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4462 ok(sz == 0, "Expected 0, got %d\n", sz);
4464 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4465 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4467 /* HelpLink value exists */
4468 sz = MAX_PATH;
4469 lstrcpyA(buf, "apple");
4470 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4471 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4472 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4473 ok(sz == 4, "Expected 4, got %d\n", sz);
4475 /* pcchBuf is NULL */
4476 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, NULL);
4477 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4479 /* lpValueBuf is NULL */
4480 sz = MAX_PATH;
4481 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, &sz);
4482 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4483 ok(sz == 4, "Expected 4, got %d\n", sz);
4485 /* lpValueBuf is NULL, pcchValueBuf is too small */
4486 sz = 2;
4487 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, &sz);
4488 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4489 ok(sz == 4, "Expected 4, got %d\n", sz);
4491 /* lpValueBuf is non-NULL, pcchValueBuf is too small */
4492 sz = 2;
4493 lstrcpyA(buf, "apple");
4494 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4495 ok(!lstrcmpA(buf, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf);
4496 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4497 ok(sz == 4, "Expected 4, got %d\n", sz);
4499 /* lpValueBuf is non-NULL, pcchValueBuf is exactly 4 */
4500 sz = 4;
4501 lstrcpyA(buf, "apple");
4502 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4503 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4504 ok(!lstrcmpA(buf, "apple"),
4505 "Expected buf to remain unchanged, got \"%s\"\n", buf);
4506 ok(sz == 4, "Expected 4, got %d\n", sz);
4508 res = RegSetValueExA(propkey, "IMadeThis", 0, REG_SZ, (LPBYTE)"random", 7);
4509 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4511 /* random property not supported by MSI, value exists */
4512 sz = MAX_PATH;
4513 lstrcpyA(buf, "apple");
4514 r = MsiGetProductInfoA(prodcode, "IMadeThis", buf, &sz);
4515 ok(r == ERROR_UNKNOWN_PROPERTY,
4516 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4517 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4518 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4520 RegDeleteValueA(propkey, "IMadeThis");
4521 RegDeleteValueA(propkey, "HelpLink");
4522 delete_key(propkey, "", access & KEY_WOW64_64KEY);
4523 delete_key(localkey, "", access & KEY_WOW64_64KEY);
4524 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
4525 RegCloseKey(propkey);
4526 RegCloseKey(localkey);
4527 RegCloseKey(prodkey);
4529 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
4530 lstrcatA(keypath, prod_squashed);
4532 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
4533 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4535 /* user product key exists */
4536 sz = MAX_PATH;
4537 lstrcpyA(buf, "apple");
4538 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4539 ok(r == ERROR_UNKNOWN_PROPERTY,
4540 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4541 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4542 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4544 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4545 lstrcatA(keypath, usersid);
4546 lstrcatA(keypath, "\\Products\\");
4547 lstrcatA(keypath, prod_squashed);
4549 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4550 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4552 /* local user product key exists */
4553 sz = MAX_PATH;
4554 lstrcpyA(buf, "apple");
4555 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4556 ok(r == ERROR_UNKNOWN_PROPERTY,
4557 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4558 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4559 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4561 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4562 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4564 /* InstallProperties key exists */
4565 sz = MAX_PATH;
4566 lstrcpyA(buf, "apple");
4567 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4568 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4569 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4570 ok(sz == 0, "Expected 0, got %d\n", sz);
4572 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4573 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4575 /* HelpLink value exists */
4576 sz = MAX_PATH;
4577 lstrcpyA(buf, "apple");
4578 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4579 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4580 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4581 ok(sz == 4, "Expected 4, got %d\n", sz);
4583 RegDeleteValueA(propkey, "HelpLink");
4584 delete_key(propkey, "", access & KEY_WOW64_64KEY);
4585 delete_key(localkey, "", access & KEY_WOW64_64KEY);
4586 RegDeleteKeyA(prodkey, "");
4587 RegCloseKey(propkey);
4588 RegCloseKey(localkey);
4589 RegCloseKey(prodkey);
4591 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
4592 lstrcatA(keypath, prod_squashed);
4594 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
4595 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4597 /* classes product key exists */
4598 sz = MAX_PATH;
4599 lstrcpyA(buf, "apple");
4600 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4601 ok(r == ERROR_UNKNOWN_PROPERTY,
4602 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4603 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4604 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4606 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4607 lstrcatA(keypath, usersid);
4608 lstrcatA(keypath, "\\Products\\");
4609 lstrcatA(keypath, prod_squashed);
4611 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4612 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4614 /* local user product key exists */
4615 sz = MAX_PATH;
4616 lstrcpyA(buf, "apple");
4617 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4618 ok(r == ERROR_UNKNOWN_PROPERTY,
4619 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4620 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4621 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4623 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4624 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4626 /* InstallProperties key exists */
4627 sz = MAX_PATH;
4628 lstrcpyA(buf, "apple");
4629 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4630 ok(r == ERROR_UNKNOWN_PROPERTY,
4631 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4632 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4633 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4635 delete_key(propkey, "", access & KEY_WOW64_64KEY);
4636 delete_key(localkey, "", access & KEY_WOW64_64KEY);
4637 RegCloseKey(propkey);
4638 RegCloseKey(localkey);
4640 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4641 lstrcatA(keypath, "S-1-5-18\\\\Products\\");
4642 lstrcatA(keypath, prod_squashed);
4644 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4645 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4647 /* Local System product key exists */
4648 sz = MAX_PATH;
4649 lstrcpyA(buf, "apple");
4650 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4651 ok(r == ERROR_UNKNOWN_PROPERTY,
4652 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4653 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4654 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4656 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4657 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4659 /* InstallProperties key exists */
4660 sz = MAX_PATH;
4661 lstrcpyA(buf, "apple");
4662 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4663 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4664 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4665 ok(sz == 0, "Expected 0, got %d\n", sz);
4667 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4668 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4670 /* HelpLink value exists */
4671 sz = MAX_PATH;
4672 lstrcpyA(buf, "apple");
4673 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4674 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4675 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4676 ok(sz == 4, "Expected 4, got %d\n", sz);
4678 res = RegSetValueExA(propkey, "HelpLink", 0, REG_DWORD,
4679 (const BYTE *)&val, sizeof(DWORD));
4680 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4682 /* HelpLink type is REG_DWORD */
4683 sz = MAX_PATH;
4684 lstrcpyA(buf, "apple");
4685 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4686 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4687 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4688 ok(sz == 2, "Expected 2, got %d\n", sz);
4690 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4691 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4693 /* DisplayName value exists */
4694 sz = MAX_PATH;
4695 lstrcpyA(buf, "apple");
4696 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
4697 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4698 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4699 ok(sz == 4, "Expected 4, got %d\n", sz);
4701 res = RegSetValueExA(propkey, "DisplayName", 0, REG_DWORD,
4702 (const BYTE *)&val, sizeof(DWORD));
4703 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4705 /* DisplayName type is REG_DWORD */
4706 sz = MAX_PATH;
4707 lstrcpyA(buf, "apple");
4708 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
4709 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4710 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4711 ok(sz == 2, "Expected 2, got %d\n", sz);
4713 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"1.1.1", 6);
4714 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4716 /* DisplayVersion value exists */
4717 sz = MAX_PATH;
4718 lstrcpyA(buf, "apple");
4719 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
4720 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4721 ok(!lstrcmpA(buf, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf);
4722 ok(sz == 5, "Expected 5, got %d\n", sz);
4724 res = RegSetValueExA(propkey, "DisplayVersion", 0,
4725 REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
4726 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4728 /* DisplayVersion type is REG_DWORD */
4729 sz = MAX_PATH;
4730 lstrcpyA(buf, "apple");
4731 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
4732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4733 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4734 ok(sz == 2, "Expected 2, got %d\n", sz);
4736 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"tele", 5);
4737 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4739 /* HelpTelephone value exists */
4740 sz = MAX_PATH;
4741 lstrcpyA(buf, "apple");
4742 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
4743 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4744 ok(!lstrcmpA(buf, "tele"), "Expected \"tele\", got \"%s\"\n", buf);
4745 ok(sz == 4, "Expected 4, got %d\n", sz);
4747 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_DWORD,
4748 (const BYTE *)&val, sizeof(DWORD));
4749 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4751 /* HelpTelephone type is REG_DWORD */
4752 sz = MAX_PATH;
4753 lstrcpyA(buf, "apple");
4754 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
4755 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4756 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4757 ok(sz == 2, "Expected 2, got %d\n", sz);
4759 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4760 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4762 /* InstallLocation value exists */
4763 sz = MAX_PATH;
4764 lstrcpyA(buf, "apple");
4765 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
4766 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4767 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4768 ok(sz == 3, "Expected 3, got %d\n", sz);
4770 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_DWORD,
4771 (const BYTE *)&val, sizeof(DWORD));
4772 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4774 /* InstallLocation type is REG_DWORD */
4775 sz = MAX_PATH;
4776 lstrcpyA(buf, "apple");
4777 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
4778 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4779 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4780 ok(sz == 2, "Expected 2, got %d\n", sz);
4782 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4783 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4785 /* InstallSource value exists */
4786 sz = MAX_PATH;
4787 lstrcpyA(buf, "apple");
4788 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
4789 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4790 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4791 ok(sz == 6, "Expected 6, got %d\n", sz);
4793 res = RegSetValueExA(propkey, "InstallSource", 0, REG_DWORD,
4794 (const BYTE *)&val, sizeof(DWORD));
4795 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4797 /* InstallSource type is REG_DWORD */
4798 sz = MAX_PATH;
4799 lstrcpyA(buf, "apple");
4800 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
4801 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4802 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4803 ok(sz == 2, "Expected 2, got %d\n", sz);
4805 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4806 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4808 /* InstallDate value exists */
4809 sz = MAX_PATH;
4810 lstrcpyA(buf, "apple");
4811 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
4812 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4813 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4814 ok(sz == 4, "Expected 4, got %d\n", sz);
4816 res = RegSetValueExA(propkey, "InstallDate", 0, REG_DWORD,
4817 (const BYTE *)&val, sizeof(DWORD));
4818 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4820 /* InstallDate type is REG_DWORD */
4821 sz = MAX_PATH;
4822 lstrcpyA(buf, "apple");
4823 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
4824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4825 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4826 ok(sz == 2, "Expected 2, got %d\n", sz);
4828 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4829 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4831 /* Publisher value exists */
4832 sz = MAX_PATH;
4833 lstrcpyA(buf, "apple");
4834 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHERA, buf, &sz);
4835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4836 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4837 ok(sz == 3, "Expected 3, got %d\n", sz);
4839 res = RegSetValueExA(propkey, "Publisher", 0, REG_DWORD,
4840 (const BYTE *)&val, sizeof(DWORD));
4841 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4843 /* Publisher type is REG_DWORD */
4844 sz = MAX_PATH;
4845 lstrcpyA(buf, "apple");
4846 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHERA, buf, &sz);
4847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4848 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4849 ok(sz == 2, "Expected 2, got %d\n", sz);
4851 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"pack", 5);
4852 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4854 /* LocalPackage value exists */
4855 sz = MAX_PATH;
4856 lstrcpyA(buf, "apple");
4857 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
4858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4859 ok(!lstrcmpA(buf, "pack"), "Expected \"pack\", got \"%s\"\n", buf);
4860 ok(sz == 4, "Expected 4, got %d\n", sz);
4862 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_DWORD,
4863 (const BYTE *)&val, sizeof(DWORD));
4864 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4866 /* LocalPackage type is REG_DWORD */
4867 sz = MAX_PATH;
4868 lstrcpyA(buf, "apple");
4869 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
4870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4871 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4872 ok(sz == 2, "Expected 2, got %d\n", sz);
4874 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4875 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4877 /* UrlInfoAbout value exists */
4878 sz = MAX_PATH;
4879 lstrcpyA(buf, "apple");
4880 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
4881 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4882 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4883 ok(sz == 5, "Expected 5, got %d\n", sz);
4885 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_DWORD,
4886 (const BYTE *)&val, sizeof(DWORD));
4887 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4889 /* UrlInfoAbout type is REG_DWORD */
4890 sz = MAX_PATH;
4891 lstrcpyA(buf, "apple");
4892 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
4893 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4894 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4895 ok(sz == 2, "Expected 2, got %d\n", sz);
4897 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_SZ, (LPBYTE)"info", 5);
4898 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4900 /* UrlUpdateInfo value exists */
4901 sz = MAX_PATH;
4902 lstrcpyA(buf, "apple");
4903 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
4904 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4905 ok(!lstrcmpA(buf, "info"), "Expected \"info\", got \"%s\"\n", buf);
4906 ok(sz == 4, "Expected 4, got %d\n", sz);
4908 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_DWORD,
4909 (const BYTE *)&val, sizeof(DWORD));
4910 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4912 /* UrlUpdateInfo type is REG_DWORD */
4913 sz = MAX_PATH;
4914 lstrcpyA(buf, "apple");
4915 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
4916 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4917 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4918 ok(sz == 2, "Expected 2, got %d\n", sz);
4920 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"1", 2);
4921 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4923 /* VersionMinor value exists */
4924 sz = MAX_PATH;
4925 lstrcpyA(buf, "apple");
4926 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
4927 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4928 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
4929 ok(sz == 1, "Expected 1, got %d\n", sz);
4931 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_DWORD,
4932 (const BYTE *)&val, sizeof(DWORD));
4933 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4935 /* VersionMinor type is REG_DWORD */
4936 sz = MAX_PATH;
4937 lstrcpyA(buf, "apple");
4938 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
4939 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4940 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4941 ok(sz == 2, "Expected 2, got %d\n", sz);
4943 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"1", 2);
4944 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4946 /* VersionMajor value exists */
4947 sz = MAX_PATH;
4948 lstrcpyA(buf, "apple");
4949 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
4950 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4951 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
4952 ok(sz == 1, "Expected 1, got %d\n", sz);
4954 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_DWORD,
4955 (const BYTE *)&val, sizeof(DWORD));
4956 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4958 /* VersionMajor type is REG_DWORD */
4959 sz = MAX_PATH;
4960 lstrcpyA(buf, "apple");
4961 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
4962 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4963 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4964 ok(sz == 2, "Expected 2, got %d\n", sz);
4966 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
4967 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4969 /* ProductID value exists */
4970 sz = MAX_PATH;
4971 lstrcpyA(buf, "apple");
4972 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
4973 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4974 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
4975 ok(sz == 2, "Expected 2, got %d\n", sz);
4977 res = RegSetValueExA(propkey, "ProductID", 0, REG_DWORD,
4978 (const BYTE *)&val, sizeof(DWORD));
4979 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4981 /* ProductID type is REG_DWORD */
4982 sz = MAX_PATH;
4983 lstrcpyA(buf, "apple");
4984 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
4985 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4986 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4987 ok(sz == 2, "Expected 2, got %d\n", sz);
4989 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
4990 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4992 /* RegCompany value exists */
4993 sz = MAX_PATH;
4994 lstrcpyA(buf, "apple");
4995 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
4996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4997 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
4998 ok(sz == 4, "Expected 4, got %d\n", sz);
5000 res = RegSetValueExA(propkey, "RegCompany", 0, REG_DWORD,
5001 (const BYTE *)&val, sizeof(DWORD));
5002 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5004 /* RegCompany type is REG_DWORD */
5005 sz = MAX_PATH;
5006 lstrcpyA(buf, "apple");
5007 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
5008 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5009 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5010 ok(sz == 2, "Expected 2, got %d\n", sz);
5012 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"own", 4);
5013 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5015 /* RegOwner value exists */
5016 sz = MAX_PATH;
5017 lstrcpyA(buf, "apple");
5018 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNERA, buf, &sz);
5019 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5020 ok(!lstrcmpA(buf, "own"), "Expected \"own\", got \"%s\"\n", buf);
5021 ok(sz == 3, "Expected 3, got %d\n", sz);
5023 res = RegSetValueExA(propkey, "RegOwner", 0, REG_DWORD,
5024 (const BYTE *)&val, sizeof(DWORD));
5025 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5027 /* RegOwner type is REG_DWORD */
5028 sz = MAX_PATH;
5029 lstrcpyA(buf, "apple");
5030 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNERA, buf, &sz);
5031 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5032 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5033 ok(sz == 2, "Expected 2, got %d\n", sz);
5035 res = RegSetValueExA(propkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
5036 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5038 /* InstanceType value exists */
5039 sz = MAX_PATH;
5040 lstrcpyA(buf, "apple");
5041 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, buf, &sz);
5042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5043 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5044 ok(sz == 0, "Expected 0, got %d\n", sz);
5046 res = RegSetValueExA(propkey, "InstanceType", 0, REG_DWORD,
5047 (const BYTE *)&val, sizeof(DWORD));
5048 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5050 /* InstanceType type is REG_DWORD */
5051 sz = MAX_PATH;
5052 lstrcpyA(buf, "apple");
5053 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, buf, &sz);
5054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5055 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5056 ok(sz == 0, "Expected 0, got %d\n", sz);
5058 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
5059 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5061 /* InstanceType value exists */
5062 sz = MAX_PATH;
5063 lstrcpyA(buf, "apple");
5064 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, buf, &sz);
5065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5066 ok(!lstrcmpA(buf, "type"), "Expected \"type\", got \"%s\"\n", buf);
5067 ok(sz == 4, "Expected 4, got %d\n", sz);
5069 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_DWORD,
5070 (const BYTE *)&val, sizeof(DWORD));
5071 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5073 /* InstanceType type is REG_DWORD */
5074 sz = MAX_PATH;
5075 lstrcpyA(buf, "apple");
5076 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, buf, &sz);
5077 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5078 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5079 ok(sz == 2, "Expected 2, got %d\n", sz);
5081 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
5082 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5084 /* Transforms value exists */
5085 sz = MAX_PATH;
5086 lstrcpyA(buf, "apple");
5087 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5088 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5089 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5090 ok(sz == 0, "Expected 0, got %d\n", sz);
5092 res = RegSetValueExA(propkey, "Transforms", 0, REG_DWORD,
5093 (const BYTE *)&val, sizeof(DWORD));
5094 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5096 /* Transforms type is REG_DWORD */
5097 sz = MAX_PATH;
5098 lstrcpyA(buf, "apple");
5099 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5100 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5101 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5102 ok(sz == 0, "Expected 0, got %d\n", sz);
5104 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
5105 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5107 /* Transforms value exists */
5108 sz = MAX_PATH;
5109 lstrcpyA(buf, "apple");
5110 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5111 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5112 ok(!lstrcmpA(buf, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf);
5113 ok(sz == 6, "Expected 6, got %d\n", sz);
5115 res = RegSetValueExA(prodkey, "Transforms", 0, REG_DWORD,
5116 (const BYTE *)&val, sizeof(DWORD));
5117 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5119 /* Transforms type is REG_DWORD */
5120 sz = MAX_PATH;
5121 lstrcpyA(buf, "apple");
5122 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5123 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5124 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5125 ok(sz == 2, "Expected 2, got %d\n", sz);
5127 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5128 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5130 /* Language value exists */
5131 sz = MAX_PATH;
5132 lstrcpyA(buf, "apple");
5133 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5134 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5135 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5136 ok(sz == 0, "Expected 0, got %d\n", sz);
5138 res = RegSetValueExA(propkey, "Language", 0, REG_DWORD,
5139 (const BYTE *)&val, sizeof(DWORD));
5140 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5142 /* Language type is REG_DWORD */
5143 sz = MAX_PATH;
5144 lstrcpyA(buf, "apple");
5145 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5147 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5148 ok(sz == 0, "Expected 0, got %d\n", sz);
5150 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5151 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5153 /* Language value exists */
5154 sz = MAX_PATH;
5155 lstrcpyA(buf, "apple");
5156 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5158 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5159 ok(sz == 4, "Expected 4, got %d\n", sz);
5161 res = RegSetValueExA(prodkey, "Language", 0, REG_DWORD,
5162 (const BYTE *)&val, sizeof(DWORD));
5163 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5165 /* Language type is REG_DWORD */
5166 sz = MAX_PATH;
5167 lstrcpyA(buf, "apple");
5168 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5169 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5170 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5171 ok(sz == 2, "Expected 2, got %d\n", sz);
5173 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5174 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5176 /* ProductName value exists */
5177 sz = MAX_PATH;
5178 lstrcpyA(buf, "apple");
5179 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5180 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5181 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5182 ok(sz == 0, "Expected 0, got %d\n", sz);
5184 res = RegSetValueExA(propkey, "ProductName", 0, REG_DWORD,
5185 (const BYTE *)&val, sizeof(DWORD));
5186 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5188 /* ProductName type is REG_DWORD */
5189 sz = MAX_PATH;
5190 lstrcpyA(buf, "apple");
5191 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5192 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5193 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5194 ok(sz == 0, "Expected 0, got %d\n", sz);
5196 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5197 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5199 /* ProductName value exists */
5200 sz = MAX_PATH;
5201 lstrcpyA(buf, "apple");
5202 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5204 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5205 ok(sz == 4, "Expected 4, got %d\n", sz);
5207 res = RegSetValueExA(prodkey, "ProductName", 0, REG_DWORD,
5208 (const BYTE *)&val, sizeof(DWORD));
5209 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5211 /* ProductName type is REG_DWORD */
5212 sz = MAX_PATH;
5213 lstrcpyA(buf, "apple");
5214 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5216 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5217 ok(sz == 2, "Expected 2, got %d\n", sz);
5219 res = RegSetValueExA(propkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
5220 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5222 /* Assignment value exists */
5223 sz = MAX_PATH;
5224 lstrcpyA(buf, "apple");
5225 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5226 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5227 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5228 ok(sz == 0, "Expected 0, got %d\n", sz);
5230 res = RegSetValueExA(propkey, "Assignment", 0, REG_DWORD,
5231 (const BYTE *)&val, sizeof(DWORD));
5232 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5234 /* Assignment type is REG_DWORD */
5235 sz = MAX_PATH;
5236 lstrcpyA(buf, "apple");
5237 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5238 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5239 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5240 ok(sz == 0, "Expected 0, got %d\n", sz);
5242 res = RegSetValueExA(prodkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
5243 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5245 /* Assignment value exists */
5246 sz = MAX_PATH;
5247 lstrcpyA(buf, "apple");
5248 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5250 ok(!lstrcmpA(buf, "at"), "Expected \"at\", got \"%s\"\n", buf);
5251 ok(sz == 2, "Expected 2, got %d\n", sz);
5253 res = RegSetValueExA(prodkey, "Assignment", 0, REG_DWORD,
5254 (const BYTE *)&val, sizeof(DWORD));
5255 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5257 /* Assignment type is REG_DWORD */
5258 sz = MAX_PATH;
5259 lstrcpyA(buf, "apple");
5260 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5262 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5263 ok(sz == 2, "Expected 2, got %d\n", sz);
5265 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5266 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5268 /* PackageCode value exists */
5269 sz = MAX_PATH;
5270 lstrcpyA(buf, "apple");
5271 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5272 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5273 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5274 ok(sz == 0, "Expected 0, got %d\n", sz);
5276 res = RegSetValueExA(propkey, "PackageCode", 0, REG_DWORD,
5277 (const BYTE *)&val, sizeof(DWORD));
5278 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5280 /* PackageCode type is REG_DWORD */
5281 sz = MAX_PATH;
5282 lstrcpyA(buf, "apple");
5283 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5284 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5285 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5286 ok(sz == 0, "Expected 0, got %d\n", sz);
5288 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5289 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5291 /* PackageCode value exists */
5292 sz = MAX_PATH;
5293 lstrcpyA(buf, "apple");
5294 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5295 ok(r == ERROR_BAD_CONFIGURATION,
5296 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5297 ok(!lstrcmpA(buf, "code"), "Expected \"code\", got \"%s\"\n", buf);
5298 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5300 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_DWORD,
5301 (const BYTE *)&val, sizeof(DWORD));
5302 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5304 /* PackageCode type is REG_DWORD */
5305 sz = MAX_PATH;
5306 lstrcpyA(buf, "apple");
5307 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5309 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5310 ok(sz == 2, "Expected 2, got %d\n", sz);
5312 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)pack_squashed, 33);
5313 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5315 /* PackageCode value exists */
5316 sz = MAX_PATH;
5317 lstrcpyA(buf, "apple");
5318 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5319 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5320 ok(!lstrcmpA(buf, packcode), "Expected \"%s\", got \"%s\"\n", packcode, buf);
5321 ok(sz == 38, "Expected 38, got %d\n", sz);
5323 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5324 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5326 /* Version value exists */
5327 sz = MAX_PATH;
5328 lstrcpyA(buf, "apple");
5329 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5330 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5331 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5332 ok(sz == 0, "Expected 0, got %d\n", sz);
5334 res = RegSetValueExA(propkey, "Version", 0, REG_DWORD,
5335 (const BYTE *)&val, sizeof(DWORD));
5336 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5338 /* Version type is REG_DWORD */
5339 sz = MAX_PATH;
5340 lstrcpyA(buf, "apple");
5341 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5342 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5343 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5344 ok(sz == 0, "Expected 0, got %d\n", sz);
5346 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5347 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5349 /* Version value exists */
5350 sz = MAX_PATH;
5351 lstrcpyA(buf, "apple");
5352 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5354 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5355 ok(sz == 3, "Expected 3, got %d\n", sz);
5357 res = RegSetValueExA(prodkey, "Version", 0, REG_DWORD,
5358 (const BYTE *)&val, sizeof(DWORD));
5359 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5361 /* Version type is REG_DWORD */
5362 sz = MAX_PATH;
5363 lstrcpyA(buf, "apple");
5364 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5366 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5367 ok(sz == 2, "Expected 2, got %d\n", sz);
5369 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
5370 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5372 /* ProductIcon value exists */
5373 sz = MAX_PATH;
5374 lstrcpyA(buf, "apple");
5375 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5376 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5377 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5378 ok(sz == 0, "Expected 0, got %d\n", sz);
5380 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_DWORD,
5381 (const BYTE *)&val, sizeof(DWORD));
5382 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5384 /* ProductIcon type is REG_DWORD */
5385 sz = MAX_PATH;
5386 lstrcpyA(buf, "apple");
5387 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5388 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5389 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5390 ok(sz == 0, "Expected 0, got %d\n", sz);
5392 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
5393 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5395 /* ProductIcon value exists */
5396 sz = MAX_PATH;
5397 lstrcpyA(buf, "apple");
5398 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5400 ok(!lstrcmpA(buf, "ico"), "Expected \"ico\", got \"%s\"\n", buf);
5401 ok(sz == 3, "Expected 3, got %d\n", sz);
5403 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_DWORD,
5404 (const BYTE *)&val, sizeof(DWORD));
5405 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5407 /* ProductIcon type is REG_DWORD */
5408 sz = MAX_PATH;
5409 lstrcpyA(buf, "apple");
5410 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5412 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5413 ok(sz == 2, "Expected 2, got %d\n", sz);
5415 /* SourceList key does not exist */
5416 sz = MAX_PATH;
5417 lstrcpyA(buf, "apple");
5418 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5419 ok(r == ERROR_UNKNOWN_PRODUCT,
5420 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5421 ok(!lstrcmpA(buf, "apple"),
5422 "Expected buf to be unchanged, got \"%s\"\n", buf);
5423 ok(sz == MAX_PATH, "Expected sz to be unchanged, got %d\n", sz);
5425 res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
5426 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5428 /* SourceList key exists, but PackageName val does not exist */
5429 sz = MAX_PATH;
5430 lstrcpyA(buf, "apple");
5431 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5432 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5433 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5434 ok(sz == 0, "Expected 0, got %d\n", sz);
5436 res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
5437 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5439 /* PackageName val exists */
5440 sz = MAX_PATH;
5441 lstrcpyA(buf, "apple");
5442 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5443 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5444 ok(!lstrcmpA(buf, "packname"), "Expected \"packname\", got \"%s\"\n", buf);
5445 ok(sz == 8, "Expected 8, got %d\n", sz);
5447 res = RegSetValueExA(source, "PackageName", 0, REG_DWORD,
5448 (const BYTE *)&val, sizeof(DWORD));
5449 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5451 /* PackageName type is REG_DWORD */
5452 sz = MAX_PATH;
5453 lstrcpyA(buf, "apple");
5454 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5455 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5456 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5457 ok(sz == 2, "Expected 2, got %d\n", sz);
5459 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5460 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5462 /* Authorized value exists */
5463 sz = MAX_PATH;
5464 lstrcpyA(buf, "apple");
5465 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5466 if (r != ERROR_UNKNOWN_PROPERTY)
5468 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5469 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5470 ok(sz == 0, "Expected 0, got %d\n", sz);
5473 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_DWORD,
5474 (const BYTE *)&val, sizeof(DWORD));
5475 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5477 /* AuthorizedLUAApp type is REG_DWORD */
5478 sz = MAX_PATH;
5479 lstrcpyA(buf, "apple");
5480 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5481 if (r != ERROR_UNKNOWN_PROPERTY)
5483 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5484 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5485 ok(sz == 0, "Expected 0, got %d\n", sz);
5488 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5489 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5491 /* Authorized value exists */
5492 sz = MAX_PATH;
5493 lstrcpyA(buf, "apple");
5494 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5495 if (r != ERROR_UNKNOWN_PROPERTY)
5497 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5498 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
5499 ok(sz == 4, "Expected 4, got %d\n", sz);
5502 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_DWORD,
5503 (const BYTE *)&val, sizeof(DWORD));
5504 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5506 /* AuthorizedLUAApp type is REG_DWORD */
5507 sz = MAX_PATH;
5508 lstrcpyA(buf, "apple");
5509 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5510 if (r != ERROR_UNKNOWN_PROPERTY)
5512 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5513 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5514 ok(sz == 2, "Expected 2, got %d\n", sz);
5517 RegDeleteValueA(propkey, "HelpLink");
5518 RegDeleteValueA(propkey, "DisplayName");
5519 RegDeleteValueA(propkey, "DisplayVersion");
5520 RegDeleteValueA(propkey, "HelpTelephone");
5521 RegDeleteValueA(propkey, "InstallLocation");
5522 RegDeleteValueA(propkey, "InstallSource");
5523 RegDeleteValueA(propkey, "InstallDate");
5524 RegDeleteValueA(propkey, "Publisher");
5525 RegDeleteValueA(propkey, "LocalPackage");
5526 RegDeleteValueA(propkey, "UrlInfoAbout");
5527 RegDeleteValueA(propkey, "UrlUpdateInfo");
5528 RegDeleteValueA(propkey, "VersionMinor");
5529 RegDeleteValueA(propkey, "VersionMajor");
5530 RegDeleteValueA(propkey, "ProductID");
5531 RegDeleteValueA(propkey, "RegCompany");
5532 RegDeleteValueA(propkey, "RegOwner");
5533 RegDeleteValueA(propkey, "InstanceType");
5534 RegDeleteValueA(propkey, "Transforms");
5535 RegDeleteValueA(propkey, "Language");
5536 RegDeleteValueA(propkey, "ProductName");
5537 RegDeleteValueA(propkey, "Assignment");
5538 RegDeleteValueA(propkey, "PackageCode");
5539 RegDeleteValueA(propkey, "Version");
5540 RegDeleteValueA(propkey, "ProductIcon");
5541 RegDeleteValueA(propkey, "AuthorizedLUAApp");
5542 delete_key(propkey, "", access & KEY_WOW64_64KEY);
5543 delete_key(localkey, "", access & KEY_WOW64_64KEY);
5544 RegDeleteValueA(prodkey, "InstanceType");
5545 RegDeleteValueA(prodkey, "Transforms");
5546 RegDeleteValueA(prodkey, "Language");
5547 RegDeleteValueA(prodkey, "ProductName");
5548 RegDeleteValueA(prodkey, "Assignment");
5549 RegDeleteValueA(prodkey, "PackageCode");
5550 RegDeleteValueA(prodkey, "Version");
5551 RegDeleteValueA(prodkey, "ProductIcon");
5552 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
5553 RegDeleteValueA(source, "PackageName");
5554 delete_key(source, "", access & KEY_WOW64_64KEY);
5555 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
5556 RegCloseKey(propkey);
5557 RegCloseKey(localkey);
5558 RegCloseKey(source);
5559 RegCloseKey(prodkey);
5560 LocalFree(usersid);
5563 static void test_MsiGetProductInfoEx(void)
5565 UINT r;
5566 LONG res;
5567 HKEY propkey, userkey;
5568 HKEY prodkey, localkey;
5569 CHAR prodcode[MAX_PATH];
5570 CHAR prod_squashed[MAX_PATH];
5571 CHAR packcode[MAX_PATH];
5572 CHAR pack_squashed[MAX_PATH];
5573 CHAR buf[MAX_PATH];
5574 CHAR keypath[MAX_PATH];
5575 LPSTR usersid;
5576 DWORD sz;
5577 REGSAM access = KEY_ALL_ACCESS;
5579 if (!pMsiGetProductInfoExA)
5581 win_skip("MsiGetProductInfoExA is not available\n");
5582 return;
5585 create_test_guid(prodcode, prod_squashed);
5586 create_test_guid(packcode, pack_squashed);
5587 usersid = get_user_sid();
5589 if (is_wow64)
5590 access |= KEY_WOW64_64KEY;
5592 /* NULL szProductCode */
5593 sz = MAX_PATH;
5594 lstrcpyA(buf, "apple");
5595 r = pMsiGetProductInfoExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
5596 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5597 ok(r == ERROR_INVALID_PARAMETER,
5598 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5599 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5600 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5602 /* empty szProductCode */
5603 sz = MAX_PATH;
5604 lstrcpyA(buf, "apple");
5605 r = pMsiGetProductInfoExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
5606 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5607 ok(r == ERROR_INVALID_PARAMETER,
5608 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5609 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5610 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5612 /* garbage szProductCode */
5613 sz = MAX_PATH;
5614 lstrcpyA(buf, "apple");
5615 r = pMsiGetProductInfoExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
5616 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5617 ok(r == ERROR_INVALID_PARAMETER,
5618 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5619 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5620 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5622 /* guid without brackets */
5623 sz = MAX_PATH;
5624 lstrcpyA(buf, "apple");
5625 r = pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
5626 MSIINSTALLCONTEXT_USERUNMANAGED,
5627 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5628 ok(r == ERROR_INVALID_PARAMETER,
5629 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5630 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5631 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5633 /* guid with brackets */
5634 sz = MAX_PATH;
5635 lstrcpyA(buf, "apple");
5636 r = pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid,
5637 MSIINSTALLCONTEXT_USERUNMANAGED,
5638 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5639 ok(r == ERROR_UNKNOWN_PRODUCT,
5640 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5641 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5642 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5644 /* szValue is non-NULL while pcchValue is NULL */
5645 lstrcpyA(buf, "apple");
5646 r = pMsiGetProductInfoExA(prodcode, usersid,
5647 MSIINSTALLCONTEXT_USERUNMANAGED,
5648 INSTALLPROPERTY_PRODUCTSTATEA, buf, NULL);
5649 ok(r == ERROR_INVALID_PARAMETER,
5650 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5651 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5653 /* dwContext is out of range */
5654 sz = MAX_PATH;
5655 lstrcpyA(buf, "apple");
5656 r = pMsiGetProductInfoExA(prodcode, usersid, 42,
5657 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5658 ok(r == ERROR_INVALID_PARAMETER,
5659 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5660 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5661 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5663 /* szProperty is NULL */
5664 sz = MAX_PATH;
5665 lstrcpyA(buf, "apple");
5666 r = pMsiGetProductInfoExA(prodcode, usersid,
5667 MSIINSTALLCONTEXT_USERUNMANAGED,
5668 NULL, buf, &sz);
5669 ok(r == ERROR_INVALID_PARAMETER,
5670 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5671 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5672 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5674 /* szProperty is empty */
5675 sz = MAX_PATH;
5676 lstrcpyA(buf, "apple");
5677 r = pMsiGetProductInfoExA(prodcode, usersid,
5678 MSIINSTALLCONTEXT_USERUNMANAGED,
5679 "", buf, &sz);
5680 ok(r == ERROR_INVALID_PARAMETER,
5681 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5682 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5683 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5685 /* szProperty is not a valid property */
5686 sz = MAX_PATH;
5687 lstrcpyA(buf, "apple");
5688 r = pMsiGetProductInfoExA(prodcode, usersid,
5689 MSIINSTALLCONTEXT_USERUNMANAGED,
5690 "notvalid", buf, &sz);
5691 ok(r == ERROR_UNKNOWN_PRODUCT,
5692 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5693 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5694 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5696 /* same length as guid, but random */
5697 sz = MAX_PATH;
5698 lstrcpyA(buf, "apple");
5699 r = pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid,
5700 MSIINSTALLCONTEXT_USERUNMANAGED,
5701 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5702 ok(r == ERROR_INVALID_PARAMETER,
5703 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5704 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5705 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5707 /* MSIINSTALLCONTEXT_USERUNMANAGED */
5709 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
5710 lstrcatA(keypath, usersid);
5711 lstrcatA(keypath, "\\Products\\");
5712 lstrcatA(keypath, prod_squashed);
5714 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
5715 if (res == ERROR_ACCESS_DENIED)
5717 skip("Not enough rights to perform tests\n");
5718 LocalFree(usersid);
5719 return;
5721 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5723 /* local user product key exists */
5724 sz = MAX_PATH;
5725 lstrcpyA(buf, "apple");
5726 r = pMsiGetProductInfoExA(prodcode, usersid,
5727 MSIINSTALLCONTEXT_USERUNMANAGED,
5728 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5729 ok(r == ERROR_UNKNOWN_PRODUCT,
5730 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5731 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5732 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5734 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
5735 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5737 /* InstallProperties key exists */
5738 sz = MAX_PATH;
5739 lstrcpyA(buf, "apple");
5740 r = pMsiGetProductInfoExA(prodcode, usersid,
5741 MSIINSTALLCONTEXT_USERUNMANAGED,
5742 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5743 ok(r == ERROR_UNKNOWN_PRODUCT,
5744 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5745 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5746 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5748 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5749 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5751 /* LocalPackage value exists */
5752 sz = MAX_PATH;
5753 lstrcpyA(buf, "apple");
5754 r = pMsiGetProductInfoExA(prodcode, usersid,
5755 MSIINSTALLCONTEXT_USERUNMANAGED,
5756 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5757 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5758 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
5759 ok(sz == 1, "Expected 1, got %d\n", sz);
5761 RegDeleteValueA(propkey, "LocalPackage");
5763 /* LocalPackage value must exist */
5764 sz = MAX_PATH;
5765 lstrcpyA(buf, "apple");
5766 r = pMsiGetProductInfoExA(prodcode, usersid,
5767 MSIINSTALLCONTEXT_USERUNMANAGED,
5768 INSTALLPROPERTY_HELPLINKA, buf, &sz);
5769 ok(r == ERROR_UNKNOWN_PRODUCT,
5770 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5771 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5772 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5774 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5775 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5777 /* LocalPackage exists, but HelpLink does not exist */
5778 sz = MAX_PATH;
5779 lstrcpyA(buf, "apple");
5780 r = pMsiGetProductInfoExA(prodcode, usersid,
5781 MSIINSTALLCONTEXT_USERUNMANAGED,
5782 INSTALLPROPERTY_HELPLINKA, buf, &sz);
5783 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5784 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5785 ok(sz == 0, "Expected 0, got %d\n", sz);
5787 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5788 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5790 /* HelpLink value exists */
5791 sz = MAX_PATH;
5792 lstrcpyA(buf, "apple");
5793 r = pMsiGetProductInfoExA(prodcode, usersid,
5794 MSIINSTALLCONTEXT_USERUNMANAGED,
5795 INSTALLPROPERTY_HELPLINKA, buf, &sz);
5796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5797 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
5798 ok(sz == 4, "Expected 4, got %d\n", sz);
5800 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5801 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5803 /* HelpTelephone value exists */
5804 sz = MAX_PATH;
5805 lstrcpyA(buf, "apple");
5806 r = pMsiGetProductInfoExA(prodcode, usersid,
5807 MSIINSTALLCONTEXT_USERUNMANAGED,
5808 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
5809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5810 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
5811 ok(sz == 5, "Expected 5, got %d\n", sz);
5813 /* szValue and pcchValue are NULL */
5814 r = pMsiGetProductInfoExA(prodcode, usersid,
5815 MSIINSTALLCONTEXT_USERUNMANAGED,
5816 INSTALLPROPERTY_HELPTELEPHONEA, NULL, NULL);
5817 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5819 /* pcchValue is exactly 5 */
5820 sz = 5;
5821 lstrcpyA(buf, "apple");
5822 r = pMsiGetProductInfoExA(prodcode, usersid,
5823 MSIINSTALLCONTEXT_USERUNMANAGED,
5824 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
5825 ok(r == ERROR_MORE_DATA,
5826 "Expected ERROR_MORE_DATA, got %d\n", r);
5827 ok(sz == 10, "Expected 10, got %d\n", sz);
5829 /* szValue is NULL, pcchValue is exactly 5 */
5830 sz = 5;
5831 r = pMsiGetProductInfoExA(prodcode, usersid,
5832 MSIINSTALLCONTEXT_USERUNMANAGED,
5833 INSTALLPROPERTY_HELPTELEPHONEA, NULL, &sz);
5834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5835 ok(sz == 10, "Expected 10, got %d\n", sz);
5837 /* szValue is NULL, pcchValue is MAX_PATH */
5838 sz = MAX_PATH;
5839 r = pMsiGetProductInfoExA(prodcode, usersid,
5840 MSIINSTALLCONTEXT_USERUNMANAGED,
5841 INSTALLPROPERTY_HELPTELEPHONEA, NULL, &sz);
5842 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5843 ok(sz == 10, "Expected 10, got %d\n", sz);
5845 /* pcchValue is exactly 0 */
5846 sz = 0;
5847 lstrcpyA(buf, "apple");
5848 r = pMsiGetProductInfoExA(prodcode, usersid,
5849 MSIINSTALLCONTEXT_USERUNMANAGED,
5850 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
5851 ok(r == ERROR_MORE_DATA,
5852 "Expected ERROR_MORE_DATA, got %d\n", r);
5853 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
5854 ok(sz == 10, "Expected 10, got %d\n", sz);
5856 res = RegSetValueExA(propkey, "notvalid", 0, REG_SZ, (LPBYTE)"invalid", 8);
5857 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5859 /* szProperty is not a valid property */
5860 sz = MAX_PATH;
5861 lstrcpyA(buf, "apple");
5862 r = pMsiGetProductInfoExA(prodcode, usersid,
5863 MSIINSTALLCONTEXT_USERUNMANAGED,
5864 "notvalid", buf, &sz);
5865 ok(r == ERROR_UNKNOWN_PROPERTY,
5866 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5867 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5868 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5870 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5871 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5873 /* InstallDate value exists */
5874 sz = MAX_PATH;
5875 lstrcpyA(buf, "apple");
5876 r = pMsiGetProductInfoExA(prodcode, usersid,
5877 MSIINSTALLCONTEXT_USERUNMANAGED,
5878 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
5879 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5880 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
5881 ok(sz == 4, "Expected 4, got %d\n", sz);
5883 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5884 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5886 /* DisplayName value exists */
5887 sz = MAX_PATH;
5888 lstrcpyA(buf, "apple");
5889 r = pMsiGetProductInfoExA(prodcode, usersid,
5890 MSIINSTALLCONTEXT_USERUNMANAGED,
5891 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
5892 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5893 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5894 ok(sz == 4, "Expected 4, got %d\n", sz);
5896 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
5897 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5899 /* InstallLocation value exists */
5900 sz = MAX_PATH;
5901 lstrcpyA(buf, "apple");
5902 r = pMsiGetProductInfoExA(prodcode, usersid,
5903 MSIINSTALLCONTEXT_USERUNMANAGED,
5904 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
5905 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5906 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
5907 ok(sz == 3, "Expected 3, got %d\n", sz);
5909 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
5910 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5912 /* InstallSource value exists */
5913 sz = MAX_PATH;
5914 lstrcpyA(buf, "apple");
5915 r = pMsiGetProductInfoExA(prodcode, usersid,
5916 MSIINSTALLCONTEXT_USERUNMANAGED,
5917 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
5918 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5919 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
5920 ok(sz == 6, "Expected 6, got %d\n", sz);
5922 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5923 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5925 /* LocalPackage value exists */
5926 sz = MAX_PATH;
5927 lstrcpyA(buf, "apple");
5928 r = pMsiGetProductInfoExA(prodcode, usersid,
5929 MSIINSTALLCONTEXT_USERUNMANAGED,
5930 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
5931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5932 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
5933 ok(sz == 5, "Expected 5, got %d\n", sz);
5935 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
5936 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5938 /* Publisher value exists */
5939 sz = MAX_PATH;
5940 lstrcpyA(buf, "apple");
5941 r = pMsiGetProductInfoExA(prodcode, usersid,
5942 MSIINSTALLCONTEXT_USERUNMANAGED,
5943 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
5944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5945 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
5946 ok(sz == 3, "Expected 3, got %d\n", sz);
5948 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
5949 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5951 /* URLInfoAbout value exists */
5952 sz = MAX_PATH;
5953 lstrcpyA(buf, "apple");
5954 r = pMsiGetProductInfoExA(prodcode, usersid,
5955 MSIINSTALLCONTEXT_USERUNMANAGED,
5956 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
5957 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5958 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
5959 ok(sz == 5, "Expected 5, got %d\n", sz);
5961 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
5962 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5964 /* URLUpdateInfo value exists */
5965 sz = MAX_PATH;
5966 lstrcpyA(buf, "apple");
5967 r = pMsiGetProductInfoExA(prodcode, usersid,
5968 MSIINSTALLCONTEXT_USERUNMANAGED,
5969 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
5970 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5971 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
5972 ok(sz == 6, "Expected 6, got %d\n", sz);
5974 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
5975 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5977 /* VersionMinor value exists */
5978 sz = MAX_PATH;
5979 lstrcpyA(buf, "apple");
5980 r = pMsiGetProductInfoExA(prodcode, usersid,
5981 MSIINSTALLCONTEXT_USERUNMANAGED,
5982 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
5983 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5984 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
5985 ok(sz == 1, "Expected 1, got %d\n", sz);
5987 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
5988 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5990 /* VersionMajor value exists */
5991 sz = MAX_PATH;
5992 lstrcpyA(buf, "apple");
5993 r = pMsiGetProductInfoExA(prodcode, usersid,
5994 MSIINSTALLCONTEXT_USERUNMANAGED,
5995 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
5996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5997 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5998 ok(sz == 1, "Expected 1, got %d\n", sz);
6000 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6001 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6003 /* DisplayVersion value exists */
6004 sz = MAX_PATH;
6005 lstrcpyA(buf, "apple");
6006 r = pMsiGetProductInfoExA(prodcode, usersid,
6007 MSIINSTALLCONTEXT_USERUNMANAGED,
6008 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
6009 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6010 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
6011 ok(sz == 5, "Expected 5, got %d\n", sz);
6013 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6014 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6016 /* ProductID value exists */
6017 sz = MAX_PATH;
6018 lstrcpyA(buf, "apple");
6019 r = pMsiGetProductInfoExA(prodcode, usersid,
6020 MSIINSTALLCONTEXT_USERUNMANAGED,
6021 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
6022 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6023 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
6024 ok(sz == 2, "Expected 2, got %d\n", sz);
6026 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6027 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6029 /* RegCompany value exists */
6030 sz = MAX_PATH;
6031 lstrcpyA(buf, "apple");
6032 r = pMsiGetProductInfoExA(prodcode, usersid,
6033 MSIINSTALLCONTEXT_USERUNMANAGED,
6034 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
6035 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6036 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
6037 ok(sz == 4, "Expected 4, got %d\n", sz);
6039 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6040 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6042 /* RegOwner value exists */
6043 sz = MAX_PATH;
6044 lstrcpyA(buf, "apple");
6045 r = pMsiGetProductInfoExA(prodcode, usersid,
6046 MSIINSTALLCONTEXT_USERUNMANAGED,
6047 INSTALLPROPERTY_REGOWNERA, buf, &sz);
6048 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6049 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
6050 ok(sz == 5, "Expected 5, got %d\n", sz);
6052 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6053 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6055 /* Transforms value exists */
6056 sz = MAX_PATH;
6057 lstrcpyA(buf, "apple");
6058 r = pMsiGetProductInfoExA(prodcode, usersid,
6059 MSIINSTALLCONTEXT_USERUNMANAGED,
6060 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
6061 ok(r == ERROR_UNKNOWN_PRODUCT,
6062 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6063 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6064 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6066 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6067 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6069 /* Language value exists */
6070 sz = MAX_PATH;
6071 lstrcpyA(buf, "apple");
6072 r = pMsiGetProductInfoExA(prodcode, usersid,
6073 MSIINSTALLCONTEXT_USERUNMANAGED,
6074 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
6075 ok(r == ERROR_UNKNOWN_PRODUCT,
6076 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6077 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6078 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6080 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6081 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6083 /* ProductName value exists */
6084 sz = MAX_PATH;
6085 lstrcpyA(buf, "apple");
6086 r = pMsiGetProductInfoExA(prodcode, usersid,
6087 MSIINSTALLCONTEXT_USERUNMANAGED,
6088 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
6089 ok(r == ERROR_UNKNOWN_PRODUCT,
6090 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6091 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6092 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6094 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6095 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6097 /* FIXME */
6099 /* AssignmentType value exists */
6100 sz = MAX_PATH;
6101 lstrcpyA(buf, "apple");
6102 r = pMsiGetProductInfoExA(prodcode, usersid,
6103 MSIINSTALLCONTEXT_USERUNMANAGED,
6104 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
6105 ok(r == ERROR_UNKNOWN_PRODUCT,
6106 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6107 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6108 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6110 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6111 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6113 /* PackageCode value exists */
6114 sz = MAX_PATH;
6115 lstrcpyA(buf, "apple");
6116 r = pMsiGetProductInfoExA(prodcode, usersid,
6117 MSIINSTALLCONTEXT_USERUNMANAGED,
6118 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
6119 ok(r == ERROR_UNKNOWN_PRODUCT,
6120 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6121 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6122 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6124 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6125 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6127 /* Version value exists */
6128 sz = MAX_PATH;
6129 lstrcpyA(buf, "apple");
6130 r = pMsiGetProductInfoExA(prodcode, usersid,
6131 MSIINSTALLCONTEXT_USERUNMANAGED,
6132 INSTALLPROPERTY_VERSIONA, buf, &sz);
6133 ok(r == ERROR_UNKNOWN_PRODUCT,
6134 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6135 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6136 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6138 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6139 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6141 /* ProductIcon value exists */
6142 sz = MAX_PATH;
6143 lstrcpyA(buf, "apple");
6144 r = pMsiGetProductInfoExA(prodcode, usersid,
6145 MSIINSTALLCONTEXT_USERUNMANAGED,
6146 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
6147 ok(r == ERROR_UNKNOWN_PRODUCT,
6148 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6149 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6150 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6152 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6153 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6155 /* PackageName value exists */
6156 sz = MAX_PATH;
6157 lstrcpyA(buf, "apple");
6158 r = pMsiGetProductInfoExA(prodcode, usersid,
6159 MSIINSTALLCONTEXT_USERUNMANAGED,
6160 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
6161 ok(r == ERROR_UNKNOWN_PRODUCT,
6162 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6163 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6164 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6166 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6167 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6169 /* AuthorizedLUAApp value exists */
6170 sz = MAX_PATH;
6171 lstrcpyA(buf, "apple");
6172 r = pMsiGetProductInfoExA(prodcode, usersid,
6173 MSIINSTALLCONTEXT_USERUNMANAGED,
6174 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
6175 ok(r == ERROR_UNKNOWN_PRODUCT,
6176 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6177 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6178 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6180 RegDeleteValueA(propkey, "AuthorizedLUAApp");
6181 RegDeleteValueA(propkey, "PackageName");
6182 RegDeleteValueA(propkey, "ProductIcon");
6183 RegDeleteValueA(propkey, "Version");
6184 RegDeleteValueA(propkey, "PackageCode");
6185 RegDeleteValueA(propkey, "AssignmentType");
6186 RegDeleteValueA(propkey, "ProductName");
6187 RegDeleteValueA(propkey, "Language");
6188 RegDeleteValueA(propkey, "Transforms");
6189 RegDeleteValueA(propkey, "RegOwner");
6190 RegDeleteValueA(propkey, "RegCompany");
6191 RegDeleteValueA(propkey, "ProductID");
6192 RegDeleteValueA(propkey, "DisplayVersion");
6193 RegDeleteValueA(propkey, "VersionMajor");
6194 RegDeleteValueA(propkey, "VersionMinor");
6195 RegDeleteValueA(propkey, "URLUpdateInfo");
6196 RegDeleteValueA(propkey, "URLInfoAbout");
6197 RegDeleteValueA(propkey, "Publisher");
6198 RegDeleteValueA(propkey, "LocalPackage");
6199 RegDeleteValueA(propkey, "InstallSource");
6200 RegDeleteValueA(propkey, "InstallLocation");
6201 RegDeleteValueA(propkey, "DisplayName");
6202 RegDeleteValueA(propkey, "InstallDate");
6203 RegDeleteValueA(propkey, "HelpTelephone");
6204 RegDeleteValueA(propkey, "HelpLink");
6205 RegDeleteValueA(propkey, "LocalPackage");
6206 RegDeleteKeyA(propkey, "");
6207 RegCloseKey(propkey);
6208 RegDeleteKeyA(localkey, "");
6209 RegCloseKey(localkey);
6211 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6212 lstrcatA(keypath, usersid);
6213 lstrcatA(keypath, "\\Installer\\Products\\");
6214 lstrcatA(keypath, prod_squashed);
6216 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
6217 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6219 /* user product key exists */
6220 sz = MAX_PATH;
6221 lstrcpyA(buf, "apple");
6222 r = pMsiGetProductInfoExA(prodcode, usersid,
6223 MSIINSTALLCONTEXT_USERUNMANAGED,
6224 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6225 ok(r == ERROR_UNKNOWN_PRODUCT,
6226 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6227 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6228 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6230 RegDeleteKeyA(userkey, "");
6231 RegCloseKey(userkey);
6233 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
6234 lstrcatA(keypath, prod_squashed);
6236 res = RegCreateKeyExA(HKEY_CURRENT_USER, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
6237 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6239 sz = MAX_PATH;
6240 lstrcpyA(buf, "apple");
6241 r = pMsiGetProductInfoExA(prodcode, usersid,
6242 MSIINSTALLCONTEXT_USERUNMANAGED,
6243 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6244 ok(r == ERROR_SUCCESS || broken(r == ERROR_UNKNOWN_PRODUCT), "Expected ERROR_SUCCESS, got %d\n", r);
6245 if (r == ERROR_UNKNOWN_PRODUCT)
6247 win_skip("skipping remaining tests for MsiGetProductInfoEx\n");
6248 delete_key(prodkey, "", access);
6249 RegCloseKey(prodkey);
6250 return;
6252 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
6253 ok(sz == 1, "Expected 1, got %d\n", sz);
6255 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
6256 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6258 /* HelpLink value exists */
6259 sz = MAX_PATH;
6260 lstrcpyA(buf, "apple");
6261 r = pMsiGetProductInfoExA(prodcode, usersid,
6262 MSIINSTALLCONTEXT_USERUNMANAGED,
6263 INSTALLPROPERTY_HELPLINKA, buf, &sz);
6264 ok(r == ERROR_UNKNOWN_PROPERTY,
6265 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6266 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6267 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6269 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
6270 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6272 /* HelpTelephone value exists */
6273 sz = MAX_PATH;
6274 lstrcpyA(buf, "apple");
6275 r = pMsiGetProductInfoExA(prodcode, usersid,
6276 MSIINSTALLCONTEXT_USERUNMANAGED,
6277 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
6278 ok(r == ERROR_UNKNOWN_PROPERTY,
6279 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6280 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6281 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6283 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
6284 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6286 /* InstallDate value exists */
6287 sz = MAX_PATH;
6288 lstrcpyA(buf, "apple");
6289 r = pMsiGetProductInfoExA(prodcode, usersid,
6290 MSIINSTALLCONTEXT_USERUNMANAGED,
6291 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
6292 ok(r == ERROR_UNKNOWN_PROPERTY,
6293 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6294 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6295 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6297 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
6298 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6300 /* DisplayName value exists */
6301 sz = MAX_PATH;
6302 lstrcpyA(buf, "apple");
6303 r = pMsiGetProductInfoExA(prodcode, usersid,
6304 MSIINSTALLCONTEXT_USERUNMANAGED,
6305 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
6306 ok(r == ERROR_UNKNOWN_PROPERTY,
6307 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6308 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6309 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6311 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6312 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6314 /* InstallLocation value exists */
6315 sz = MAX_PATH;
6316 lstrcpyA(buf, "apple");
6317 r = pMsiGetProductInfoExA(prodcode, usersid,
6318 MSIINSTALLCONTEXT_USERUNMANAGED,
6319 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
6320 ok(r == ERROR_UNKNOWN_PROPERTY,
6321 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6322 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6323 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6325 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6326 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6328 /* InstallSource value exists */
6329 sz = MAX_PATH;
6330 lstrcpyA(buf, "apple");
6331 r = pMsiGetProductInfoExA(prodcode, usersid,
6332 MSIINSTALLCONTEXT_USERUNMANAGED,
6333 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
6334 ok(r == ERROR_UNKNOWN_PROPERTY,
6335 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6336 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6337 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6339 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6340 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6342 /* LocalPackage value exists */
6343 sz = MAX_PATH;
6344 lstrcpyA(buf, "apple");
6345 r = pMsiGetProductInfoExA(prodcode, usersid,
6346 MSIINSTALLCONTEXT_USERUNMANAGED,
6347 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
6348 ok(r == ERROR_UNKNOWN_PROPERTY,
6349 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6350 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6351 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6353 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6354 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6356 /* Publisher value exists */
6357 sz = MAX_PATH;
6358 lstrcpyA(buf, "apple");
6359 r = pMsiGetProductInfoExA(prodcode, usersid,
6360 MSIINSTALLCONTEXT_USERUNMANAGED,
6361 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
6362 ok(r == ERROR_UNKNOWN_PROPERTY,
6363 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6364 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6365 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6367 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6368 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6370 /* URLInfoAbout value exists */
6371 sz = MAX_PATH;
6372 lstrcpyA(buf, "apple");
6373 r = pMsiGetProductInfoExA(prodcode, usersid,
6374 MSIINSTALLCONTEXT_USERUNMANAGED,
6375 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
6376 ok(r == ERROR_UNKNOWN_PROPERTY,
6377 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6378 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6379 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6381 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6382 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6384 /* URLUpdateInfo value exists */
6385 sz = MAX_PATH;
6386 lstrcpyA(buf, "apple");
6387 r = pMsiGetProductInfoExA(prodcode, usersid,
6388 MSIINSTALLCONTEXT_USERUNMANAGED,
6389 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
6390 ok(r == ERROR_UNKNOWN_PROPERTY,
6391 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6392 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6393 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6395 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6396 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6398 /* VersionMinor value exists */
6399 sz = MAX_PATH;
6400 lstrcpyA(buf, "apple");
6401 r = pMsiGetProductInfoExA(prodcode, usersid,
6402 MSIINSTALLCONTEXT_USERUNMANAGED,
6403 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
6404 ok(r == ERROR_UNKNOWN_PROPERTY,
6405 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6406 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6407 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6409 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6410 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6412 /* VersionMajor value exists */
6413 sz = MAX_PATH;
6414 lstrcpyA(buf, "apple");
6415 r = pMsiGetProductInfoExA(prodcode, usersid,
6416 MSIINSTALLCONTEXT_USERUNMANAGED,
6417 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
6418 ok(r == ERROR_UNKNOWN_PROPERTY,
6419 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6420 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6421 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6423 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6424 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6426 /* DisplayVersion value exists */
6427 sz = MAX_PATH;
6428 lstrcpyA(buf, "apple");
6429 r = pMsiGetProductInfoExA(prodcode, usersid,
6430 MSIINSTALLCONTEXT_USERUNMANAGED,
6431 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
6432 ok(r == ERROR_UNKNOWN_PROPERTY,
6433 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6434 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6435 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6437 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6438 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6440 /* ProductID value exists */
6441 sz = MAX_PATH;
6442 lstrcpyA(buf, "apple");
6443 r = pMsiGetProductInfoExA(prodcode, usersid,
6444 MSIINSTALLCONTEXT_USERUNMANAGED,
6445 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
6446 ok(r == ERROR_UNKNOWN_PROPERTY,
6447 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6448 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6449 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6451 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6452 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6454 /* RegCompany value exists */
6455 sz = MAX_PATH;
6456 lstrcpyA(buf, "apple");
6457 r = pMsiGetProductInfoExA(prodcode, usersid,
6458 MSIINSTALLCONTEXT_USERUNMANAGED,
6459 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
6460 ok(r == ERROR_UNKNOWN_PROPERTY,
6461 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6462 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6463 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6465 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6466 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6468 /* RegOwner value exists */
6469 sz = MAX_PATH;
6470 lstrcpyA(buf, "apple");
6471 r = pMsiGetProductInfoExA(prodcode, usersid,
6472 MSIINSTALLCONTEXT_USERUNMANAGED,
6473 INSTALLPROPERTY_REGOWNERA, buf, &sz);
6474 ok(r == ERROR_UNKNOWN_PROPERTY,
6475 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6476 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6477 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6479 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6480 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6482 /* Transforms value exists */
6483 sz = MAX_PATH;
6484 lstrcpyA(buf, "apple");
6485 r = pMsiGetProductInfoExA(prodcode, usersid,
6486 MSIINSTALLCONTEXT_USERUNMANAGED,
6487 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
6488 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6489 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
6490 ok(sz == 5, "Expected 5, got %d\n", sz);
6492 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6493 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6495 /* Language value exists */
6496 sz = MAX_PATH;
6497 lstrcpyA(buf, "apple");
6498 r = pMsiGetProductInfoExA(prodcode, usersid,
6499 MSIINSTALLCONTEXT_USERUNMANAGED,
6500 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
6501 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6502 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
6503 ok(sz == 4, "Expected 4, got %d\n", sz);
6505 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6506 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6508 /* ProductName value exists */
6509 sz = MAX_PATH;
6510 lstrcpyA(buf, "apple");
6511 r = pMsiGetProductInfoExA(prodcode, usersid,
6512 MSIINSTALLCONTEXT_USERUNMANAGED,
6513 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
6514 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6515 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6516 ok(sz == 4, "Expected 4, got %d\n", sz);
6518 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6519 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6521 /* FIXME */
6523 /* AssignmentType value exists */
6524 sz = MAX_PATH;
6525 lstrcpyA(buf, "apple");
6526 r = pMsiGetProductInfoExA(prodcode, usersid,
6527 MSIINSTALLCONTEXT_USERUNMANAGED,
6528 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
6529 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6530 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
6531 ok(sz == 0, "Expected 0, got %d\n", sz);
6533 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6534 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6536 /* FIXME */
6538 /* PackageCode value exists */
6539 sz = MAX_PATH;
6540 lstrcpyA(buf, "apple");
6541 r = pMsiGetProductInfoExA(prodcode, usersid,
6542 MSIINSTALLCONTEXT_USERUNMANAGED,
6543 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
6544 todo_wine
6546 ok(r == ERROR_BAD_CONFIGURATION,
6547 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
6548 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6549 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6552 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6553 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6555 /* Version value exists */
6556 sz = MAX_PATH;
6557 lstrcpyA(buf, "apple");
6558 r = pMsiGetProductInfoExA(prodcode, usersid,
6559 MSIINSTALLCONTEXT_USERUNMANAGED,
6560 INSTALLPROPERTY_VERSIONA, buf, &sz);
6561 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6562 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
6563 ok(sz == 3, "Expected 3, got %d\n", sz);
6565 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6566 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6568 /* ProductIcon value exists */
6569 sz = MAX_PATH;
6570 lstrcpyA(buf, "apple");
6571 r = pMsiGetProductInfoExA(prodcode, usersid,
6572 MSIINSTALLCONTEXT_USERUNMANAGED,
6573 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
6574 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6575 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
6576 ok(sz == 4, "Expected 4, got %d\n", sz);
6578 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6579 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6581 /* PackageName value exists */
6582 sz = MAX_PATH;
6583 lstrcpyA(buf, "apple");
6584 r = pMsiGetProductInfoExA(prodcode, usersid,
6585 MSIINSTALLCONTEXT_USERUNMANAGED,
6586 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
6587 todo_wine
6589 ok(r == ERROR_UNKNOWN_PRODUCT,
6590 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6591 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6592 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6595 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6596 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6598 /* AuthorizedLUAApp value exists */
6599 sz = MAX_PATH;
6600 lstrcpyA(buf, "apple");
6601 r = pMsiGetProductInfoExA(prodcode, usersid,
6602 MSIINSTALLCONTEXT_USERUNMANAGED,
6603 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
6604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6605 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
6606 ok(sz == 4, "Expected 4, got %d\n", sz);
6608 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
6609 RegDeleteValueA(prodkey, "PackageName");
6610 RegDeleteValueA(prodkey, "ProductIcon");
6611 RegDeleteValueA(prodkey, "Version");
6612 RegDeleteValueA(prodkey, "PackageCode");
6613 RegDeleteValueA(prodkey, "AssignmentType");
6614 RegDeleteValueA(prodkey, "ProductName");
6615 RegDeleteValueA(prodkey, "Language");
6616 RegDeleteValueA(prodkey, "Transforms");
6617 RegDeleteValueA(prodkey, "RegOwner");
6618 RegDeleteValueA(prodkey, "RegCompany");
6619 RegDeleteValueA(prodkey, "ProductID");
6620 RegDeleteValueA(prodkey, "DisplayVersion");
6621 RegDeleteValueA(prodkey, "VersionMajor");
6622 RegDeleteValueA(prodkey, "VersionMinor");
6623 RegDeleteValueA(prodkey, "URLUpdateInfo");
6624 RegDeleteValueA(prodkey, "URLInfoAbout");
6625 RegDeleteValueA(prodkey, "Publisher");
6626 RegDeleteValueA(prodkey, "LocalPackage");
6627 RegDeleteValueA(prodkey, "InstallSource");
6628 RegDeleteValueA(prodkey, "InstallLocation");
6629 RegDeleteValueA(prodkey, "DisplayName");
6630 RegDeleteValueA(prodkey, "InstallDate");
6631 RegDeleteValueA(prodkey, "HelpTelephone");
6632 RegDeleteValueA(prodkey, "HelpLink");
6633 RegDeleteValueA(prodkey, "LocalPackage");
6634 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
6635 RegCloseKey(prodkey);
6637 /* MSIINSTALLCONTEXT_USERMANAGED */
6639 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
6640 lstrcatA(keypath, usersid);
6641 lstrcatA(keypath, "\\Products\\");
6642 lstrcatA(keypath, prod_squashed);
6644 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
6645 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6647 /* local user product key exists */
6648 sz = MAX_PATH;
6649 lstrcpyA(buf, "apple");
6650 r = pMsiGetProductInfoExA(prodcode, usersid,
6651 MSIINSTALLCONTEXT_USERMANAGED,
6652 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6653 ok(r == ERROR_UNKNOWN_PRODUCT,
6654 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6655 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6656 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6658 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
6659 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6661 /* InstallProperties key exists */
6662 sz = MAX_PATH;
6663 lstrcpyA(buf, "apple");
6664 r = pMsiGetProductInfoExA(prodcode, usersid,
6665 MSIINSTALLCONTEXT_USERMANAGED,
6666 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6667 ok(r == ERROR_UNKNOWN_PRODUCT,
6668 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6669 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6670 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6672 res = RegSetValueExA(propkey, "ManagedLocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6673 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6675 /* ManagedLocalPackage value exists */
6676 sz = MAX_PATH;
6677 lstrcpyA(buf, "apple");
6678 r = pMsiGetProductInfoExA(prodcode, usersid,
6679 MSIINSTALLCONTEXT_USERMANAGED,
6680 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6682 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
6683 ok(sz == 1, "Expected 1, got %d\n", sz);
6685 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
6686 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6688 /* HelpLink value exists */
6689 sz = MAX_PATH;
6690 lstrcpyA(buf, "apple");
6691 r = pMsiGetProductInfoExA(prodcode, usersid,
6692 MSIINSTALLCONTEXT_USERMANAGED,
6693 INSTALLPROPERTY_HELPLINKA, buf, &sz);
6694 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6695 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
6696 ok(sz == 4, "Expected 4, got %d\n", sz);
6698 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
6699 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6701 /* HelpTelephone value exists */
6702 sz = MAX_PATH;
6703 lstrcpyA(buf, "apple");
6704 r = pMsiGetProductInfoExA(prodcode, usersid,
6705 MSIINSTALLCONTEXT_USERMANAGED,
6706 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
6707 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6708 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
6709 ok(sz == 5, "Expected 5, got %d\n", sz);
6711 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
6712 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6714 /* InstallDate value exists */
6715 sz = MAX_PATH;
6716 lstrcpyA(buf, "apple");
6717 r = pMsiGetProductInfoExA(prodcode, usersid,
6718 MSIINSTALLCONTEXT_USERMANAGED,
6719 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
6720 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6721 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
6722 ok(sz == 4, "Expected 4, got %d\n", sz);
6724 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
6725 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6727 /* DisplayName value exists */
6728 sz = MAX_PATH;
6729 lstrcpyA(buf, "apple");
6730 r = pMsiGetProductInfoExA(prodcode, usersid,
6731 MSIINSTALLCONTEXT_USERMANAGED,
6732 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
6733 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6734 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6735 ok(sz == 4, "Expected 4, got %d\n", sz);
6737 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6738 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6740 /* InstallLocation value exists */
6741 sz = MAX_PATH;
6742 lstrcpyA(buf, "apple");
6743 r = pMsiGetProductInfoExA(prodcode, usersid,
6744 MSIINSTALLCONTEXT_USERMANAGED,
6745 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
6746 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6747 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
6748 ok(sz == 3, "Expected 3, got %d\n", sz);
6750 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6751 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6753 /* InstallSource value exists */
6754 sz = MAX_PATH;
6755 lstrcpyA(buf, "apple");
6756 r = pMsiGetProductInfoExA(prodcode, usersid,
6757 MSIINSTALLCONTEXT_USERMANAGED,
6758 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
6759 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6760 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
6761 ok(sz == 6, "Expected 6, got %d\n", sz);
6763 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6764 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6766 /* LocalPackage value exists */
6767 sz = MAX_PATH;
6768 lstrcpyA(buf, "apple");
6769 r = pMsiGetProductInfoExA(prodcode, usersid,
6770 MSIINSTALLCONTEXT_USERMANAGED,
6771 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
6772 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6773 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
6774 ok(sz == 5, "Expected 5, got %d\n", sz);
6776 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6777 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6779 /* Publisher value exists */
6780 sz = MAX_PATH;
6781 lstrcpyA(buf, "apple");
6782 r = pMsiGetProductInfoExA(prodcode, usersid,
6783 MSIINSTALLCONTEXT_USERMANAGED,
6784 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
6785 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6786 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
6787 ok(sz == 3, "Expected 3, got %d\n", sz);
6789 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6790 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6792 /* URLInfoAbout value exists */
6793 sz = MAX_PATH;
6794 lstrcpyA(buf, "apple");
6795 r = pMsiGetProductInfoExA(prodcode, usersid,
6796 MSIINSTALLCONTEXT_USERMANAGED,
6797 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
6798 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6799 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
6800 ok(sz == 5, "Expected 5, got %d\n", sz);
6802 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6803 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6805 /* URLUpdateInfo value exists */
6806 sz = MAX_PATH;
6807 lstrcpyA(buf, "apple");
6808 r = pMsiGetProductInfoExA(prodcode, usersid,
6809 MSIINSTALLCONTEXT_USERMANAGED,
6810 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
6811 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6812 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
6813 ok(sz == 6, "Expected 6, got %d\n", sz);
6815 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6816 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6818 /* VersionMinor value exists */
6819 sz = MAX_PATH;
6820 lstrcpyA(buf, "apple");
6821 r = pMsiGetProductInfoExA(prodcode, usersid,
6822 MSIINSTALLCONTEXT_USERMANAGED,
6823 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
6824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6825 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
6826 ok(sz == 1, "Expected 1, got %d\n", sz);
6828 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6829 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6831 /* VersionMajor value exists */
6832 sz = MAX_PATH;
6833 lstrcpyA(buf, "apple");
6834 r = pMsiGetProductInfoExA(prodcode, usersid,
6835 MSIINSTALLCONTEXT_USERMANAGED,
6836 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
6837 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6838 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
6839 ok(sz == 1, "Expected 1, got %d\n", sz);
6841 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6842 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6844 /* DisplayVersion value exists */
6845 sz = MAX_PATH;
6846 lstrcpyA(buf, "apple");
6847 r = pMsiGetProductInfoExA(prodcode, usersid,
6848 MSIINSTALLCONTEXT_USERMANAGED,
6849 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
6850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6851 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
6852 ok(sz == 5, "Expected 5, got %d\n", sz);
6854 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6855 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6857 /* ProductID value exists */
6858 sz = MAX_PATH;
6859 lstrcpyA(buf, "apple");
6860 r = pMsiGetProductInfoExA(prodcode, usersid,
6861 MSIINSTALLCONTEXT_USERMANAGED,
6862 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
6863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6864 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
6865 ok(sz == 2, "Expected 2, got %d\n", sz);
6867 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6868 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6870 /* RegCompany value exists */
6871 sz = MAX_PATH;
6872 lstrcpyA(buf, "apple");
6873 r = pMsiGetProductInfoExA(prodcode, usersid,
6874 MSIINSTALLCONTEXT_USERMANAGED,
6875 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
6876 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6877 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
6878 ok(sz == 4, "Expected 4, got %d\n", sz);
6880 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6881 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6883 /* RegOwner value exists */
6884 sz = MAX_PATH;
6885 lstrcpyA(buf, "apple");
6886 r = pMsiGetProductInfoExA(prodcode, usersid,
6887 MSIINSTALLCONTEXT_USERMANAGED,
6888 INSTALLPROPERTY_REGOWNERA, buf, &sz);
6889 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6890 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
6891 ok(sz == 5, "Expected 5, got %d\n", sz);
6893 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6894 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6896 /* Transforms value exists */
6897 sz = MAX_PATH;
6898 lstrcpyA(buf, "apple");
6899 r = pMsiGetProductInfoExA(prodcode, usersid,
6900 MSIINSTALLCONTEXT_USERMANAGED,
6901 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
6902 ok(r == ERROR_UNKNOWN_PRODUCT,
6903 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6904 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6905 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6907 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6908 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6910 /* Language value exists */
6911 sz = MAX_PATH;
6912 lstrcpyA(buf, "apple");
6913 r = pMsiGetProductInfoExA(prodcode, usersid,
6914 MSIINSTALLCONTEXT_USERMANAGED,
6915 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
6916 ok(r == ERROR_UNKNOWN_PRODUCT,
6917 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6918 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6919 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6921 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6922 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6924 /* ProductName value exists */
6925 sz = MAX_PATH;
6926 lstrcpyA(buf, "apple");
6927 r = pMsiGetProductInfoExA(prodcode, usersid,
6928 MSIINSTALLCONTEXT_USERMANAGED,
6929 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
6930 ok(r == ERROR_UNKNOWN_PRODUCT,
6931 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6932 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6933 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6935 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6936 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6938 /* FIXME */
6940 /* AssignmentType value exists */
6941 sz = MAX_PATH;
6942 lstrcpyA(buf, "apple");
6943 r = pMsiGetProductInfoExA(prodcode, usersid,
6944 MSIINSTALLCONTEXT_USERMANAGED,
6945 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
6946 ok(r == ERROR_UNKNOWN_PRODUCT,
6947 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6948 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6949 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6951 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6952 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6954 /* PackageCode value exists */
6955 sz = MAX_PATH;
6956 lstrcpyA(buf, "apple");
6957 r = pMsiGetProductInfoExA(prodcode, usersid,
6958 MSIINSTALLCONTEXT_USERMANAGED,
6959 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
6960 ok(r == ERROR_UNKNOWN_PRODUCT,
6961 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6962 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6963 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6965 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6966 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6968 /* Version value exists */
6969 sz = MAX_PATH;
6970 lstrcpyA(buf, "apple");
6971 r = pMsiGetProductInfoExA(prodcode, usersid,
6972 MSIINSTALLCONTEXT_USERMANAGED,
6973 INSTALLPROPERTY_VERSIONA, buf, &sz);
6974 ok(r == ERROR_UNKNOWN_PRODUCT,
6975 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6976 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6977 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6979 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6980 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6982 /* ProductIcon value exists */
6983 sz = MAX_PATH;
6984 lstrcpyA(buf, "apple");
6985 r = pMsiGetProductInfoExA(prodcode, usersid,
6986 MSIINSTALLCONTEXT_USERMANAGED,
6987 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
6988 ok(r == ERROR_UNKNOWN_PRODUCT,
6989 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6990 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6991 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6993 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6994 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6996 /* PackageName value exists */
6997 sz = MAX_PATH;
6998 lstrcpyA(buf, "apple");
6999 r = pMsiGetProductInfoExA(prodcode, usersid,
7000 MSIINSTALLCONTEXT_USERMANAGED,
7001 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
7002 ok(r == ERROR_UNKNOWN_PRODUCT,
7003 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7004 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7005 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7007 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
7008 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7010 /* AuthorizedLUAApp value exists */
7011 sz = MAX_PATH;
7012 lstrcpyA(buf, "apple");
7013 r = pMsiGetProductInfoExA(prodcode, usersid,
7014 MSIINSTALLCONTEXT_USERMANAGED,
7015 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
7016 ok(r == ERROR_UNKNOWN_PRODUCT,
7017 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7018 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7019 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7021 RegDeleteValueA(propkey, "AuthorizedLUAApp");
7022 RegDeleteValueA(propkey, "PackageName");
7023 RegDeleteValueA(propkey, "ProductIcon");
7024 RegDeleteValueA(propkey, "Version");
7025 RegDeleteValueA(propkey, "PackageCode");
7026 RegDeleteValueA(propkey, "AssignmentType");
7027 RegDeleteValueA(propkey, "ProductName");
7028 RegDeleteValueA(propkey, "Language");
7029 RegDeleteValueA(propkey, "Transforms");
7030 RegDeleteValueA(propkey, "RegOwner");
7031 RegDeleteValueA(propkey, "RegCompany");
7032 RegDeleteValueA(propkey, "ProductID");
7033 RegDeleteValueA(propkey, "DisplayVersion");
7034 RegDeleteValueA(propkey, "VersionMajor");
7035 RegDeleteValueA(propkey, "VersionMinor");
7036 RegDeleteValueA(propkey, "URLUpdateInfo");
7037 RegDeleteValueA(propkey, "URLInfoAbout");
7038 RegDeleteValueA(propkey, "Publisher");
7039 RegDeleteValueA(propkey, "LocalPackage");
7040 RegDeleteValueA(propkey, "InstallSource");
7041 RegDeleteValueA(propkey, "InstallLocation");
7042 RegDeleteValueA(propkey, "DisplayName");
7043 RegDeleteValueA(propkey, "InstallDate");
7044 RegDeleteValueA(propkey, "HelpTelephone");
7045 RegDeleteValueA(propkey, "HelpLink");
7046 RegDeleteValueA(propkey, "ManagedLocalPackage");
7047 delete_key(propkey, "", access & KEY_WOW64_64KEY);
7048 RegCloseKey(propkey);
7049 delete_key(localkey, "", access & KEY_WOW64_64KEY);
7050 RegCloseKey(localkey);
7052 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
7053 lstrcatA(keypath, usersid);
7054 lstrcatA(keypath, "\\Installer\\Products\\");
7055 lstrcatA(keypath, prod_squashed);
7057 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
7058 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7060 /* user product key exists */
7061 sz = MAX_PATH;
7062 lstrcpyA(buf, "apple");
7063 r = pMsiGetProductInfoExA(prodcode, usersid,
7064 MSIINSTALLCONTEXT_USERMANAGED,
7065 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7067 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
7068 ok(sz == 1, "Expected 1, got %d\n", sz);
7070 delete_key(userkey, "", access & KEY_WOW64_64KEY);
7071 RegCloseKey(userkey);
7073 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
7074 lstrcatA(keypath, prod_squashed);
7076 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
7077 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7079 /* current user product key exists */
7080 sz = MAX_PATH;
7081 lstrcpyA(buf, "apple");
7082 r = pMsiGetProductInfoExA(prodcode, usersid,
7083 MSIINSTALLCONTEXT_USERMANAGED,
7084 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7085 ok(r == ERROR_UNKNOWN_PRODUCT,
7086 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7087 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7088 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7090 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7091 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7093 /* HelpLink value exists, user product key does not exist */
7094 sz = MAX_PATH;
7095 lstrcpyA(buf, "apple");
7096 r = pMsiGetProductInfoExA(prodcode, usersid,
7097 MSIINSTALLCONTEXT_USERMANAGED,
7098 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7099 ok(r == ERROR_UNKNOWN_PRODUCT,
7100 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7101 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7102 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7104 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
7105 lstrcatA(keypath, usersid);
7106 lstrcatA(keypath, "\\Installer\\Products\\");
7107 lstrcatA(keypath, prod_squashed);
7109 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
7110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7112 res = RegSetValueExA(userkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7113 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7115 /* HelpLink value exists, user product key does exist */
7116 sz = MAX_PATH;
7117 lstrcpyA(buf, "apple");
7118 r = pMsiGetProductInfoExA(prodcode, usersid,
7119 MSIINSTALLCONTEXT_USERMANAGED,
7120 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7121 ok(r == ERROR_UNKNOWN_PROPERTY,
7122 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7123 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7124 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7126 res = RegSetValueExA(userkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
7127 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7129 /* HelpTelephone value exists */
7130 sz = MAX_PATH;
7131 lstrcpyA(buf, "apple");
7132 r = pMsiGetProductInfoExA(prodcode, usersid,
7133 MSIINSTALLCONTEXT_USERMANAGED,
7134 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
7135 ok(r == ERROR_UNKNOWN_PROPERTY,
7136 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7137 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7138 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7140 res = RegSetValueExA(userkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
7141 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7143 /* InstallDate value exists */
7144 sz = MAX_PATH;
7145 lstrcpyA(buf, "apple");
7146 r = pMsiGetProductInfoExA(prodcode, usersid,
7147 MSIINSTALLCONTEXT_USERMANAGED,
7148 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
7149 ok(r == ERROR_UNKNOWN_PROPERTY,
7150 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7151 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7152 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7154 res = RegSetValueExA(userkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
7155 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7157 /* DisplayName value exists */
7158 sz = MAX_PATH;
7159 lstrcpyA(buf, "apple");
7160 r = pMsiGetProductInfoExA(prodcode, usersid,
7161 MSIINSTALLCONTEXT_USERMANAGED,
7162 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
7163 ok(r == ERROR_UNKNOWN_PROPERTY,
7164 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7165 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7166 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7168 res = RegSetValueExA(userkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
7169 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7171 /* InstallLocation value exists */
7172 sz = MAX_PATH;
7173 lstrcpyA(buf, "apple");
7174 r = pMsiGetProductInfoExA(prodcode, usersid,
7175 MSIINSTALLCONTEXT_USERMANAGED,
7176 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
7177 ok(r == ERROR_UNKNOWN_PROPERTY,
7178 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7179 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7180 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7182 res = RegSetValueExA(userkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
7183 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7185 /* InstallSource value exists */
7186 sz = MAX_PATH;
7187 lstrcpyA(buf, "apple");
7188 r = pMsiGetProductInfoExA(prodcode, usersid,
7189 MSIINSTALLCONTEXT_USERMANAGED,
7190 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
7191 ok(r == ERROR_UNKNOWN_PROPERTY,
7192 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7193 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7194 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7196 res = RegSetValueExA(userkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
7197 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7199 /* LocalPackage value exists */
7200 sz = MAX_PATH;
7201 lstrcpyA(buf, "apple");
7202 r = pMsiGetProductInfoExA(prodcode, usersid,
7203 MSIINSTALLCONTEXT_USERMANAGED,
7204 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
7205 ok(r == ERROR_UNKNOWN_PROPERTY,
7206 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7207 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7208 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7210 res = RegSetValueExA(userkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
7211 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7213 /* Publisher value exists */
7214 sz = MAX_PATH;
7215 lstrcpyA(buf, "apple");
7216 r = pMsiGetProductInfoExA(prodcode, usersid,
7217 MSIINSTALLCONTEXT_USERMANAGED,
7218 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
7219 ok(r == ERROR_UNKNOWN_PROPERTY,
7220 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7221 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7222 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7224 res = RegSetValueExA(userkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
7225 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7227 /* URLInfoAbout value exists */
7228 sz = MAX_PATH;
7229 lstrcpyA(buf, "apple");
7230 r = pMsiGetProductInfoExA(prodcode, usersid,
7231 MSIINSTALLCONTEXT_USERMANAGED,
7232 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
7233 ok(r == ERROR_UNKNOWN_PROPERTY,
7234 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7235 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7236 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7238 res = RegSetValueExA(userkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
7239 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7241 /* URLUpdateInfo value exists */
7242 sz = MAX_PATH;
7243 lstrcpyA(buf, "apple");
7244 r = pMsiGetProductInfoExA(prodcode, usersid,
7245 MSIINSTALLCONTEXT_USERMANAGED,
7246 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
7247 ok(r == ERROR_UNKNOWN_PROPERTY,
7248 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7249 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7250 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7252 res = RegSetValueExA(userkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
7253 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7255 /* VersionMinor value exists */
7256 sz = MAX_PATH;
7257 lstrcpyA(buf, "apple");
7258 r = pMsiGetProductInfoExA(prodcode, usersid,
7259 MSIINSTALLCONTEXT_USERMANAGED,
7260 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
7261 ok(r == ERROR_UNKNOWN_PROPERTY,
7262 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7263 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7264 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7266 res = RegSetValueExA(userkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
7267 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7269 /* VersionMajor value exists */
7270 sz = MAX_PATH;
7271 lstrcpyA(buf, "apple");
7272 r = pMsiGetProductInfoExA(prodcode, usersid,
7273 MSIINSTALLCONTEXT_USERMANAGED,
7274 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
7275 ok(r == ERROR_UNKNOWN_PROPERTY,
7276 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7277 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7278 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7280 res = RegSetValueExA(userkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
7281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7283 /* DisplayVersion value exists */
7284 sz = MAX_PATH;
7285 lstrcpyA(buf, "apple");
7286 r = pMsiGetProductInfoExA(prodcode, usersid,
7287 MSIINSTALLCONTEXT_USERMANAGED,
7288 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
7289 ok(r == ERROR_UNKNOWN_PROPERTY,
7290 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7291 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7292 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7294 res = RegSetValueExA(userkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
7295 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7297 /* ProductID value exists */
7298 sz = MAX_PATH;
7299 lstrcpyA(buf, "apple");
7300 r = pMsiGetProductInfoExA(prodcode, usersid,
7301 MSIINSTALLCONTEXT_USERMANAGED,
7302 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
7303 ok(r == ERROR_UNKNOWN_PROPERTY,
7304 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7305 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7306 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7308 res = RegSetValueExA(userkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
7309 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7311 /* RegCompany value exists */
7312 sz = MAX_PATH;
7313 lstrcpyA(buf, "apple");
7314 r = pMsiGetProductInfoExA(prodcode, usersid,
7315 MSIINSTALLCONTEXT_USERMANAGED,
7316 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
7317 ok(r == ERROR_UNKNOWN_PROPERTY,
7318 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7319 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7320 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7322 res = RegSetValueExA(userkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
7323 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7325 /* RegOwner value exists */
7326 sz = MAX_PATH;
7327 lstrcpyA(buf, "apple");
7328 r = pMsiGetProductInfoExA(prodcode, usersid,
7329 MSIINSTALLCONTEXT_USERMANAGED,
7330 INSTALLPROPERTY_REGOWNERA, buf, &sz);
7331 ok(r == ERROR_UNKNOWN_PROPERTY,
7332 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7333 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7334 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7336 res = RegSetValueExA(userkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
7337 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7339 /* Transforms value exists */
7340 sz = MAX_PATH;
7341 lstrcpyA(buf, "apple");
7342 r = pMsiGetProductInfoExA(prodcode, usersid,
7343 MSIINSTALLCONTEXT_USERMANAGED,
7344 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
7345 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7346 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
7347 ok(sz == 5, "Expected 5, got %d\n", sz);
7349 res = RegSetValueExA(userkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
7350 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7352 /* Language value exists */
7353 sz = MAX_PATH;
7354 lstrcpyA(buf, "apple");
7355 r = pMsiGetProductInfoExA(prodcode, usersid,
7356 MSIINSTALLCONTEXT_USERMANAGED,
7357 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
7358 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7359 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
7360 ok(sz == 4, "Expected 4, got %d\n", sz);
7362 res = RegSetValueExA(userkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
7363 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7365 /* ProductName value exists */
7366 sz = MAX_PATH;
7367 lstrcpyA(buf, "apple");
7368 r = pMsiGetProductInfoExA(prodcode, usersid,
7369 MSIINSTALLCONTEXT_USERMANAGED,
7370 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
7371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7372 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
7373 ok(sz == 4, "Expected 4, got %d\n", sz);
7375 res = RegSetValueExA(userkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
7376 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7378 /* FIXME */
7380 /* AssignmentType value exists */
7381 sz = MAX_PATH;
7382 lstrcpyA(buf, "apple");
7383 r = pMsiGetProductInfoExA(prodcode, usersid,
7384 MSIINSTALLCONTEXT_USERMANAGED,
7385 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
7386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7387 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7388 ok(sz == 0, "Expected 0, got %d\n", sz);
7390 res = RegSetValueExA(userkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
7391 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7393 /* FIXME */
7395 /* PackageCode value exists */
7396 sz = MAX_PATH;
7397 lstrcpyA(buf, "apple");
7398 r = pMsiGetProductInfoExA(prodcode, usersid,
7399 MSIINSTALLCONTEXT_USERMANAGED,
7400 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
7401 todo_wine
7403 ok(r == ERROR_BAD_CONFIGURATION,
7404 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
7405 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7406 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7409 res = RegSetValueExA(userkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
7410 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7412 /* Version value exists */
7413 sz = MAX_PATH;
7414 lstrcpyA(buf, "apple");
7415 r = pMsiGetProductInfoExA(prodcode, usersid,
7416 MSIINSTALLCONTEXT_USERMANAGED,
7417 INSTALLPROPERTY_VERSIONA, buf, &sz);
7418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7419 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
7420 ok(sz == 3, "Expected 3, got %d\n", sz);
7422 res = RegSetValueExA(userkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
7423 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7425 /* ProductIcon value exists */
7426 sz = MAX_PATH;
7427 lstrcpyA(buf, "apple");
7428 r = pMsiGetProductInfoExA(prodcode, usersid,
7429 MSIINSTALLCONTEXT_USERMANAGED,
7430 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
7431 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7432 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
7433 ok(sz == 4, "Expected 4, got %d\n", sz);
7435 res = RegSetValueExA(userkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
7436 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7438 /* PackageName value exists */
7439 sz = MAX_PATH;
7440 lstrcpyA(buf, "apple");
7441 r = pMsiGetProductInfoExA(prodcode, usersid,
7442 MSIINSTALLCONTEXT_USERMANAGED,
7443 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
7444 todo_wine
7446 ok(r == ERROR_UNKNOWN_PRODUCT,
7447 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7448 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7449 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7452 res = RegSetValueExA(userkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
7453 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7455 /* AuthorizedLUAApp value exists */
7456 sz = MAX_PATH;
7457 lstrcpyA(buf, "apple");
7458 r = pMsiGetProductInfoExA(prodcode, usersid,
7459 MSIINSTALLCONTEXT_USERMANAGED,
7460 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
7461 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7462 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
7463 ok(sz == 4, "Expected 4, got %d\n", sz);
7465 RegDeleteValueA(userkey, "AuthorizedLUAApp");
7466 RegDeleteValueA(userkey, "PackageName");
7467 RegDeleteValueA(userkey, "ProductIcon");
7468 RegDeleteValueA(userkey, "Version");
7469 RegDeleteValueA(userkey, "PackageCode");
7470 RegDeleteValueA(userkey, "AssignmentType");
7471 RegDeleteValueA(userkey, "ProductName");
7472 RegDeleteValueA(userkey, "Language");
7473 RegDeleteValueA(userkey, "Transforms");
7474 RegDeleteValueA(userkey, "RegOwner");
7475 RegDeleteValueA(userkey, "RegCompany");
7476 RegDeleteValueA(userkey, "ProductID");
7477 RegDeleteValueA(userkey, "DisplayVersion");
7478 RegDeleteValueA(userkey, "VersionMajor");
7479 RegDeleteValueA(userkey, "VersionMinor");
7480 RegDeleteValueA(userkey, "URLUpdateInfo");
7481 RegDeleteValueA(userkey, "URLInfoAbout");
7482 RegDeleteValueA(userkey, "Publisher");
7483 RegDeleteValueA(userkey, "LocalPackage");
7484 RegDeleteValueA(userkey, "InstallSource");
7485 RegDeleteValueA(userkey, "InstallLocation");
7486 RegDeleteValueA(userkey, "DisplayName");
7487 RegDeleteValueA(userkey, "InstallDate");
7488 RegDeleteValueA(userkey, "HelpTelephone");
7489 RegDeleteValueA(userkey, "HelpLink");
7490 delete_key(userkey, "", access & KEY_WOW64_64KEY);
7491 RegCloseKey(userkey);
7492 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
7493 RegCloseKey(prodkey);
7495 /* MSIINSTALLCONTEXT_MACHINE */
7497 /* szUserSid is non-NULL */
7498 sz = MAX_PATH;
7499 lstrcpyA(buf, "apple");
7500 r = pMsiGetProductInfoExA(prodcode, usersid,
7501 MSIINSTALLCONTEXT_MACHINE,
7502 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7503 ok(r == ERROR_INVALID_PARAMETER,
7504 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7505 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7506 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7508 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
7509 lstrcatA(keypath, prod_squashed);
7511 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
7512 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7514 /* local system product key exists */
7515 sz = MAX_PATH;
7516 lstrcpyA(buf, "apple");
7517 r = pMsiGetProductInfoExA(prodcode, NULL,
7518 MSIINSTALLCONTEXT_MACHINE,
7519 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7520 ok(r == ERROR_UNKNOWN_PRODUCT,
7521 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7522 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7523 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7525 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
7526 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7528 /* InstallProperties key exists */
7529 sz = MAX_PATH;
7530 lstrcpyA(buf, "apple");
7531 r = pMsiGetProductInfoExA(prodcode, NULL,
7532 MSIINSTALLCONTEXT_MACHINE,
7533 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7534 ok(r == ERROR_UNKNOWN_PRODUCT,
7535 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7536 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7537 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7539 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
7540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7542 /* LocalPackage value exists */
7543 sz = MAX_PATH;
7544 lstrcpyA(buf, "apple");
7545 r = pMsiGetProductInfoExA(prodcode, NULL,
7546 MSIINSTALLCONTEXT_MACHINE,
7547 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7549 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
7550 ok(sz == 1, "Expected 1, got %d\n", sz);
7552 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7553 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7555 /* HelpLink value exists */
7556 sz = MAX_PATH;
7557 lstrcpyA(buf, "apple");
7558 r = pMsiGetProductInfoExA(prodcode, NULL,
7559 MSIINSTALLCONTEXT_MACHINE,
7560 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7561 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7562 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
7563 ok(sz == 4, "Expected 4, got %d\n", sz);
7565 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
7566 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7568 /* HelpTelephone value exists */
7569 sz = MAX_PATH;
7570 lstrcpyA(buf, "apple");
7571 r = pMsiGetProductInfoExA(prodcode, NULL,
7572 MSIINSTALLCONTEXT_MACHINE,
7573 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
7574 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7575 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
7576 ok(sz == 5, "Expected 5, got %d\n", sz);
7578 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
7579 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7581 /* InstallDate value exists */
7582 sz = MAX_PATH;
7583 lstrcpyA(buf, "apple");
7584 r = pMsiGetProductInfoExA(prodcode, NULL,
7585 MSIINSTALLCONTEXT_MACHINE,
7586 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
7587 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7588 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
7589 ok(sz == 4, "Expected 4, got %d\n", sz);
7591 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
7592 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7594 /* DisplayName value exists */
7595 sz = MAX_PATH;
7596 lstrcpyA(buf, "apple");
7597 r = pMsiGetProductInfoExA(prodcode, NULL,
7598 MSIINSTALLCONTEXT_MACHINE,
7599 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
7600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7601 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
7602 ok(sz == 4, "Expected 4, got %d\n", sz);
7604 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
7605 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7607 /* InstallLocation value exists */
7608 sz = MAX_PATH;
7609 lstrcpyA(buf, "apple");
7610 r = pMsiGetProductInfoExA(prodcode, NULL,
7611 MSIINSTALLCONTEXT_MACHINE,
7612 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
7613 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7614 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
7615 ok(sz == 3, "Expected 3, got %d\n", sz);
7617 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
7618 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7620 /* InstallSource value exists */
7621 sz = MAX_PATH;
7622 lstrcpyA(buf, "apple");
7623 r = pMsiGetProductInfoExA(prodcode, NULL,
7624 MSIINSTALLCONTEXT_MACHINE,
7625 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
7626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7627 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
7628 ok(sz == 6, "Expected 6, got %d\n", sz);
7630 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
7631 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7633 /* LocalPackage value exists */
7634 sz = MAX_PATH;
7635 lstrcpyA(buf, "apple");
7636 r = pMsiGetProductInfoExA(prodcode, NULL,
7637 MSIINSTALLCONTEXT_MACHINE,
7638 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
7639 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7640 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
7641 ok(sz == 5, "Expected 5, got %d\n", sz);
7643 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
7644 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7646 /* Publisher value exists */
7647 sz = MAX_PATH;
7648 lstrcpyA(buf, "apple");
7649 r = pMsiGetProductInfoExA(prodcode, NULL,
7650 MSIINSTALLCONTEXT_MACHINE,
7651 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
7652 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7653 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
7654 ok(sz == 3, "Expected 3, got %d\n", sz);
7656 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
7657 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7659 /* URLInfoAbout value exists */
7660 sz = MAX_PATH;
7661 lstrcpyA(buf, "apple");
7662 r = pMsiGetProductInfoExA(prodcode, NULL,
7663 MSIINSTALLCONTEXT_MACHINE,
7664 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
7665 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7666 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
7667 ok(sz == 5, "Expected 5, got %d\n", sz);
7669 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
7670 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7672 /* URLUpdateInfo value exists */
7673 sz = MAX_PATH;
7674 lstrcpyA(buf, "apple");
7675 r = pMsiGetProductInfoExA(prodcode, NULL,
7676 MSIINSTALLCONTEXT_MACHINE,
7677 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
7678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7679 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
7680 ok(sz == 6, "Expected 6, got %d\n", sz);
7682 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
7683 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7685 /* VersionMinor value exists */
7686 sz = MAX_PATH;
7687 lstrcpyA(buf, "apple");
7688 r = pMsiGetProductInfoExA(prodcode, NULL,
7689 MSIINSTALLCONTEXT_MACHINE,
7690 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
7691 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7692 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
7693 ok(sz == 1, "Expected 1, got %d\n", sz);
7695 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
7696 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7698 /* VersionMajor value exists */
7699 sz = MAX_PATH;
7700 lstrcpyA(buf, "apple");
7701 r = pMsiGetProductInfoExA(prodcode, NULL,
7702 MSIINSTALLCONTEXT_MACHINE,
7703 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
7704 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7705 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
7706 ok(sz == 1, "Expected 1, got %d\n", sz);
7708 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
7709 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7711 /* DisplayVersion value exists */
7712 sz = MAX_PATH;
7713 lstrcpyA(buf, "apple");
7714 r = pMsiGetProductInfoExA(prodcode, NULL,
7715 MSIINSTALLCONTEXT_MACHINE,
7716 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
7717 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7718 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
7719 ok(sz == 5, "Expected 5, got %d\n", sz);
7721 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
7722 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7724 /* ProductID value exists */
7725 sz = MAX_PATH;
7726 lstrcpyA(buf, "apple");
7727 r = pMsiGetProductInfoExA(prodcode, NULL,
7728 MSIINSTALLCONTEXT_MACHINE,
7729 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
7730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7731 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
7732 ok(sz == 2, "Expected 2, got %d\n", sz);
7734 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
7735 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7737 /* RegCompany value exists */
7738 sz = MAX_PATH;
7739 lstrcpyA(buf, "apple");
7740 r = pMsiGetProductInfoExA(prodcode, NULL,
7741 MSIINSTALLCONTEXT_MACHINE,
7742 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
7743 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7744 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
7745 ok(sz == 4, "Expected 4, got %d\n", sz);
7747 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
7748 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7750 /* RegOwner value exists */
7751 sz = MAX_PATH;
7752 lstrcpyA(buf, "apple");
7753 r = pMsiGetProductInfoExA(prodcode, NULL,
7754 MSIINSTALLCONTEXT_MACHINE,
7755 INSTALLPROPERTY_REGOWNERA, buf, &sz);
7756 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7757 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
7758 ok(sz == 5, "Expected 5, got %d\n", sz);
7760 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
7761 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7763 /* Transforms value exists */
7764 sz = MAX_PATH;
7765 lstrcpyA(buf, "apple");
7766 r = pMsiGetProductInfoExA(prodcode, NULL,
7767 MSIINSTALLCONTEXT_MACHINE,
7768 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
7769 ok(r == ERROR_UNKNOWN_PRODUCT,
7770 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7771 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7772 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7774 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
7775 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7777 /* Language value exists */
7778 sz = MAX_PATH;
7779 lstrcpyA(buf, "apple");
7780 r = pMsiGetProductInfoExA(prodcode, NULL,
7781 MSIINSTALLCONTEXT_MACHINE,
7782 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
7783 ok(r == ERROR_UNKNOWN_PRODUCT,
7784 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7785 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7786 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7788 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
7789 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7791 /* ProductName value exists */
7792 sz = MAX_PATH;
7793 lstrcpyA(buf, "apple");
7794 r = pMsiGetProductInfoExA(prodcode, NULL,
7795 MSIINSTALLCONTEXT_MACHINE,
7796 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
7797 ok(r == ERROR_UNKNOWN_PRODUCT,
7798 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7799 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7800 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7802 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
7803 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7805 /* FIXME */
7807 /* AssignmentType value exists */
7808 sz = MAX_PATH;
7809 lstrcpyA(buf, "apple");
7810 r = pMsiGetProductInfoExA(prodcode, NULL,
7811 MSIINSTALLCONTEXT_MACHINE,
7812 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
7813 ok(r == ERROR_UNKNOWN_PRODUCT,
7814 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7815 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7816 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7818 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
7819 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7821 /* PackageCode value exists */
7822 sz = MAX_PATH;
7823 lstrcpyA(buf, "apple");
7824 r = pMsiGetProductInfoExA(prodcode, NULL,
7825 MSIINSTALLCONTEXT_MACHINE,
7826 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
7827 ok(r == ERROR_UNKNOWN_PRODUCT,
7828 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7829 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7830 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7832 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
7833 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7835 /* Version value exists */
7836 sz = MAX_PATH;
7837 lstrcpyA(buf, "apple");
7838 r = pMsiGetProductInfoExA(prodcode, NULL,
7839 MSIINSTALLCONTEXT_MACHINE,
7840 INSTALLPROPERTY_VERSIONA, buf, &sz);
7841 ok(r == ERROR_UNKNOWN_PRODUCT,
7842 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7843 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7844 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7846 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
7847 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7849 /* ProductIcon value exists */
7850 sz = MAX_PATH;
7851 lstrcpyA(buf, "apple");
7852 r = pMsiGetProductInfoExA(prodcode, NULL,
7853 MSIINSTALLCONTEXT_MACHINE,
7854 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
7855 ok(r == ERROR_UNKNOWN_PRODUCT,
7856 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7857 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7858 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7860 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
7861 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7863 /* PackageName value exists */
7864 sz = MAX_PATH;
7865 lstrcpyA(buf, "apple");
7866 r = pMsiGetProductInfoExA(prodcode, NULL,
7867 MSIINSTALLCONTEXT_MACHINE,
7868 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
7869 ok(r == ERROR_UNKNOWN_PRODUCT,
7870 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7871 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7872 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7874 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
7875 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7877 /* AuthorizedLUAApp value exists */
7878 sz = MAX_PATH;
7879 lstrcpyA(buf, "apple");
7880 r = pMsiGetProductInfoExA(prodcode, NULL,
7881 MSIINSTALLCONTEXT_MACHINE,
7882 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
7883 ok(r == ERROR_UNKNOWN_PRODUCT,
7884 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7885 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7886 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7888 RegDeleteValueA(propkey, "AuthorizedLUAApp");
7889 RegDeleteValueA(propkey, "PackageName");
7890 RegDeleteValueA(propkey, "ProductIcon");
7891 RegDeleteValueA(propkey, "Version");
7892 RegDeleteValueA(propkey, "PackageCode");
7893 RegDeleteValueA(propkey, "AssignmentType");
7894 RegDeleteValueA(propkey, "ProductName");
7895 RegDeleteValueA(propkey, "Language");
7896 RegDeleteValueA(propkey, "Transforms");
7897 RegDeleteValueA(propkey, "RegOwner");
7898 RegDeleteValueA(propkey, "RegCompany");
7899 RegDeleteValueA(propkey, "ProductID");
7900 RegDeleteValueA(propkey, "DisplayVersion");
7901 RegDeleteValueA(propkey, "VersionMajor");
7902 RegDeleteValueA(propkey, "VersionMinor");
7903 RegDeleteValueA(propkey, "URLUpdateInfo");
7904 RegDeleteValueA(propkey, "URLInfoAbout");
7905 RegDeleteValueA(propkey, "Publisher");
7906 RegDeleteValueA(propkey, "LocalPackage");
7907 RegDeleteValueA(propkey, "InstallSource");
7908 RegDeleteValueA(propkey, "InstallLocation");
7909 RegDeleteValueA(propkey, "DisplayName");
7910 RegDeleteValueA(propkey, "InstallDate");
7911 RegDeleteValueA(propkey, "HelpTelephone");
7912 RegDeleteValueA(propkey, "HelpLink");
7913 RegDeleteValueA(propkey, "LocalPackage");
7914 delete_key(propkey, "", access & KEY_WOW64_64KEY);
7915 RegCloseKey(propkey);
7916 delete_key(localkey, "", access & KEY_WOW64_64KEY);
7917 RegCloseKey(localkey);
7919 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
7920 lstrcatA(keypath, prod_squashed);
7922 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
7923 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7925 /* local classes product key exists */
7926 sz = MAX_PATH;
7927 lstrcpyA(buf, "apple");
7928 r = pMsiGetProductInfoExA(prodcode, NULL,
7929 MSIINSTALLCONTEXT_MACHINE,
7930 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7932 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
7933 ok(sz == 1, "Expected 1, got %d\n", sz);
7935 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7936 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7938 /* HelpLink value exists */
7939 sz = MAX_PATH;
7940 lstrcpyA(buf, "apple");
7941 r = pMsiGetProductInfoExA(prodcode, NULL,
7942 MSIINSTALLCONTEXT_MACHINE,
7943 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7944 ok(r == ERROR_UNKNOWN_PROPERTY,
7945 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7946 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7947 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7949 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
7950 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7952 /* HelpTelephone value exists */
7953 sz = MAX_PATH;
7954 lstrcpyA(buf, "apple");
7955 r = pMsiGetProductInfoExA(prodcode, NULL,
7956 MSIINSTALLCONTEXT_MACHINE,
7957 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
7958 ok(r == ERROR_UNKNOWN_PROPERTY,
7959 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7960 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7961 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7963 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
7964 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7966 /* InstallDate value exists */
7967 sz = MAX_PATH;
7968 lstrcpyA(buf, "apple");
7969 r = pMsiGetProductInfoExA(prodcode, NULL,
7970 MSIINSTALLCONTEXT_MACHINE,
7971 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
7972 ok(r == ERROR_UNKNOWN_PROPERTY,
7973 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7974 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7975 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7977 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
7978 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7980 /* DisplayName value exists */
7981 sz = MAX_PATH;
7982 lstrcpyA(buf, "apple");
7983 r = pMsiGetProductInfoExA(prodcode, NULL,
7984 MSIINSTALLCONTEXT_MACHINE,
7985 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
7986 ok(r == ERROR_UNKNOWN_PROPERTY,
7987 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7988 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7989 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7991 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
7992 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7994 /* InstallLocation value exists */
7995 sz = MAX_PATH;
7996 lstrcpyA(buf, "apple");
7997 r = pMsiGetProductInfoExA(prodcode, NULL,
7998 MSIINSTALLCONTEXT_MACHINE,
7999 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
8000 ok(r == ERROR_UNKNOWN_PROPERTY,
8001 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8002 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8003 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8005 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
8006 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8008 /* InstallSource value exists */
8009 sz = MAX_PATH;
8010 lstrcpyA(buf, "apple");
8011 r = pMsiGetProductInfoExA(prodcode, NULL,
8012 MSIINSTALLCONTEXT_MACHINE,
8013 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
8014 ok(r == ERROR_UNKNOWN_PROPERTY,
8015 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8016 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8017 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8019 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
8020 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8022 /* LocalPackage value exists */
8023 sz = MAX_PATH;
8024 lstrcpyA(buf, "apple");
8025 r = pMsiGetProductInfoExA(prodcode, NULL,
8026 MSIINSTALLCONTEXT_MACHINE,
8027 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
8028 ok(r == ERROR_UNKNOWN_PROPERTY,
8029 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8030 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8031 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8033 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
8034 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8036 /* Publisher value exists */
8037 sz = MAX_PATH;
8038 lstrcpyA(buf, "apple");
8039 r = pMsiGetProductInfoExA(prodcode, NULL,
8040 MSIINSTALLCONTEXT_MACHINE,
8041 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
8042 ok(r == ERROR_UNKNOWN_PROPERTY,
8043 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8044 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8045 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8047 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
8048 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8050 /* URLInfoAbout value exists */
8051 sz = MAX_PATH;
8052 lstrcpyA(buf, "apple");
8053 r = pMsiGetProductInfoExA(prodcode, NULL,
8054 MSIINSTALLCONTEXT_MACHINE,
8055 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
8056 ok(r == ERROR_UNKNOWN_PROPERTY,
8057 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8058 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8059 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8061 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
8062 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8064 /* URLUpdateInfo value exists */
8065 sz = MAX_PATH;
8066 lstrcpyA(buf, "apple");
8067 r = pMsiGetProductInfoExA(prodcode, NULL,
8068 MSIINSTALLCONTEXT_MACHINE,
8069 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
8070 ok(r == ERROR_UNKNOWN_PROPERTY,
8071 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8072 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8073 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8075 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
8076 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8078 /* VersionMinor value exists */
8079 sz = MAX_PATH;
8080 lstrcpyA(buf, "apple");
8081 r = pMsiGetProductInfoExA(prodcode, NULL,
8082 MSIINSTALLCONTEXT_MACHINE,
8083 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
8084 ok(r == ERROR_UNKNOWN_PROPERTY,
8085 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8086 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8087 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8089 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
8090 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8092 /* VersionMajor value exists */
8093 sz = MAX_PATH;
8094 lstrcpyA(buf, "apple");
8095 r = pMsiGetProductInfoExA(prodcode, NULL,
8096 MSIINSTALLCONTEXT_MACHINE,
8097 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
8098 ok(r == ERROR_UNKNOWN_PROPERTY,
8099 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8100 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8101 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8103 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
8104 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8106 /* DisplayVersion value exists */
8107 sz = MAX_PATH;
8108 lstrcpyA(buf, "apple");
8109 r = pMsiGetProductInfoExA(prodcode, NULL,
8110 MSIINSTALLCONTEXT_MACHINE,
8111 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
8112 ok(r == ERROR_UNKNOWN_PROPERTY,
8113 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8114 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8115 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8117 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
8118 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8120 /* ProductID value exists */
8121 sz = MAX_PATH;
8122 lstrcpyA(buf, "apple");
8123 r = pMsiGetProductInfoExA(prodcode, NULL,
8124 MSIINSTALLCONTEXT_MACHINE,
8125 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
8126 ok(r == ERROR_UNKNOWN_PROPERTY,
8127 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8128 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8129 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8131 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
8132 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8134 /* RegCompany value exists */
8135 sz = MAX_PATH;
8136 lstrcpyA(buf, "apple");
8137 r = pMsiGetProductInfoExA(prodcode, NULL,
8138 MSIINSTALLCONTEXT_MACHINE,
8139 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
8140 ok(r == ERROR_UNKNOWN_PROPERTY,
8141 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8142 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8143 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8145 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8146 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8148 /* RegOwner value exists */
8149 sz = MAX_PATH;
8150 lstrcpyA(buf, "apple");
8151 r = pMsiGetProductInfoExA(prodcode, NULL,
8152 MSIINSTALLCONTEXT_MACHINE,
8153 INSTALLPROPERTY_REGOWNERA, buf, &sz);
8154 ok(r == ERROR_UNKNOWN_PROPERTY,
8155 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8156 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8157 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8159 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
8160 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8162 /* Transforms value exists */
8163 sz = MAX_PATH;
8164 lstrcpyA(buf, "apple");
8165 r = pMsiGetProductInfoExA(prodcode, NULL,
8166 MSIINSTALLCONTEXT_MACHINE,
8167 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
8168 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8169 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
8170 ok(sz == 5, "Expected 5, got %d\n", sz);
8172 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
8173 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8175 /* Language value exists */
8176 sz = MAX_PATH;
8177 lstrcpyA(buf, "apple");
8178 r = pMsiGetProductInfoExA(prodcode, NULL,
8179 MSIINSTALLCONTEXT_MACHINE,
8180 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
8181 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8182 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
8183 ok(sz == 4, "Expected 4, got %d\n", sz);
8185 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
8186 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8188 /* ProductName value exists */
8189 sz = MAX_PATH;
8190 lstrcpyA(buf, "apple");
8191 r = pMsiGetProductInfoExA(prodcode, NULL,
8192 MSIINSTALLCONTEXT_MACHINE,
8193 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
8194 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8195 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
8196 ok(sz == 4, "Expected 4, got %d\n", sz);
8198 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
8199 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8201 /* FIXME */
8203 /* AssignmentType value exists */
8204 sz = MAX_PATH;
8205 lstrcpyA(buf, "apple");
8206 r = pMsiGetProductInfoExA(prodcode, NULL,
8207 MSIINSTALLCONTEXT_MACHINE,
8208 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
8209 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8210 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8211 ok(sz == 0, "Expected 0, got %d\n", sz);
8213 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
8214 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8216 /* FIXME */
8218 /* PackageCode value exists */
8219 sz = MAX_PATH;
8220 lstrcpyA(buf, "apple");
8221 r = pMsiGetProductInfoExA(prodcode, NULL,
8222 MSIINSTALLCONTEXT_MACHINE,
8223 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
8224 todo_wine
8226 ok(r == ERROR_BAD_CONFIGURATION,
8227 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
8228 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8229 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8232 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
8233 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8235 /* Version value exists */
8236 sz = MAX_PATH;
8237 lstrcpyA(buf, "apple");
8238 r = pMsiGetProductInfoExA(prodcode, NULL,
8239 MSIINSTALLCONTEXT_MACHINE,
8240 INSTALLPROPERTY_VERSIONA, buf, &sz);
8241 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8242 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
8243 ok(sz == 3, "Expected 3, got %d\n", sz);
8245 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
8246 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8248 /* ProductIcon value exists */
8249 sz = MAX_PATH;
8250 lstrcpyA(buf, "apple");
8251 r = pMsiGetProductInfoExA(prodcode, NULL,
8252 MSIINSTALLCONTEXT_MACHINE,
8253 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
8254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8255 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
8256 ok(sz == 4, "Expected 4, got %d\n", sz);
8258 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
8259 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8261 /* PackageName value exists */
8262 sz = MAX_PATH;
8263 lstrcpyA(buf, "apple");
8264 r = pMsiGetProductInfoExA(prodcode, NULL,
8265 MSIINSTALLCONTEXT_MACHINE,
8266 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
8267 todo_wine
8269 ok(r == ERROR_UNKNOWN_PRODUCT,
8270 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
8271 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8272 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8275 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
8276 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8278 /* AuthorizedLUAApp value exists */
8279 sz = MAX_PATH;
8280 lstrcpyA(buf, "apple");
8281 r = pMsiGetProductInfoExA(prodcode, NULL,
8282 MSIINSTALLCONTEXT_MACHINE,
8283 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
8284 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8285 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
8286 ok(sz == 4, "Expected 4, got %d\n", sz);
8288 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
8289 RegDeleteValueA(prodkey, "PackageName");
8290 RegDeleteValueA(prodkey, "ProductIcon");
8291 RegDeleteValueA(prodkey, "Version");
8292 RegDeleteValueA(prodkey, "PackageCode");
8293 RegDeleteValueA(prodkey, "AssignmentType");
8294 RegDeleteValueA(prodkey, "ProductName");
8295 RegDeleteValueA(prodkey, "Language");
8296 RegDeleteValueA(prodkey, "Transforms");
8297 RegDeleteValueA(prodkey, "RegOwner");
8298 RegDeleteValueA(prodkey, "RegCompany");
8299 RegDeleteValueA(prodkey, "ProductID");
8300 RegDeleteValueA(prodkey, "DisplayVersion");
8301 RegDeleteValueA(prodkey, "VersionMajor");
8302 RegDeleteValueA(prodkey, "VersionMinor");
8303 RegDeleteValueA(prodkey, "URLUpdateInfo");
8304 RegDeleteValueA(prodkey, "URLInfoAbout");
8305 RegDeleteValueA(prodkey, "Publisher");
8306 RegDeleteValueA(prodkey, "LocalPackage");
8307 RegDeleteValueA(prodkey, "InstallSource");
8308 RegDeleteValueA(prodkey, "InstallLocation");
8309 RegDeleteValueA(prodkey, "DisplayName");
8310 RegDeleteValueA(prodkey, "InstallDate");
8311 RegDeleteValueA(prodkey, "HelpTelephone");
8312 RegDeleteValueA(prodkey, "HelpLink");
8313 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
8314 RegCloseKey(prodkey);
8315 LocalFree(usersid);
8318 #define INIT_USERINFO() \
8319 lstrcpyA(user, "apple"); \
8320 lstrcpyA(org, "orange"); \
8321 lstrcpyA(serial, "banana"); \
8322 usersz = orgsz = serialsz = MAX_PATH;
8324 static void test_MsiGetUserInfo(void)
8326 USERINFOSTATE state;
8327 CHAR user[MAX_PATH];
8328 CHAR org[MAX_PATH];
8329 CHAR serial[MAX_PATH];
8330 DWORD usersz, orgsz, serialsz;
8331 CHAR keypath[MAX_PATH * 2];
8332 CHAR prodcode[MAX_PATH];
8333 CHAR prod_squashed[MAX_PATH];
8334 HKEY prodkey, userprod, props;
8335 LPSTR usersid;
8336 LONG res;
8337 REGSAM access = KEY_ALL_ACCESS;
8339 create_test_guid(prodcode, prod_squashed);
8340 usersid = get_user_sid();
8342 if (is_wow64)
8343 access |= KEY_WOW64_64KEY;
8345 /* NULL szProduct */
8346 INIT_USERINFO();
8347 state = MsiGetUserInfoA(NULL, user, &usersz, org, &orgsz, serial, &serialsz);
8348 ok(state == USERINFOSTATE_INVALIDARG,
8349 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8350 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8351 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8352 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8353 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8354 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8355 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8357 /* empty szProductCode */
8358 INIT_USERINFO();
8359 state = MsiGetUserInfoA("", user, &usersz, org, &orgsz, serial, &serialsz);
8360 ok(state == USERINFOSTATE_INVALIDARG,
8361 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8362 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8363 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8364 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8365 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8366 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8367 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8369 /* garbage szProductCode */
8370 INIT_USERINFO();
8371 state = MsiGetUserInfoA("garbage", user, &usersz, org, &orgsz, serial, &serialsz);
8372 ok(state == USERINFOSTATE_INVALIDARG,
8373 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8374 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8375 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8376 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8377 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8378 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8379 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8381 /* guid without brackets */
8382 INIT_USERINFO();
8383 state = MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
8384 user, &usersz, org, &orgsz, serial, &serialsz);
8385 ok(state == USERINFOSTATE_INVALIDARG,
8386 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8387 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8388 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8389 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8390 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8391 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8392 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8394 /* guid with brackets */
8395 INIT_USERINFO();
8396 state = MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
8397 user, &usersz, org, &orgsz, serial, &serialsz);
8398 ok(state == USERINFOSTATE_UNKNOWN,
8399 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8400 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8401 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8402 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8403 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8404 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8405 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8407 /* NULL lpUserNameBuf */
8408 INIT_USERINFO();
8409 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
8410 ok(state == USERINFOSTATE_UNKNOWN,
8411 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8412 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8413 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8414 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8415 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8416 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8418 /* NULL pcchUserNameBuf */
8419 INIT_USERINFO();
8420 state = MsiGetUserInfoA(prodcode, user, NULL, org, &orgsz, serial, &serialsz);
8421 ok(state == USERINFOSTATE_INVALIDARG,
8422 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8423 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8424 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8425 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8426 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8427 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8429 /* both lpUserNameBuf and pcchUserNameBuf NULL */
8430 INIT_USERINFO();
8431 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8432 ok(state == USERINFOSTATE_UNKNOWN,
8433 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8434 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8435 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8436 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8437 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8439 /* NULL lpOrgNameBuf */
8440 INIT_USERINFO();
8441 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, &orgsz, serial, &serialsz);
8442 ok(state == USERINFOSTATE_UNKNOWN,
8443 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8444 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8445 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8446 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8447 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8448 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8450 /* NULL pcchOrgNameBuf */
8451 INIT_USERINFO();
8452 state = MsiGetUserInfoA(prodcode, user, &usersz, org, NULL, serial, &serialsz);
8453 ok(state == USERINFOSTATE_INVALIDARG,
8454 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8455 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8456 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8457 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8458 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8459 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8461 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
8462 INIT_USERINFO();
8463 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, NULL, serial, &serialsz);
8464 ok(state == USERINFOSTATE_UNKNOWN,
8465 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8466 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8467 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8468 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8469 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8471 /* NULL lpSerialBuf */
8472 INIT_USERINFO();
8473 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, &serialsz);
8474 ok(state == USERINFOSTATE_UNKNOWN,
8475 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8476 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8477 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8478 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8479 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8480 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8482 /* NULL pcchSerialBuf */
8483 INIT_USERINFO();
8484 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, NULL);
8485 ok(state == USERINFOSTATE_INVALIDARG,
8486 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8487 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8488 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8489 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8490 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8491 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8493 /* both lpSerialBuf and pcchSerialBuf NULL */
8494 INIT_USERINFO();
8495 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, NULL);
8496 ok(state == USERINFOSTATE_UNKNOWN,
8497 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8498 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8499 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8500 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8501 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8503 /* MSIINSTALLCONTEXT_USERMANAGED */
8505 /* create local system product key */
8506 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
8507 lstrcatA(keypath, usersid);
8508 lstrcatA(keypath, "\\Installer\\Products\\");
8509 lstrcatA(keypath, prod_squashed);
8511 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8512 if (res == ERROR_ACCESS_DENIED)
8514 skip("Not enough rights to perform tests\n");
8515 LocalFree(usersid);
8516 return;
8518 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8520 /* managed product key exists */
8521 INIT_USERINFO();
8522 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8523 ok(state == USERINFOSTATE_ABSENT,
8524 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8525 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8526 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8527 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8528 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8529 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8530 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8532 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8533 lstrcatA(keypath, "Installer\\UserData\\");
8534 lstrcatA(keypath, usersid);
8535 lstrcatA(keypath, "\\Products\\");
8536 lstrcatA(keypath, prod_squashed);
8538 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userprod, NULL);
8539 if (res == ERROR_ACCESS_DENIED)
8541 skip("Not enough rights to perform tests\n");
8542 LocalFree(usersid);
8543 return;
8545 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8547 res = RegCreateKeyExA(userprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8548 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8550 /* InstallProperties key exists */
8551 INIT_USERINFO();
8552 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8553 ok(state == USERINFOSTATE_ABSENT,
8554 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8555 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8556 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8557 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8558 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
8559 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8560 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8562 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8563 INIT_USERINFO();
8564 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8565 ok(state == USERINFOSTATE_ABSENT,
8566 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8567 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8568 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8569 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8570 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8572 /* RegOwner, RegCompany don't exist, out params are NULL */
8573 INIT_USERINFO();
8574 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
8575 ok(state == USERINFOSTATE_ABSENT,
8576 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8577 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8578 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8580 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8581 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8583 /* RegOwner value exists */
8584 INIT_USERINFO();
8585 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8586 ok(state == USERINFOSTATE_ABSENT,
8587 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8588 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8589 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8590 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8591 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8592 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8593 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8595 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
8596 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8598 /* RegCompany value exists */
8599 INIT_USERINFO();
8600 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8601 ok(state == USERINFOSTATE_ABSENT,
8602 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8603 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8604 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8605 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8606 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8607 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8608 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8610 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
8611 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8613 /* ProductID value exists */
8614 INIT_USERINFO();
8615 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8616 ok(state == USERINFOSTATE_PRESENT,
8617 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8618 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8619 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8620 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8621 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8622 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8623 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8625 /* pcchUserNameBuf is too small */
8626 INIT_USERINFO();
8627 usersz = 0;
8628 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8629 ok(state == USERINFOSTATE_MOREDATA,
8630 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
8631 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8632 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8633 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8634 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8635 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8636 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8638 /* pcchUserNameBuf has no room for NULL terminator */
8639 INIT_USERINFO();
8640 usersz = 5;
8641 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8642 ok(state == USERINFOSTATE_MOREDATA,
8643 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
8644 todo_wine
8646 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8648 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8649 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8650 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8651 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8652 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8654 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
8655 INIT_USERINFO();
8656 usersz = 0;
8657 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
8658 ok(state == USERINFOSTATE_PRESENT,
8659 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8660 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8661 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8662 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8663 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8664 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8665 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8667 RegDeleteValueA(props, "ProductID");
8668 RegDeleteValueA(props, "RegCompany");
8669 RegDeleteValueA(props, "RegOwner");
8670 delete_key(props, "", access & KEY_WOW64_64KEY);
8671 RegCloseKey(props);
8672 delete_key(userprod, "", access & KEY_WOW64_64KEY);
8673 RegCloseKey(userprod);
8674 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
8675 RegCloseKey(prodkey);
8677 /* MSIINSTALLCONTEXT_USERUNMANAGED */
8679 /* create local system product key */
8680 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
8681 lstrcatA(keypath, prod_squashed);
8683 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
8684 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8686 /* product key exists */
8687 INIT_USERINFO();
8688 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8689 ok(state == USERINFOSTATE_ABSENT,
8690 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8691 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8692 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8693 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8694 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8695 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8696 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8698 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8699 lstrcatA(keypath, "Installer\\UserData\\");
8700 lstrcatA(keypath, usersid);
8701 lstrcatA(keypath, "\\Products\\");
8702 lstrcatA(keypath, prod_squashed);
8704 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userprod, NULL);
8705 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8707 res = RegCreateKeyExA(userprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8708 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8710 /* InstallProperties key exists */
8711 INIT_USERINFO();
8712 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8713 ok(state == USERINFOSTATE_ABSENT,
8714 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8715 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8716 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8717 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8718 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
8719 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8720 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8722 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8723 INIT_USERINFO();
8724 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8725 ok(state == USERINFOSTATE_ABSENT,
8726 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8727 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8728 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8729 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8730 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8732 /* RegOwner, RegCompany don't exist, out params are NULL */
8733 INIT_USERINFO();
8734 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
8735 ok(state == USERINFOSTATE_ABSENT,
8736 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8737 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8738 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8740 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8741 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8743 /* RegOwner value exists */
8744 INIT_USERINFO();
8745 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8746 ok(state == USERINFOSTATE_ABSENT,
8747 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8748 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8749 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8750 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8751 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8752 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8753 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8755 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
8756 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8758 /* RegCompany value exists */
8759 INIT_USERINFO();
8760 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8761 ok(state == USERINFOSTATE_ABSENT,
8762 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8763 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8764 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8765 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8766 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8767 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8768 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8770 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
8771 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8773 /* ProductID value exists */
8774 INIT_USERINFO();
8775 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8776 ok(state == USERINFOSTATE_PRESENT,
8777 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8778 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8779 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8780 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8781 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8782 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8783 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8785 RegDeleteValueA(props, "ProductID");
8786 RegDeleteValueA(props, "RegCompany");
8787 RegDeleteValueA(props, "RegOwner");
8788 delete_key(props, "", access & KEY_WOW64_64KEY);
8789 RegCloseKey(props);
8790 delete_key(userprod, "", access & KEY_WOW64_64KEY);
8791 RegCloseKey(userprod);
8792 RegDeleteKeyA(prodkey, "");
8793 RegCloseKey(prodkey);
8795 /* MSIINSTALLCONTEXT_MACHINE */
8797 /* create local system product key */
8798 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8799 lstrcatA(keypath, prod_squashed);
8801 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8802 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8804 /* product key exists */
8805 INIT_USERINFO();
8806 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8807 ok(state == USERINFOSTATE_ABSENT,
8808 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8809 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8810 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8811 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8812 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8813 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8814 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8816 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8817 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18");
8818 lstrcatA(keypath, "\\Products\\");
8819 lstrcatA(keypath, prod_squashed);
8821 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userprod, NULL);
8822 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8824 res = RegCreateKeyExA(userprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8825 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8827 /* InstallProperties key exists */
8828 INIT_USERINFO();
8829 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8830 ok(state == USERINFOSTATE_ABSENT,
8831 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8832 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8833 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8834 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8835 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
8836 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8837 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8839 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8840 INIT_USERINFO();
8841 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8842 ok(state == USERINFOSTATE_ABSENT,
8843 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8844 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8845 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8846 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8847 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8849 /* RegOwner, RegCompany don't exist, out params are NULL */
8850 INIT_USERINFO();
8851 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
8852 ok(state == USERINFOSTATE_ABSENT,
8853 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8854 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8855 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8857 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8858 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8860 /* RegOwner value exists */
8861 INIT_USERINFO();
8862 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8863 ok(state == USERINFOSTATE_ABSENT,
8864 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8865 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8866 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8867 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8868 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8869 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8870 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8872 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
8873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8875 /* RegCompany value exists */
8876 INIT_USERINFO();
8877 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8878 ok(state == USERINFOSTATE_ABSENT,
8879 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8880 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8881 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8882 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8883 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8884 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8885 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8887 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
8888 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8890 /* ProductID value exists */
8891 INIT_USERINFO();
8892 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8893 ok(state == USERINFOSTATE_PRESENT,
8894 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8895 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8896 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8897 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8898 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8899 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8900 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8902 RegDeleteValueA(props, "ProductID");
8903 RegDeleteValueA(props, "RegCompany");
8904 RegDeleteValueA(props, "RegOwner");
8905 delete_key(props, "", access & KEY_WOW64_64KEY);
8906 RegCloseKey(props);
8907 delete_key(userprod, "", access & KEY_WOW64_64KEY);
8908 RegCloseKey(userprod);
8909 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
8910 RegCloseKey(prodkey);
8911 LocalFree(usersid);
8914 static void test_MsiOpenProduct(void)
8916 MSIHANDLE hprod, hdb;
8917 CHAR val[MAX_PATH];
8918 CHAR path[MAX_PATH];
8919 CHAR keypath[MAX_PATH*2];
8920 CHAR prodcode[MAX_PATH];
8921 CHAR prod_squashed[MAX_PATH];
8922 HKEY prodkey, userkey, props;
8923 LPSTR usersid;
8924 DWORD size;
8925 LONG res;
8926 UINT r;
8927 REGSAM access = KEY_ALL_ACCESS;
8929 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8931 GetCurrentDirectoryA(MAX_PATH, path);
8932 lstrcatA(path, "\\");
8934 create_test_guid(prodcode, prod_squashed);
8935 usersid = get_user_sid();
8937 if (is_wow64)
8938 access |= KEY_WOW64_64KEY;
8940 hdb = create_package_db(prodcode);
8941 MsiCloseHandle(hdb);
8943 /* NULL szProduct */
8944 hprod = 0xdeadbeef;
8945 r = MsiOpenProductA(NULL, &hprod);
8946 ok(r == ERROR_INVALID_PARAMETER,
8947 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8948 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8950 /* empty szProduct */
8951 hprod = 0xdeadbeef;
8952 r = MsiOpenProductA("", &hprod);
8953 ok(r == ERROR_INVALID_PARAMETER,
8954 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8955 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8957 /* garbage szProduct */
8958 hprod = 0xdeadbeef;
8959 r = MsiOpenProductA("garbage", &hprod);
8960 ok(r == ERROR_INVALID_PARAMETER,
8961 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8962 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8964 /* guid without brackets */
8965 hprod = 0xdeadbeef;
8966 r = MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod);
8967 ok(r == ERROR_INVALID_PARAMETER,
8968 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8969 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8971 /* guid with brackets */
8972 hprod = 0xdeadbeef;
8973 r = MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod);
8974 ok(r == ERROR_UNKNOWN_PRODUCT,
8975 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
8976 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8978 /* same length as guid, but random */
8979 hprod = 0xdeadbeef;
8980 r = MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod);
8981 ok(r == ERROR_INVALID_PARAMETER,
8982 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8983 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8985 /* hProduct is NULL */
8986 hprod = 0xdeadbeef;
8987 r = MsiOpenProductA(prodcode, NULL);
8988 ok(r == ERROR_INVALID_PARAMETER,
8989 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8990 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
8992 /* MSIINSTALLCONTEXT_USERMANAGED */
8994 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8995 lstrcatA(keypath, "Installer\\Managed\\");
8996 lstrcatA(keypath, usersid);
8997 lstrcatA(keypath, "\\Installer\\Products\\");
8998 lstrcatA(keypath, prod_squashed);
9000 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
9001 if (res == ERROR_ACCESS_DENIED)
9003 skip("Not enough rights to perform tests\n");
9004 LocalFree(usersid);
9005 return;
9007 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9009 /* managed product key exists */
9010 hprod = 0xdeadbeef;
9011 r = MsiOpenProductA(prodcode, &hprod);
9012 ok(r == ERROR_UNKNOWN_PRODUCT,
9013 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9014 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9016 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9017 lstrcatA(keypath, "Installer\\UserData\\");
9018 lstrcatA(keypath, usersid);
9019 lstrcatA(keypath, "\\Products\\");
9020 lstrcatA(keypath, prod_squashed);
9022 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
9023 if (res == ERROR_ACCESS_DENIED)
9025 skip("Not enough rights to perform tests\n");
9026 LocalFree(usersid);
9027 return;
9029 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9031 /* user product key exists */
9032 hprod = 0xdeadbeef;
9033 r = MsiOpenProductA(prodcode, &hprod);
9034 ok(r == ERROR_UNKNOWN_PRODUCT,
9035 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9036 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9038 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
9039 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9041 /* InstallProperties key exists */
9042 hprod = 0xdeadbeef;
9043 r = MsiOpenProductA(prodcode, &hprod);
9044 ok(r == ERROR_UNKNOWN_PRODUCT,
9045 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9046 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9048 lstrcpyA(val, path);
9049 lstrcatA(val, "\\winetest.msi");
9050 res = RegSetValueExA(props, "ManagedLocalPackage", 0, REG_SZ,
9051 (const BYTE *)val, lstrlenA(val) + 1);
9052 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9054 /* ManagedLocalPackage value exists */
9055 hprod = 0xdeadbeef;
9056 r = MsiOpenProductA(prodcode, &hprod);
9057 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9058 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
9060 size = MAX_PATH;
9061 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
9062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9063 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
9064 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
9066 MsiCloseHandle(hprod);
9068 RegDeleteValueA(props, "ManagedLocalPackage");
9069 delete_key(props, "", access & KEY_WOW64_64KEY);
9070 RegCloseKey(props);
9071 delete_key(userkey, "", access & KEY_WOW64_64KEY);
9072 RegCloseKey(userkey);
9073 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9074 RegCloseKey(prodkey);
9076 /* MSIINSTALLCONTEXT_USERUNMANAGED */
9078 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
9079 lstrcatA(keypath, prod_squashed);
9081 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
9082 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9084 /* unmanaged product key exists */
9085 hprod = 0xdeadbeef;
9086 r = MsiOpenProductA(prodcode, &hprod);
9087 ok(r == ERROR_UNKNOWN_PRODUCT,
9088 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9089 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9091 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9092 lstrcatA(keypath, "Installer\\UserData\\");
9093 lstrcatA(keypath, usersid);
9094 lstrcatA(keypath, "\\Products\\");
9095 lstrcatA(keypath, prod_squashed);
9097 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
9098 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9100 /* user product key exists */
9101 hprod = 0xdeadbeef;
9102 r = MsiOpenProductA(prodcode, &hprod);
9103 ok(r == ERROR_UNKNOWN_PRODUCT,
9104 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9105 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9107 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
9108 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9110 /* InstallProperties key exists */
9111 hprod = 0xdeadbeef;
9112 r = MsiOpenProductA(prodcode, &hprod);
9113 ok(r == ERROR_UNKNOWN_PRODUCT,
9114 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9115 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9117 lstrcpyA(val, path);
9118 lstrcatA(val, "\\winetest.msi");
9119 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9120 (const BYTE *)val, lstrlenA(val) + 1);
9121 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9123 /* LocalPackage value exists */
9124 hprod = 0xdeadbeef;
9125 r = MsiOpenProductA(prodcode, &hprod);
9126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9127 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
9129 size = MAX_PATH;
9130 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
9131 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9132 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
9133 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
9135 MsiCloseHandle(hprod);
9137 RegDeleteValueA(props, "LocalPackage");
9138 delete_key(props, "", access & KEY_WOW64_64KEY);
9139 RegCloseKey(props);
9140 delete_key(userkey, "", access & KEY_WOW64_64KEY);
9141 RegCloseKey(userkey);
9142 RegDeleteKeyA(prodkey, "");
9143 RegCloseKey(prodkey);
9145 /* MSIINSTALLCONTEXT_MACHINE */
9147 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
9148 lstrcatA(keypath, prod_squashed);
9150 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
9151 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9153 /* managed product key exists */
9154 hprod = 0xdeadbeef;
9155 r = MsiOpenProductA(prodcode, &hprod);
9156 ok(r == ERROR_UNKNOWN_PRODUCT,
9157 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9158 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9160 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9161 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
9162 lstrcatA(keypath, prod_squashed);
9164 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
9165 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9167 /* user product key exists */
9168 hprod = 0xdeadbeef;
9169 r = MsiOpenProductA(prodcode, &hprod);
9170 ok(r == ERROR_UNKNOWN_PRODUCT,
9171 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9172 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9174 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
9175 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9177 /* InstallProperties key exists */
9178 hprod = 0xdeadbeef;
9179 r = MsiOpenProductA(prodcode, &hprod);
9180 ok(r == ERROR_UNKNOWN_PRODUCT,
9181 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9182 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9184 lstrcpyA(val, path);
9185 lstrcatA(val, "\\winetest.msi");
9186 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9187 (const BYTE *)val, lstrlenA(val) + 1);
9188 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9190 /* LocalPackage value exists */
9191 hprod = 0xdeadbeef;
9192 r = MsiOpenProductA(prodcode, &hprod);
9193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9194 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
9196 size = MAX_PATH;
9197 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
9198 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9199 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
9200 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
9202 MsiCloseHandle(hprod);
9204 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9205 (const BYTE *)"winetest.msi", 13);
9206 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9208 lstrcpyA(val, path);
9209 lstrcatA(val, "\\winetest.msi");
9210 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9211 (const BYTE *)val, lstrlenA(val) + 1);
9212 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9214 DeleteFileA(msifile);
9216 /* local package does not exist */
9217 hprod = 0xdeadbeef;
9218 r = MsiOpenProductA(prodcode, &hprod);
9219 ok(r == ERROR_UNKNOWN_PRODUCT,
9220 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9221 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9223 RegDeleteValueA(props, "LocalPackage");
9224 delete_key(props, "", access & KEY_WOW64_64KEY);
9225 RegCloseKey(props);
9226 delete_key(userkey, "", access & KEY_WOW64_64KEY);
9227 RegCloseKey(userkey);
9228 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9229 RegCloseKey(prodkey);
9231 DeleteFileA(msifile);
9232 LocalFree(usersid);
9235 static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid)
9237 MSIINSTALLCONTEXT context;
9238 CHAR keypath[MAX_PATH], patch[MAX_PATH];
9239 CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
9240 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
9241 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
9242 HKEY prodkey, patches, udprod, udpatch, hpatch;
9243 DWORD size, data;
9244 LONG res;
9245 UINT r;
9246 REGSAM access = KEY_ALL_ACCESS;
9248 create_test_guid(prodcode, prod_squashed);
9249 create_test_guid(patch, patch_squashed);
9251 if (is_wow64)
9252 access |= KEY_WOW64_64KEY;
9254 /* MSIPATCHSTATE_APPLIED */
9256 lstrcpyA(patchcode, "apple");
9257 lstrcpyA(targetprod, "banana");
9258 context = 0xdeadbeef;
9259 lstrcpyA(targetsid, "kiwi");
9260 size = MAX_PATH;
9261 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9262 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9263 &context, targetsid, &size);
9264 if (r == ERROR_ACCESS_DENIED)
9266 skip("Not enough rights to perform tests\n");
9267 return;
9269 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9270 ok(!lstrcmpA(patchcode, "apple"),
9271 "Expected patchcode to be unchanged, got %s\n", patchcode);
9272 ok(!lstrcmpA(targetprod, "banana"),
9273 "Expected targetprod to be unchanged, got %s\n", targetprod);
9274 ok(context == 0xdeadbeef,
9275 "Expected context to be unchanged, got %d\n", context);
9276 ok(!lstrcmpA(targetsid, "kiwi"),
9277 "Expected targetsid to be unchanged, got %s\n", targetsid);
9278 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9280 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
9281 lstrcatA(keypath, expectedsid);
9282 lstrcatA(keypath, "\\Installer\\Products\\");
9283 lstrcatA(keypath, prod_squashed);
9285 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
9286 if (res == ERROR_ACCESS_DENIED)
9288 skip("Not enough rights to perform tests\n");
9289 return;
9291 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9293 /* managed product key exists */
9294 lstrcpyA(patchcode, "apple");
9295 lstrcpyA(targetprod, "banana");
9296 context = 0xdeadbeef;
9297 lstrcpyA(targetsid, "kiwi");
9298 size = MAX_PATH;
9299 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9300 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9301 &context, targetsid, &size);
9302 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9303 ok(!lstrcmpA(patchcode, "apple"),
9304 "Expected patchcode to be unchanged, got %s\n", patchcode);
9305 ok(!lstrcmpA(targetprod, "banana"),
9306 "Expected targetprod to be unchanged, got %s\n", targetprod);
9307 ok(context == 0xdeadbeef,
9308 "Expected context to be unchanged, got %d\n", context);
9309 ok(!lstrcmpA(targetsid, "kiwi"),
9310 "Expected targetsid to be unchanged, got %s\n", targetsid);
9311 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9313 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
9314 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9316 /* patches key exists */
9317 lstrcpyA(patchcode, "apple");
9318 lstrcpyA(targetprod, "banana");
9319 context = 0xdeadbeef;
9320 lstrcpyA(targetsid, "kiwi");
9321 size = MAX_PATH;
9322 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9323 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9324 &context, targetsid, &size);
9325 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9326 ok(!lstrcmpA(patchcode, "apple"),
9327 "Expected patchcode to be unchanged, got %s\n", patchcode);
9328 ok(!lstrcmpA(targetprod, "banana"),
9329 "Expected targetprod to be unchanged, got %s\n", targetprod);
9330 ok(context == 0xdeadbeef,
9331 "Expected context to be unchanged, got %d\n", context);
9332 ok(!lstrcmpA(targetsid, "kiwi"),
9333 "Expected targetsid to be unchanged, got %s\n", targetsid);
9334 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9336 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
9337 (const BYTE *)patch_squashed,
9338 lstrlenA(patch_squashed) + 1);
9339 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9341 /* Patches value exists, is not REG_MULTI_SZ */
9342 lstrcpyA(patchcode, "apple");
9343 lstrcpyA(targetprod, "banana");
9344 context = 0xdeadbeef;
9345 lstrcpyA(targetsid, "kiwi");
9346 size = MAX_PATH;
9347 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9348 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9349 &context, targetsid, &size);
9350 ok(r == ERROR_BAD_CONFIGURATION,
9351 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9352 ok(!lstrcmpA(patchcode, "apple"),
9353 "Expected patchcode to be unchanged, got %s\n", patchcode);
9354 ok(!lstrcmpA(targetprod, "banana"),
9355 "Expected targetprod to be unchanged, got %s\n", targetprod);
9356 ok(context == 0xdeadbeef,
9357 "Expected context to be unchanged, got %d\n", context);
9358 ok(!lstrcmpA(targetsid, "kiwi"),
9359 "Expected targetsid to be unchanged, got %s\n", targetsid);
9360 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9362 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
9363 (const BYTE *)"a\0b\0c\0\0", 7);
9364 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9366 /* Patches value exists, is not a squashed guid */
9367 lstrcpyA(patchcode, "apple");
9368 lstrcpyA(targetprod, "banana");
9369 context = 0xdeadbeef;
9370 lstrcpyA(targetsid, "kiwi");
9371 size = MAX_PATH;
9372 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9373 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9374 &context, targetsid, &size);
9375 ok(r == ERROR_BAD_CONFIGURATION,
9376 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9377 ok(!lstrcmpA(patchcode, "apple"),
9378 "Expected patchcode to be unchanged, got %s\n", patchcode);
9379 ok(!lstrcmpA(targetprod, "banana"),
9380 "Expected targetprod to be unchanged, got %s\n", targetprod);
9381 ok(context == 0xdeadbeef,
9382 "Expected context to be unchanged, got %d\n", context);
9383 ok(!lstrcmpA(targetsid, "kiwi"),
9384 "Expected targetsid to be unchanged, got %s\n", targetsid);
9385 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9387 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
9388 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
9389 (const BYTE *)patch_squashed,
9390 lstrlenA(patch_squashed) + 2);
9391 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9393 /* Patches value exists */
9394 lstrcpyA(patchcode, "apple");
9395 lstrcpyA(targetprod, "banana");
9396 context = 0xdeadbeef;
9397 lstrcpyA(targetsid, "kiwi");
9398 size = MAX_PATH;
9399 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9400 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9401 &context, targetsid, &size);
9402 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9403 ok(!lstrcmpA(patchcode, "apple"),
9404 "Expected patchcode to be unchanged, got %s\n", patchcode);
9405 ok(!lstrcmpA(targetprod, "banana"),
9406 "Expected targetprod to be unchanged, got %s\n", targetprod);
9407 ok(context == 0xdeadbeef,
9408 "Expected context to be unchanged, got %d\n", context);
9409 ok(!lstrcmpA(targetsid, "kiwi"),
9410 "Expected targetsid to be unchanged, got %s\n", targetsid);
9411 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9413 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
9414 (const BYTE *)"whatever", 9);
9415 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9417 /* patch squashed value exists */
9418 lstrcpyA(patchcode, "apple");
9419 lstrcpyA(targetprod, "banana");
9420 context = 0xdeadbeef;
9421 lstrcpyA(targetsid, "kiwi");
9422 size = MAX_PATH;
9423 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9424 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9425 &context, targetsid, &size);
9426 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9427 ok(!lstrcmpA(patchcode, patch),
9428 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9429 ok(!lstrcmpA(targetprod, prodcode),
9430 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9431 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9432 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9433 ok(!lstrcmpA(targetsid, expectedsid),
9434 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9435 ok(size == lstrlenA(expectedsid),
9436 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9438 /* increase the index */
9439 lstrcpyA(patchcode, "apple");
9440 lstrcpyA(targetprod, "banana");
9441 context = 0xdeadbeef;
9442 lstrcpyA(targetsid, "kiwi");
9443 size = MAX_PATH;
9444 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9445 MSIPATCHSTATE_APPLIED, 1, patchcode, targetprod,
9446 &context, targetsid, &size);
9447 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9448 ok(!lstrcmpA(patchcode, "apple"),
9449 "Expected patchcode to be unchanged, got %s\n", patchcode);
9450 ok(!lstrcmpA(targetprod, "banana"),
9451 "Expected targetprod to be unchanged, got %s\n", targetprod);
9452 ok(context == 0xdeadbeef,
9453 "Expected context to be unchanged, got %d\n", context);
9454 ok(!lstrcmpA(targetsid, "kiwi"),
9455 "Expected targetsid to be unchanged, got %s\n", targetsid);
9456 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9458 /* increase again */
9459 lstrcpyA(patchcode, "apple");
9460 lstrcpyA(targetprod, "banana");
9461 context = 0xdeadbeef;
9462 lstrcpyA(targetsid, "kiwi");
9463 size = MAX_PATH;
9464 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9465 MSIPATCHSTATE_APPLIED, 2, patchcode, targetprod,
9466 &context, targetsid, &size);
9467 ok(r == ERROR_INVALID_PARAMETER,
9468 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9469 ok(!lstrcmpA(patchcode, "apple"),
9470 "Expected patchcode to be unchanged, got %s\n", patchcode);
9471 ok(!lstrcmpA(targetprod, "banana"),
9472 "Expected targetprod to be unchanged, got %s\n", targetprod);
9473 ok(context == 0xdeadbeef,
9474 "Expected context to be unchanged, got %d\n", context);
9475 ok(!lstrcmpA(targetsid, "kiwi"),
9476 "Expected targetsid to be unchanged, got %s\n", targetsid);
9477 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9479 /* szPatchCode is NULL */
9480 lstrcpyA(targetprod, "banana");
9481 context = 0xdeadbeef;
9482 lstrcpyA(targetsid, "kiwi");
9483 size = MAX_PATH;
9484 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9485 MSIPATCHSTATE_APPLIED, 0, NULL, targetprod,
9486 &context, targetsid, &size);
9487 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9488 ok(!lstrcmpA(targetprod, prodcode),
9489 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9490 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9491 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9492 ok(!lstrcmpA(targetsid, expectedsid),
9493 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9494 ok(size == lstrlenA(expectedsid),
9495 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9497 /* szTargetProductCode is NULL */
9498 lstrcpyA(patchcode, "apple");
9499 context = 0xdeadbeef;
9500 lstrcpyA(targetsid, "kiwi");
9501 size = MAX_PATH;
9502 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9503 MSIPATCHSTATE_APPLIED, 0, patchcode, NULL,
9504 &context, targetsid, &size);
9505 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9506 ok(!lstrcmpA(patchcode, patch),
9507 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9508 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9509 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9510 ok(!lstrcmpA(targetsid, expectedsid),
9511 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9512 ok(size == lstrlenA(expectedsid),
9513 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9515 /* pdwTargetProductContext is NULL */
9516 lstrcpyA(patchcode, "apple");
9517 lstrcpyA(targetprod, "banana");
9518 lstrcpyA(targetsid, "kiwi");
9519 size = MAX_PATH;
9520 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9521 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9522 NULL, targetsid, &size);
9523 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9524 ok(!lstrcmpA(patchcode, patch),
9525 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9526 ok(!lstrcmpA(targetprod, prodcode),
9527 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9528 ok(!lstrcmpA(targetsid, expectedsid),
9529 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9530 ok(size == lstrlenA(expectedsid),
9531 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9533 /* szTargetUserSid is NULL */
9534 lstrcpyA(patchcode, "apple");
9535 lstrcpyA(targetprod, "banana");
9536 context = 0xdeadbeef;
9537 size = MAX_PATH;
9538 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9539 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9540 &context, NULL, &size);
9541 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9542 ok(!lstrcmpA(patchcode, patch),
9543 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9544 ok(!lstrcmpA(targetprod, prodcode),
9545 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9546 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9547 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9548 ok(size == lstrlenA(expectedsid) * sizeof(WCHAR),
9549 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid), size);
9551 /* pcchTargetUserSid is exactly the length of szTargetUserSid */
9552 lstrcpyA(patchcode, "apple");
9553 lstrcpyA(targetprod, "banana");
9554 context = 0xdeadbeef;
9555 lstrcpyA(targetsid, "kiwi");
9556 size = lstrlenA(expectedsid);
9557 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9558 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9559 &context, targetsid, &size);
9560 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
9561 ok(!lstrcmpA(patchcode, patch),
9562 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9563 ok(!lstrcmpA(targetprod, prodcode),
9564 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9565 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9566 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9567 ok(!strncmp(targetsid, expectedsid, lstrlenA(expectedsid) - 1),
9568 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9569 ok(size == lstrlenA(expectedsid) * sizeof(WCHAR),
9570 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid), size);
9572 /* pcchTargetUserSid has enough room for NULL terminator */
9573 lstrcpyA(patchcode, "apple");
9574 lstrcpyA(targetprod, "banana");
9575 context = 0xdeadbeef;
9576 lstrcpyA(targetsid, "kiwi");
9577 size = lstrlenA(expectedsid) + 1;
9578 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9579 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9580 &context, targetsid, &size);
9581 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9582 ok(!lstrcmpA(patchcode, patch),
9583 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9584 ok(!lstrcmpA(targetprod, prodcode),
9585 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9586 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9587 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9588 ok(!lstrcmpA(targetsid, expectedsid),
9589 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9590 ok(size == lstrlenA(expectedsid),
9591 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9593 /* both szTargetuserSid and pcchTargetUserSid are NULL */
9594 lstrcpyA(patchcode, "apple");
9595 lstrcpyA(targetprod, "banana");
9596 context = 0xdeadbeef;
9597 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9598 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9599 &context, NULL, NULL);
9600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9601 ok(!lstrcmpA(patchcode, patch),
9602 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9603 ok(!lstrcmpA(targetprod, prodcode),
9604 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9605 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9606 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9608 /* MSIPATCHSTATE_SUPERSEDED */
9610 lstrcpyA(patchcode, "apple");
9611 lstrcpyA(targetprod, "banana");
9612 context = 0xdeadbeef;
9613 lstrcpyA(targetsid, "kiwi");
9614 size = MAX_PATH;
9615 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9616 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9617 &context, targetsid, &size);
9618 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9619 ok(!lstrcmpA(patchcode, "apple"),
9620 "Expected patchcode to be unchanged, got %s\n", patchcode);
9621 ok(!lstrcmpA(targetprod, "banana"),
9622 "Expected targetprod to be unchanged, got %s\n", targetprod);
9623 ok(context == 0xdeadbeef,
9624 "Expected context to be unchanged, got %d\n", context);
9625 ok(!lstrcmpA(targetsid, "kiwi"),
9626 "Expected targetsid to be unchanged, got %s\n", targetsid);
9627 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9629 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9630 lstrcatA(keypath, expectedsid);
9631 lstrcatA(keypath, "\\Products\\");
9632 lstrcatA(keypath, prod_squashed);
9634 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
9635 if (res == ERROR_ACCESS_DENIED)
9637 skip("Not enough rights to perform tests\n");
9638 return;
9640 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9642 /* UserData product key exists */
9643 lstrcpyA(patchcode, "apple");
9644 lstrcpyA(targetprod, "banana");
9645 context = 0xdeadbeef;
9646 lstrcpyA(targetsid, "kiwi");
9647 size = MAX_PATH;
9648 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9649 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9650 &context, targetsid, &size);
9651 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9652 ok(!lstrcmpA(patchcode, "apple"),
9653 "Expected patchcode to be unchanged, got %s\n", patchcode);
9654 ok(!lstrcmpA(targetprod, "banana"),
9655 "Expected targetprod to be unchanged, got %s\n", targetprod);
9656 ok(context == 0xdeadbeef,
9657 "Expected context to be unchanged, got %d\n", context);
9658 ok(!lstrcmpA(targetsid, "kiwi"),
9659 "Expected targetsid to be unchanged, got %s\n", targetsid);
9660 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9662 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
9663 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9665 /* UserData patches key exists */
9666 lstrcpyA(patchcode, "apple");
9667 lstrcpyA(targetprod, "banana");
9668 context = 0xdeadbeef;
9669 lstrcpyA(targetsid, "kiwi");
9670 size = MAX_PATH;
9671 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9672 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9673 &context, targetsid, &size);
9674 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9675 ok(!lstrcmpA(patchcode, "apple"),
9676 "Expected patchcode to be unchanged, got %s\n", patchcode);
9677 ok(!lstrcmpA(targetprod, "banana"),
9678 "Expected targetprod to be unchanged, got %s\n", targetprod);
9679 ok(context == 0xdeadbeef,
9680 "Expected context to be unchanged, got %d\n", context);
9681 ok(!lstrcmpA(targetsid, "kiwi"),
9682 "Expected targetsid to be unchanged, got %s\n", targetsid);
9683 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9685 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
9686 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9688 /* specific UserData patch key exists */
9689 lstrcpyA(patchcode, "apple");
9690 lstrcpyA(targetprod, "banana");
9691 context = 0xdeadbeef;
9692 lstrcpyA(targetsid, "kiwi");
9693 size = MAX_PATH;
9694 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9695 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9696 &context, targetsid, &size);
9697 ok(r == ERROR_BAD_CONFIGURATION,
9698 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9699 ok(!lstrcmpA(patchcode, "apple"),
9700 "Expected patchcode to be unchanged, got %s\n", patchcode);
9701 ok(!lstrcmpA(targetprod, "banana"),
9702 "Expected targetprod to be unchanged, got %s\n", targetprod);
9703 ok(context == 0xdeadbeef,
9704 "Expected context to be unchanged, got %d\n", context);
9705 ok(!lstrcmpA(targetsid, "kiwi"),
9706 "Expected targetsid to be unchanged, got %s\n", targetsid);
9707 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9709 data = MSIPATCHSTATE_SUPERSEDED;
9710 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
9711 (const BYTE *)&data, sizeof(DWORD));
9712 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9714 /* State value exists */
9715 lstrcpyA(patchcode, "apple");
9716 lstrcpyA(targetprod, "banana");
9717 context = 0xdeadbeef;
9718 lstrcpyA(targetsid, "kiwi");
9719 size = MAX_PATH;
9720 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9721 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9722 &context, targetsid, &size);
9723 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9724 ok(!lstrcmpA(patchcode, patch),
9725 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9726 ok(!lstrcmpA(targetprod, prodcode),
9727 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9728 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9729 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9730 ok(!lstrcmpA(targetsid, expectedsid),
9731 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9732 ok(size == lstrlenA(expectedsid),
9733 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9735 /* MSIPATCHSTATE_OBSOLETED */
9737 lstrcpyA(patchcode, "apple");
9738 lstrcpyA(targetprod, "banana");
9739 context = 0xdeadbeef;
9740 lstrcpyA(targetsid, "kiwi");
9741 size = MAX_PATH;
9742 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9743 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
9744 &context, targetsid, &size);
9745 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9746 ok(!lstrcmpA(patchcode, "apple"),
9747 "Expected patchcode to be unchanged, got %s\n", patchcode);
9748 ok(!lstrcmpA(targetprod, "banana"),
9749 "Expected targetprod to be unchanged, got %s\n", targetprod);
9750 ok(context == 0xdeadbeef,
9751 "Expected context to be unchanged, got %d\n", context);
9752 ok(!lstrcmpA(targetsid, "kiwi"),
9753 "Expected targetsid to be unchanged, got %s\n", targetsid);
9754 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9756 data = MSIPATCHSTATE_OBSOLETED;
9757 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
9758 (const BYTE *)&data, sizeof(DWORD));
9759 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9761 /* State value is obsoleted */
9762 lstrcpyA(patchcode, "apple");
9763 lstrcpyA(targetprod, "banana");
9764 context = 0xdeadbeef;
9765 lstrcpyA(targetsid, "kiwi");
9766 size = MAX_PATH;
9767 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9768 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
9769 &context, targetsid, &size);
9770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9771 ok(!lstrcmpA(patchcode, patch),
9772 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9773 ok(!lstrcmpA(targetprod, prodcode),
9774 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9775 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9776 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9777 ok(!lstrcmpA(targetsid, expectedsid),
9778 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9779 ok(size == lstrlenA(expectedsid),
9780 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9782 /* MSIPATCHSTATE_REGISTERED */
9783 /* FIXME */
9785 /* MSIPATCHSTATE_ALL */
9787 /* 1st */
9788 lstrcpyA(patchcode, "apple");
9789 lstrcpyA(targetprod, "banana");
9790 context = 0xdeadbeef;
9791 lstrcpyA(targetsid, "kiwi");
9792 size = MAX_PATH;
9793 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9794 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
9795 &context, targetsid, &size);
9796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9797 ok(!lstrcmpA(patchcode, patch),
9798 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9799 ok(!lstrcmpA(targetprod, prodcode),
9800 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9801 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9802 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9803 ok(!lstrcmpA(targetsid, expectedsid),
9804 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9805 ok(size == lstrlenA(expectedsid),
9806 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9808 /* same patch in multiple places, only one is enumerated */
9809 lstrcpyA(patchcode, "apple");
9810 lstrcpyA(targetprod, "banana");
9811 context = 0xdeadbeef;
9812 lstrcpyA(targetsid, "kiwi");
9813 size = MAX_PATH;
9814 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9815 MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
9816 &context, targetsid, &size);
9817 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9818 ok(!lstrcmpA(patchcode, "apple"),
9819 "Expected patchcode to be unchanged, got %s\n", patchcode);
9820 ok(!lstrcmpA(targetprod, "banana"),
9821 "Expected targetprod to be unchanged, got %s\n", targetprod);
9822 ok(context == 0xdeadbeef,
9823 "Expected context to be unchanged, got %d\n", context);
9824 ok(!lstrcmpA(targetsid, "kiwi"),
9825 "Expected targetsid to be unchanged, got %s\n", targetsid);
9826 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9828 RegDeleteValueA(hpatch, "State");
9829 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
9830 RegCloseKey(hpatch);
9831 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
9832 RegCloseKey(udpatch);
9833 delete_key(udprod, "", access & KEY_WOW64_64KEY);
9834 RegCloseKey(udprod);
9835 RegDeleteValueA(patches, "Patches");
9836 delete_key(patches, "", access & KEY_WOW64_64KEY);
9837 RegCloseKey(patches);
9838 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9839 RegCloseKey(prodkey);
9842 static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expectedsid)
9844 MSIINSTALLCONTEXT context;
9845 CHAR keypath[MAX_PATH], patch[MAX_PATH];
9846 CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
9847 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
9848 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
9849 HKEY prodkey, patches, udprod, udpatch;
9850 HKEY userkey, hpatch;
9851 DWORD size, data;
9852 LONG res;
9853 UINT r;
9854 REGSAM access = KEY_ALL_ACCESS;
9856 create_test_guid(prodcode, prod_squashed);
9857 create_test_guid(patch, patch_squashed);
9859 if (is_wow64)
9860 access |= KEY_WOW64_64KEY;
9862 /* MSIPATCHSTATE_APPLIED */
9864 lstrcpyA(patchcode, "apple");
9865 lstrcpyA(targetprod, "banana");
9866 context = 0xdeadbeef;
9867 lstrcpyA(targetsid, "kiwi");
9868 size = MAX_PATH;
9869 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
9870 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9871 &context, targetsid, &size);
9872 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9873 ok(!lstrcmpA(patchcode, "apple"),
9874 "Expected patchcode to be unchanged, got %s\n", patchcode);
9875 ok(!lstrcmpA(targetprod, "banana"),
9876 "Expected targetprod to be unchanged, got %s\n", targetprod);
9877 ok(context == 0xdeadbeef,
9878 "Expected context to be unchanged, got %d\n", context);
9879 ok(!lstrcmpA(targetsid, "kiwi"),
9880 "Expected targetsid to be unchanged, got %s\n", targetsid);
9881 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9883 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
9884 lstrcatA(keypath, prod_squashed);
9886 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
9887 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9889 /* current user product key exists */
9890 lstrcpyA(patchcode, "apple");
9891 lstrcpyA(targetprod, "banana");
9892 context = 0xdeadbeef;
9893 lstrcpyA(targetsid, "kiwi");
9894 size = MAX_PATH;
9895 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
9896 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9897 &context, targetsid, &size);
9898 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9899 ok(!lstrcmpA(patchcode, "apple"),
9900 "Expected patchcode to be unchanged, got %s\n", patchcode);
9901 ok(!lstrcmpA(targetprod, "banana"),
9902 "Expected targetprod to be unchanged, got %s\n", targetprod);
9903 ok(context == 0xdeadbeef,
9904 "Expected context to be unchanged, got %d\n", context);
9905 ok(!lstrcmpA(targetsid, "kiwi"),
9906 "Expected targetsid to be unchanged, got %s\n", targetsid);
9907 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9909 res = RegCreateKeyA(prodkey, "Patches", &patches);
9910 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9912 /* Patches key exists */
9913 lstrcpyA(patchcode, "apple");
9914 lstrcpyA(targetprod, "banana");
9915 context = 0xdeadbeef;
9916 lstrcpyA(targetsid, "kiwi");
9917 size = MAX_PATH;
9918 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
9919 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9920 &context, targetsid, &size);
9921 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9922 ok(!lstrcmpA(patchcode, "apple"),
9923 "Expected patchcode to be unchanged, got %s\n", patchcode);
9924 ok(!lstrcmpA(targetprod, "banana"),
9925 "Expected targetprod to be unchanged, got %s\n", targetprod);
9926 ok(context == 0xdeadbeef,
9927 "Expected context to be unchanged, got %d\n", context);
9928 ok(!lstrcmpA(targetsid, "kiwi"),
9929 "Expected targetsid to be unchanged, got %s\n", targetsid);
9930 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9932 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
9933 (const BYTE *)patch_squashed,
9934 lstrlenA(patch_squashed) + 1);
9935 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9937 /* Patches value exists, is not REG_MULTI_SZ */
9938 lstrcpyA(patchcode, "apple");
9939 lstrcpyA(targetprod, "banana");
9940 context = 0xdeadbeef;
9941 lstrcpyA(targetsid, "kiwi");
9942 size = MAX_PATH;
9943 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
9944 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9945 &context, targetsid, &size);
9946 ok(r == ERROR_BAD_CONFIGURATION,
9947 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9948 ok(!lstrcmpA(patchcode, "apple"),
9949 "Expected patchcode to be unchanged, got %s\n", patchcode);
9950 ok(!lstrcmpA(targetprod, "banana"),
9951 "Expected targetprod to be unchanged, got %s\n", targetprod);
9952 ok(context == 0xdeadbeef,
9953 "Expected context to be unchanged, got %d\n", context);
9954 ok(!lstrcmpA(targetsid, "kiwi"),
9955 "Expected targetsid to be unchanged, got %s\n", targetsid);
9956 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9958 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
9959 (const BYTE *)"a\0b\0c\0\0", 7);
9960 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9962 /* Patches value exists, is not a squashed guid */
9963 lstrcpyA(patchcode, "apple");
9964 lstrcpyA(targetprod, "banana");
9965 context = 0xdeadbeef;
9966 lstrcpyA(targetsid, "kiwi");
9967 size = MAX_PATH;
9968 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
9969 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9970 &context, targetsid, &size);
9971 ok(r == ERROR_BAD_CONFIGURATION,
9972 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9973 ok(!lstrcmpA(patchcode, "apple"),
9974 "Expected patchcode to be unchanged, got %s\n", patchcode);
9975 ok(!lstrcmpA(targetprod, "banana"),
9976 "Expected targetprod to be unchanged, got %s\n", targetprod);
9977 ok(context == 0xdeadbeef,
9978 "Expected context to be unchanged, got %d\n", context);
9979 ok(!lstrcmpA(targetsid, "kiwi"),
9980 "Expected targetsid to be unchanged, got %s\n", targetsid);
9981 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9983 patch_squashed[lstrlenA(patch_squashed) + 1] = 0;
9984 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
9985 (const BYTE *)patch_squashed,
9986 lstrlenA(patch_squashed) + 2);
9987 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9989 /* Patches value exists */
9990 lstrcpyA(patchcode, "apple");
9991 lstrcpyA(targetprod, "banana");
9992 context = 0xdeadbeef;
9993 lstrcpyA(targetsid, "kiwi");
9994 size = MAX_PATH;
9995 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
9996 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9997 &context, targetsid, &size);
9998 ok(r == ERROR_NO_MORE_ITEMS ||
9999 broken(r == ERROR_BAD_CONFIGURATION), /* Windows Installer 3.0 */
10000 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10001 ok(!lstrcmpA(patchcode, "apple"),
10002 "Expected patchcode to be unchanged, got %s\n", patchcode);
10003 ok(!lstrcmpA(targetprod, "banana"),
10004 "Expected targetprod to be unchanged, got %s\n", targetprod);
10005 ok(context == 0xdeadbeef,
10006 "Expected context to be unchanged, got %d\n", context);
10007 ok(!lstrcmpA(targetsid, "kiwi"),
10008 "Expected targetsid to be unchanged, got %s\n", targetsid);
10009 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10011 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
10012 (const BYTE *)"whatever", 9);
10013 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10015 /* patch code value exists */
10016 lstrcpyA(patchcode, "apple");
10017 lstrcpyA(targetprod, "banana");
10018 context = 0xdeadbeef;
10019 lstrcpyA(targetsid, "kiwi");
10020 size = MAX_PATH;
10021 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10022 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10023 &context, targetsid, &size);
10024 ok(r == ERROR_NO_MORE_ITEMS ||
10025 broken(r == ERROR_BAD_CONFIGURATION), /* Windows Installer 3.0 */
10026 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10027 ok(!lstrcmpA(patchcode, "apple"),
10028 "Expected patchcode to be unchanged, got %s\n", patchcode);
10029 ok(!lstrcmpA(targetprod, "banana"),
10030 "Expected targetprod to be unchanged, got %s\n", targetprod);
10031 ok(context == 0xdeadbeef,
10032 "Expected context to be unchanged, got %d\n", context);
10033 ok(!lstrcmpA(targetsid, "kiwi"),
10034 "Expected targetsid to be unchanged, got %s\n", targetsid);
10035 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10037 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
10038 lstrcatA(keypath, expectedsid);
10039 lstrcatA(keypath, "\\Patches\\");
10040 lstrcatA(keypath, patch_squashed);
10042 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
10043 if (res == ERROR_ACCESS_DENIED)
10045 skip("Not enough rights to perform tests\n");
10046 goto error;
10048 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10050 /* userdata patch key exists */
10051 lstrcpyA(patchcode, "apple");
10052 lstrcpyA(targetprod, "banana");
10053 context = 0xdeadbeef;
10054 lstrcpyA(targetsid, "kiwi");
10055 size = MAX_PATH;
10056 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10057 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10058 &context, targetsid, &size);
10059 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10060 ok(!lstrcmpA(patchcode, patch),
10061 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10062 ok(!lstrcmpA(targetprod, prodcode),
10063 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10064 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10065 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10066 ok(!lstrcmpA(targetsid, expectedsid),
10067 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10068 ok(size == lstrlenA(expectedsid),
10069 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10071 /* MSIPATCHSTATE_SUPERSEDED */
10073 lstrcpyA(patchcode, "apple");
10074 lstrcpyA(targetprod, "banana");
10075 context = 0xdeadbeef;
10076 lstrcpyA(targetsid, "kiwi");
10077 size = MAX_PATH;
10078 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10079 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10080 &context, targetsid, &size);
10081 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10082 ok(!lstrcmpA(patchcode, "apple"),
10083 "Expected patchcode to be unchanged, got %s\n", patchcode);
10084 ok(!lstrcmpA(targetprod, "banana"),
10085 "Expected targetprod to be unchanged, got %s\n", targetprod);
10086 ok(context == 0xdeadbeef,
10087 "Expected context to be unchanged, got %d\n", context);
10088 ok(!lstrcmpA(targetsid, "kiwi"),
10089 "Expected targetsid to be unchanged, got %s\n", targetsid);
10090 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10092 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
10093 lstrcatA(keypath, expectedsid);
10094 lstrcatA(keypath, "\\Products\\");
10095 lstrcatA(keypath, prod_squashed);
10097 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
10098 if (res == ERROR_ACCESS_DENIED)
10100 skip("Not enough rights to perform tests\n");
10101 goto error;
10103 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10105 /* UserData product key exists */
10106 lstrcpyA(patchcode, "apple");
10107 lstrcpyA(targetprod, "banana");
10108 context = 0xdeadbeef;
10109 lstrcpyA(targetsid, "kiwi");
10110 size = MAX_PATH;
10111 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10112 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10113 &context, targetsid, &size);
10114 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10115 ok(!lstrcmpA(patchcode, "apple"),
10116 "Expected patchcode to be unchanged, got %s\n", patchcode);
10117 ok(!lstrcmpA(targetprod, "banana"),
10118 "Expected targetprod to be unchanged, got %s\n", targetprod);
10119 ok(context == 0xdeadbeef,
10120 "Expected context to be unchanged, got %d\n", context);
10121 ok(!lstrcmpA(targetsid, "kiwi"),
10122 "Expected targetsid to be unchanged, got %s\n", targetsid);
10123 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10125 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
10126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10128 /* UserData patches key exists */
10129 lstrcpyA(patchcode, "apple");
10130 lstrcpyA(targetprod, "banana");
10131 context = 0xdeadbeef;
10132 lstrcpyA(targetsid, "kiwi");
10133 size = MAX_PATH;
10134 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10135 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10136 &context, targetsid, &size);
10137 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10138 ok(!lstrcmpA(patchcode, "apple"),
10139 "Expected patchcode to be unchanged, got %s\n", patchcode);
10140 ok(!lstrcmpA(targetprod, "banana"),
10141 "Expected targetprod to be unchanged, got %s\n", targetprod);
10142 ok(context == 0xdeadbeef,
10143 "Expected context to be unchanged, got %d\n", context);
10144 ok(!lstrcmpA(targetsid, "kiwi"),
10145 "Expected targetsid to be unchanged, got %s\n", targetsid);
10146 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10148 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
10149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10151 /* specific UserData patch key exists */
10152 lstrcpyA(patchcode, "apple");
10153 lstrcpyA(targetprod, "banana");
10154 context = 0xdeadbeef;
10155 lstrcpyA(targetsid, "kiwi");
10156 size = MAX_PATH;
10157 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10158 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10159 &context, targetsid, &size);
10160 ok(r == ERROR_BAD_CONFIGURATION,
10161 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10162 ok(!lstrcmpA(patchcode, "apple"),
10163 "Expected patchcode to be unchanged, got %s\n", patchcode);
10164 ok(!lstrcmpA(targetprod, "banana"),
10165 "Expected targetprod to be unchanged, got %s\n", targetprod);
10166 ok(context == 0xdeadbeef,
10167 "Expected context to be unchanged, got %d\n", context);
10168 ok(!lstrcmpA(targetsid, "kiwi"),
10169 "Expected targetsid to be unchanged, got %s\n", targetsid);
10170 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10172 data = MSIPATCHSTATE_SUPERSEDED;
10173 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10174 (const BYTE *)&data, sizeof(DWORD));
10175 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10177 /* State value exists */
10178 lstrcpyA(patchcode, "apple");
10179 lstrcpyA(targetprod, "banana");
10180 context = 0xdeadbeef;
10181 lstrcpyA(targetsid, "kiwi");
10182 size = MAX_PATH;
10183 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10184 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10185 &context, targetsid, &size);
10186 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10187 ok(!lstrcmpA(patchcode, patch),
10188 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10189 ok(!lstrcmpA(targetprod, prodcode),
10190 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10191 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10192 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10193 ok(!lstrcmpA(targetsid, expectedsid),
10194 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10195 ok(size == lstrlenA(expectedsid),
10196 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10198 /* MSIPATCHSTATE_OBSOLETED */
10200 lstrcpyA(patchcode, "apple");
10201 lstrcpyA(targetprod, "banana");
10202 context = 0xdeadbeef;
10203 lstrcpyA(targetsid, "kiwi");
10204 size = MAX_PATH;
10205 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10206 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10207 &context, targetsid, &size);
10208 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10209 ok(!lstrcmpA(patchcode, "apple"),
10210 "Expected patchcode to be unchanged, got %s\n", patchcode);
10211 ok(!lstrcmpA(targetprod, "banana"),
10212 "Expected targetprod to be unchanged, got %s\n", targetprod);
10213 ok(context == 0xdeadbeef,
10214 "Expected context to be unchanged, got %d\n", context);
10215 ok(!lstrcmpA(targetsid, "kiwi"),
10216 "Expected targetsid to be unchanged, got %s\n", targetsid);
10217 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10219 data = MSIPATCHSTATE_OBSOLETED;
10220 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10221 (const BYTE *)&data, sizeof(DWORD));
10222 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10224 /* State value is obsoleted */
10225 lstrcpyA(patchcode, "apple");
10226 lstrcpyA(targetprod, "banana");
10227 context = 0xdeadbeef;
10228 lstrcpyA(targetsid, "kiwi");
10229 size = MAX_PATH;
10230 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10231 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10232 &context, targetsid, &size);
10233 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10234 ok(!lstrcmpA(patchcode, patch),
10235 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10236 ok(!lstrcmpA(targetprod, prodcode),
10237 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10238 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10239 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10240 ok(!lstrcmpA(targetsid, expectedsid),
10241 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10242 ok(size == lstrlenA(expectedsid),
10243 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10245 /* MSIPATCHSTATE_REGISTERED */
10246 /* FIXME */
10248 /* MSIPATCHSTATE_ALL */
10250 /* 1st */
10251 lstrcpyA(patchcode, "apple");
10252 lstrcpyA(targetprod, "banana");
10253 context = 0xdeadbeef;
10254 lstrcpyA(targetsid, "kiwi");
10255 size = MAX_PATH;
10256 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10257 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10258 &context, targetsid, &size);
10259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10260 ok(!lstrcmpA(patchcode, patch),
10261 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10262 ok(!lstrcmpA(targetprod, prodcode),
10263 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10264 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10265 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10266 ok(!lstrcmpA(targetsid, expectedsid),
10267 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10268 ok(size == lstrlenA(expectedsid),
10269 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10271 /* same patch in multiple places, only one is enumerated */
10272 lstrcpyA(patchcode, "apple");
10273 lstrcpyA(targetprod, "banana");
10274 context = 0xdeadbeef;
10275 lstrcpyA(targetsid, "kiwi");
10276 size = MAX_PATH;
10277 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10278 MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
10279 &context, targetsid, &size);
10280 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10281 ok(!lstrcmpA(patchcode, "apple"),
10282 "Expected patchcode to be unchanged, got %s\n", patchcode);
10283 ok(!lstrcmpA(targetprod, "banana"),
10284 "Expected targetprod to be unchanged, got %s\n", targetprod);
10285 ok(context == 0xdeadbeef,
10286 "Expected context to be unchanged, got %d\n", context);
10287 ok(!lstrcmpA(targetsid, "kiwi"),
10288 "Expected targetsid to be unchanged, got %s\n", targetsid);
10289 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10291 RegDeleteValueA(hpatch, "State");
10292 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
10293 RegCloseKey(hpatch);
10294 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
10295 RegCloseKey(udpatch);
10296 delete_key(udprod, "", access & KEY_WOW64_64KEY);
10297 RegCloseKey(udprod);
10298 delete_key(userkey, "", access & KEY_WOW64_64KEY);
10299 RegCloseKey(userkey);
10300 RegDeleteValueA(patches, patch_squashed);
10301 RegDeleteValueA(patches, "Patches");
10303 error:
10304 RegDeleteKeyA(patches, "");
10305 RegCloseKey(patches);
10306 RegDeleteKeyA(prodkey, "");
10307 RegCloseKey(prodkey);
10310 static void test_MsiEnumPatchesEx_machine(void)
10312 CHAR keypath[MAX_PATH], patch[MAX_PATH];
10313 CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
10314 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
10315 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
10316 HKEY prodkey, patches, udprod, udpatch;
10317 HKEY hpatch;
10318 MSIINSTALLCONTEXT context;
10319 DWORD size, data;
10320 LONG res;
10321 UINT r;
10322 REGSAM access = KEY_ALL_ACCESS;
10324 create_test_guid(prodcode, prod_squashed);
10325 create_test_guid(patch, patch_squashed);
10327 if (is_wow64)
10328 access |= KEY_WOW64_64KEY;
10330 /* MSIPATCHSTATE_APPLIED */
10332 lstrcpyA(patchcode, "apple");
10333 lstrcpyA(targetprod, "banana");
10334 context = 0xdeadbeef;
10335 lstrcpyA(targetsid, "kiwi");
10336 size = MAX_PATH;
10337 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10338 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10339 &context, targetsid, &size);
10340 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10341 ok(!lstrcmpA(patchcode, "apple"),
10342 "Expected patchcode to be unchanged, got %s\n", patchcode);
10343 ok(!lstrcmpA(targetprod, "banana"),
10344 "Expected targetprod to be unchanged, got %s\n", targetprod);
10345 ok(context == 0xdeadbeef,
10346 "Expected context to be unchanged, got %d\n", context);
10347 ok(!lstrcmpA(targetsid, "kiwi"),
10348 "Expected targetsid to be unchanged, got %s\n", targetsid);
10349 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10351 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
10352 lstrcatA(keypath, prod_squashed);
10354 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
10355 if (res == ERROR_ACCESS_DENIED)
10357 skip("Not enough rights to perform tests\n");
10358 return;
10360 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10362 /* local product key exists */
10363 lstrcpyA(patchcode, "apple");
10364 lstrcpyA(targetprod, "banana");
10365 context = 0xdeadbeef;
10366 lstrcpyA(targetsid, "kiwi");
10367 size = MAX_PATH;
10368 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10369 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10370 &context, targetsid, &size);
10371 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10372 ok(!lstrcmpA(patchcode, "apple"),
10373 "Expected patchcode to be unchanged, got %s\n", patchcode);
10374 ok(!lstrcmpA(targetprod, "banana"),
10375 "Expected targetprod to be unchanged, got %s\n", targetprod);
10376 ok(context == 0xdeadbeef,
10377 "Expected context to be unchanged, got %d\n", context);
10378 ok(!lstrcmpA(targetsid, "kiwi"),
10379 "Expected targetsid to be unchanged, got %s\n", targetsid);
10380 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10382 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
10383 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10385 /* Patches key exists */
10386 lstrcpyA(patchcode, "apple");
10387 lstrcpyA(targetprod, "banana");
10388 context = 0xdeadbeef;
10389 lstrcpyA(targetsid, "kiwi");
10390 size = MAX_PATH;
10391 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10392 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10393 &context, targetsid, &size);
10394 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10395 ok(!lstrcmpA(patchcode, "apple"),
10396 "Expected patchcode to be unchanged, got %s\n", patchcode);
10397 ok(!lstrcmpA(targetprod, "banana"),
10398 "Expected targetprod to be unchanged, got %s\n", targetprod);
10399 ok(context == 0xdeadbeef,
10400 "Expected context to be unchanged, got %d\n", context);
10401 ok(!lstrcmpA(targetsid, "kiwi"),
10402 "Expected targetsid to be unchanged, got %s\n", targetsid);
10403 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10405 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
10406 (const BYTE *)patch_squashed,
10407 lstrlenA(patch_squashed) + 1);
10408 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10410 /* Patches value exists, is not REG_MULTI_SZ */
10411 lstrcpyA(patchcode, "apple");
10412 lstrcpyA(targetprod, "banana");
10413 context = 0xdeadbeef;
10414 lstrcpyA(targetsid, "kiwi");
10415 size = MAX_PATH;
10416 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10417 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10418 &context, targetsid, &size);
10419 ok(r == ERROR_BAD_CONFIGURATION,
10420 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10421 ok(!lstrcmpA(patchcode, "apple"),
10422 "Expected patchcode to be unchanged, got %s\n", patchcode);
10423 ok(!lstrcmpA(targetprod, "banana"),
10424 "Expected targetprod to be unchanged, got %s\n", targetprod);
10425 ok(context == 0xdeadbeef,
10426 "Expected context to be unchanged, got %d\n", context);
10427 ok(!lstrcmpA(targetsid, "kiwi"),
10428 "Expected targetsid to be unchanged, got %s\n", targetsid);
10429 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10431 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
10432 (const BYTE *)"a\0b\0c\0\0", 7);
10433 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10435 /* Patches value exists, is not a squashed guid */
10436 lstrcpyA(patchcode, "apple");
10437 lstrcpyA(targetprod, "banana");
10438 context = 0xdeadbeef;
10439 lstrcpyA(targetsid, "kiwi");
10440 size = MAX_PATH;
10441 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10442 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10443 &context, targetsid, &size);
10444 ok(r == ERROR_BAD_CONFIGURATION,
10445 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10446 ok(!lstrcmpA(patchcode, "apple"),
10447 "Expected patchcode to be unchanged, got %s\n", patchcode);
10448 ok(!lstrcmpA(targetprod, "banana"),
10449 "Expected targetprod to be unchanged, got %s\n", targetprod);
10450 ok(context == 0xdeadbeef,
10451 "Expected context to be unchanged, got %d\n", context);
10452 ok(!lstrcmpA(targetsid, "kiwi"),
10453 "Expected targetsid to be unchanged, got %s\n", targetsid);
10454 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10456 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
10457 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
10458 (const BYTE *)patch_squashed,
10459 lstrlenA(patch_squashed) + 2);
10460 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10462 /* Patches value exists */
10463 lstrcpyA(patchcode, "apple");
10464 lstrcpyA(targetprod, "banana");
10465 context = 0xdeadbeef;
10466 lstrcpyA(targetsid, "kiwi");
10467 size = MAX_PATH;
10468 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10469 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10470 &context, targetsid, &size);
10471 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10472 ok(!lstrcmpA(patchcode, "apple"),
10473 "Expected patchcode to be unchanged, got %s\n", patchcode);
10474 ok(!lstrcmpA(targetprod, "banana"),
10475 "Expected targetprod to be unchanged, got %s\n", targetprod);
10476 ok(context == 0xdeadbeef,
10477 "Expected context to be unchanged, got %d\n", context);
10478 ok(!lstrcmpA(targetsid, "kiwi"),
10479 "Expected targetsid to be unchanged, got %s\n", targetsid);
10480 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10482 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
10483 (const BYTE *)"whatever", 9);
10484 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10486 /* patch code value exists */
10487 lstrcpyA(patchcode, "apple");
10488 lstrcpyA(targetprod, "banana");
10489 context = 0xdeadbeef;
10490 lstrcpyA(targetsid, "kiwi");
10491 size = MAX_PATH;
10492 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10493 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10494 &context, targetsid, &size);
10495 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10496 ok(!lstrcmpA(patchcode, patch),
10497 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10498 ok(!lstrcmpA(targetprod, prodcode),
10499 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10500 ok(context == MSIINSTALLCONTEXT_MACHINE,
10501 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10502 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10503 ok(size == 0, "Expected 0, got %d\n", size);
10505 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
10506 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
10507 lstrcatA(keypath, prod_squashed);
10509 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
10510 if (res == ERROR_ACCESS_DENIED)
10512 skip("Not enough rights to perform tests\n");
10513 goto done;
10515 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10517 /* local UserData product key exists */
10518 lstrcpyA(patchcode, "apple");
10519 lstrcpyA(targetprod, "banana");
10520 context = 0xdeadbeef;
10521 lstrcpyA(targetsid, "kiwi");
10522 size = MAX_PATH;
10523 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10524 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10525 &context, targetsid, &size);
10526 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10527 ok(!lstrcmpA(patchcode, patch),
10528 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10529 ok(!lstrcmpA(targetprod, prodcode),
10530 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10531 ok(context == MSIINSTALLCONTEXT_MACHINE,
10532 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10533 ok(!lstrcmpA(targetsid, ""),
10534 "Expected \"\", got \"%s\"\n", targetsid);
10535 ok(size == 0, "Expected 0, got %d\n", size);
10537 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
10538 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10540 /* local UserData Patches key exists */
10541 lstrcpyA(patchcode, "apple");
10542 lstrcpyA(targetprod, "banana");
10543 context = 0xdeadbeef;
10544 lstrcpyA(targetsid, "kiwi");
10545 size = MAX_PATH;
10546 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10547 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10548 &context, targetsid, &size);
10549 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10550 ok(!lstrcmpA(patchcode, patch),
10551 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10552 ok(!lstrcmpA(targetprod, prodcode),
10553 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10554 ok(context == MSIINSTALLCONTEXT_MACHINE,
10555 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10556 ok(!lstrcmpA(targetsid, ""),
10557 "Expected \"\", got \"%s\"\n", targetsid);
10558 ok(size == 0, "Expected 0, got %d\n", size);
10560 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
10561 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10563 /* local UserData Product patch key exists */
10564 lstrcpyA(patchcode, "apple");
10565 lstrcpyA(targetprod, "banana");
10566 context = 0xdeadbeef;
10567 lstrcpyA(targetsid, "kiwi");
10568 size = MAX_PATH;
10569 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10570 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10571 &context, targetsid, &size);
10572 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10573 ok(!lstrcmpA(patchcode, "apple"),
10574 "Expected patchcode to be unchanged, got %s\n", patchcode);
10575 ok(!lstrcmpA(targetprod, "banana"),
10576 "Expected targetprod to be unchanged, got %s\n", targetprod);
10577 ok(context == 0xdeadbeef,
10578 "Expected context to be unchanged, got %d\n", context);
10579 ok(!lstrcmpA(targetsid, "kiwi"),
10580 "Expected targetsid to be unchanged, got %s\n", targetsid);
10581 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10583 data = MSIPATCHSTATE_APPLIED;
10584 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10585 (const BYTE *)&data, sizeof(DWORD));
10586 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10588 /* State value exists */
10589 lstrcpyA(patchcode, "apple");
10590 lstrcpyA(targetprod, "banana");
10591 context = 0xdeadbeef;
10592 lstrcpyA(targetsid, "kiwi");
10593 size = MAX_PATH;
10594 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10595 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10596 &context, targetsid, &size);
10597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10598 ok(!lstrcmpA(patchcode, patch),
10599 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10600 ok(!lstrcmpA(targetprod, prodcode),
10601 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10602 ok(context == MSIINSTALLCONTEXT_MACHINE,
10603 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10604 ok(!lstrcmpA(targetsid, ""),
10605 "Expected \"\", got \"%s\"\n", targetsid);
10606 ok(size == 0, "Expected 0, got %d\n", size);
10608 /* MSIPATCHSTATE_SUPERSEDED */
10610 lstrcpyA(patchcode, "apple");
10611 lstrcpyA(targetprod, "banana");
10612 context = 0xdeadbeef;
10613 lstrcpyA(targetsid, "kiwi");
10614 size = MAX_PATH;
10615 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10616 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10617 &context, targetsid, &size);
10618 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10619 ok(!lstrcmpA(patchcode, "apple"),
10620 "Expected patchcode to be unchanged, got %s\n", patchcode);
10621 ok(!lstrcmpA(targetprod, "banana"),
10622 "Expected targetprod to be unchanged, got %s\n", targetprod);
10623 ok(context == 0xdeadbeef,
10624 "Expected context to be unchanged, got %d\n", context);
10625 ok(!lstrcmpA(targetsid, "kiwi"),
10626 "Expected targetsid to be unchanged, got %s\n", targetsid);
10627 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10629 data = MSIPATCHSTATE_SUPERSEDED;
10630 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10631 (const BYTE *)&data, sizeof(DWORD));
10632 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10634 /* State value is MSIPATCHSTATE_SUPERSEDED */
10635 lstrcpyA(patchcode, "apple");
10636 lstrcpyA(targetprod, "banana");
10637 context = 0xdeadbeef;
10638 lstrcpyA(targetsid, "kiwi");
10639 size = MAX_PATH;
10640 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10641 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10642 &context, targetsid, &size);
10643 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10644 ok(!lstrcmpA(patchcode, patch),
10645 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10646 ok(!lstrcmpA(targetprod, prodcode),
10647 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10648 ok(context == MSIINSTALLCONTEXT_MACHINE,
10649 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10650 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10651 ok(size == 0, "Expected 0, got %d\n", size);
10653 /* MSIPATCHSTATE_OBSOLETED */
10655 lstrcpyA(patchcode, "apple");
10656 lstrcpyA(targetprod, "banana");
10657 context = 0xdeadbeef;
10658 lstrcpyA(targetsid, "kiwi");
10659 size = MAX_PATH;
10660 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10661 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10662 &context, targetsid, &size);
10663 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10664 ok(!lstrcmpA(patchcode, "apple"),
10665 "Expected patchcode to be unchanged, got %s\n", patchcode);
10666 ok(!lstrcmpA(targetprod, "banana"),
10667 "Expected targetprod to be unchanged, got %s\n", targetprod);
10668 ok(context == 0xdeadbeef,
10669 "Expected context to be unchanged, got %d\n", context);
10670 ok(!lstrcmpA(targetsid, "kiwi"),
10671 "Expected targetsid to be unchanged, got %s\n", targetsid);
10672 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10674 data = MSIPATCHSTATE_OBSOLETED;
10675 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10676 (const BYTE *)&data, sizeof(DWORD));
10677 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10679 /* State value is obsoleted */
10680 lstrcpyA(patchcode, "apple");
10681 lstrcpyA(targetprod, "banana");
10682 context = 0xdeadbeef;
10683 lstrcpyA(targetsid, "kiwi");
10684 size = MAX_PATH;
10685 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10686 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10687 &context, targetsid, &size);
10688 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10689 ok(!lstrcmpA(patchcode, patch),
10690 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10691 ok(!lstrcmpA(targetprod, prodcode),
10692 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10693 ok(context == MSIINSTALLCONTEXT_MACHINE,
10694 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10695 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10696 ok(size == 0, "Expected 0, got %d\n", size);
10698 /* MSIPATCHSTATE_REGISTERED */
10699 /* FIXME */
10701 /* MSIPATCHSTATE_ALL */
10703 /* 1st */
10704 lstrcpyA(patchcode, "apple");
10705 lstrcpyA(targetprod, "banana");
10706 context = 0xdeadbeef;
10707 lstrcpyA(targetsid, "kiwi");
10708 size = MAX_PATH;
10709 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10710 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10711 &context, targetsid, &size);
10712 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10713 ok(!lstrcmpA(patchcode, patch),
10714 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10715 ok(!lstrcmpA(targetprod, prodcode),
10716 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10717 ok(context == MSIINSTALLCONTEXT_MACHINE,
10718 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10719 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10720 ok(size == 0, "Expected 0, got %d\n", size);
10722 /* same patch in multiple places, only one is enumerated */
10723 lstrcpyA(patchcode, "apple");
10724 lstrcpyA(targetprod, "banana");
10725 context = 0xdeadbeef;
10726 lstrcpyA(targetsid, "kiwi");
10727 size = MAX_PATH;
10728 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10729 MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
10730 &context, targetsid, &size);
10731 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10732 ok(!lstrcmpA(patchcode, "apple"),
10733 "Expected patchcode to be unchanged, got %s\n", patchcode);
10734 ok(!lstrcmpA(targetprod, "banana"),
10735 "Expected targetprod to be unchanged, got %s\n", targetprod);
10736 ok(context == 0xdeadbeef,
10737 "Expected context to be unchanged, got %d\n", context);
10738 ok(!lstrcmpA(targetsid, "kiwi"),
10739 "Expected targetsid to be unchanged, got %s\n", targetsid);
10740 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10742 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
10743 RegCloseKey(hpatch);
10744 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
10745 RegCloseKey(udpatch);
10747 done:
10748 RegDeleteValueA(patches, patch_squashed);
10749 RegDeleteValueA(patches, "Patches");
10750 delete_key(patches, "", access & KEY_WOW64_64KEY);
10751 RegCloseKey(patches);
10752 RegDeleteValueA(hpatch, "State");
10753 delete_key(udprod, "", access & KEY_WOW64_64KEY);
10754 RegCloseKey(udprod);
10755 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
10756 RegCloseKey(prodkey);
10759 static void test_MsiEnumPatchesEx(void)
10761 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
10762 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
10763 CHAR patchcode[MAX_PATH];
10764 MSIINSTALLCONTEXT context;
10765 LPSTR usersid;
10766 DWORD size;
10767 UINT r;
10769 if (!pMsiEnumPatchesExA)
10771 win_skip("MsiEnumPatchesExA not implemented\n");
10772 return;
10775 create_test_guid(prodcode, prod_squashed);
10776 usersid = get_user_sid();
10778 /* empty szProductCode */
10779 lstrcpyA(patchcode, "apple");
10780 lstrcpyA(targetprod, "banana");
10781 context = 0xdeadbeef;
10782 lstrcpyA(targetsid, "kiwi");
10783 size = MAX_PATH;
10784 r = pMsiEnumPatchesExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10785 MSIPATCHSTATE_ALL, 0, patchcode, targetprod, &context,
10786 targetsid, &size);
10787 ok(r == ERROR_INVALID_PARAMETER,
10788 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10789 ok(!lstrcmpA(patchcode, "apple"),
10790 "Expected patchcode to be unchanged, got %s\n", patchcode);
10791 ok(!lstrcmpA(targetprod, "banana"),
10792 "Expected targetprod to be unchanged, got %s\n", targetprod);
10793 ok(context == 0xdeadbeef,
10794 "Expected context to be unchanged, got %d\n", context);
10795 ok(!lstrcmpA(targetsid, "kiwi"),
10796 "Expected targetsid to be unchanged, got %s\n", targetsid);
10797 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10799 /* garbage szProductCode */
10800 lstrcpyA(patchcode, "apple");
10801 lstrcpyA(targetprod, "banana");
10802 context = 0xdeadbeef;
10803 lstrcpyA(targetsid, "kiwi");
10804 size = MAX_PATH;
10805 r = pMsiEnumPatchesExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10806 MSIPATCHSTATE_ALL, 0, patchcode, targetprod, &context,
10807 targetsid, &size);
10808 ok(r == ERROR_INVALID_PARAMETER,
10809 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10810 ok(!lstrcmpA(patchcode, "apple"),
10811 "Expected patchcode to be unchanged, got %s\n", patchcode);
10812 ok(!lstrcmpA(targetprod, "banana"),
10813 "Expected targetprod to be unchanged, got %s\n", targetprod);
10814 ok(context == 0xdeadbeef,
10815 "Expected context to be unchanged, got %d\n", context);
10816 ok(!lstrcmpA(targetsid, "kiwi"),
10817 "Expected targetsid to be unchanged, got %s\n", targetsid);
10818 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10820 /* guid without brackets */
10821 lstrcpyA(patchcode, "apple");
10822 lstrcpyA(targetprod, "banana");
10823 context = 0xdeadbeef;
10824 lstrcpyA(targetsid, "kiwi");
10825 size = MAX_PATH;
10826 r = pMsiEnumPatchesExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
10827 MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
10828 0, patchcode, targetprod, &context,
10829 targetsid, &size);
10830 ok(r == ERROR_INVALID_PARAMETER,
10831 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10832 ok(!lstrcmpA(patchcode, "apple"),
10833 "Expected patchcode to be unchanged, got %s\n", patchcode);
10834 ok(!lstrcmpA(targetprod, "banana"),
10835 "Expected targetprod to be unchanged, got %s\n", targetprod);
10836 ok(context == 0xdeadbeef,
10837 "Expected context to be unchanged, got %d\n", context);
10838 ok(!lstrcmpA(targetsid, "kiwi"),
10839 "Expected targetsid to be unchanged, got %s\n", targetsid);
10840 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10842 /* guid with brackets */
10843 lstrcpyA(patchcode, "apple");
10844 lstrcpyA(targetprod, "banana");
10845 context = 0xdeadbeef;
10846 lstrcpyA(targetsid, "kiwi");
10847 size = MAX_PATH;
10848 r = pMsiEnumPatchesExA("{6700E8CF-95AB-4D9C-BC2C-15840DDA7A5D}", usersid,
10849 MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
10850 0, patchcode, targetprod, &context,
10851 targetsid, &size);
10852 ok(r == ERROR_NO_MORE_ITEMS,
10853 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10854 ok(!lstrcmpA(patchcode, "apple"),
10855 "Expected patchcode to be unchanged, got %s\n", patchcode);
10856 ok(!lstrcmpA(targetprod, "banana"),
10857 "Expected targetprod to be unchanged, got %s\n", targetprod);
10858 ok(context == 0xdeadbeef,
10859 "Expected context to be unchanged, got %d\n", context);
10860 ok(!lstrcmpA(targetsid, "kiwi"),
10861 "Expected targetsid to be unchanged, got %s\n", targetsid);
10862 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10864 /* szUserSid is S-1-5-18 */
10865 lstrcpyA(patchcode, "apple");
10866 lstrcpyA(targetprod, "banana");
10867 context = 0xdeadbeef;
10868 lstrcpyA(targetsid, "kiwi");
10869 size = MAX_PATH;
10870 r = pMsiEnumPatchesExA(prodcode, "S-1-5-18",
10871 MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
10872 0, patchcode, targetprod, &context,
10873 targetsid, &size);
10874 ok(r == ERROR_INVALID_PARAMETER,
10875 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10876 ok(!lstrcmpA(patchcode, "apple"),
10877 "Expected patchcode to be unchanged, got %s\n", patchcode);
10878 ok(!lstrcmpA(targetprod, "banana"),
10879 "Expected targetprod to be unchanged, got %s\n", targetprod);
10880 ok(context == 0xdeadbeef,
10881 "Expected context to be unchanged, got %d\n", context);
10882 ok(!lstrcmpA(targetsid, "kiwi"),
10883 "Expected targetsid to be unchanged, got %s\n", targetsid);
10884 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10886 /* dwContext is MSIINSTALLCONTEXT_MACHINE, but szUserSid is non-NULL */
10887 lstrcpyA(patchcode, "apple");
10888 lstrcpyA(targetprod, "banana");
10889 context = 0xdeadbeef;
10890 lstrcpyA(targetsid, "kiwi");
10891 size = MAX_PATH;
10892 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_MACHINE,
10893 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10894 &context, targetsid, &size);
10895 ok(r == ERROR_INVALID_PARAMETER,
10896 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10897 ok(!lstrcmpA(patchcode, "apple"),
10898 "Expected patchcode to be unchanged, got %s\n", patchcode);
10899 ok(!lstrcmpA(targetprod, "banana"),
10900 "Expected targetprod to be unchanged, got %s\n", targetprod);
10901 ok(context == 0xdeadbeef,
10902 "Expected context to be unchanged, got %d\n", context);
10903 ok(!lstrcmpA(targetsid, "kiwi"),
10904 "Expected targetsid to be unchanged, got %s\n", targetsid);
10905 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10907 /* dwContext is out of bounds */
10908 lstrcpyA(patchcode, "apple");
10909 lstrcpyA(targetprod, "banana");
10910 context = 0xdeadbeef;
10911 lstrcpyA(targetsid, "kiwi");
10912 size = MAX_PATH;
10913 r = pMsiEnumPatchesExA(prodcode, usersid, 0,
10914 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10915 &context, targetsid, &size);
10916 ok(r == ERROR_INVALID_PARAMETER,
10917 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10918 ok(!lstrcmpA(patchcode, "apple"),
10919 "Expected patchcode to be unchanged, got %s\n", patchcode);
10920 ok(!lstrcmpA(targetprod, "banana"),
10921 "Expected targetprod to be unchanged, got %s\n", targetprod);
10922 ok(context == 0xdeadbeef,
10923 "Expected context to be unchanged, got %d\n", context);
10924 ok(!lstrcmpA(targetsid, "kiwi"),
10925 "Expected targetsid to be unchanged, got %s\n", targetsid);
10926 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10928 /* dwContext is out of bounds */
10929 lstrcpyA(patchcode, "apple");
10930 lstrcpyA(targetprod, "banana");
10931 context = 0xdeadbeef;
10932 lstrcpyA(targetsid, "kiwi");
10933 size = MAX_PATH;
10934 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_ALL + 1,
10935 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10936 &context, targetsid, &size);
10937 ok(r == ERROR_INVALID_PARAMETER,
10938 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10939 ok(!lstrcmpA(patchcode, "apple"),
10940 "Expected patchcode to be unchanged, got %s\n", patchcode);
10941 ok(!lstrcmpA(targetprod, "banana"),
10942 "Expected targetprod to be unchanged, got %s\n", targetprod);
10943 ok(context == 0xdeadbeef,
10944 "Expected context to be unchanged, got %d\n", context);
10945 ok(!lstrcmpA(targetsid, "kiwi"),
10946 "Expected targetsid to be unchanged, got %s\n", targetsid);
10947 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10949 /* dwFilter is out of bounds */
10950 lstrcpyA(patchcode, "apple");
10951 lstrcpyA(targetprod, "banana");
10952 context = 0xdeadbeef;
10953 lstrcpyA(targetsid, "kiwi");
10954 size = MAX_PATH;
10955 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10956 MSIPATCHSTATE_INVALID, 0, patchcode, targetprod,
10957 &context, targetsid, &size);
10958 ok(r == ERROR_INVALID_PARAMETER,
10959 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10960 ok(!lstrcmpA(patchcode, "apple"),
10961 "Expected patchcode to be unchanged, got %s\n", patchcode);
10962 ok(!lstrcmpA(targetprod, "banana"),
10963 "Expected targetprod to be unchanged, got %s\n", targetprod);
10964 ok(context == 0xdeadbeef,
10965 "Expected context to be unchanged, got %d\n", context);
10966 ok(!lstrcmpA(targetsid, "kiwi"),
10967 "Expected targetsid to be unchanged, got %s\n", targetsid);
10968 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10970 /* dwFilter is out of bounds */
10971 lstrcpyA(patchcode, "apple");
10972 lstrcpyA(targetprod, "banana");
10973 context = 0xdeadbeef;
10974 lstrcpyA(targetsid, "kiwi");
10975 size = MAX_PATH;
10976 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10977 MSIPATCHSTATE_ALL + 1, 0, patchcode, targetprod,
10978 &context, targetsid, &size);
10979 ok(r == ERROR_INVALID_PARAMETER,
10980 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10981 ok(!lstrcmpA(patchcode, "apple"),
10982 "Expected patchcode to be unchanged, got %s\n", patchcode);
10983 ok(!lstrcmpA(targetprod, "banana"),
10984 "Expected targetprod to be unchanged, got %s\n", targetprod);
10985 ok(context == 0xdeadbeef,
10986 "Expected context to be unchanged, got %d\n", context);
10987 ok(!lstrcmpA(targetsid, "kiwi"),
10988 "Expected targetsid to be unchanged, got %s\n", targetsid);
10989 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10991 /* pcchTargetUserSid is NULL while szTargetUserSid is non-NULL */
10992 lstrcpyA(patchcode, "apple");
10993 lstrcpyA(targetprod, "banana");
10994 context = 0xdeadbeef;
10995 lstrcpyA(targetsid, "kiwi");
10996 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10997 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10998 &context, targetsid, NULL);
10999 ok(r == ERROR_INVALID_PARAMETER,
11000 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11001 ok(!lstrcmpA(patchcode, "apple"),
11002 "Expected patchcode to be unchanged, got %s\n", patchcode);
11003 ok(!lstrcmpA(targetprod, "banana"),
11004 "Expected targetprod to be unchanged, got %s\n", targetprod);
11005 ok(context == 0xdeadbeef,
11006 "Expected context to be unchanged, got %d\n", context);
11007 ok(!lstrcmpA(targetsid, "kiwi"),
11008 "Expected targetsid to be unchanged, got %s\n", targetsid);
11010 test_MsiEnumPatchesEx_usermanaged(usersid, usersid);
11011 test_MsiEnumPatchesEx_usermanaged(NULL, usersid);
11012 test_MsiEnumPatchesEx_usermanaged("S-1-2-34", "S-1-2-34");
11013 test_MsiEnumPatchesEx_userunmanaged(usersid, usersid);
11014 test_MsiEnumPatchesEx_userunmanaged(NULL, usersid);
11015 /* FIXME: Successfully test userunmanaged with a different user */
11016 test_MsiEnumPatchesEx_machine();
11017 LocalFree(usersid);
11020 static void test_MsiEnumPatches(void)
11022 CHAR keypath[MAX_PATH], patch[MAX_PATH];
11023 CHAR patchcode[MAX_PATH], patch_squashed[MAX_PATH];
11024 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
11025 CHAR transforms[MAX_PATH];
11026 WCHAR patchW[MAX_PATH], prodcodeW[MAX_PATH], transformsW[MAX_PATH];
11027 HKEY prodkey, patches, udprod;
11028 HKEY userkey, hpatch, udpatch;
11029 DWORD size, data;
11030 LPSTR usersid;
11031 LONG res;
11032 UINT r;
11033 REGSAM access = KEY_ALL_ACCESS;
11035 create_test_guid(prodcode, prod_squashed);
11036 create_test_guid(patchcode, patch_squashed);
11037 usersid = get_user_sid();
11039 if (is_wow64)
11040 access |= KEY_WOW64_64KEY;
11042 /* NULL szProduct */
11043 size = MAX_PATH;
11044 lstrcpyA(patch, "apple");
11045 lstrcpyA(transforms, "banana");
11046 r = MsiEnumPatchesA(NULL, 0, patch, transforms, &size);
11047 ok(r == ERROR_INVALID_PARAMETER,
11048 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11049 ok(!lstrcmpA(patch, "apple"),
11050 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11051 ok(!lstrcmpA(transforms, "banana"),
11052 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11053 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11055 /* empty szProduct */
11056 size = MAX_PATH;
11057 lstrcpyA(patch, "apple");
11058 lstrcpyA(transforms, "banana");
11059 r = MsiEnumPatchesA("", 0, patch, transforms, &size);
11060 ok(r == ERROR_INVALID_PARAMETER,
11061 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11062 ok(!lstrcmpA(patch, "apple"),
11063 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11064 ok(!lstrcmpA(transforms, "banana"),
11065 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11066 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11068 /* garbage szProduct */
11069 size = MAX_PATH;
11070 lstrcpyA(patch, "apple");
11071 lstrcpyA(transforms, "banana");
11072 r = MsiEnumPatchesA("garbage", 0, patch, transforms, &size);
11073 ok(r == ERROR_INVALID_PARAMETER,
11074 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11075 ok(!lstrcmpA(patch, "apple"),
11076 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11077 ok(!lstrcmpA(transforms, "banana"),
11078 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11079 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11081 /* guid without brackets */
11082 size = MAX_PATH;
11083 lstrcpyA(patch, "apple");
11084 lstrcpyA(transforms, "banana");
11085 r = MsiEnumPatchesA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", 0, patch,
11086 transforms, &size);
11087 ok(r == ERROR_INVALID_PARAMETER,
11088 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11089 ok(!lstrcmpA(patch, "apple"),
11090 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11091 ok(!lstrcmpA(transforms, "banana"),
11092 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11093 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11095 /* guid with brackets */
11096 size = MAX_PATH;
11097 lstrcpyA(patch, "apple");
11098 lstrcpyA(transforms, "banana");
11099 r = MsiEnumPatchesA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", 0, patch,
11100 transforms, &size);
11101 ok(r == ERROR_UNKNOWN_PRODUCT,
11102 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11103 ok(!lstrcmpA(patch, "apple"),
11104 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11105 ok(!lstrcmpA(transforms, "banana"),
11106 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11107 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11109 /* same length as guid, but random */
11110 size = MAX_PATH;
11111 lstrcpyA(patch, "apple");
11112 lstrcpyA(transforms, "banana");
11113 r = MsiEnumPatchesA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", 0, patch,
11114 transforms, &size);
11115 ok(r == ERROR_INVALID_PARAMETER,
11116 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11117 ok(!lstrcmpA(patch, "apple"),
11118 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11119 ok(!lstrcmpA(transforms, "banana"),
11120 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11121 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11123 /* MSIINSTALLCONTEXT_USERMANAGED */
11125 size = MAX_PATH;
11126 lstrcpyA(patch, "apple");
11127 lstrcpyA(transforms, "banana");
11128 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11129 ok(r == ERROR_UNKNOWN_PRODUCT,
11130 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11131 ok(!lstrcmpA(patch, "apple"),
11132 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11133 ok(!lstrcmpA(transforms, "banana"),
11134 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11135 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11137 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
11138 lstrcatA(keypath, usersid);
11139 lstrcatA(keypath, "\\Installer\\Products\\");
11140 lstrcatA(keypath, prod_squashed);
11142 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
11143 if (res == ERROR_ACCESS_DENIED)
11145 skip("Not enough rights to perform tests\n");
11146 LocalFree(usersid);
11147 return;
11149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11151 /* managed product key exists */
11152 size = MAX_PATH;
11153 lstrcpyA(patch, "apple");
11154 lstrcpyA(transforms, "banana");
11155 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11156 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11157 ok(!lstrcmpA(patch, "apple"),
11158 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11159 ok(!lstrcmpA(transforms, "banana"),
11160 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11161 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11163 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
11164 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11166 /* patches key exists */
11167 size = MAX_PATH;
11168 lstrcpyA(patch, "apple");
11169 lstrcpyA(transforms, "banana");
11170 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11171 ok(r == ERROR_NO_MORE_ITEMS ||
11172 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11173 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11174 ok(!lstrcmpA(patch, "apple"),
11175 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11176 ok(!lstrcmpA(transforms, "banana"),
11177 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11178 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11180 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
11181 (const BYTE *)patch_squashed,
11182 lstrlenA(patch_squashed) + 1);
11183 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11185 /* Patches value exists, is not REG_MULTI_SZ */
11186 size = MAX_PATH;
11187 lstrcpyA(patch, "apple");
11188 lstrcpyA(transforms, "banana");
11189 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11190 ok(r == ERROR_BAD_CONFIGURATION ||
11191 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11192 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11193 ok(!lstrcmpA(patch, "apple"),
11194 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11195 ok(!lstrcmpA(transforms, "banana"),
11196 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11197 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11199 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11200 (const BYTE *)"a\0b\0c\0\0", 7);
11201 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11203 /* Patches value exists, is not a squashed guid */
11204 size = MAX_PATH;
11205 lstrcpyA(patch, "apple");
11206 lstrcpyA(transforms, "banana");
11207 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11208 ok(r == ERROR_BAD_CONFIGURATION,
11209 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11210 ok(!lstrcmpA(patch, "apple"),
11211 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11212 ok(!lstrcmpA(transforms, "banana"),
11213 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11214 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11216 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
11217 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11218 (const BYTE *)patch_squashed,
11219 lstrlenA(patch_squashed) + 2);
11220 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11222 /* Patches value exists */
11223 size = MAX_PATH;
11224 lstrcpyA(patch, "apple");
11225 lstrcpyA(transforms, "banana");
11226 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11227 ok(r == ERROR_NO_MORE_ITEMS ||
11228 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11229 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11230 ok(!lstrcmpA(patch, "apple") ||
11231 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11232 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11233 ok(!lstrcmpA(transforms, "banana"),
11234 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11235 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11237 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
11238 (const BYTE *)"whatever", 9);
11239 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11241 /* patch squashed value exists */
11242 size = MAX_PATH;
11243 lstrcpyA(patch, "apple");
11244 lstrcpyA(transforms, "banana");
11245 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11246 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11247 ok(!lstrcmpA(patch, patchcode),
11248 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11249 ok(!lstrcmpA(transforms, "whatever"),
11250 "Expected \"whatever\", got \"%s\"\n", transforms);
11251 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11253 /* lpPatchBuf is NULL */
11254 size = MAX_PATH;
11255 lstrcpyA(transforms, "banana");
11256 r = MsiEnumPatchesA(prodcode, 0, NULL, transforms, &size);
11257 ok(r == ERROR_INVALID_PARAMETER,
11258 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11259 ok(!lstrcmpA(transforms, "banana"),
11260 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11261 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11263 /* lpTransformsBuf is NULL, pcchTransformsBuf is not */
11264 size = MAX_PATH;
11265 lstrcpyA(patch, "apple");
11266 r = MsiEnumPatchesA(prodcode, 0, patch, NULL, &size);
11267 ok(r == ERROR_INVALID_PARAMETER,
11268 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11269 ok(!lstrcmpA(patch, "apple"),
11270 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11271 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11273 /* pcchTransformsBuf is NULL, lpTransformsBuf is not */
11274 lstrcpyA(patch, "apple");
11275 lstrcpyA(transforms, "banana");
11276 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, NULL);
11277 ok(r == ERROR_INVALID_PARAMETER,
11278 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11279 ok(!lstrcmpA(patch, "apple"),
11280 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11281 ok(!lstrcmpA(transforms, "banana"),
11282 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11284 /* pcchTransformsBuf is too small */
11285 size = 6;
11286 lstrcpyA(patch, "apple");
11287 lstrcpyA(transforms, "banana");
11288 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11289 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11290 ok(!lstrcmpA(patch, patchcode),
11291 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11292 ok(!lstrcmpA(transforms, "whate") ||
11293 broken(!lstrcmpA(transforms, "banana")), /* Windows Installer < 3.0 */
11294 "Expected \"whate\", got \"%s\"\n", transforms);
11295 ok(size == 8 || size == 16, "Expected 8 or 16, got %d\n", size);
11297 /* increase the index */
11298 size = MAX_PATH;
11299 lstrcpyA(patch, "apple");
11300 lstrcpyA(transforms, "banana");
11301 r = MsiEnumPatchesA(prodcode, 1, patch, transforms, &size);
11302 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11303 ok(!lstrcmpA(patch, "apple"),
11304 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11305 ok(!lstrcmpA(transforms, "banana"),
11306 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11307 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11309 /* increase again */
11310 size = MAX_PATH;
11311 lstrcpyA(patch, "apple");
11312 lstrcpyA(transforms, "banana");
11313 r = MsiEnumPatchesA(prodcode, 2, patch, transforms, &size);
11314 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11315 ok(!lstrcmpA(patch, "apple"),
11316 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11317 ok(!lstrcmpA(transforms, "banana"),
11318 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11319 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11321 RegDeleteValueA(patches, "Patches");
11322 delete_key(patches, "", access & KEY_WOW64_64KEY);
11323 RegCloseKey(patches);
11324 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
11325 RegCloseKey(prodkey);
11327 /* MSIINSTALLCONTEXT_USERUNMANAGED */
11329 size = MAX_PATH;
11330 lstrcpyA(patch, "apple");
11331 lstrcpyA(transforms, "banana");
11332 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11333 ok(r == ERROR_UNKNOWN_PRODUCT,
11334 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11335 ok(!lstrcmpA(patch, "apple"),
11336 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11337 ok(!lstrcmpA(transforms, "banana"),
11338 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11339 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11341 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
11342 lstrcatA(keypath, prod_squashed);
11344 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
11345 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11347 /* current user product key exists */
11348 size = MAX_PATH;
11349 lstrcpyA(patch, "apple");
11350 lstrcpyA(transforms, "banana");
11351 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11352 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11353 ok(!lstrcmpA(patch, "apple"),
11354 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11355 ok(!lstrcmpA(transforms, "banana"),
11356 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11357 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11359 res = RegCreateKeyA(prodkey, "Patches", &patches);
11360 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11362 /* Patches key exists */
11363 size = MAX_PATH;
11364 lstrcpyA(patch, "apple");
11365 lstrcpyA(transforms, "banana");
11366 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11367 ok(r == ERROR_NO_MORE_ITEMS ||
11368 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11369 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11370 ok(!lstrcmpA(patch, "apple"),
11371 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11372 ok(!lstrcmpA(transforms, "banana"),
11373 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11374 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11376 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
11377 (const BYTE *)patch_squashed,
11378 lstrlenA(patch_squashed) + 1);
11379 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11381 /* Patches value exists, is not REG_MULTI_SZ */
11382 size = MAX_PATH;
11383 lstrcpyA(patch, "apple");
11384 lstrcpyA(transforms, "banana");
11385 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11386 ok(r == ERROR_BAD_CONFIGURATION ||
11387 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11388 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11389 ok(!lstrcmpA(patch, "apple"),
11390 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11391 ok(!lstrcmpA(transforms, "banana"),
11392 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11393 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11395 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11396 (const BYTE *)"a\0b\0c\0\0", 7);
11397 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11399 /* Patches value exists, is not a squashed guid */
11400 size = MAX_PATH;
11401 lstrcpyA(patch, "apple");
11402 lstrcpyA(transforms, "banana");
11403 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11404 ok(r == ERROR_BAD_CONFIGURATION,
11405 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11406 ok(!lstrcmpA(patch, "apple"),
11407 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11408 ok(!lstrcmpA(transforms, "banana"),
11409 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11410 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11412 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
11413 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11414 (const BYTE *)patch_squashed,
11415 lstrlenA(patch_squashed) + 2);
11416 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11418 /* Patches value exists */
11419 size = MAX_PATH;
11420 lstrcpyA(patch, "apple");
11421 lstrcpyA(transforms, "banana");
11422 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11423 ok(r == ERROR_NO_MORE_ITEMS ||
11424 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11425 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11426 ok(!lstrcmpA(patch, "apple") ||
11427 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11428 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11429 ok(!lstrcmpA(transforms, "banana"),
11430 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11431 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11433 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
11434 (const BYTE *)"whatever", 9);
11435 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11437 /* patch code value exists */
11438 size = MAX_PATH;
11439 lstrcpyA(patch, "apple");
11440 lstrcpyA(transforms, "banana");
11441 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11442 ok(r == ERROR_NO_MORE_ITEMS ||
11443 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11444 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11445 ok(!lstrcmpA(patch, "apple") ||
11446 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11447 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11448 ok(!lstrcmpA(transforms, "banana") ||
11449 broken(!lstrcmpA(transforms, "whatever")), /* Windows Installer < 3.0 */
11450 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11451 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11453 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11454 lstrcatA(keypath, usersid);
11455 lstrcatA(keypath, "\\Patches\\");
11456 lstrcatA(keypath, patch_squashed);
11458 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
11459 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11461 /* userdata patch key exists */
11462 size = MAX_PATH;
11463 lstrcpyA(patch, "apple");
11464 lstrcpyA(transforms, "banana");
11465 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11467 ok(!lstrcmpA(patch, patchcode),
11468 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11469 ok(!lstrcmpA(transforms, "whatever"),
11470 "Expected \"whatever\", got \"%s\"\n", transforms);
11471 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11473 delete_key(userkey, "", access & KEY_WOW64_64KEY);
11474 RegCloseKey(userkey);
11475 RegDeleteValueA(patches, patch_squashed);
11476 RegDeleteValueA(patches, "Patches");
11477 RegDeleteKeyA(patches, "");
11478 RegCloseKey(patches);
11479 RegDeleteKeyA(prodkey, "");
11480 RegCloseKey(prodkey);
11482 /* MSIINSTALLCONTEXT_MACHINE */
11484 size = MAX_PATH;
11485 lstrcpyA(patch, "apple");
11486 lstrcpyA(transforms, "banana");
11487 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11488 ok(r == ERROR_UNKNOWN_PRODUCT,
11489 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11490 ok(!lstrcmpA(patch, "apple"),
11491 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11492 ok(!lstrcmpA(transforms, "banana"),
11493 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11494 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11496 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
11497 lstrcatA(keypath, prod_squashed);
11499 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
11500 if (res == ERROR_ACCESS_DENIED)
11502 skip("Not enough rights to perform tests\n");
11503 LocalFree(usersid);
11504 return;
11506 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11508 /* local product key exists */
11509 size = MAX_PATH;
11510 lstrcpyA(patch, "apple");
11511 lstrcpyA(transforms, "banana");
11512 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11513 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11514 ok(!lstrcmpA(patch, "apple"),
11515 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11516 ok(!lstrcmpA(transforms, "banana"),
11517 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11518 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11520 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
11521 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11523 /* Patches key exists */
11524 size = MAX_PATH;
11525 lstrcpyA(patch, "apple");
11526 lstrcpyA(transforms, "banana");
11527 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11528 ok(r == ERROR_NO_MORE_ITEMS ||
11529 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11530 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11531 ok(!lstrcmpA(patch, "apple"),
11532 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11533 ok(!lstrcmpA(transforms, "banana"),
11534 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11535 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11537 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
11538 (const BYTE *)patch_squashed,
11539 lstrlenA(patch_squashed) + 1);
11540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11542 /* Patches value exists, is not REG_MULTI_SZ */
11543 size = MAX_PATH;
11544 lstrcpyA(patch, "apple");
11545 lstrcpyA(transforms, "banana");
11546 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11547 ok(r == ERROR_BAD_CONFIGURATION ||
11548 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11549 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11550 ok(!lstrcmpA(patch, "apple"),
11551 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11552 ok(!lstrcmpA(transforms, "banana"),
11553 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11554 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11556 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11557 (const BYTE *)"a\0b\0c\0\0", 7);
11558 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11560 /* Patches value exists, is not a squashed guid */
11561 size = MAX_PATH;
11562 lstrcpyA(patch, "apple");
11563 lstrcpyA(transforms, "banana");
11564 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11565 ok(r == ERROR_BAD_CONFIGURATION,
11566 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11567 ok(!lstrcmpA(patch, "apple"),
11568 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11569 ok(!lstrcmpA(transforms, "banana"),
11570 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11571 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11573 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
11574 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11575 (const BYTE *)patch_squashed,
11576 lstrlenA(patch_squashed) + 2);
11577 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11579 /* Patches value exists */
11580 size = MAX_PATH;
11581 lstrcpyA(patch, "apple");
11582 lstrcpyA(transforms, "banana");
11583 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11584 ok(r == ERROR_NO_MORE_ITEMS ||
11585 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11586 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11587 ok(!lstrcmpA(patch, "apple") ||
11588 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11589 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11590 ok(!lstrcmpA(transforms, "banana"),
11591 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11592 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11594 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
11595 (const BYTE *)"whatever", 9);
11596 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11598 /* patch code value exists */
11599 size = MAX_PATH;
11600 lstrcpyA(patch, "apple");
11601 lstrcpyA(transforms, "banana");
11602 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11603 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11604 ok(!lstrcmpA(patch, patchcode),
11605 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11606 ok(!lstrcmpA(transforms, "whatever"),
11607 "Expected \"whatever\", got \"%s\"\n", transforms);
11608 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11610 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11611 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
11612 lstrcatA(keypath, prod_squashed);
11614 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
11615 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11617 /* local UserData product key exists */
11618 size = MAX_PATH;
11619 lstrcpyA(patch, "apple");
11620 lstrcpyA(transforms, "banana");
11621 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11622 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11623 ok(!lstrcmpA(patch, patchcode),
11624 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11625 ok(!lstrcmpA(transforms, "whatever"),
11626 "Expected \"whatever\", got \"%s\"\n", transforms);
11627 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11629 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
11630 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11632 /* local UserData Patches key exists */
11633 size = MAX_PATH;
11634 lstrcpyA(patch, "apple");
11635 lstrcpyA(transforms, "banana");
11636 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11638 ok(!lstrcmpA(patch, patchcode),
11639 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11640 ok(!lstrcmpA(transforms, "whatever"),
11641 "Expected \"whatever\", got \"%s\"\n", transforms);
11642 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11644 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
11645 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11647 /* local UserData Product patch key exists */
11648 size = MAX_PATH;
11649 lstrcpyA(patch, "apple");
11650 lstrcpyA(transforms, "banana");
11651 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11652 ok(r == ERROR_NO_MORE_ITEMS ||
11653 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11654 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11655 ok(!lstrcmpA(patch, "apple") ||
11656 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11657 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11658 ok(!lstrcmpA(transforms, "banana") ||
11659 broken(!lstrcmpA(transforms, "whatever")), /* Windows Installer < 3.0 */
11660 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11661 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11663 data = MSIPATCHSTATE_APPLIED;
11664 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
11665 (const BYTE *)&data, sizeof(DWORD));
11666 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11668 /* State value exists */
11669 size = MAX_PATH;
11670 lstrcpyA(patch, "apple");
11671 lstrcpyA(transforms, "banana");
11672 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11673 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11674 ok(!lstrcmpA(patch, patchcode),
11675 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11676 ok(!lstrcmpA(transforms, "whatever"),
11677 "Expected \"whatever\", got \"%s\"\n", transforms);
11678 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11680 /* now duplicate some of the tests for the W version */
11682 /* pcchTransformsBuf is too small */
11683 size = 6;
11684 MultiByteToWideChar( CP_ACP, 0, prodcode, -1, prodcodeW, MAX_PATH );
11685 MultiByteToWideChar( CP_ACP, 0, "apple", -1, patchW, MAX_PATH );
11686 MultiByteToWideChar( CP_ACP, 0, "banana", -1, transformsW, MAX_PATH );
11687 r = MsiEnumPatchesW(prodcodeW, 0, patchW, transformsW, &size);
11688 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11689 WideCharToMultiByte( CP_ACP, 0, patchW, -1, patch, MAX_PATH, NULL, NULL );
11690 WideCharToMultiByte( CP_ACP, 0, transformsW, -1, transforms, MAX_PATH, NULL, NULL );
11691 ok(!lstrcmpA(patch, patchcode),
11692 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11693 ok(!lstrcmpA(transforms, "whate") ||
11694 broken(!lstrcmpA(transforms, "banana")), /* Windows Installer < 3.0 */
11695 "Expected \"whate\", got \"%s\"\n", transforms);
11696 ok(size == 8, "Expected 8, got %d\n", size);
11698 /* patch code value exists */
11699 size = MAX_PATH;
11700 MultiByteToWideChar( CP_ACP, 0, "apple", -1, patchW, MAX_PATH );
11701 MultiByteToWideChar( CP_ACP, 0, "banana", -1, transformsW, MAX_PATH );
11702 r = MsiEnumPatchesW(prodcodeW, 0, patchW, transformsW, &size);
11703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11704 WideCharToMultiByte( CP_ACP, 0, patchW, -1, patch, MAX_PATH, NULL, NULL );
11705 WideCharToMultiByte( CP_ACP, 0, transformsW, -1, transforms, MAX_PATH, NULL, NULL );
11706 ok(!lstrcmpA(patch, patchcode),
11707 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11708 ok(!lstrcmpA(transforms, "whatever"),
11709 "Expected \"whatever\", got \"%s\"\n", transforms);
11710 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11712 RegDeleteValueA(patches, patch_squashed);
11713 RegDeleteValueA(patches, "Patches");
11714 delete_key(patches, "", access & KEY_WOW64_64KEY);
11715 RegCloseKey(patches);
11716 RegDeleteValueA(hpatch, "State");
11717 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
11718 RegCloseKey(hpatch);
11719 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
11720 RegCloseKey(udpatch);
11721 delete_key(udprod, "", access & KEY_WOW64_64KEY);
11722 RegCloseKey(udprod);
11723 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
11724 RegCloseKey(prodkey);
11725 LocalFree(usersid);
11728 static void test_MsiGetPatchInfoEx(void)
11730 CHAR keypath[MAX_PATH], val[MAX_PATH];
11731 CHAR patchcode[MAX_PATH], patch_squashed[MAX_PATH];
11732 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
11733 HKEY prodkey, patches, udprod, props;
11734 HKEY hpatch, udpatch, prodpatches;
11735 LPSTR usersid;
11736 DWORD size;
11737 LONG res;
11738 UINT r;
11739 REGSAM access = KEY_ALL_ACCESS;
11741 if (!pMsiGetPatchInfoExA)
11743 win_skip("MsiGetPatchInfoEx not implemented\n");
11744 return;
11747 create_test_guid(prodcode, prod_squashed);
11748 create_test_guid(patchcode, patch_squashed);
11749 usersid = get_user_sid();
11751 if (is_wow64)
11752 access |= KEY_WOW64_64KEY;
11754 /* NULL szPatchCode */
11755 lstrcpyA(val, "apple");
11756 size = MAX_PATH;
11757 r = pMsiGetPatchInfoExA(NULL, prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED,
11758 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11759 ok(r == ERROR_INVALID_PARAMETER,
11760 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11761 ok(!lstrcmpA(val, "apple"),
11762 "Expected val to be unchanged, got \"%s\"\n", val);
11763 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11765 /* empty szPatchCode */
11766 size = MAX_PATH;
11767 lstrcpyA(val, "apple");
11768 r = pMsiGetPatchInfoExA("", prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED,
11769 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11770 ok(r == ERROR_INVALID_PARAMETER,
11771 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11772 ok(!lstrcmpA(val, "apple"),
11773 "Expected val to be unchanged, got \"%s\"\n", val);
11774 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11776 /* garbage szPatchCode */
11777 size = MAX_PATH;
11778 lstrcpyA(val, "apple");
11779 r = pMsiGetPatchInfoExA("garbage", prodcode, NULL,
11780 MSIINSTALLCONTEXT_USERMANAGED,
11781 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11782 ok(r == ERROR_INVALID_PARAMETER,
11783 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11784 ok(!lstrcmpA(val, "apple"),
11785 "Expected val to be unchanged, got \"%s\"\n", val);
11786 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11788 /* guid without brackets */
11789 size = MAX_PATH;
11790 lstrcpyA(val, "apple");
11791 r = pMsiGetPatchInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", prodcode,
11792 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11793 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11794 ok(r == ERROR_INVALID_PARAMETER,
11795 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11796 ok(!lstrcmpA(val, "apple"),
11797 "Expected val to be unchanged, got \"%s\"\n", val);
11798 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11800 /* guid with brackets */
11801 size = MAX_PATH;
11802 lstrcpyA(val, "apple");
11803 r = pMsiGetPatchInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", prodcode,
11804 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11805 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11806 ok(r == ERROR_UNKNOWN_PRODUCT,
11807 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11808 ok(!lstrcmpA(val, "apple"),
11809 "Expected val to be unchanged, got \"%s\"\n", val);
11810 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11812 /* same length as guid, but random */
11813 size = MAX_PATH;
11814 lstrcpyA(val, "apple");
11815 r = pMsiGetPatchInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", prodcode,
11816 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11817 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11818 ok(r == ERROR_INVALID_PARAMETER,
11819 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11820 ok(!lstrcmpA(val, "apple"),
11821 "Expected val to be unchanged, got \"%s\"\n", val);
11822 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11824 /* NULL szProductCode */
11825 lstrcpyA(val, "apple");
11826 size = MAX_PATH;
11827 r = pMsiGetPatchInfoExA(patchcode, NULL, NULL, MSIINSTALLCONTEXT_USERMANAGED,
11828 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11829 ok(r == ERROR_INVALID_PARAMETER,
11830 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11831 ok(!lstrcmpA(val, "apple"),
11832 "Expected val to be unchanged, got \"%s\"\n", val);
11833 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11835 /* empty szProductCode */
11836 size = MAX_PATH;
11837 lstrcpyA(val, "apple");
11838 r = pMsiGetPatchInfoExA(patchcode, "", NULL, MSIINSTALLCONTEXT_USERMANAGED,
11839 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11840 ok(r == ERROR_INVALID_PARAMETER,
11841 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11842 ok(!lstrcmpA(val, "apple"),
11843 "Expected val to be unchanged, got \"%s\"\n", val);
11844 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11846 /* garbage szProductCode */
11847 size = MAX_PATH;
11848 lstrcpyA(val, "apple");
11849 r = pMsiGetPatchInfoExA(patchcode, "garbage", NULL,
11850 MSIINSTALLCONTEXT_USERMANAGED,
11851 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11852 ok(r == ERROR_INVALID_PARAMETER,
11853 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11854 ok(!lstrcmpA(val, "apple"),
11855 "Expected val to be unchanged, got \"%s\"\n", val);
11856 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11858 /* guid without brackets */
11859 size = MAX_PATH;
11860 lstrcpyA(val, "apple");
11861 r = pMsiGetPatchInfoExA(patchcode, "6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
11862 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11863 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11864 ok(r == ERROR_INVALID_PARAMETER,
11865 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11866 ok(!lstrcmpA(val, "apple"),
11867 "Expected val to be unchanged, got \"%s\"\n", val);
11868 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11870 /* guid with brackets */
11871 size = MAX_PATH;
11872 lstrcpyA(val, "apple");
11873 r = pMsiGetPatchInfoExA(patchcode, "{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
11874 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11875 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11876 ok(r == ERROR_UNKNOWN_PRODUCT,
11877 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11878 ok(!lstrcmpA(val, "apple"),
11879 "Expected val to be unchanged, got \"%s\"\n", val);
11880 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11882 /* same length as guid, but random */
11883 size = MAX_PATH;
11884 lstrcpyA(val, "apple");
11885 r = pMsiGetPatchInfoExA(patchcode, "A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
11886 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11887 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11888 ok(r == ERROR_INVALID_PARAMETER,
11889 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11890 ok(!lstrcmpA(val, "apple"),
11891 "Expected val to be unchanged, got \"%s\"\n", val);
11892 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11894 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERMANAGED */
11895 size = MAX_PATH;
11896 lstrcpyA(val, "apple");
11897 r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
11898 MSIINSTALLCONTEXT_USERMANAGED,
11899 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11900 ok(r == ERROR_INVALID_PARAMETER,
11901 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11902 ok(!lstrcmpA(val, "apple"),
11903 "Expected val to be unchanged, got \"%s\"\n", val);
11904 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11906 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERUNMANAGED */
11907 size = MAX_PATH;
11908 lstrcpyA(val, "apple");
11909 r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
11910 MSIINSTALLCONTEXT_USERUNMANAGED,
11911 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11912 ok(r == ERROR_INVALID_PARAMETER,
11913 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11914 ok(!lstrcmpA(val, "apple"),
11915 "Expected val to be unchanged, got \"%s\"\n", val);
11916 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11918 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_MACHINE */
11919 size = MAX_PATH;
11920 lstrcpyA(val, "apple");
11921 r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
11922 MSIINSTALLCONTEXT_MACHINE,
11923 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11924 ok(r == ERROR_INVALID_PARAMETER,
11925 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11926 ok(!lstrcmpA(val, "apple"),
11927 "Expected val to be unchanged, got \"%s\"\n", val);
11928 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11930 /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
11931 size = MAX_PATH;
11932 lstrcpyA(val, "apple");
11933 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
11934 MSIINSTALLCONTEXT_MACHINE,
11935 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11936 ok(r == ERROR_INVALID_PARAMETER,
11937 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11938 ok(!lstrcmpA(val, "apple"),
11939 "Expected val to be unchanged, got \"%s\"\n", val);
11940 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11942 /* dwContext is out of range */
11943 size = MAX_PATH;
11944 lstrcpyA(val, "apple");
11945 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
11946 MSIINSTALLCONTEXT_NONE,
11947 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11948 ok(r == ERROR_INVALID_PARAMETER,
11949 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11950 ok(!lstrcmpA(val, "apple"),
11951 "Expected val to be unchanged, got \"%s\"\n", val);
11952 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11954 /* dwContext is out of range */
11955 size = MAX_PATH;
11956 lstrcpyA(val, "apple");
11957 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
11958 MSIINSTALLCONTEXT_ALL,
11959 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11960 ok(r == ERROR_INVALID_PARAMETER,
11961 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11962 ok(!lstrcmpA(val, "apple"),
11963 "Expected val to be unchanged, got \"%s\"\n", val);
11964 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11966 /* dwContext is invalid */
11967 size = MAX_PATH;
11968 lstrcpyA(val, "apple");
11969 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid, 3,
11970 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11971 ok(r == ERROR_INVALID_PARAMETER,
11972 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11973 ok(!lstrcmpA(val, "apple"),
11974 "Expected val to be unchanged, got \"%s\"\n", val);
11975 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11977 /* MSIINSTALLCONTEXT_USERMANAGED */
11979 size = MAX_PATH;
11980 lstrcpyA(val, "apple");
11981 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
11982 MSIINSTALLCONTEXT_USERMANAGED,
11983 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11984 ok(r == ERROR_UNKNOWN_PRODUCT,
11985 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11986 ok(!lstrcmpA(val, "apple"),
11987 "Expected val to be unchanged, got \"%s\"\n", val);
11988 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11990 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11991 lstrcatA(keypath, usersid);
11992 lstrcatA(keypath, "\\Products\\");
11993 lstrcatA(keypath, prod_squashed);
11995 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
11996 if (res == ERROR_ACCESS_DENIED)
11998 skip("Not enough rights to perform tests\n");
11999 LocalFree(usersid);
12000 return;
12002 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12004 /* local UserData product key exists */
12005 size = MAX_PATH;
12006 lstrcpyA(val, "apple");
12007 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12008 MSIINSTALLCONTEXT_USERMANAGED,
12009 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12010 ok(r == ERROR_UNKNOWN_PRODUCT,
12011 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12012 ok(!lstrcmpA(val, "apple"),
12013 "Expected val to be unchanged, got \"%s\"\n", val);
12014 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12016 res = RegCreateKeyExA(udprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12017 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12019 /* InstallProperties key exists */
12020 size = MAX_PATH;
12021 lstrcpyA(val, "apple");
12022 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12023 MSIINSTALLCONTEXT_USERMANAGED,
12024 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12025 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12026 ok(!lstrcmpA(val, "apple"),
12027 "Expected val to be unchanged, got \"%s\"\n", val);
12028 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12030 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
12031 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12033 /* Patches key exists */
12034 size = MAX_PATH;
12035 lstrcpyA(val, "apple");
12036 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12037 MSIINSTALLCONTEXT_USERMANAGED,
12038 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12039 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCHA, got %d\n", r);
12040 ok(!lstrcmpA(val, "apple"),
12041 "Expected val to be unchanged, got \"%s\"\n", val);
12042 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12044 res = RegCreateKeyExA(patches, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
12045 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12047 /* Patches key exists */
12048 size = MAX_PATH;
12049 lstrcpyA(val, "apple");
12050 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12051 MSIINSTALLCONTEXT_USERMANAGED,
12052 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12053 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12054 ok(!lstrcmpA(val, "apple"),
12055 "Expected val to be unchanged, got \"%s\"\n", val);
12056 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12058 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
12059 lstrcatA(keypath, usersid);
12060 lstrcatA(keypath, "\\Installer\\Products\\");
12061 lstrcatA(keypath, prod_squashed);
12063 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12064 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12066 /* managed product key exists */
12067 size = MAX_PATH;
12068 lstrcpyA(val, "apple");
12069 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12070 MSIINSTALLCONTEXT_USERMANAGED,
12071 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12072 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12073 ok(!lstrcmpA(val, "apple"),
12074 "Expected val to be unchanged, got \"%s\"\n", val);
12075 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12077 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &prodpatches, NULL);
12078 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12080 /* Patches key exists */
12081 size = MAX_PATH;
12082 lstrcpyA(val, "apple");
12083 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12084 MSIINSTALLCONTEXT_USERMANAGED,
12085 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12086 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12087 ok(!lstrcmpA(val, "apple"),
12088 "Expected val to be unchanged, got \"%s\"\n", val);
12089 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12091 res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
12092 (const BYTE *)"transforms", 11);
12093 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12095 /* specific patch value exists */
12096 size = MAX_PATH;
12097 lstrcpyA(val, "apple");
12098 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12099 MSIINSTALLCONTEXT_USERMANAGED,
12100 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12101 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12102 ok(!lstrcmpA(val, "apple"),
12103 "Expected val to be unchanged, got \"%s\"\n", val);
12104 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12106 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12107 lstrcatA(keypath, usersid);
12108 lstrcatA(keypath, "\\Patches\\");
12109 lstrcatA(keypath, patch_squashed);
12111 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udpatch, NULL);
12112 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12114 /* UserData Patches key exists */
12115 size = MAX_PATH;
12116 lstrcpyA(val, "apple");
12117 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12118 MSIINSTALLCONTEXT_USERMANAGED,
12119 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12120 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12121 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12122 ok(size == 0, "Expected 0, got %d\n", size);
12124 res = RegSetValueExA(udpatch, "ManagedLocalPackage", 0, REG_SZ,
12125 (const BYTE *)"pack", 5);
12126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12128 /* ManagedLocalPatch value exists */
12129 size = MAX_PATH;
12130 lstrcpyA(val, "apple");
12131 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12132 MSIINSTALLCONTEXT_USERMANAGED,
12133 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12134 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12135 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12136 ok(size == 4, "Expected 4, got %d\n", size);
12138 size = MAX_PATH;
12139 lstrcpyA(val, "apple");
12140 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12141 MSIINSTALLCONTEXT_USERMANAGED,
12142 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12144 ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
12145 ok(size == 10, "Expected 10, got %d\n", size);
12147 res = RegSetValueExA(hpatch, "Installed", 0, REG_SZ,
12148 (const BYTE *)"mydate", 7);
12149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12151 /* Installed value exists */
12152 size = MAX_PATH;
12153 lstrcpyA(val, "apple");
12154 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12155 MSIINSTALLCONTEXT_USERMANAGED,
12156 INSTALLPROPERTY_INSTALLDATEA, val, &size);
12157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12158 ok(!lstrcmpA(val, "mydate"), "Expected \"mydate\", got \"%s\"\n", val);
12159 ok(size == 6, "Expected 6, got %d\n", size);
12161 res = RegSetValueExA(hpatch, "Uninstallable", 0, REG_SZ,
12162 (const BYTE *)"yes", 4);
12163 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12165 /* Uninstallable value exists */
12166 size = MAX_PATH;
12167 lstrcpyA(val, "apple");
12168 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12169 MSIINSTALLCONTEXT_USERMANAGED,
12170 INSTALLPROPERTY_UNINSTALLABLEA, val, &size);
12171 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12172 ok(!lstrcmpA(val, "yes"), "Expected \"yes\", got \"%s\"\n", val);
12173 ok(size == 3, "Expected 3, got %d\n", size);
12175 res = RegSetValueExA(hpatch, "State", 0, REG_SZ,
12176 (const BYTE *)"good", 5);
12177 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12179 /* State value exists */
12180 size = MAX_PATH;
12181 lstrcpyA(val, "apple");
12182 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12183 MSIINSTALLCONTEXT_USERMANAGED,
12184 INSTALLPROPERTY_PATCHSTATEA, val, &size);
12185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12186 ok(!lstrcmpA(val, "good"), "Expected \"good\", got \"%s\"\n", val);
12187 ok(size == 4, "Expected 4, got %d\n", size);
12189 size = 1;
12190 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
12191 (const BYTE *)&size, sizeof(DWORD));
12192 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12194 /* State value exists */
12195 size = MAX_PATH;
12196 lstrcpyA(val, "apple");
12197 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12198 MSIINSTALLCONTEXT_USERMANAGED,
12199 INSTALLPROPERTY_PATCHSTATEA, val, &size);
12200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12201 todo_wine ok(!lstrcmpA(val, "1"), "Expected \"1\", got \"%s\"\n", val);
12202 ok(size == 1, "Expected 1, got %d\n", size);
12204 res = RegSetValueExA(hpatch, "DisplayName", 0, REG_SZ,
12205 (const BYTE *)"display", 8);
12206 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12208 /* DisplayName value exists */
12209 size = MAX_PATH;
12210 lstrcpyA(val, "apple");
12211 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12212 MSIINSTALLCONTEXT_USERMANAGED,
12213 INSTALLPROPERTY_DISPLAYNAMEA, val, &size);
12214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12215 ok(!lstrcmpA(val, "display"), "Expected \"display\", got \"%s\"\n", val);
12216 ok(size == 7, "Expected 7, got %d\n", size);
12218 res = RegSetValueExA(hpatch, "MoreInfoURL", 0, REG_SZ,
12219 (const BYTE *)"moreinfo", 9);
12220 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12222 /* MoreInfoURL value exists */
12223 size = MAX_PATH;
12224 lstrcpyA(val, "apple");
12225 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12226 MSIINSTALLCONTEXT_USERMANAGED,
12227 INSTALLPROPERTY_MOREINFOURLA, val, &size);
12228 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12229 ok(!lstrcmpA(val, "moreinfo"), "Expected \"moreinfo\", got \"%s\"\n", val);
12230 ok(size == 8, "Expected 8, got %d\n", size);
12232 /* szProperty is invalid */
12233 size = MAX_PATH;
12234 lstrcpyA(val, "apple");
12235 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12236 MSIINSTALLCONTEXT_USERMANAGED,
12237 "IDontExist", val, &size);
12238 ok(r == ERROR_UNKNOWN_PROPERTY,
12239 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
12240 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12241 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12243 /* lpValue is NULL, while pcchValue is non-NULL */
12244 size = MAX_PATH;
12245 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12246 MSIINSTALLCONTEXT_USERMANAGED,
12247 INSTALLPROPERTY_MOREINFOURLA, NULL, &size);
12248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12249 ok(size == 16, "Expected 16, got %d\n", size);
12251 /* pcchValue is NULL, while lpValue is non-NULL */
12252 lstrcpyA(val, "apple");
12253 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12254 MSIINSTALLCONTEXT_USERMANAGED,
12255 INSTALLPROPERTY_MOREINFOURLA, val, NULL);
12256 ok(r == ERROR_INVALID_PARAMETER,
12257 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12258 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12260 /* both lpValue and pcchValue are NULL */
12261 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12262 MSIINSTALLCONTEXT_USERMANAGED,
12263 INSTALLPROPERTY_MOREINFOURLA, NULL, NULL);
12264 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12266 /* pcchValue doesn't have enough room for NULL terminator */
12267 size = 8;
12268 lstrcpyA(val, "apple");
12269 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12270 MSIINSTALLCONTEXT_USERMANAGED,
12271 INSTALLPROPERTY_MOREINFOURLA, val, &size);
12272 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12273 ok(!lstrcmpA(val, "moreinf"),
12274 "Expected \"moreinf\", got \"%s\"\n", val);
12275 ok(size == 16, "Expected 16, got %d\n", size);
12277 /* pcchValue has exactly enough room for NULL terminator */
12278 size = 9;
12279 lstrcpyA(val, "apple");
12280 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12281 MSIINSTALLCONTEXT_USERMANAGED,
12282 INSTALLPROPERTY_MOREINFOURLA, val, &size);
12283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12284 ok(!lstrcmpA(val, "moreinfo"),
12285 "Expected \"moreinfo\", got \"%s\"\n", val);
12286 ok(size == 8, "Expected 8, got %d\n", size);
12288 /* pcchValue is too small, lpValue is NULL */
12289 size = 0;
12290 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12291 MSIINSTALLCONTEXT_USERMANAGED,
12292 INSTALLPROPERTY_MOREINFOURLA, NULL, &size);
12293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12294 ok(size == 16, "Expected 16, got %d\n", size);
12296 RegDeleteValueA(prodpatches, patch_squashed);
12297 delete_key(prodpatches, "", access & KEY_WOW64_64KEY);
12298 RegCloseKey(prodpatches);
12299 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
12300 RegCloseKey(prodkey);
12302 /* UserData is sufficient for all properties
12303 * except INSTALLPROPERTY_TRANSFORMS
12305 size = MAX_PATH;
12306 lstrcpyA(val, "apple");
12307 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12308 MSIINSTALLCONTEXT_USERMANAGED,
12309 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12310 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12311 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12312 ok(size == 4, "Expected 4, got %d\n", size);
12314 /* UserData is sufficient for all properties
12315 * except INSTALLPROPERTY_TRANSFORMS
12317 size = MAX_PATH;
12318 lstrcpyA(val, "apple");
12319 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12320 MSIINSTALLCONTEXT_USERMANAGED,
12321 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12322 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12323 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12324 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12326 RegDeleteValueA(hpatch, "MoreInfoURL");
12327 RegDeleteValueA(hpatch, "Display");
12328 RegDeleteValueA(hpatch, "State");
12329 RegDeleteValueA(hpatch, "Uninstallable");
12330 RegDeleteValueA(hpatch, "Installed");
12331 RegDeleteValueA(udpatch, "ManagedLocalPackage");
12332 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
12333 RegCloseKey(udpatch);
12334 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
12335 RegCloseKey(hpatch);
12336 delete_key(patches, "", access & KEY_WOW64_64KEY);
12337 RegCloseKey(patches);
12338 delete_key(props, "", access & KEY_WOW64_64KEY);
12339 RegCloseKey(props);
12340 delete_key(udprod, "", access & KEY_WOW64_64KEY);
12341 RegCloseKey(udprod);
12343 /* MSIINSTALLCONTEXT_USERUNMANAGED */
12345 size = MAX_PATH;
12346 lstrcpyA(val, "apple");
12347 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12348 MSIINSTALLCONTEXT_USERUNMANAGED,
12349 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12350 ok(r == ERROR_UNKNOWN_PRODUCT,
12351 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12352 ok(!lstrcmpA(val, "apple"),
12353 "Expected val to be unchanged, got \"%s\"\n", val);
12354 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12356 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12357 lstrcatA(keypath, usersid);
12358 lstrcatA(keypath, "\\Products\\");
12359 lstrcatA(keypath, prod_squashed);
12361 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
12362 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12364 /* local UserData product key exists */
12365 size = MAX_PATH;
12366 lstrcpyA(val, "apple");
12367 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12368 MSIINSTALLCONTEXT_USERUNMANAGED,
12369 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12370 ok(r == ERROR_UNKNOWN_PRODUCT,
12371 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12372 ok(!lstrcmpA(val, "apple"),
12373 "Expected val to be unchanged, got \"%s\"\n", val);
12374 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12376 res = RegCreateKeyExA(udprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12377 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12379 /* InstallProperties key exists */
12380 size = MAX_PATH;
12381 lstrcpyA(val, "apple");
12382 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12383 MSIINSTALLCONTEXT_USERUNMANAGED,
12384 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12385 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12386 ok(!lstrcmpA(val, "apple"),
12387 "Expected val to be unchanged, got \"%s\"\n", val);
12388 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12390 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
12391 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12393 /* Patches key exists */
12394 size = MAX_PATH;
12395 lstrcpyA(val, "apple");
12396 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12397 MSIINSTALLCONTEXT_USERUNMANAGED,
12398 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12399 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12400 ok(!lstrcmpA(val, "apple"),
12401 "Expected val to be unchanged, got \"%s\"\n", val);
12402 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12404 res = RegCreateKeyExA(patches, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
12405 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12407 /* Patches key exists */
12408 size = MAX_PATH;
12409 lstrcpyA(val, "apple");
12410 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12411 MSIINSTALLCONTEXT_USERUNMANAGED,
12412 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12413 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12414 ok(!lstrcmpA(val, "apple"),
12415 "Expected val to be unchanged, got \"%s\"\n", val);
12416 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12418 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
12419 lstrcatA(keypath, prod_squashed);
12421 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
12422 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12424 /* current user product key exists */
12425 size = MAX_PATH;
12426 lstrcpyA(val, "apple");
12427 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12428 MSIINSTALLCONTEXT_USERUNMANAGED,
12429 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12430 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12431 ok(!lstrcmpA(val, "apple"),
12432 "Expected val to be unchanged, got \"%s\"\n", val);
12433 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12435 res = RegCreateKeyA(prodkey, "Patches", &prodpatches);
12436 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12438 /* Patches key exists */
12439 size = MAX_PATH;
12440 lstrcpyA(val, "apple");
12441 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12442 MSIINSTALLCONTEXT_USERUNMANAGED,
12443 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12444 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12445 ok(!lstrcmpA(val, "apple"),
12446 "Expected val to be unchanged, got \"%s\"\n", val);
12447 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12449 res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
12450 (const BYTE *)"transforms", 11);
12451 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12453 /* specific patch value exists */
12454 size = MAX_PATH;
12455 lstrcpyA(val, "apple");
12456 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12457 MSIINSTALLCONTEXT_USERUNMANAGED,
12458 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12459 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12460 ok(!lstrcmpA(val, "apple"),
12461 "Expected val to be unchanged, got \"%s\"\n", val);
12462 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12464 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12465 lstrcatA(keypath, usersid);
12466 lstrcatA(keypath, "\\Patches\\");
12467 lstrcatA(keypath, patch_squashed);
12469 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udpatch, NULL);
12470 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12472 /* UserData Patches key exists */
12473 size = MAX_PATH;
12474 lstrcpyA(val, "apple");
12475 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12476 MSIINSTALLCONTEXT_USERUNMANAGED,
12477 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12478 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12479 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12480 ok(size == 0, "Expected 0, got %d\n", size);
12482 res = RegSetValueExA(udpatch, "LocalPackage", 0, REG_SZ,
12483 (const BYTE *)"pack", 5);
12484 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12486 /* LocalPatch value exists */
12487 size = MAX_PATH;
12488 lstrcpyA(val, "apple");
12489 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12490 MSIINSTALLCONTEXT_USERUNMANAGED,
12491 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12492 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12493 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12494 ok(size == 4, "Expected 4, got %d\n", size);
12496 size = MAX_PATH;
12497 lstrcpyA(val, "apple");
12498 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12499 MSIINSTALLCONTEXT_USERUNMANAGED,
12500 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12501 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12502 ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
12503 ok(size == 10, "Expected 10, got %d\n", size);
12505 RegDeleteValueA(prodpatches, patch_squashed);
12506 delete_key(prodpatches, "", access & KEY_WOW64_64KEY);
12507 RegCloseKey(prodpatches);
12508 RegDeleteKeyA(prodkey, "");
12509 RegCloseKey(prodkey);
12511 /* UserData is sufficient for all properties
12512 * except INSTALLPROPERTY_TRANSFORMS
12514 size = MAX_PATH;
12515 lstrcpyA(val, "apple");
12516 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12517 MSIINSTALLCONTEXT_USERUNMANAGED,
12518 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12519 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12520 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12521 ok(size == 4, "Expected 4, got %d\n", size);
12523 /* UserData is sufficient for all properties
12524 * except INSTALLPROPERTY_TRANSFORMS
12526 size = MAX_PATH;
12527 lstrcpyA(val, "apple");
12528 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12529 MSIINSTALLCONTEXT_USERUNMANAGED,
12530 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12531 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12532 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12533 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12535 RegDeleteValueA(udpatch, "LocalPackage");
12536 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
12537 RegCloseKey(udpatch);
12538 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
12539 RegCloseKey(hpatch);
12540 delete_key(patches, "", access & KEY_WOW64_64KEY);
12541 RegCloseKey(patches);
12542 delete_key(props, "", access & KEY_WOW64_64KEY);
12543 RegCloseKey(props);
12544 delete_key(udprod, "", access & KEY_WOW64_64KEY);
12545 RegCloseKey(udprod);
12547 /* MSIINSTALLCONTEXT_MACHINE */
12549 size = MAX_PATH;
12550 lstrcpyA(val, "apple");
12551 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12552 MSIINSTALLCONTEXT_MACHINE,
12553 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12554 ok(r == ERROR_UNKNOWN_PRODUCT,
12555 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12556 ok(!lstrcmpA(val, "apple"),
12557 "Expected val to be unchanged, got \"%s\"\n", val);
12558 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12560 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12561 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\");
12562 lstrcatA(keypath, prod_squashed);
12564 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
12565 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12567 /* local UserData product key exists */
12568 size = MAX_PATH;
12569 lstrcpyA(val, "apple");
12570 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12571 MSIINSTALLCONTEXT_MACHINE,
12572 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12573 ok(r == ERROR_UNKNOWN_PRODUCT,
12574 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12575 ok(!lstrcmpA(val, "apple"),
12576 "Expected val to be unchanged, got \"%s\"\n", val);
12577 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12579 res = RegCreateKeyExA(udprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12580 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12582 /* InstallProperties key exists */
12583 size = MAX_PATH;
12584 lstrcpyA(val, "apple");
12585 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12586 MSIINSTALLCONTEXT_MACHINE,
12587 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12588 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12589 ok(!lstrcmpA(val, "apple"),
12590 "Expected val to be unchanged, got \"%s\"\n", val);
12591 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12593 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
12594 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12596 /* Patches key exists */
12597 size = MAX_PATH;
12598 lstrcpyA(val, "apple");
12599 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12600 MSIINSTALLCONTEXT_MACHINE,
12601 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12602 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12603 ok(!lstrcmpA(val, "apple"),
12604 "Expected val to be unchanged, got \"%s\"\n", val);
12605 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12607 res = RegCreateKeyExA(patches, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
12608 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12610 /* Patches key exists */
12611 size = MAX_PATH;
12612 lstrcpyA(val, "apple");
12613 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12614 MSIINSTALLCONTEXT_MACHINE,
12615 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12616 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12617 ok(!lstrcmpA(val, "apple"),
12618 "Expected val to be unchanged, got \"%s\"\n", val);
12619 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12621 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12622 lstrcatA(keypath, prod_squashed);
12624 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12625 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12627 /* local product key exists */
12628 size = MAX_PATH;
12629 lstrcpyA(val, "apple");
12630 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12631 MSIINSTALLCONTEXT_MACHINE,
12632 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12633 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12634 ok(!lstrcmpA(val, "apple"),
12635 "Expected val to be unchanged, got \"%s\"\n", val);
12636 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12638 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &prodpatches, NULL);
12639 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12641 /* Patches key exists */
12642 size = MAX_PATH;
12643 lstrcpyA(val, "apple");
12644 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12645 MSIINSTALLCONTEXT_MACHINE,
12646 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12647 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12648 ok(!lstrcmpA(val, "apple"),
12649 "Expected val to be unchanged, got \"%s\"\n", val);
12650 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12652 res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
12653 (const BYTE *)"transforms", 11);
12654 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12656 /* specific patch value exists */
12657 size = MAX_PATH;
12658 lstrcpyA(val, "apple");
12659 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12660 MSIINSTALLCONTEXT_MACHINE,
12661 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12662 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12663 ok(!lstrcmpA(val, "apple"),
12664 "Expected val to be unchanged, got \"%s\"\n", val);
12665 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12667 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12668 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\");
12669 lstrcatA(keypath, patch_squashed);
12671 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udpatch, NULL);
12672 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12674 /* UserData Patches key exists */
12675 size = MAX_PATH;
12676 lstrcpyA(val, "apple");
12677 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12678 MSIINSTALLCONTEXT_MACHINE,
12679 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12680 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12681 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12682 ok(size == 0, "Expected 0, got %d\n", size);
12684 res = RegSetValueExA(udpatch, "LocalPackage", 0, REG_SZ,
12685 (const BYTE *)"pack", 5);
12686 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12688 /* LocalPatch value exists */
12689 size = MAX_PATH;
12690 lstrcpyA(val, "apple");
12691 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12692 MSIINSTALLCONTEXT_MACHINE,
12693 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12694 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12695 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12696 ok(size == 4, "Expected 4, got %d\n", size);
12698 size = MAX_PATH;
12699 lstrcpyA(val, "apple");
12700 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12701 MSIINSTALLCONTEXT_MACHINE,
12702 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12704 ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
12705 ok(size == 10, "Expected 10, got %d\n", size);
12707 RegDeleteValueA(prodpatches, patch_squashed);
12708 delete_key(prodpatches, "", access & KEY_WOW64_64KEY);
12709 RegCloseKey(prodpatches);
12710 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
12711 RegCloseKey(prodkey);
12713 /* UserData is sufficient for all properties
12714 * except INSTALLPROPERTY_TRANSFORMS
12716 size = MAX_PATH;
12717 lstrcpyA(val, "apple");
12718 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12719 MSIINSTALLCONTEXT_MACHINE,
12720 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12721 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12722 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12723 ok(size == 4, "Expected 4, got %d\n", size);
12725 /* UserData is sufficient for all properties
12726 * except INSTALLPROPERTY_TRANSFORMS
12728 size = MAX_PATH;
12729 lstrcpyA(val, "apple");
12730 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12731 MSIINSTALLCONTEXT_MACHINE,
12732 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12733 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12734 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12735 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12737 RegDeleteValueA(udpatch, "LocalPackage");
12738 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
12739 RegCloseKey(udpatch);
12740 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
12741 RegCloseKey(hpatch);
12742 delete_key(patches, "", access & KEY_WOW64_64KEY);
12743 RegCloseKey(patches);
12744 delete_key(props, "", access & KEY_WOW64_64KEY);
12745 RegCloseKey(props);
12746 delete_key(udprod, "", access & KEY_WOW64_64KEY);
12747 RegCloseKey(udprod);
12748 LocalFree(usersid);
12751 static void test_MsiGetPatchInfo(void)
12753 UINT r;
12754 char prod_code[MAX_PATH], prod_squashed[MAX_PATH], val[MAX_PATH];
12755 char patch_code[MAX_PATH], patch_squashed[MAX_PATH], keypath[MAX_PATH];
12756 WCHAR valW[MAX_PATH], patch_codeW[MAX_PATH];
12757 HKEY hkey_product, hkey_patch, hkey_patches, hkey_udprops, hkey_udproduct;
12758 HKEY hkey_udpatch, hkey_udpatches, hkey_udproductpatches, hkey_udproductpatch;
12759 DWORD size;
12760 LONG res;
12761 REGSAM access = KEY_ALL_ACCESS;
12763 create_test_guid(patch_code, patch_squashed);
12764 create_test_guid(prod_code, prod_squashed);
12765 MultiByteToWideChar(CP_ACP, 0, patch_code, -1, patch_codeW, MAX_PATH);
12767 if (is_wow64)
12768 access |= KEY_WOW64_64KEY;
12770 r = MsiGetPatchInfoA(NULL, NULL, NULL, NULL);
12771 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
12773 r = MsiGetPatchInfoA(patch_code, NULL, NULL, NULL);
12774 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
12776 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, NULL, NULL);
12777 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
12779 size = 0;
12780 r = MsiGetPatchInfoA(patch_code, NULL, NULL, &size);
12781 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
12783 r = MsiGetPatchInfoA(patch_code, "", NULL, &size);
12784 ok(r == ERROR_UNKNOWN_PROPERTY, "expected ERROR_UNKNOWN_PROPERTY, got %u\n", r);
12786 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12787 lstrcatA(keypath, prod_squashed);
12789 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_product, NULL);
12790 if (res == ERROR_ACCESS_DENIED)
12792 skip("Not enough rights to perform tests\n");
12793 return;
12795 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12797 /* product key exists */
12798 size = MAX_PATH;
12799 lstrcpyA(val, "apple");
12800 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12801 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12802 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val);
12803 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12805 res = RegCreateKeyExA(hkey_product, "Patches", 0, NULL, 0, access, NULL, &hkey_patches, NULL);
12806 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12808 /* patches key exists */
12809 size = MAX_PATH;
12810 lstrcpyA(val, "apple");
12811 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12812 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12813 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12814 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12816 res = RegCreateKeyExA(hkey_patches, patch_squashed, 0, NULL, 0, access, NULL, &hkey_patch, NULL);
12817 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12819 /* patch key exists */
12820 size = MAX_PATH;
12821 lstrcpyA(val, "apple");
12822 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12823 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12824 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12825 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12827 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12828 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\");
12829 lstrcatA(keypath, prod_squashed);
12831 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_udproduct, NULL);
12832 if (res == ERROR_ACCESS_DENIED)
12834 skip("Not enough rights to perform tests\n");
12835 goto done;
12837 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
12839 /* UserData product key exists */
12840 size = MAX_PATH;
12841 lstrcpyA(val, "apple");
12842 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12843 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12844 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12845 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12847 res = RegCreateKeyExA(hkey_udproduct, "InstallProperties", 0, NULL, 0, access, NULL, &hkey_udprops, NULL);
12848 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12850 /* InstallProperties key exists */
12851 size = MAX_PATH;
12852 lstrcpyA(val, "apple");
12853 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12854 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12855 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val);
12856 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12858 res = RegCreateKeyExA(hkey_udproduct, "Patches", 0, NULL, 0, access, NULL, &hkey_udpatches, NULL);
12859 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12861 /* UserData Patches key exists */
12862 size = MAX_PATH;
12863 lstrcpyA(val, "apple");
12864 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12865 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12866 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12867 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12869 res = RegCreateKeyExA(hkey_udproduct, "Patches", 0, NULL, 0, access, NULL, &hkey_udproductpatches, NULL);
12870 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12872 res = RegCreateKeyExA(hkey_udproductpatches, patch_squashed, 0, NULL, 0, access, NULL, &hkey_udproductpatch, NULL);
12873 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12875 /* UserData product patch key exists */
12876 size = MAX_PATH;
12877 lstrcpyA(val, "apple");
12878 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12879 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12880 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12881 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12883 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12884 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\");
12885 lstrcatA(keypath, patch_squashed);
12887 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_udpatch, NULL);
12888 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12890 res = RegSetValueExA(hkey_udpatch, "LocalPackage", 0, REG_SZ, (const BYTE *)"c:\\test.msp", 12);
12891 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12893 /* UserData Patch key exists */
12894 size = 0;
12895 lstrcpyA(val, "apple");
12896 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12897 ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r);
12898 ok(!lstrcmpA(val, "apple"), "expected \"apple\", got \"%s\"\n", val);
12899 ok(size == 11, "expected 11 got %u\n", size);
12901 size = MAX_PATH;
12902 lstrcpyA(val, "apple");
12903 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12904 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r);
12905 ok(!lstrcmpA(val, "c:\\test.msp"), "expected \"c:\\test.msp\", got \"%s\"\n", val);
12906 ok(size == 11, "expected 11 got %u\n", size);
12908 size = 0;
12909 valW[0] = 0;
12910 r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size);
12911 ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r);
12912 ok(!valW[0], "expected 0 got %u\n", valW[0]);
12913 ok(size == 11, "expected 11 got %u\n", size);
12915 size = MAX_PATH;
12916 valW[0] = 0;
12917 r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size);
12918 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r);
12919 ok(valW[0], "expected > 0 got %u\n", valW[0]);
12920 ok(size == 11, "expected 11 got %u\n", size);
12922 delete_key(hkey_udproductpatch, "", access & KEY_WOW64_64KEY);
12923 RegCloseKey(hkey_udproductpatch);
12924 delete_key(hkey_udproductpatches, "", access & KEY_WOW64_64KEY);
12925 RegCloseKey(hkey_udproductpatches);
12926 delete_key(hkey_udpatch, "", access & KEY_WOW64_64KEY);
12927 RegCloseKey(hkey_udpatch);
12928 delete_key(hkey_udpatches, "", access & KEY_WOW64_64KEY);
12929 RegCloseKey(hkey_udpatches);
12930 delete_key(hkey_udprops, "", access & KEY_WOW64_64KEY);
12931 RegCloseKey(hkey_udprops);
12932 delete_key(hkey_udproduct, "", access & KEY_WOW64_64KEY);
12933 RegCloseKey(hkey_udproduct);
12935 done:
12936 delete_key(hkey_patches, "", access & KEY_WOW64_64KEY);
12937 RegCloseKey(hkey_patches);
12938 delete_key(hkey_product, "", access & KEY_WOW64_64KEY);
12939 RegCloseKey(hkey_product);
12940 delete_key(hkey_patch, "", access & KEY_WOW64_64KEY);
12941 RegCloseKey(hkey_patch);
12944 static void test_MsiEnumProducts(void)
12946 UINT r;
12947 BOOL found1, found2, found3;
12948 DWORD index;
12949 char product1[39], product2[39], product3[39], guid[39];
12950 char product_squashed1[33], product_squashed2[33], product_squashed3[33];
12951 char keypath1[MAX_PATH], keypath2[MAX_PATH], keypath3[MAX_PATH];
12952 char *usersid;
12953 HKEY key1, key2, key3;
12954 REGSAM access = KEY_ALL_ACCESS;
12956 create_test_guid(product1, product_squashed1);
12957 create_test_guid(product2, product_squashed2);
12958 create_test_guid(product3, product_squashed3);
12959 usersid = get_user_sid();
12961 if (is_wow64)
12962 access |= KEY_WOW64_64KEY;
12964 strcpy(keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
12965 strcat(keypath2, usersid);
12966 strcat(keypath2, "\\Installer\\Products\\");
12967 strcat(keypath2, product_squashed2);
12969 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL);
12970 if (r == ERROR_ACCESS_DENIED)
12972 skip("Not enough rights to perform tests\n");
12973 LocalFree(usersid);
12974 return;
12976 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12978 strcpy(keypath1, "Software\\Classes\\Installer\\Products\\");
12979 strcat(keypath1, product_squashed1);
12981 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL);
12982 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12984 strcpy(keypath3, "Software\\Microsoft\\Installer\\Products\\");
12985 strcat(keypath3, product_squashed3);
12987 r = RegCreateKeyA(HKEY_CURRENT_USER, keypath3, &key3);
12988 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12990 index = 0;
12991 r = MsiEnumProductsA(index, guid);
12992 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
12994 r = MsiEnumProductsA(index, NULL);
12995 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
12997 index = 2;
12998 r = MsiEnumProductsA(index, guid);
12999 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
13001 index = 0;
13002 r = MsiEnumProductsA(index, guid);
13003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13005 found1 = found2 = found3 = FALSE;
13006 while ((r = MsiEnumProductsA(index, guid)) == ERROR_SUCCESS)
13008 if (!strcmp(product1, guid)) found1 = TRUE;
13009 if (!strcmp(product2, guid)) found2 = TRUE;
13010 if (!strcmp(product3, guid)) found3 = TRUE;
13011 index++;
13013 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r);
13014 ok(found1, "product1 not found\n");
13015 ok(found2, "product2 not found\n");
13016 ok(found3, "product3 not found\n");
13018 delete_key(key1, "", access & KEY_WOW64_64KEY);
13019 delete_key(key2, "", access & KEY_WOW64_64KEY);
13020 RegDeleteKeyA(key3, "");
13021 RegCloseKey(key1);
13022 RegCloseKey(key2);
13023 RegCloseKey(key3);
13024 LocalFree(usersid);
13027 static void test_MsiGetFileSignatureInformation(void)
13029 HRESULT hr;
13030 const CERT_CONTEXT *cert;
13031 DWORD len;
13033 hr = MsiGetFileSignatureInformationA( NULL, 0, NULL, NULL, NULL );
13034 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13036 hr = MsiGetFileSignatureInformationA( NULL, 0, NULL, NULL, &len );
13037 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13039 hr = MsiGetFileSignatureInformationA( NULL, 0, &cert, NULL, &len );
13040 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13042 hr = MsiGetFileSignatureInformationA( "", 0, NULL, NULL, NULL );
13043 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13045 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, NULL );
13046 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13048 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, &len );
13049 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13051 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, &cert, NULL, &len );
13052 todo_wine ok(hr == CRYPT_E_FILE_ERROR, "expected CRYPT_E_FILE_ERROR got 0x%08x\n", hr);
13054 create_file( "signature.bin", "signature", sizeof("signature") );
13056 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, NULL );
13057 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13059 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, &len );
13060 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13062 cert = (const CERT_CONTEXT *)0xdeadbeef;
13063 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, &cert, NULL, &len );
13064 todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_FUNCTION_FAILED), "got 0x%08x\n", hr);
13065 ok(cert == NULL, "got %p\n", cert);
13067 DeleteFileA( "signature.bin" );
13070 static void test_MsiEnumProductsEx(void)
13072 UINT r;
13073 DWORD len, index;
13074 MSIINSTALLCONTEXT context;
13075 char product0[39], product1[39], product2[39], product3[39], guid[39], sid[128];
13076 char product_squashed1[33], product_squashed2[33], product_squashed3[33];
13077 char keypath1[MAX_PATH], keypath2[MAX_PATH], keypath3[MAX_PATH];
13078 HKEY key1 = NULL, key2 = NULL, key3 = NULL;
13079 REGSAM access = KEY_ALL_ACCESS;
13080 char *usersid = get_user_sid();
13082 if (!pMsiEnumProductsExA)
13084 win_skip("MsiEnumProductsExA not implemented\n");
13085 return;
13088 create_test_guid( product0, NULL );
13089 create_test_guid( product1, product_squashed1 );
13090 create_test_guid( product2, product_squashed2 );
13091 create_test_guid( product3, product_squashed3 );
13093 if (is_wow64) access |= KEY_WOW64_64KEY;
13095 strcpy( keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\" );
13096 strcat( keypath2, usersid );
13097 strcat( keypath2, "\\Installer\\Products\\" );
13098 strcat( keypath2, product_squashed2 );
13100 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL );
13101 if (r == ERROR_ACCESS_DENIED)
13103 skip( "insufficient rights\n" );
13104 goto done;
13106 ok( r == ERROR_SUCCESS, "got %u\n", r );
13108 strcpy( keypath1, "Software\\Classes\\Installer\\Products\\" );
13109 strcat( keypath1, product_squashed1 );
13111 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL );
13112 ok( r == ERROR_SUCCESS, "got %u\n", r );
13114 strcpy( keypath3, usersid );
13115 strcat( keypath3, "\\Software\\Microsoft\\Installer\\Products\\" );
13116 strcat( keypath3, product_squashed3 );
13118 r = RegCreateKeyExA( HKEY_USERS, keypath3, 0, NULL, 0, access, NULL, &key3, NULL );
13119 ok( r == ERROR_SUCCESS, "got %u\n", r );
13121 r = pMsiEnumProductsExA( NULL, NULL, 0, 0, NULL, NULL, NULL, NULL );
13122 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13124 len = sizeof(sid);
13125 r = pMsiEnumProductsExA( NULL, NULL, 0, 0, NULL, NULL, NULL, &len );
13126 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13127 ok( len == sizeof(sid), "got %u\n", len );
13129 r = pMsiEnumProductsExA( NULL, NULL, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, NULL, NULL );
13130 ok( r == ERROR_SUCCESS, "got %u\n", r );
13132 sid[0] = 0;
13133 len = sizeof(sid);
13134 r = pMsiEnumProductsExA( product0, NULL, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, sid, &len );
13135 ok( r == ERROR_NO_MORE_ITEMS, "got %u\n", r );
13136 ok( len == sizeof(sid), "got %u\n", len );
13137 ok( !sid[0], "got %s\n", sid );
13139 sid[0] = 0;
13140 len = sizeof(sid);
13141 r = pMsiEnumProductsExA( product0, usersid, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, sid, &len );
13142 ok( r == ERROR_NO_MORE_ITEMS, "got %u\n", r );
13143 ok( len == sizeof(sid), "got %u\n", len );
13144 ok( !sid[0], "got %s\n", sid );
13146 sid[0] = 0;
13147 len = 0;
13148 r = pMsiEnumProductsExA( NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED, 0, NULL, NULL, sid, &len );
13149 ok( r == ERROR_MORE_DATA, "got %u\n", r );
13150 ok( len, "length unchanged\n" );
13151 ok( !sid[0], "got %s\n", sid );
13153 guid[0] = 0;
13154 context = 0xdeadbeef;
13155 sid[0] = 0;
13156 len = sizeof(sid);
13157 r = pMsiEnumProductsExA( NULL, NULL, MSIINSTALLCONTEXT_ALL, 0, guid, &context, sid, &len );
13158 ok( r == ERROR_SUCCESS, "got %u\n", r );
13159 ok( guid[0], "empty guid\n" );
13160 ok( context != 0xdeadbeef, "context unchanged\n" );
13161 ok( !len, "got %u\n", len );
13162 ok( !sid[0], "got %s\n", sid );
13164 guid[0] = 0;
13165 context = 0xdeadbeef;
13166 sid[0] = 0;
13167 len = sizeof(sid);
13168 r = pMsiEnumProductsExA( NULL, usersid, MSIINSTALLCONTEXT_ALL, 0, guid, &context, sid, &len );
13169 ok( r == ERROR_SUCCESS, "got %u\n", r );
13170 ok( guid[0], "empty guid\n" );
13171 ok( context != 0xdeadbeef, "context unchanged\n" );
13172 ok( !len, "got %u\n", len );
13173 ok( !sid[0], "got %s\n", sid );
13175 guid[0] = 0;
13176 context = 0xdeadbeef;
13177 sid[0] = 0;
13178 len = sizeof(sid);
13179 r = pMsiEnumProductsExA( NULL, "S-1-1-0", MSIINSTALLCONTEXT_ALL, 0, guid, &context, sid, &len );
13180 if (r == ERROR_ACCESS_DENIED)
13182 skip( "insufficient rights\n" );
13183 goto done;
13185 ok( r == ERROR_SUCCESS, "got %u\n", r );
13186 ok( guid[0], "empty guid\n" );
13187 ok( context != 0xdeadbeef, "context unchanged\n" );
13188 ok( !len, "got %u\n", len );
13189 ok( !sid[0], "got %s\n", sid );
13191 index = 0;
13192 guid[0] = 0;
13193 context = 0xdeadbeef;
13194 sid[0] = 0;
13195 len = sizeof(sid);
13196 while (!pMsiEnumProductsExA( NULL, "S-1-1-0", MSIINSTALLCONTEXT_ALL, index, guid, &context, sid, &len ))
13198 if (!strcmp( product1, guid ))
13200 ok( context == MSIINSTALLCONTEXT_MACHINE, "got %u\n", context );
13201 ok( !sid[0], "got \"%s\"\n", sid );
13202 ok( !len, "unexpected length %u\n", len );
13204 if (!strcmp( product2, guid ))
13206 ok( context == MSIINSTALLCONTEXT_USERMANAGED, "got %u\n", context );
13207 ok( sid[0], "empty sid\n" );
13208 ok( len == strlen(sid), "unexpected length %u\n", len );
13210 if (!strcmp( product3, guid ))
13212 ok( context == MSIINSTALLCONTEXT_USERUNMANAGED, "got %u\n", context );
13213 ok( sid[0], "empty sid\n" );
13214 ok( len == strlen(sid), "unexpected length %u\n", len );
13216 index++;
13217 guid[0] = 0;
13218 context = 0xdeadbeef;
13219 sid[0] = 0;
13220 len = sizeof(sid);
13223 done:
13224 delete_key( key1, "", access );
13225 delete_key( key2, "", access );
13226 delete_key( key3, "", access );
13227 RegCloseKey( key1 );
13228 RegCloseKey( key2 );
13229 RegCloseKey( key3 );
13230 LocalFree( usersid );
13233 static void test_MsiEnumComponents(void)
13235 UINT r;
13236 BOOL found1, found2;
13237 DWORD index;
13238 char comp1[39], comp2[39], guid[39];
13239 char comp_squashed1[33], comp_squashed2[33];
13240 char keypath1[MAX_PATH], keypath2[MAX_PATH];
13241 REGSAM access = KEY_ALL_ACCESS;
13242 char *usersid = get_user_sid();
13243 HKEY key1 = NULL, key2 = NULL;
13245 create_test_guid( comp1, comp_squashed1 );
13246 create_test_guid( comp2, comp_squashed2 );
13248 if (is_wow64) access |= KEY_WOW64_64KEY;
13250 strcpy( keypath1, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13251 strcat( keypath1, "S-1-5-18\\Components\\" );
13252 strcat( keypath1, comp_squashed1 );
13254 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL );
13255 if (r == ERROR_ACCESS_DENIED)
13257 skip( "insufficient rights\n" );
13258 goto done;
13260 ok( r == ERROR_SUCCESS, "got %u\n", r );
13262 strcpy( keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13263 strcat( keypath2, usersid );
13264 strcat( keypath2, "\\Components\\" );
13265 strcat( keypath2, comp_squashed2 );
13267 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL );
13268 if (r == ERROR_ACCESS_DENIED)
13270 skip( "insufficient rights\n" );
13271 goto done;
13274 r = MsiEnumComponentsA( 0, NULL );
13275 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13277 index = 0;
13278 guid[0] = 0;
13279 found1 = found2 = FALSE;
13280 while (!MsiEnumComponentsA( index, guid ))
13282 if (!strcmp( guid, comp1 )) found1 = TRUE;
13283 if (!strcmp( guid, comp2 )) found2 = TRUE;
13284 ok( guid[0], "empty guid\n" );
13285 guid[0] = 0;
13286 index++;
13288 ok( found1, "comp1 not found\n" );
13289 ok( found2, "comp2 not found\n" );
13291 done:
13292 delete_key( key1, "", access );
13293 delete_key( key2, "", access );
13294 RegCloseKey( key1 );
13295 RegCloseKey( key2 );
13296 LocalFree( usersid );
13299 static void test_MsiEnumComponentsEx(void)
13301 UINT r;
13302 BOOL found1, found2;
13303 DWORD len, index;
13304 MSIINSTALLCONTEXT context;
13305 char comp1[39], comp2[39], guid[39], sid[128];
13306 char comp_squashed1[33], comp_squashed2[33];
13307 char keypath1[MAX_PATH], keypath2[MAX_PATH];
13308 HKEY key1 = NULL, key2 = NULL;
13309 REGSAM access = KEY_ALL_ACCESS;
13310 char *usersid = get_user_sid();
13312 if (!pMsiEnumComponentsExA)
13314 win_skip( "MsiEnumComponentsExA not implemented\n" );
13315 return;
13317 create_test_guid( comp1, comp_squashed1 );
13318 create_test_guid( comp2, comp_squashed2 );
13320 if (is_wow64) access |= KEY_WOW64_64KEY;
13322 strcpy( keypath1, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13323 strcat( keypath1, "S-1-5-18\\Components\\" );
13324 strcat( keypath1, comp_squashed1 );
13326 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL );
13327 if (r == ERROR_ACCESS_DENIED)
13329 skip( "insufficient rights\n" );
13330 goto done;
13332 ok( r == ERROR_SUCCESS, "got %u\n", r );
13334 strcpy( keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13335 strcat( keypath2, usersid );
13336 strcat( keypath2, "\\Components\\" );
13337 strcat( keypath2, comp_squashed2 );
13339 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL );
13340 if (r == ERROR_ACCESS_DENIED)
13342 skip( "insufficient rights\n" );
13343 goto done;
13345 ok( r == ERROR_SUCCESS, "got %u\n", r );
13346 r = RegSetValueExA( key2, comp_squashed2, 0, REG_SZ, (const BYTE *)"c:\\doesnotexist",
13347 sizeof("c:\\doesnotexist"));
13348 ok( r == ERROR_SUCCESS, "got %u\n", r );
13350 index = 0;
13351 guid[0] = 0;
13352 context = 0xdeadbeef;
13353 sid[0] = 0;
13354 len = sizeof(sid);
13355 found1 = found2 = FALSE;
13356 while (!pMsiEnumComponentsExA( "S-1-1-0", MSIINSTALLCONTEXT_ALL, index, guid, &context, sid, &len ))
13358 if (!strcmp( comp1, guid ))
13360 ok( context == MSIINSTALLCONTEXT_MACHINE, "got %u\n", context );
13361 ok( !sid[0], "got \"%s\"\n", sid );
13362 ok( !len, "unexpected length %u\n", len );
13363 found1 = TRUE;
13365 if (!strcmp( comp2, guid ))
13367 ok( context == MSIINSTALLCONTEXT_USERUNMANAGED, "got %u\n", context );
13368 ok( sid[0], "empty sid\n" );
13369 ok( len == strlen(sid), "unexpected length %u\n", len );
13370 found2 = TRUE;
13372 index++;
13373 guid[0] = 0;
13374 context = 0xdeadbeef;
13375 sid[0] = 0;
13376 len = sizeof(sid);
13378 ok( found1, "comp1 not found\n" );
13379 ok( found2, "comp2 not found\n" );
13381 r = pMsiEnumComponentsExA( NULL, 0, 0, NULL, NULL, NULL, NULL );
13382 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13384 r = pMsiEnumComponentsExA( NULL, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, sid, NULL );
13385 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13387 done:
13388 RegDeleteValueA( key2, comp_squashed2 );
13389 delete_key( key1, "", access );
13390 delete_key( key2, "", access );
13391 RegCloseKey( key1 );
13392 RegCloseKey( key2 );
13393 LocalFree( usersid );
13396 static void test_MsiConfigureProductEx(void)
13398 UINT r;
13399 LONG res;
13400 DWORD type, size;
13401 HKEY props, source;
13402 CHAR keypath[MAX_PATH * 2], localpackage[MAX_PATH], packagename[MAX_PATH];
13403 REGSAM access = KEY_ALL_ACCESS;
13405 if (is_process_limited())
13407 skip("process is limited\n");
13408 return;
13411 CreateDirectoryA("msitest", NULL);
13412 create_file("msitest\\hydrogen", "hydrogen", 500);
13413 create_file("msitest\\helium", "helium", 500);
13414 create_file("msitest\\lithium", "lithium", 500);
13416 create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
13418 if (is_wow64)
13419 access |= KEY_WOW64_64KEY;
13421 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
13423 /* NULL szProduct */
13424 r = MsiConfigureProductExA(NULL, INSTALLLEVEL_DEFAULT,
13425 INSTALLSTATE_DEFAULT, "PROPVAR=42");
13426 ok(r == ERROR_INVALID_PARAMETER,
13427 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13429 /* empty szProduct */
13430 r = MsiConfigureProductExA("", INSTALLLEVEL_DEFAULT,
13431 INSTALLSTATE_DEFAULT, "PROPVAR=42");
13432 ok(r == ERROR_INVALID_PARAMETER,
13433 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13435 /* garbage szProduct */
13436 r = MsiConfigureProductExA("garbage", INSTALLLEVEL_DEFAULT,
13437 INSTALLSTATE_DEFAULT, "PROPVAR=42");
13438 ok(r == ERROR_INVALID_PARAMETER,
13439 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13441 /* guid without brackets */
13442 r = MsiConfigureProductExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
13443 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13444 "PROPVAR=42");
13445 ok(r == ERROR_INVALID_PARAMETER,
13446 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13448 /* guid with brackets */
13449 r = MsiConfigureProductExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
13450 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13451 "PROPVAR=42");
13452 ok(r == ERROR_UNKNOWN_PRODUCT,
13453 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
13455 /* same length as guid, but random */
13456 r = MsiConfigureProductExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
13457 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13458 "PROPVAR=42");
13459 ok(r == ERROR_UNKNOWN_PRODUCT,
13460 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
13462 /* product not installed yet */
13463 r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
13464 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13465 "PROPVAR=42");
13466 ok(r == ERROR_UNKNOWN_PRODUCT,
13467 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
13469 /* install the product, per-user unmanaged */
13470 r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
13471 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13473 skip("Not enough rights to perform tests\n");
13474 goto error;
13476 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13477 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13478 ok(pf_exists("msitest\\helium"), "File not installed\n");
13479 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13480 ok(pf_exists("msitest"), "File not installed\n");
13482 /* product is installed per-user managed, remove it */
13483 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13484 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13485 "PROPVAR=42");
13486 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13487 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13488 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13489 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13490 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13492 /* product has been removed */
13493 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13494 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13495 "PROPVAR=42");
13496 ok(r == ERROR_UNKNOWN_PRODUCT,
13497 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
13499 /* install the product, machine */
13500 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13501 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13502 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13503 ok(pf_exists("msitest\\helium"), "File not installed\n");
13504 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13505 ok(pf_exists("msitest"), "File not installed\n");
13507 /* product is installed machine, remove it */
13508 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13509 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13510 "PROPVAR=42");
13511 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13512 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13513 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13514 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13515 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13517 /* product has been removed */
13518 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13519 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13520 "PROPVAR=42");
13521 ok(r == ERROR_UNKNOWN_PRODUCT,
13522 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
13524 /* install the product, machine */
13525 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13526 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13527 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13528 ok(pf_exists("msitest\\helium"), "File not installed\n");
13529 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13530 ok(pf_exists("msitest"), "File not installed\n");
13532 DeleteFileA(msifile);
13534 /* msifile is removed */
13535 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13536 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13537 "PROPVAR=42");
13538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13539 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13540 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13541 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13542 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13544 create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
13546 /* install the product, machine */
13547 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13549 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13550 ok(pf_exists("msitest\\helium"), "File not installed\n");
13551 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13552 ok(pf_exists("msitest"), "File not installed\n");
13554 DeleteFileA(msifile);
13556 lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13557 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
13558 lstrcatA(keypath, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13560 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
13561 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13563 type = REG_SZ;
13564 size = MAX_PATH;
13565 res = RegQueryValueExA(props, "LocalPackage", NULL, &type,
13566 (LPBYTE)localpackage, &size);
13567 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13569 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
13570 (const BYTE *)"C:\\idontexist.msi", 18);
13571 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13573 /* LocalPackage is used to find the cached msi package */
13574 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13575 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13576 "PROPVAR=42");
13577 ok(r == ERROR_INSTALL_SOURCE_ABSENT,
13578 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
13579 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13580 ok(pf_exists("msitest\\helium"), "File not installed\n");
13581 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13582 ok(pf_exists("msitest"), "File not installed\n");
13584 RegCloseKey(props);
13585 create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
13587 /* LastUsedSource can be used as a last resort */
13588 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13589 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13590 "PROPVAR=42");
13591 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13592 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13593 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13594 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13595 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13596 DeleteFileA( localpackage );
13598 /* install the product, machine */
13599 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13601 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13602 ok(pf_exists("msitest\\helium"), "File not installed\n");
13603 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13604 ok(pf_exists("msitest"), "File not installed\n");
13606 lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13607 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
13608 lstrcatA(keypath, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13610 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
13611 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13613 type = REG_SZ;
13614 size = MAX_PATH;
13615 res = RegQueryValueExA(props, "LocalPackage", NULL, &type,
13616 (LPBYTE)localpackage, &size);
13617 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13619 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
13620 (const BYTE *)"C:\\idontexist.msi", 18);
13621 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13623 lstrcpyA(keypath, "SOFTWARE\\Classes\\Installer\\Products\\");
13624 lstrcatA(keypath, "83374883CBB1401418CAF2AA7CCEDDDC\\SourceList");
13626 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &source);
13627 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13629 type = REG_SZ;
13630 size = MAX_PATH;
13631 res = RegQueryValueExA(source, "PackageName", NULL, &type,
13632 (LPBYTE)packagename, &size);
13633 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13635 res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
13636 (const BYTE *)"idontexist.msi", 15);
13637 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13639 /* SourceList is altered */
13640 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13641 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13642 "PROPVAR=42");
13643 ok(r == ERROR_INSTALL_SOURCE_ABSENT,
13644 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
13645 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13646 ok(pf_exists("msitest\\helium"), "File not installed\n");
13647 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13648 ok(pf_exists("msitest"), "File not installed\n");
13650 /* restore PackageName */
13651 res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
13652 (const BYTE *)packagename, lstrlenA(packagename) + 1);
13653 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13655 /* restore LocalPackage */
13656 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
13657 (const BYTE *)localpackage, lstrlenA(localpackage) + 1);
13658 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13660 /* finally remove the product */
13661 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13662 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13663 "PROPVAR=42");
13664 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13665 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13666 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13667 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13668 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13670 RegCloseKey(source);
13671 RegCloseKey(props);
13673 error:
13674 DeleteFileA("msitest\\hydrogen");
13675 DeleteFileA("msitest\\helium");
13676 DeleteFileA("msitest\\lithium");
13677 RemoveDirectoryA("msitest");
13678 DeleteFileA(msifile);
13681 static void test_MsiSetFeatureAttributes(void)
13683 UINT r;
13684 DWORD attrs;
13685 char path[MAX_PATH];
13686 MSIHANDLE package;
13688 if (is_process_limited())
13690 skip("process is limited\n");
13691 return;
13693 create_database( msifile, tables, sizeof(tables) / sizeof(tables[0]) );
13695 strcpy( path, CURR_DIR );
13696 strcat( path, "\\" );
13697 strcat( path, msifile );
13699 r = MsiOpenPackageA( path, &package );
13700 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13702 skip("Not enough rights to perform tests\n");
13703 DeleteFileA( msifile );
13704 return;
13706 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13708 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13709 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %u\n", r);
13711 r = MsiDoActionA( package, "CostInitialize" );
13712 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13714 r = MsiSetFeatureAttributesA( 0, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13715 ok(r == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", r);
13717 r = MsiSetFeatureAttributesA( package, "", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13718 ok(r == ERROR_UNKNOWN_FEATURE, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
13720 r = MsiSetFeatureAttributesA( package, NULL, INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13721 ok(r == ERROR_UNKNOWN_FEATURE, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
13723 r = MsiSetFeatureAttributesA( package, "One", 0 );
13724 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13726 attrs = 0xdeadbeef;
13727 r = MsiGetFeatureInfoA( package, "One", &attrs, NULL, NULL, NULL, NULL );
13728 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13729 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL,
13730 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs);
13732 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13733 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13735 attrs = 0;
13736 r = MsiGetFeatureInfoA( package, "One", &attrs, NULL, NULL, NULL, NULL );
13737 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13738 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL,
13739 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs);
13741 r = MsiDoActionA( package, "FileCost" );
13742 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13744 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORSOURCE );
13745 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13747 attrs = 0;
13748 r = MsiGetFeatureInfoA( package, "One", &attrs, NULL, NULL, NULL, NULL );
13749 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13750 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORSOURCE,
13751 "expected INSTALLFEATUREATTRIBUTE_FAVORSOURCE, got 0x%08x\n", attrs);
13753 r = MsiDoActionA( package, "CostFinalize" );
13754 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13756 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13757 ok(r == ERROR_FUNCTION_FAILED, "expected ERROR_FUNCTION_FAILED, got %u\n", r);
13759 MsiCloseHandle( package );
13760 DeleteFileA( msifile );
13763 static void test_MsiGetFeatureInfo(void)
13765 UINT r;
13766 MSIHANDLE package;
13767 char title[32], help[32], path[MAX_PATH];
13768 DWORD attrs, title_len, help_len;
13770 if (is_process_limited())
13772 skip("process is limited\n");
13773 return;
13775 create_database( msifile, tables, sizeof(tables) / sizeof(tables[0]) );
13777 strcpy( path, CURR_DIR );
13778 strcat( path, "\\" );
13779 strcat( path, msifile );
13781 r = MsiOpenPackageA( path, &package );
13782 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13784 skip("Not enough rights to perform tests\n");
13785 DeleteFileA( msifile );
13786 return;
13788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13790 r = MsiGetFeatureInfoA( 0, NULL, NULL, NULL, NULL, NULL, NULL );
13791 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
13793 r = MsiGetFeatureInfoA( package, NULL, NULL, NULL, NULL, NULL, NULL );
13794 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
13796 r = MsiGetFeatureInfoA( package, "", NULL, NULL, NULL, NULL, NULL );
13797 ok(r == ERROR_UNKNOWN_FEATURE, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
13799 r = MsiGetFeatureInfoA( package, "One", NULL, NULL, NULL, NULL, NULL );
13800 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13802 r = MsiGetFeatureInfoA( 0, "One", NULL, NULL, NULL, NULL, NULL );
13803 ok(r == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", r);
13805 title_len = help_len = 0;
13806 r = MsiGetFeatureInfoA( package, "One", NULL, NULL, &title_len, NULL, &help_len );
13807 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13808 ok(title_len == 3, "expected 3, got %u\n", title_len);
13809 ok(help_len == 3, "expected 3, got %u\n", help_len);
13811 title[0] = help[0] = 0;
13812 title_len = help_len = 0;
13813 r = MsiGetFeatureInfoA( package, "One", NULL, title, &title_len, help, &help_len );
13814 ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %u\n", r);
13815 ok(title_len == 3, "expected 3, got %u\n", title_len);
13816 ok(help_len == 3, "expected 3, got %u\n", help_len);
13818 attrs = 0;
13819 title[0] = help[0] = 0;
13820 title_len = sizeof(title);
13821 help_len = sizeof(help);
13822 r = MsiGetFeatureInfoA( package, "One", &attrs, title, &title_len, help, &help_len );
13823 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13824 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs);
13825 ok(title_len == 3, "expected 3, got %u\n", title_len);
13826 ok(help_len == 3, "expected 3, got %u\n", help_len);
13827 ok(!strcmp(title, "One"), "expected \"One\", got \"%s\"\n", title);
13828 ok(!strcmp(help, "One"), "expected \"One\", got \"%s\"\n", help);
13830 attrs = 0;
13831 title[0] = help[0] = 0;
13832 title_len = sizeof(title);
13833 help_len = sizeof(help);
13834 r = MsiGetFeatureInfoA( package, "Two", &attrs, title, &title_len, help, &help_len );
13835 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13836 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs);
13837 ok(!title_len, "expected 0, got %u\n", title_len);
13838 ok(!help_len, "expected 0, got %u\n", help_len);
13839 ok(!title[0], "expected \"\", got \"%s\"\n", title);
13840 ok(!help[0], "expected \"\", got \"%s\"\n", help);
13842 MsiCloseHandle( package );
13843 DeleteFileA( msifile );
13846 static INT CALLBACK handler_a(LPVOID context, UINT type, LPCSTR msg)
13848 return IDOK;
13851 static INT CALLBACK handler_w(LPVOID context, UINT type, LPCWSTR msg)
13853 return IDOK;
13856 static INT CALLBACK handler_record(LPVOID context, UINT type, MSIHANDLE record)
13858 return IDOK;
13861 static void test_MsiSetExternalUI(void)
13863 INSTALLUI_HANDLERA ret_a;
13864 INSTALLUI_HANDLERW ret_w;
13865 INSTALLUI_HANDLER_RECORD prev;
13866 UINT error;
13868 ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
13869 ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
13871 ret_a = MsiSetExternalUIA(NULL, 0, NULL);
13872 ok(ret_a == handler_a, "expected %p, got %p\n", handler_a, ret_a);
13874 /* Not present before Installer 3.1 */
13875 if (!pMsiSetExternalUIRecord) {
13876 win_skip("MsiSetExternalUIRecord is not available\n");
13877 return;
13880 error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
13881 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
13882 ok(prev == NULL, "expected NULL, got %p\n", prev);
13884 prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
13885 error = pMsiSetExternalUIRecord(NULL, INSTALLLOGMODE_ERROR, NULL, &prev);
13886 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
13887 ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
13889 ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
13890 ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
13892 ret_w = MsiSetExternalUIW(NULL, 0, NULL);
13893 ok(ret_w == handler_w, "expected %p, got %p\n", handler_w, ret_w);
13895 ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
13896 ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
13898 ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
13899 ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
13901 prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
13902 error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
13903 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
13904 ok(prev == NULL, "expected NULL, got %p\n", prev);
13906 ret_a = MsiSetExternalUIA(NULL, 0, NULL);
13907 ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
13909 ret_w = MsiSetExternalUIW(NULL, 0, NULL);
13910 ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
13912 prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
13913 error = pMsiSetExternalUIRecord(NULL, 0, NULL, &prev);
13914 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
13915 ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
13917 error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, NULL);
13918 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
13920 error = pMsiSetExternalUIRecord(NULL, 0, NULL, NULL);
13921 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
13924 static void test_lastusedsource(void)
13926 static const char prodcode[] = "{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}";
13927 char value[MAX_PATH], path[MAX_PATH];
13928 DWORD size;
13929 UINT r;
13931 if (!pMsiSourceListGetInfoA)
13933 win_skip("MsiSourceListGetInfoA is not available\n");
13934 return;
13937 CreateDirectoryA("msitest", NULL);
13938 create_file("maximus", "maximus", 500);
13939 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
13940 DeleteFileA("maximus");
13942 create_database("msifile0.msi", lus0_tables, sizeof(lus0_tables) / sizeof(msi_table));
13943 create_database("msifile1.msi", lus1_tables, sizeof(lus1_tables) / sizeof(msi_table));
13944 create_database("msifile2.msi", lus2_tables, sizeof(lus2_tables) / sizeof(msi_table));
13946 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
13948 /* no cabinet file */
13950 size = MAX_PATH;
13951 lstrcpyA(value, "aaa");
13952 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
13953 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
13954 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
13955 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
13957 r = MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1");
13958 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13960 skip("Not enough rights to perform tests\n");
13961 goto error;
13963 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13965 lstrcpyA(path, CURR_DIR);
13966 lstrcatA(path, "\\");
13968 size = MAX_PATH;
13969 lstrcpyA(value, "aaa");
13970 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
13971 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
13972 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13973 ok(!lstrcmpA(value, path), "expected \"%s\", got \"%s\"\n", path, value);
13974 ok(size == lstrlenA(path), "expected %d, got %d\n", lstrlenA(path), size);
13976 r = MsiInstallProductA("msifile0.msi", "REMOVE=ALL");
13977 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13979 /* separate cabinet file */
13981 size = MAX_PATH;
13982 lstrcpyA(value, "aaa");
13983 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
13984 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
13985 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
13986 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
13988 r = MsiInstallProductA("msifile1.msi", "PUBLISH_PRODUCT=1");
13989 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13991 lstrcpyA(path, CURR_DIR);
13992 lstrcatA(path, "\\");
13994 size = MAX_PATH;
13995 lstrcpyA(value, "aaa");
13996 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
13997 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
13998 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13999 ok(!lstrcmpA(value, path), "expected \"%s\", got \"%s\"\n", path, value);
14000 ok(size == lstrlenA(path), "expected %d, got %d\n", lstrlenA(path), size);
14002 r = MsiInstallProductA("msifile1.msi", "REMOVE=ALL");
14003 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14005 size = MAX_PATH;
14006 lstrcpyA(value, "aaa");
14007 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14008 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14009 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
14010 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
14012 /* embedded cabinet stream */
14014 add_cabinet_storage("msifile2.msi", "test1.cab");
14016 r = MsiInstallProductA("msifile2.msi", "PUBLISH_PRODUCT=1");
14017 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14019 size = MAX_PATH;
14020 lstrcpyA(value, "aaa");
14021 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14022 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14023 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14024 ok(!lstrcmpA(value, path), "expected \"%s\", got \"%s\"\n", path, value);
14025 ok(size == lstrlenA(path), "expected %d, got %d\n", lstrlenA(path), size);
14027 r = MsiInstallProductA("msifile2.msi", "REMOVE=ALL");
14028 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14030 size = MAX_PATH;
14031 lstrcpyA(value, "aaa");
14032 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14033 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14034 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
14035 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
14037 error:
14038 delete_cab_files();
14039 DeleteFileA("msitest\\maximus");
14040 RemoveDirectoryA("msitest");
14041 DeleteFileA("msifile0.msi");
14042 DeleteFileA("msifile1.msi");
14043 DeleteFileA("msifile2.msi");
14046 static void test_setpropertyfolder(void)
14048 UINT r;
14049 CHAR path[MAX_PATH];
14050 DWORD attr;
14052 if (is_process_limited())
14054 skip("process is limited\n");
14055 return;
14058 lstrcpyA(path, PROG_FILES_DIR);
14059 lstrcatA(path, "\\msitest\\added");
14061 CreateDirectoryA("msitest", NULL);
14062 create_file("msitest\\maximus", "msitest\\maximus", 500);
14064 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
14066 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14068 r = MsiInstallProductA(msifile, NULL);
14069 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
14071 skip("Not enough rights to perform tests\n");
14072 goto error;
14074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14075 attr = GetFileAttributesA(path);
14076 if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
14078 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
14079 ok(delete_pf("msitest\\added", FALSE), "Directory not created\n");
14080 ok(delete_pf("msitest", FALSE), "Directory not created\n");
14082 else
14084 trace("changing folder property not supported\n");
14085 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
14086 ok(delete_pf("msitest", FALSE), "Directory not created\n");
14089 error:
14090 DeleteFileA(msifile);
14091 DeleteFileA("msitest\\maximus");
14092 RemoveDirectoryA("msitest");
14095 static void test_sourcedir_props(void)
14097 UINT r;
14099 if (is_process_limited())
14101 skip("process is limited\n");
14102 return;
14105 create_test_files();
14106 create_file("msitest\\sourcedir.txt", "msitest\\sourcedir.txt", 1000);
14107 create_database(msifile, sd_tables, sizeof(sd_tables) / sizeof(msi_table));
14109 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14111 /* full UI, no ResolveSource action */
14112 r = MsiInstallProductA(msifile, NULL);
14113 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14115 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14116 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14118 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14119 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14121 /* full UI, ResolveSource action */
14122 r = MsiInstallProductA(msifile, "ResolveSource=1");
14123 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14125 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14128 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14129 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14131 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
14133 /* no UI, no ResolveSource action */
14134 r = MsiInstallProductA(msifile, NULL);
14135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14137 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14140 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14141 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14143 /* no UI, ResolveSource action */
14144 r = MsiInstallProductA(msifile, "ResolveSource=1");
14145 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14147 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14150 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14151 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14153 DeleteFileA("msitest\\sourcedir.txt");
14154 delete_test_files();
14155 DeleteFileA(msifile);
14158 static void test_concurrentinstall(void)
14160 UINT r;
14161 CHAR path[MAX_PATH];
14163 if (is_process_limited())
14165 skip("process is limited\n");
14166 return;
14169 CreateDirectoryA("msitest", NULL);
14170 CreateDirectoryA("msitest\\msitest", NULL);
14171 create_file("msitest\\maximus", "msitest\\maximus", 500);
14172 create_file("msitest\\msitest\\augustus", "msitest\\msitest\\augustus", 500);
14174 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
14176 lstrcpyA(path, CURR_DIR);
14177 lstrcatA(path, "\\msitest\\concurrent.msi");
14178 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
14180 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14182 r = MsiInstallProductA(msifile, NULL);
14183 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
14185 skip("Not enough rights to perform tests\n");
14186 DeleteFileA(path);
14187 goto error;
14189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14190 if (!delete_pf("msitest\\augustus", TRUE))
14191 trace("concurrent installs not supported\n");
14192 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
14193 ok(delete_pf("msitest", FALSE), "Directory not created\n");
14195 r = MsiConfigureProductA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", INSTALLLEVEL_DEFAULT,
14196 INSTALLSTATE_ABSENT);
14197 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14199 DeleteFileA(path);
14201 error:
14202 DeleteFileA(msifile);
14203 DeleteFileA("msitest\\msitest\\augustus");
14204 DeleteFileA("msitest\\maximus");
14205 RemoveDirectoryA("msitest\\msitest");
14206 RemoveDirectoryA("msitest");
14209 static void test_command_line_parsing(void)
14211 UINT r;
14212 const char *cmd;
14214 if (is_process_limited())
14216 skip("process is limited\n");
14217 return;
14220 create_test_files();
14221 create_database(msifile, cl_tables, sizeof(cl_tables)/sizeof(msi_table));
14223 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
14225 cmd = " ";
14226 r = MsiInstallProductA(msifile, cmd);
14227 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14229 cmd = "=";
14230 r = MsiInstallProductA(msifile, cmd);
14231 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14233 cmd = "==";
14234 r = MsiInstallProductA(msifile, cmd);
14235 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14237 cmd = "one";
14238 r = MsiInstallProductA(msifile, cmd);
14239 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14241 cmd = "=one";
14242 r = MsiInstallProductA(msifile, cmd);
14243 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14245 cmd = "P=";
14246 r = MsiInstallProductA(msifile, cmd);
14247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14249 cmd = " P=";
14250 r = MsiInstallProductA(msifile, cmd);
14251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14253 cmd = "P= ";
14254 r = MsiInstallProductA(msifile, cmd);
14255 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14257 cmd = "P=\"";
14258 r = MsiInstallProductA(msifile, cmd);
14259 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14261 cmd = "P=\"\"";
14262 r = MsiInstallProductA(msifile, cmd);
14263 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14265 cmd = "P=\"\"\"";
14266 r = MsiInstallProductA(msifile, cmd);
14267 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14269 cmd = "P=\"\"\"\"";
14270 r = MsiInstallProductA(msifile, cmd);
14271 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14273 cmd = "P=\" ";
14274 r = MsiInstallProductA(msifile, cmd);
14275 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14277 cmd = "P= \"";
14278 r = MsiInstallProductA(msifile, cmd);
14279 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14281 cmd = "P= \"\" ";
14282 r = MsiInstallProductA(msifile, cmd);
14283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14285 cmd = "P=\" \"";
14286 r = MsiInstallProductA(msifile, cmd);
14287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14289 cmd = "P=one";
14290 r = MsiInstallProductA(msifile, cmd);
14291 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14293 cmd = "P= one";
14294 r = MsiInstallProductA(msifile, cmd);
14295 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14297 cmd = "P=\"one";
14298 r = MsiInstallProductA(msifile, cmd);
14299 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14301 cmd = "P=one\"";
14302 r = MsiInstallProductA(msifile, cmd);
14303 todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14305 cmd = "P=\"one\"";
14306 r = MsiInstallProductA(msifile, cmd);
14307 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14309 cmd = "P= \"one\" ";
14310 r = MsiInstallProductA(msifile, cmd);
14311 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14313 cmd = "P=\"one\"\"";
14314 r = MsiInstallProductA(msifile, cmd);
14315 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14317 cmd = "P=\"\"one\"";
14318 r = MsiInstallProductA(msifile, cmd);
14319 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14321 cmd = "P=\"\"one\"\"";
14322 r = MsiInstallProductA(msifile, cmd);
14323 todo_wine ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14325 cmd = "P=\"one two\"";
14326 r = MsiInstallProductA(msifile, cmd);
14327 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14329 cmd = "P=\"\"\"one\"\" two\"";
14330 r = MsiInstallProductA(msifile, cmd);
14331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14333 cmd = "P=\"\"\"one\"\" two\" Q=three";
14334 r = MsiInstallProductA(msifile, cmd);
14335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14337 cmd = "P=\"\" Q=\"two\"";
14338 r = MsiInstallProductA(msifile, cmd);
14339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14341 cmd = "P=\"one\" Q=\"two\"";
14342 r = MsiInstallProductA(msifile, cmd);
14343 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14345 cmd = "P=\"one=two\"";
14346 r = MsiInstallProductA(msifile, cmd);
14347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14349 cmd = "Q=\"\" P=\"one\"";
14350 r = MsiInstallProductA(msifile, cmd);
14351 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14353 cmd = "P=\"\"\"one\"\"\" Q=\"two\"";
14354 r = MsiInstallProductA(msifile, cmd);
14355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14357 cmd = "P=\"one \"\"two\"\"\" Q=\"three\"";
14358 r = MsiInstallProductA(msifile, cmd);
14359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14361 cmd = "P=\"\"\"one\"\" two\" Q=\"three\"";
14362 r = MsiInstallProductA(msifile, cmd);
14363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14365 DeleteFileA(msifile);
14366 delete_test_files();
14369 START_TEST(msi)
14371 DWORD len;
14372 char temp_path[MAX_PATH], prev_path[MAX_PATH];
14374 init_functionpointers();
14376 if (pIsWow64Process)
14377 pIsWow64Process(GetCurrentProcess(), &is_wow64);
14379 GetCurrentDirectoryA(MAX_PATH, prev_path);
14380 GetTempPathA(MAX_PATH, temp_path);
14381 SetCurrentDirectoryA(temp_path);
14383 lstrcpyA(CURR_DIR, temp_path);
14384 len = lstrlenA(CURR_DIR);
14386 if(len && (CURR_DIR[len - 1] == '\\'))
14387 CURR_DIR[len - 1] = 0;
14389 ok(get_system_dirs(), "failed to retrieve system dirs\n");
14391 test_usefeature();
14392 test_null();
14393 test_getcomponentpath();
14394 test_MsiGetFileHash();
14396 if (!pConvertSidToStringSidA)
14397 win_skip("ConvertSidToStringSidA not implemented\n");
14398 else
14400 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
14401 test_MsiQueryProductState();
14402 test_MsiQueryFeatureState();
14403 test_MsiQueryComponentState();
14404 test_MsiGetComponentPath();
14405 test_MsiProvideComponent();
14406 test_MsiGetProductCode();
14407 test_MsiEnumClients();
14408 test_MsiGetProductInfo();
14409 test_MsiGetProductInfoEx();
14410 test_MsiGetUserInfo();
14411 test_MsiOpenProduct();
14412 test_MsiEnumPatchesEx();
14413 test_MsiEnumPatches();
14414 test_MsiGetPatchInfoEx();
14415 test_MsiGetPatchInfo();
14416 test_MsiEnumProducts();
14417 test_MsiEnumProductsEx();
14418 test_MsiEnumComponents();
14419 test_MsiEnumComponentsEx();
14421 test_MsiGetFileVersion();
14422 test_MsiGetFileSignatureInformation();
14423 test_MsiConfigureProductEx();
14424 test_MsiSetFeatureAttributes();
14425 test_MsiGetFeatureInfo();
14426 test_MsiSetExternalUI();
14427 test_lastusedsource();
14428 test_setpropertyfolder();
14429 test_sourcedir_props();
14430 if (pMsiGetComponentPathExA)
14431 test_concurrentinstall();
14432 test_command_line_parsing();
14434 SetCurrentDirectoryA(prev_path);