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
32 #include "wine/test.h"
35 static const char msifile
[] = "winetest.msi";
36 static char CURR_DIR
[MAX_PATH
];
37 static char PROG_FILES_DIR
[MAX_PATH
];
38 static char PROG_FILES_DIR_NATIVE
[MAX_PATH
];
39 static char COMMON_FILES_DIR
[MAX_PATH
];
40 static char WINDOWS_DIR
[MAX_PATH
];
42 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
43 static BOOL (WINAPI
*pOpenProcessToken
)( HANDLE
, DWORD
, PHANDLE
);
44 static LONG (WINAPI
*pRegDeleteKeyExA
)(HKEY
, LPCSTR
, REGSAM
, DWORD
);
45 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
47 static INSTALLSTATE (WINAPI
*pMsiGetComponentPathA
)
48 (LPCSTR
, LPCSTR
, LPSTR
, DWORD
*);
49 static UINT (WINAPI
*pMsiGetFileHashA
)
50 (LPCSTR
, DWORD
, PMSIFILEHASHINFO
);
51 static UINT (WINAPI
*pMsiGetProductInfoExA
)
52 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPCSTR
, LPSTR
, LPDWORD
);
53 static UINT (WINAPI
*pMsiOpenPackageExA
)
54 (LPCSTR
, DWORD
, MSIHANDLE
*);
55 static UINT (WINAPI
*pMsiOpenPackageExW
)
56 (LPCWSTR
, DWORD
, MSIHANDLE
*);
57 static UINT (WINAPI
*pMsiEnumPatchesExA
)
58 (LPCSTR
, LPCSTR
, DWORD
, DWORD
, DWORD
, LPSTR
, LPSTR
,
59 MSIINSTALLCONTEXT
*, LPSTR
, LPDWORD
);
60 static UINT (WINAPI
*pMsiQueryComponentStateA
)
61 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPCSTR
, INSTALLSTATE
*);
62 static INSTALLSTATE (WINAPI
*pMsiUseFeatureExA
)
63 (LPCSTR
, LPCSTR
,DWORD
, DWORD
);
64 static UINT (WINAPI
*pMsiGetPatchInfoExA
)
65 (LPCSTR
, LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPCSTR
, LPSTR
, DWORD
*);
66 static UINT (WINAPI
*pMsiEnumProductsExA
)
67 (LPCSTR
, LPCSTR
, DWORD
, DWORD
, CHAR
[39], MSIINSTALLCONTEXT
*, LPSTR
, LPDWORD
);
68 static UINT (WINAPI
*pMsiEnumComponentsExA
)
69 (LPCSTR
, DWORD
, DWORD
, CHAR
[39], MSIINSTALLCONTEXT
*, LPSTR
, LPDWORD
);
70 static UINT (WINAPI
*pMsiSetExternalUIRecord
)
71 (INSTALLUI_HANDLER_RECORD
, DWORD
, LPVOID
, PINSTALLUI_HANDLER_RECORD
);
72 static UINT (WINAPI
*pMsiSourceListGetInfoA
)
73 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, LPCSTR
, LPSTR
, LPDWORD
);
75 static void init_functionpointers(void)
77 HMODULE hmsi
= GetModuleHandleA("msi.dll");
78 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
79 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
81 #define GET_PROC(dll, func) \
82 p ## func = (void *)GetProcAddress(dll, #func); \
84 trace("GetProcAddress(%s) failed\n", #func);
86 GET_PROC(hmsi
, MsiGetComponentPathA
)
87 GET_PROC(hmsi
, MsiGetFileHashA
)
88 GET_PROC(hmsi
, MsiGetProductInfoExA
)
89 GET_PROC(hmsi
, MsiOpenPackageExA
)
90 GET_PROC(hmsi
, MsiOpenPackageExW
)
91 GET_PROC(hmsi
, MsiEnumPatchesExA
)
92 GET_PROC(hmsi
, MsiQueryComponentStateA
)
93 GET_PROC(hmsi
, MsiSetExternalUIRecord
)
94 GET_PROC(hmsi
, MsiUseFeatureExA
)
95 GET_PROC(hmsi
, MsiGetPatchInfoExA
)
96 GET_PROC(hmsi
, MsiEnumProductsExA
)
97 GET_PROC(hmsi
, MsiEnumComponentsExA
)
98 GET_PROC(hmsi
, MsiSourceListGetInfoA
)
100 GET_PROC(hadvapi32
, ConvertSidToStringSidA
)
101 GET_PROC(hadvapi32
, OpenProcessToken
);
102 GET_PROC(hadvapi32
, RegDeleteKeyExA
)
103 GET_PROC(hkernel32
, IsWow64Process
)
108 static BOOL
get_system_dirs(void)
113 if (RegOpenKey(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey
))
117 if (RegQueryValueExA(hkey
, "ProgramFilesDir (x86)", 0, &type
, (LPBYTE
)PROG_FILES_DIR
, &size
) &&
118 RegQueryValueExA(hkey
, "ProgramFilesDir", 0, &type
, (LPBYTE
)PROG_FILES_DIR
, &size
))
124 if (RegQueryValueExA(hkey
, "CommonFilesDir (x86)", 0, &type
, (LPBYTE
)COMMON_FILES_DIR
, &size
) &&
125 RegQueryValueExA(hkey
, "CommonFilesDir", 0, &type
, (LPBYTE
)COMMON_FILES_DIR
, &size
))
131 if (RegQueryValueExA(hkey
, "ProgramFilesDir", 0, &type
, (LPBYTE
)PROG_FILES_DIR_NATIVE
, &size
))
137 if (!GetWindowsDirectoryA(WINDOWS_DIR
, MAX_PATH
)) return FALSE
;
141 static BOOL
file_exists(const char *file
)
143 return GetFileAttributes(file
) != INVALID_FILE_ATTRIBUTES
;
146 static BOOL
pf_exists(const char *file
)
150 lstrcpyA(path
, PROG_FILES_DIR
);
151 lstrcatA(path
, "\\");
152 lstrcatA(path
, file
);
153 return file_exists(path
);
156 static BOOL
delete_pf(const char *rel_path
, BOOL is_file
)
160 lstrcpyA(path
, PROG_FILES_DIR
);
161 lstrcatA(path
, "\\");
162 lstrcatA(path
, rel_path
);
165 return DeleteFileA(path
);
167 return RemoveDirectoryA(path
);
170 static BOOL
is_process_limited(void)
173 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
177 if (!pOpenProcessToken
) return FALSE
;
178 if (!pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
)) return FALSE
;
179 ret
= GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
181 return (ret
&& type
== TokenElevationTypeLimited
);
184 /* cabinet definitions */
186 /* make the max size large so there is only one cab file */
187 #define MEDIA_SIZE 0x7FFFFFFF
188 #define FOLDER_THRESHOLD 900000
190 /* the FCI callbacks */
192 static void * CDECL
mem_alloc(ULONG cb
)
194 return HeapAlloc(GetProcessHeap(), 0, cb
);
197 static void CDECL
mem_free(void *memory
)
199 HeapFree(GetProcessHeap(), 0, memory
);
202 static BOOL CDECL
get_next_cabinet(PCCAB pccab
, ULONG cbPrevCab
, void *pv
)
204 sprintf(pccab
->szCab
, pv
, pccab
->iCab
);
208 static LONG CDECL
progress(UINT typeStatus
, ULONG cb1
, ULONG cb2
, void *pv
)
213 static int CDECL
file_placed(PCCAB pccab
, char *pszFile
, LONG cbFile
,
214 BOOL fContinuation
, void *pv
)
219 static INT_PTR CDECL
fci_open(char *pszFile
, int oflag
, int pmode
, int *err
, void *pv
)
223 DWORD dwShareMode
= 0;
224 DWORD dwCreateDisposition
= OPEN_EXISTING
;
226 dwAccess
= GENERIC_READ
| GENERIC_WRITE
;
227 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
228 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
230 if (GetFileAttributesA(pszFile
) != INVALID_FILE_ATTRIBUTES
)
231 dwCreateDisposition
= OPEN_EXISTING
;
233 dwCreateDisposition
= CREATE_NEW
;
235 handle
= CreateFileA(pszFile
, dwAccess
, dwShareMode
, NULL
,
236 dwCreateDisposition
, 0, NULL
);
238 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to CreateFile %s\n", pszFile
);
240 return (INT_PTR
)handle
;
243 static UINT CDECL
fci_read(INT_PTR hf
, void *memory
, UINT cb
, int *err
, void *pv
)
245 HANDLE handle
= (HANDLE
)hf
;
249 res
= ReadFile(handle
, memory
, cb
, &dwRead
, NULL
);
250 ok(res
, "Failed to ReadFile\n");
255 static UINT CDECL
fci_write(INT_PTR hf
, void *memory
, UINT cb
, int *err
, void *pv
)
257 HANDLE handle
= (HANDLE
)hf
;
261 res
= WriteFile(handle
, memory
, cb
, &dwWritten
, NULL
);
262 ok(res
, "Failed to WriteFile\n");
267 static int CDECL
fci_close(INT_PTR hf
, int *err
, void *pv
)
269 HANDLE handle
= (HANDLE
)hf
;
270 ok(CloseHandle(handle
), "Failed to CloseHandle\n");
275 static LONG CDECL
fci_seek(INT_PTR hf
, LONG dist
, int seektype
, int *err
, void *pv
)
277 HANDLE handle
= (HANDLE
)hf
;
280 ret
= SetFilePointer(handle
, dist
, NULL
, seektype
);
281 ok(ret
!= INVALID_SET_FILE_POINTER
, "Failed to SetFilePointer\n");
286 static int CDECL
fci_delete(char *pszFile
, int *err
, void *pv
)
288 BOOL ret
= DeleteFileA(pszFile
);
289 ok(ret
, "Failed to DeleteFile %s\n", pszFile
);
294 static BOOL CDECL
get_temp_file(char *pszTempName
, int cbTempName
, void *pv
)
298 tempname
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
299 GetTempFileNameA(".", "xx", 0, tempname
);
301 if (tempname
&& (strlen(tempname
) < (unsigned)cbTempName
))
303 lstrcpyA(pszTempName
, tempname
);
304 HeapFree(GetProcessHeap(), 0, tempname
);
308 HeapFree(GetProcessHeap(), 0, tempname
);
313 static INT_PTR CDECL
get_open_info(char *pszName
, USHORT
*pdate
, USHORT
*ptime
,
314 USHORT
*pattribs
, int *err
, void *pv
)
316 BY_HANDLE_FILE_INFORMATION finfo
;
322 handle
= CreateFile(pszName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
323 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
| FILE_FLAG_SEQUENTIAL_SCAN
, NULL
);
325 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to CreateFile %s\n", pszName
);
327 res
= GetFileInformationByHandle(handle
, &finfo
);
328 ok(res
, "Expected GetFileInformationByHandle to succeed\n");
330 FileTimeToLocalFileTime(&finfo
.ftLastWriteTime
, &filetime
);
331 FileTimeToDosDateTime(&filetime
, pdate
, ptime
);
333 attrs
= GetFileAttributes(pszName
);
334 ok(attrs
!= INVALID_FILE_ATTRIBUTES
, "Failed to GetFileAttributes\n");
336 return (INT_PTR
)handle
;
339 static BOOL
add_file(HFCI hfci
, const char *file
, TCOMP compress
)
342 char filename
[MAX_PATH
];
344 lstrcpyA(path
, CURR_DIR
);
345 lstrcatA(path
, "\\");
346 lstrcatA(path
, file
);
348 lstrcpyA(filename
, file
);
350 return FCIAddFile(hfci
, path
, filename
, FALSE
, get_next_cabinet
,
351 progress
, get_open_info
, compress
);
354 static void set_cab_parameters(PCCAB pCabParams
, const CHAR
*name
, DWORD max_size
)
356 ZeroMemory(pCabParams
, sizeof(CCAB
));
358 pCabParams
->cb
= max_size
;
359 pCabParams
->cbFolderThresh
= FOLDER_THRESHOLD
;
360 pCabParams
->setID
= 0xbeef;
361 pCabParams
->iCab
= 1;
362 lstrcpyA(pCabParams
->szCabPath
, CURR_DIR
);
363 lstrcatA(pCabParams
->szCabPath
, "\\");
364 lstrcpyA(pCabParams
->szCab
, name
);
367 static void create_cab_file(const CHAR
*name
, DWORD max_size
, const CHAR
*files
)
375 set_cab_parameters(&cabParams
, name
, max_size
);
377 hfci
= FCICreate(&erf
, file_placed
, mem_alloc
, mem_free
, fci_open
,
378 fci_read
, fci_write
, fci_close
, fci_seek
, fci_delete
,
379 get_temp_file
, &cabParams
, NULL
);
381 ok(hfci
!= NULL
, "Failed to create an FCI context\n");
386 res
= add_file(hfci
, ptr
, tcompTYPE_MSZIP
);
387 ok(res
, "Failed to add file: %s\n", ptr
);
388 ptr
+= lstrlen(ptr
) + 1;
391 res
= FCIFlushCabinet(hfci
, FALSE
, get_next_cabinet
, progress
);
392 ok(res
, "Failed to flush the cabinet\n");
394 res
= FCIDestroy(hfci
);
395 ok(res
, "Failed to destroy the cabinet\n");
398 static BOOL
add_cabinet_storage(LPCSTR db
, LPCSTR cabinet
)
400 WCHAR dbW
[MAX_PATH
], cabinetW
[MAX_PATH
];
406 MultiByteToWideChar(CP_ACP
, 0, db
, -1, dbW
, MAX_PATH
);
407 hr
= StgOpenStorage(dbW
, NULL
, STGM_DIRECT
|STGM_READWRITE
|STGM_SHARE_EXCLUSIVE
, NULL
, 0, &stg
);
411 MultiByteToWideChar(CP_ACP
, 0, cabinet
, -1, cabinetW
, MAX_PATH
);
412 hr
= IStorage_CreateStream(stg
, cabinetW
, STGM_WRITE
|STGM_SHARE_EXCLUSIVE
, 0, 0, &stm
);
415 IStorage_Release(stg
);
419 handle
= CreateFileW(cabinetW
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
420 if (handle
!= INVALID_HANDLE_VALUE
)
424 if (ReadFile(handle
, buffer
, sizeof(buffer
), &count
, NULL
))
425 IStream_Write(stm
, buffer
, count
, &count
);
429 IStream_Release(stm
);
430 IStorage_Release(stg
);
435 static void delete_cab_files(void)
438 CHAR path
[MAX_PATH
+10];
440 lstrcpyA(path
, CURR_DIR
);
441 lstrcatA(path
, "\\*.cab");
442 path
[strlen(path
) + 1] = '\0';
445 shfl
.wFunc
= FO_DELETE
;
448 shfl
.fFlags
= FOF_FILESONLY
| FOF_NOCONFIRMATION
| FOF_NORECURSION
| FOF_SILENT
;
450 SHFileOperation(&shfl
);
453 /* msi database data */
455 static const char directory_dat
[] =
456 "Directory\tDirectory_Parent\tDefaultDir\n"
458 "Directory\tDirectory\n"
459 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
460 "ProgramFilesFolder\tTARGETDIR\t.\n"
461 "TARGETDIR\t\tSourceDir";
463 static const char component_dat
[] =
464 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
465 "s72\tS38\ts72\ti2\tS255\tS72\n"
466 "Component\tComponent\n"
467 "One\t{8F5BAEEF-DD92-40AC-9397-BE3CF9F97C81}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n";
469 static const char feature_dat
[] =
470 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
471 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
473 "One\t\tOne\tOne\t1\t3\tMSITESTDIR\t0\n"
474 "Two\t\t\t\t2\t1\tTARGETDIR\t0\n";
476 static const char feature_comp_dat
[] =
477 "Feature_\tComponent_\n"
479 "FeatureComponents\tFeature_\tComponent_\n"
482 static const char file_dat
[] =
483 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
484 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
486 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n";
488 static const char install_exec_seq_dat
[] =
489 "Action\tCondition\tSequence\n"
491 "InstallExecuteSequence\tAction\n"
492 "ValidateProductID\t\t700\n"
493 "CostInitialize\t\t800\n"
495 "CostFinalize\t\t1000\n"
496 "InstallValidate\t\t1400\n"
497 "InstallInitialize\t\t1500\n"
498 "ProcessComponents\t\t1600\n"
499 "UnpublishFeatures\t\t1800\n"
500 "RemoveFiles\t\t3500\n"
501 "InstallFiles\t\t4000\n"
502 "RegisterProduct\t\t6100\n"
503 "PublishFeatures\t\t6300\n"
504 "PublishProduct\t\t6400\n"
505 "InstallFinalize\t\t6600";
507 static const char media_dat
[] =
508 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
509 "i2\ti4\tL64\tS255\tS32\tS72\n"
511 "1\t1\t\t\tDISK1\t\n";
513 static const char property_dat
[] =
516 "Property\tProperty\n"
518 "Manufacturer\tWine\n"
519 "ProductCode\t{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}\n"
520 "ProductName\tMSITEST\n"
521 "ProductVersion\t1.1.1\n"
522 "UpgradeCode\t{9574448F-9B86-4E07-B6F6-8D199DA12127}\n"
523 "MSIFASTINSTALL\t1\n";
525 static const char mcp_component_dat
[] =
526 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
527 "s72\tS38\ts72\ti2\tS255\tS72\n"
528 "Component\tComponent\n"
529 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
530 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
531 "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";
533 static const char mcp_feature_dat
[] =
534 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
535 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
537 "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
538 "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
539 "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";
541 static const char mcp_feature_comp_dat
[] =
542 "Feature_\tComponent_\n"
544 "FeatureComponents\tFeature_\tComponent_\n"
545 "hydroxyl\thydrogen\n"
549 static const char mcp_file_dat
[] =
550 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
551 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
553 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
554 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
555 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
557 static const char lus_component_dat
[] =
558 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
559 "s72\tS38\ts72\ti2\tS255\tS72\n"
560 "Component\tComponent\n"
561 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
563 static const char lus_feature_dat
[] =
564 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
565 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
567 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
568 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
570 static const char lus_file_dat
[] =
571 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
572 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
574 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
576 static const char lus_feature_comp_dat
[] =
577 "Feature_\tComponent_\n"
579 "FeatureComponents\tFeature_\tComponent_\n"
581 "montecristo\tmaximus";
583 static const char lus_install_exec_seq_dat
[] =
584 "Action\tCondition\tSequence\n"
586 "InstallExecuteSequence\tAction\n"
587 "ValidateProductID\t\t700\n"
588 "CostInitialize\t\t800\n"
590 "CostFinalize\t\t1000\n"
591 "InstallValidate\t\t1400\n"
592 "InstallInitialize\t\t1500\n"
593 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
594 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
595 "RemoveFiles\t\t3500\n"
596 "InstallFiles\t\t4000\n"
597 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
598 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
599 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
600 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
601 "InstallFinalize\t\t6600";
603 static const char lus0_media_dat
[] =
604 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
605 "i2\ti4\tL64\tS255\tS32\tS72\n"
607 "1\t1\t\t\tDISK1\t\n";
609 static const char lus1_media_dat
[] =
610 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
611 "i2\ti4\tL64\tS255\tS32\tS72\n"
613 "1\t1\t\ttest1.cab\tDISK1\t\n";
615 static const char lus2_media_dat
[] =
616 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
617 "i2\ti4\tL64\tS255\tS32\tS72\n"
619 "1\t1\t\t#test1.cab\tDISK1\t\n";
621 static const char spf_custom_action_dat
[] =
622 "Action\tType\tSource\tTarget\tISComments\n"
623 "s72\ti2\tS64\tS0\tS255\n"
624 "CustomAction\tAction\n"
625 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
627 static const char spf_install_exec_seq_dat
[] =
628 "Action\tCondition\tSequence\n"
630 "InstallExecuteSequence\tAction\n"
631 "CostFinalize\t\t1000\n"
632 "CostInitialize\t\t800\n"
634 "SetFolderProp\t\t950\n"
635 "InstallFiles\t\t4000\n"
636 "InstallServices\t\t5000\n"
637 "InstallFinalize\t\t6600\n"
638 "InstallInitialize\t\t1500\n"
639 "InstallValidate\t\t1400\n"
640 "LaunchConditions\t\t100";
642 static const char spf_install_ui_seq_dat
[] =
643 "Action\tCondition\tSequence\n"
645 "InstallUISequence\tAction\n"
646 "CostInitialize\t\t800\n"
648 "CostFinalize\t\t1000\n"
649 "ExecuteAction\t\t1100\n";
651 static const char sd_file_dat
[] =
652 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
653 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
655 "sourcedir.txt\tsourcedir\tsourcedir.txt\t1000\t\t\t8192\t1\n";
657 static const char sd_feature_dat
[] =
658 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
659 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
661 "sourcedir\t\t\tsourcedir feature\t1\t2\tMSITESTDIR\t0\n";
663 static const char sd_feature_comp_dat
[] =
664 "Feature_\tComponent_\n"
666 "FeatureComponents\tFeature_\tComponent_\n"
667 "sourcedir\tsourcedir\n";
669 static const char sd_component_dat
[] =
670 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
671 "s72\tS38\ts72\ti2\tS255\tS72\n"
672 "Component\tComponent\n"
673 "sourcedir\t{DD422F92-3ED8-49B5-A0B7-F266F98357DF}\tMSITESTDIR\t0\t\tsourcedir.txt\n";
675 static const char sd_install_ui_seq_dat
[] =
676 "Action\tCondition\tSequence\n"
678 "InstallUISequence\tAction\n"
679 "TestSourceDirProp1\tnot SourceDir and not SOURCEDIR and not Installed\t99\n"
681 "TestSourceDirProp2\tnot SourceDir and not SOURCEDIR and not Installed\t101\n"
682 "LaunchConditions\tnot Installed \t110\n"
683 "TestSourceDirProp3\tnot SourceDir and not SOURCEDIR and not Installed\t111\n"
684 "FindRelatedProducts\t\t120\n"
685 "TestSourceDirProp4\tnot SourceDir and not SOURCEDIR and not Installed\t121\n"
687 "TestSourceDirProp5\tnot SourceDir and not SOURCEDIR and not Installed\t131\n"
688 "RMCCPSearch\t\t140\n"
689 "TestSourceDirProp6\tnot SourceDir and not SOURCEDIR and not Installed\t141\n"
690 "ValidateProductID\t\t150\n"
691 "TestSourceDirProp7\tnot SourceDir and not SOURCEDIR and not Installed\t151\n"
692 "CostInitialize\t\t800\n"
693 "TestSourceDirProp8\tnot SourceDir and not SOURCEDIR and not Installed\t801\n"
695 "TestSourceDirProp9\tnot SourceDir and not SOURCEDIR and not Installed\t901\n"
696 "IsolateComponents\t\t1000\n"
697 "TestSourceDirProp10\tnot SourceDir and not SOURCEDIR and not Installed\t1001\n"
698 "CostFinalize\t\t1100\n"
699 "TestSourceDirProp11\tnot SourceDir and not SOURCEDIR and not Installed\t1101\n"
700 "MigrateFeatureStates\t\t1200\n"
701 "TestSourceDirProp12\tnot SourceDir and not SOURCEDIR and not Installed\t1201\n"
702 "ExecuteAction\t\t1300\n"
703 "TestSourceDirProp13\tnot SourceDir and not SOURCEDIR and not Installed\t1301\n";
705 static const char sd_install_exec_seq_dat
[] =
706 "Action\tCondition\tSequence\n"
708 "InstallExecuteSequence\tAction\n"
709 "TestSourceDirProp14\tSourceDir and SOURCEDIR and not Installed\t99\n"
710 "LaunchConditions\t\t100\n"
711 "TestSourceDirProp15\tSourceDir and SOURCEDIR and not Installed\t101\n"
712 "ValidateProductID\t\t700\n"
713 "TestSourceDirProp16\tSourceDir and SOURCEDIR and not Installed\t701\n"
714 "CostInitialize\t\t800\n"
715 "TestSourceDirProp17\tSourceDir and SOURCEDIR and not Installed\t801\n"
716 "ResolveSource\tResolveSource and not Installed\t850\n"
717 "TestSourceDirProp18\tResolveSource and not SourceDir and not SOURCEDIR and not Installed\t851\n"
718 "TestSourceDirProp19\tnot ResolveSource and SourceDir and SOURCEDIR and not Installed\t852\n"
720 "TestSourceDirProp20\tSourceDir and SOURCEDIR and not Installed\t901\n"
721 "IsolateComponents\t\t1000\n"
722 "TestSourceDirProp21\tSourceDir and SOURCEDIR and not Installed\t1001\n"
723 "CostFinalize\t\t1100\n"
724 "TestSourceDirProp22\tSourceDir and SOURCEDIR and not Installed\t1101\n"
725 "MigrateFeatureStates\t\t1200\n"
726 "TestSourceDirProp23\tSourceDir and SOURCEDIR and not Installed\t1201\n"
727 "InstallValidate\t\t1400\n"
728 "TestSourceDirProp24\tSourceDir and SOURCEDIR and not Installed\t1401\n"
729 "InstallInitialize\t\t1500\n"
730 "TestSourceDirProp25\tSourceDir and SOURCEDIR and not Installed\t1501\n"
731 "ProcessComponents\t\t1600\n"
732 "TestSourceDirProp26\tnot SourceDir and not SOURCEDIR and not Installed\t1601\n"
733 "UnpublishFeatures\t\t1800\n"
734 "TestSourceDirProp27\tnot SourceDir and not SOURCEDIR and not Installed\t1801\n"
735 "RemoveFiles\t\t3500\n"
736 "TestSourceDirProp28\tnot SourceDir and not SOURCEDIR and not Installed\t3501\n"
737 "InstallFiles\t\t4000\n"
738 "TestSourceDirProp29\tnot SourceDir and not SOURCEDIR and not Installed\t4001\n"
739 "RegisterUser\t\t6000\n"
740 "TestSourceDirProp30\tnot SourceDir and not SOURCEDIR and not Installed\t6001\n"
741 "RegisterProduct\t\t6100\n"
742 "TestSourceDirProp31\tnot SourceDir and not SOURCEDIR and not Installed\t6101\n"
743 "PublishFeatures\t\t6300\n"
744 "TestSourceDirProp32\tnot SourceDir and not SOURCEDIR and not Installed\t6301\n"
745 "PublishProduct\t\t6400\n"
746 "TestSourceDirProp33\tnot SourceDir and not SOURCEDIR and not Installed\t6401\n"
747 "InstallExecute\t\t6500\n"
748 "TestSourceDirProp34\tnot SourceDir and not SOURCEDIR and not Installed\t6501\n"
749 "InstallFinalize\t\t6600\n"
750 "TestSourceDirProp35\tnot SourceDir and not SOURCEDIR and not Installed\t6601\n";
752 static const char sd_custom_action_dat
[] =
753 "Action\tType\tSource\tTarget\tISComments\n"
754 "s72\ti2\tS64\tS0\tS255\n"
755 "CustomAction\tAction\n"
756 "TestSourceDirProp1\t19\t\tTest 1 failed\t\n"
757 "TestSourceDirProp2\t19\t\tTest 2 failed\t\n"
758 "TestSourceDirProp3\t19\t\tTest 3 failed\t\n"
759 "TestSourceDirProp4\t19\t\tTest 4 failed\t\n"
760 "TestSourceDirProp5\t19\t\tTest 5 failed\t\n"
761 "TestSourceDirProp6\t19\t\tTest 6 failed\t\n"
762 "TestSourceDirProp7\t19\t\tTest 7 failed\t\n"
763 "TestSourceDirProp8\t19\t\tTest 8 failed\t\n"
764 "TestSourceDirProp9\t19\t\tTest 9 failed\t\n"
765 "TestSourceDirProp10\t19\t\tTest 10 failed\t\n"
766 "TestSourceDirProp11\t19\t\tTest 11 failed\t\n"
767 "TestSourceDirProp12\t19\t\tTest 12 failed\t\n"
768 "TestSourceDirProp13\t19\t\tTest 13 failed\t\n"
769 "TestSourceDirProp14\t19\t\tTest 14 failed\t\n"
770 "TestSourceDirProp15\t19\t\tTest 15 failed\t\n"
771 "TestSourceDirProp16\t19\t\tTest 16 failed\t\n"
772 "TestSourceDirProp17\t19\t\tTest 17 failed\t\n"
773 "TestSourceDirProp18\t19\t\tTest 18 failed\t\n"
774 "TestSourceDirProp19\t19\t\tTest 19 failed\t\n"
775 "TestSourceDirProp20\t19\t\tTest 20 failed\t\n"
776 "TestSourceDirProp21\t19\t\tTest 21 failed\t\n"
777 "TestSourceDirProp22\t19\t\tTest 22 failed\t\n"
778 "TestSourceDirProp23\t19\t\tTest 23 failed\t\n"
779 "TestSourceDirProp24\t19\t\tTest 24 failed\t\n"
780 "TestSourceDirProp25\t19\t\tTest 25 failed\t\n"
781 "TestSourceDirProp26\t19\t\tTest 26 failed\t\n"
782 "TestSourceDirProp27\t19\t\tTest 27 failed\t\n"
783 "TestSourceDirProp28\t19\t\tTest 28 failed\t\n"
784 "TestSourceDirProp29\t19\t\tTest 29 failed\t\n"
785 "TestSourceDirProp30\t19\t\tTest 30 failed\t\n"
786 "TestSourceDirProp31\t19\t\tTest 31 failed\t\n"
787 "TestSourceDirProp32\t19\t\tTest 32 failed\t\n"
788 "TestSourceDirProp33\t19\t\tTest 33 failed\t\n"
789 "TestSourceDirProp34\t19\t\tTest 34 failed\t\n"
790 "TestSourceDirProp35\t19\t\tTest 35 failed\t\n";
792 static const char ci_install_exec_seq_dat
[] =
793 "Action\tCondition\tSequence\n"
795 "InstallExecuteSequence\tAction\n"
796 "CostFinalize\t\t1000\n"
797 "CostInitialize\t\t800\n"
799 "InstallFiles\t\t4000\n"
800 "InstallServices\t\t5000\n"
801 "InstallFinalize\t\t6600\n"
802 "InstallInitialize\t\t1500\n"
803 "RunInstall\t\t1600\n"
804 "InstallValidate\t\t1400\n"
805 "LaunchConditions\t\t100";
807 static const char ci_custom_action_dat
[] =
808 "Action\tType\tSource\tTarget\tISComments\n"
809 "s72\ti2\tS64\tS0\tS255\n"
810 "CustomAction\tAction\n"
811 "RunInstall\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
813 static const char ci_component_dat
[] =
814 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
815 "s72\tS38\ts72\ti2\tS255\tS72\n"
816 "Component\tComponent\n"
817 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
819 static const char ci2_component_dat
[] =
820 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
821 "s72\tS38\ts72\ti2\tS255\tS72\n"
822 "Component\tComponent\n"
823 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
825 static const char ci2_feature_comp_dat
[] =
826 "Feature_\tComponent_\n"
828 "FeatureComponents\tFeature_\tComponent_\n"
831 static const char ci2_file_dat
[] =
832 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
833 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
835 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
837 static const char cl_custom_action_dat
[] =
838 "Action\tType\tSource\tTarget\tISComments\n"
839 "s72\ti2\tS64\tS0\tS255\n"
840 "CustomAction\tAction\n"
841 "TestCommandlineProp\t19\t\tTest1\t\n";
843 static const char cl_install_exec_seq_dat
[] =
844 "Action\tCondition\tSequence\n"
846 "InstallExecuteSequence\tAction\n"
847 "LaunchConditions\t\t100\n"
848 "ValidateProductID\t\t700\n"
849 "CostInitialize\t\t800\n"
851 "CostFinalize\t\t1000\n"
852 "TestCommandlineProp\tP=\"one\"\t1100\n"
853 "InstallInitialize\t\t1500\n"
854 "ProcessComponents\t\t1600\n"
855 "InstallValidate\t\t1400\n"
856 "InstallFinalize\t\t5000\n";
858 typedef struct _msi_table
860 const CHAR
*filename
;
865 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
867 static const msi_table tables
[] =
869 ADD_TABLE(directory
),
870 ADD_TABLE(component
),
872 ADD_TABLE(feature_comp
),
874 ADD_TABLE(install_exec_seq
),
879 static const msi_table mcp_tables
[] =
881 ADD_TABLE(directory
),
882 ADD_TABLE(mcp_component
),
883 ADD_TABLE(mcp_feature
),
884 ADD_TABLE(mcp_feature_comp
),
886 ADD_TABLE(install_exec_seq
),
891 static const msi_table lus0_tables
[] =
893 ADD_TABLE(lus_component
),
894 ADD_TABLE(directory
),
895 ADD_TABLE(lus_feature
),
896 ADD_TABLE(lus_feature_comp
),
898 ADD_TABLE(lus_install_exec_seq
),
899 ADD_TABLE(lus0_media
),
903 static const msi_table lus1_tables
[] =
905 ADD_TABLE(lus_component
),
906 ADD_TABLE(directory
),
907 ADD_TABLE(lus_feature
),
908 ADD_TABLE(lus_feature_comp
),
910 ADD_TABLE(lus_install_exec_seq
),
911 ADD_TABLE(lus1_media
),
915 static const msi_table lus2_tables
[] =
917 ADD_TABLE(lus_component
),
918 ADD_TABLE(directory
),
919 ADD_TABLE(lus_feature
),
920 ADD_TABLE(lus_feature_comp
),
922 ADD_TABLE(lus_install_exec_seq
),
923 ADD_TABLE(lus2_media
),
927 static const msi_table spf_tables
[] =
929 ADD_TABLE(lus_component
),
930 ADD_TABLE(directory
),
931 ADD_TABLE(lus_feature
),
932 ADD_TABLE(lus_feature_comp
),
934 ADD_TABLE(lus0_media
),
936 ADD_TABLE(spf_custom_action
),
937 ADD_TABLE(spf_install_exec_seq
),
938 ADD_TABLE(spf_install_ui_seq
)
941 static const msi_table sd_tables
[] =
943 ADD_TABLE(directory
),
944 ADD_TABLE(sd_component
),
945 ADD_TABLE(sd_feature
),
946 ADD_TABLE(sd_feature_comp
),
948 ADD_TABLE(sd_install_exec_seq
),
949 ADD_TABLE(sd_install_ui_seq
),
950 ADD_TABLE(sd_custom_action
),
955 static const msi_table ci_tables
[] =
957 ADD_TABLE(ci_component
),
958 ADD_TABLE(directory
),
959 ADD_TABLE(lus_feature
),
960 ADD_TABLE(lus_feature_comp
),
962 ADD_TABLE(ci_install_exec_seq
),
963 ADD_TABLE(lus0_media
),
965 ADD_TABLE(ci_custom_action
),
968 static const msi_table ci2_tables
[] =
970 ADD_TABLE(ci2_component
),
971 ADD_TABLE(directory
),
972 ADD_TABLE(lus_feature
),
973 ADD_TABLE(ci2_feature_comp
),
975 ADD_TABLE(install_exec_seq
),
976 ADD_TABLE(lus0_media
),
980 static const msi_table cl_tables
[] =
982 ADD_TABLE(component
),
983 ADD_TABLE(directory
),
985 ADD_TABLE(feature_comp
),
987 ADD_TABLE(cl_custom_action
),
988 ADD_TABLE(cl_install_exec_seq
),
993 static void write_file(const CHAR
*filename
, const char *data
, int data_size
)
997 HANDLE hf
= CreateFile(filename
, GENERIC_WRITE
, 0, NULL
,
998 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1000 WriteFile(hf
, data
, data_size
, &size
, NULL
);
1004 static void write_msi_summary_info(MSIHANDLE db
, INT version
, INT wordcount
, const char *template)
1009 r
= MsiGetSummaryInformationA(db
, NULL
, 5, &summary
);
1010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1012 r
= MsiSummaryInfoSetPropertyA(summary
, PID_TEMPLATE
, VT_LPSTR
, 0, NULL
, template);
1013 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1015 r
= MsiSummaryInfoSetPropertyA(summary
, PID_REVNUMBER
, VT_LPSTR
, 0, NULL
,
1016 "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}");
1017 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1019 r
= MsiSummaryInfoSetPropertyA(summary
, PID_PAGECOUNT
, VT_I4
, version
, NULL
, NULL
);
1020 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1022 r
= MsiSummaryInfoSetPropertyA(summary
, PID_WORDCOUNT
, VT_I4
, wordcount
, NULL
, NULL
);
1023 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1025 r
= MsiSummaryInfoSetPropertyA(summary
, PID_TITLE
, VT_LPSTR
, 0, NULL
, "MSITEST");
1026 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1028 /* write the summary changes back to the stream */
1029 r
= MsiSummaryInfoPersist(summary
);
1030 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1032 MsiCloseHandle(summary
);
1035 #define create_database(name, tables, num_tables) \
1036 create_database_wordcount(name, tables, num_tables, 100, 0, ";1033");
1038 #define create_database_template(name, tables, num_tables, version, template) \
1039 create_database_wordcount(name, tables, num_tables, version, 0, template);
1041 static void create_database_wordcount(const CHAR
*name
, const msi_table
*tables
,
1042 int num_tables
, INT version
, INT wordcount
,
1043 const char *template)
1049 r
= MsiOpenDatabaseA(name
, MSIDBOPEN_CREATE
, &db
);
1050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1052 /* import the tables into the database */
1053 for (j
= 0; j
< num_tables
; j
++)
1055 const msi_table
*table
= &tables
[j
];
1057 write_file(table
->filename
, table
->data
, (table
->size
- 1) * sizeof(char));
1059 r
= MsiDatabaseImportA(db
, CURR_DIR
, table
->filename
);
1060 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1062 DeleteFileA(table
->filename
);
1065 write_msi_summary_info(db
, version
, wordcount
, template);
1067 r
= MsiDatabaseCommit(db
);
1068 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1073 static UINT
run_query(MSIHANDLE hdb
, const char *query
)
1075 MSIHANDLE hview
= 0;
1078 r
= MsiDatabaseOpenView(hdb
, query
, &hview
);
1079 if (r
!= ERROR_SUCCESS
)
1082 r
= MsiViewExecute(hview
, 0);
1083 if (r
== ERROR_SUCCESS
)
1084 r
= MsiViewClose(hview
);
1085 MsiCloseHandle(hview
);
1089 static UINT
set_summary_info(MSIHANDLE hdb
, LPSTR prodcode
)
1094 /* build summary info */
1095 res
= MsiGetSummaryInformation(hdb
, NULL
, 7, &suminfo
);
1096 ok(res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n");
1098 res
= MsiSummaryInfoSetProperty(suminfo
, 2, VT_LPSTR
, 0, NULL
,
1099 "Installation Database");
1100 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1102 res
= MsiSummaryInfoSetProperty(suminfo
, 3, VT_LPSTR
, 0, NULL
,
1103 "Installation Database");
1104 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1106 res
= MsiSummaryInfoSetProperty(suminfo
, 4, VT_LPSTR
, 0, NULL
,
1108 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1110 res
= MsiSummaryInfoSetProperty(suminfo
, 7, VT_LPSTR
, 0, NULL
,
1112 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1114 res
= MsiSummaryInfoSetProperty(suminfo
, PID_REVNUMBER
, VT_LPSTR
, 0, NULL
,
1115 "{A2078D65-94D6-4205-8DEE-F68D6FD622AA}");
1116 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1118 res
= MsiSummaryInfoSetProperty(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
1119 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1121 res
= MsiSummaryInfoSetProperty(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
1122 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1124 res
= MsiSummaryInfoPersist(suminfo
);
1125 ok(res
== ERROR_SUCCESS
, "Failed to make summary info persist\n");
1127 res
= MsiCloseHandle(suminfo
);
1128 ok(res
== ERROR_SUCCESS
, "Failed to close suminfo\n");
1133 static MSIHANDLE
create_package_db(LPSTR prodcode
)
1136 CHAR query
[MAX_PATH
];
1139 DeleteFile(msifile
);
1141 /* create an empty database */
1142 res
= MsiOpenDatabase(msifile
, MSIDBOPEN_CREATE
, &hdb
);
1143 ok( res
== ERROR_SUCCESS
, "Failed to create database\n" );
1144 if (res
!= ERROR_SUCCESS
)
1147 res
= MsiDatabaseCommit(hdb
);
1148 ok(res
== ERROR_SUCCESS
, "Failed to commit database\n");
1150 set_summary_info(hdb
, prodcode
);
1152 res
= run_query(hdb
,
1153 "CREATE TABLE `Directory` ( "
1154 "`Directory` CHAR(255) NOT NULL, "
1155 "`Directory_Parent` CHAR(255), "
1156 "`DefaultDir` CHAR(255) NOT NULL "
1157 "PRIMARY KEY `Directory`)");
1158 ok(res
== ERROR_SUCCESS
, "Failed to create directory table\n");
1160 res
= run_query(hdb
,
1161 "CREATE TABLE `Property` ( "
1162 "`Property` CHAR(72) NOT NULL, "
1163 "`Value` CHAR(255) "
1164 "PRIMARY KEY `Property`)");
1165 ok(res
== ERROR_SUCCESS
, "Failed to create directory table\n");
1167 sprintf(query
, "INSERT INTO `Property` "
1168 "(`Property`, `Value`) "
1169 "VALUES( 'ProductCode', '%s' )", prodcode
);
1170 res
= run_query(hdb
, query
);
1171 ok(res
== ERROR_SUCCESS
, "Failed\n");
1173 res
= MsiDatabaseCommit(hdb
);
1174 ok(res
== ERROR_SUCCESS
, "Failed to commit database\n");
1179 static void test_usefeature(void)
1183 if (!pMsiUseFeatureExA
)
1185 win_skip("MsiUseFeatureExA not implemented\n");
1189 r
= MsiQueryFeatureState(NULL
,NULL
);
1190 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1192 r
= MsiQueryFeatureState("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL
);
1193 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1195 r
= pMsiUseFeatureExA(NULL
,NULL
,0,0);
1196 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1198 r
= pMsiUseFeatureExA(NULL
, "WORDVIEWFiles", -2, 1 );
1199 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1201 r
= pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
1203 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1205 r
= pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
1206 "WORDVIEWFiles", -2, 0 );
1207 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1209 r
= pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
1210 "WORDVIEWFiles", -2, 0 );
1211 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1213 r
= pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
1214 "WORDVIEWFiles", -2, 1 );
1215 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1218 static LONG
delete_key( HKEY key
, LPCSTR subkey
, REGSAM access
)
1220 if (pRegDeleteKeyExA
)
1221 return pRegDeleteKeyExA( key
, subkey
, access
, 0 );
1222 return RegDeleteKeyA( key
, subkey
);
1225 static void test_null(void)
1230 DWORD dwType
, cbData
;
1231 LPBYTE lpData
= NULL
;
1233 REGSAM access
= KEY_ALL_ACCESS
;
1236 access
|= KEY_WOW64_64KEY
;
1238 r
= pMsiOpenPackageExW(NULL
, 0, &hpkg
);
1239 ok( r
== ERROR_INVALID_PARAMETER
,"wrong error\n");
1241 state
= MsiQueryProductStateW(NULL
);
1242 ok( state
== INSTALLSTATE_INVALIDARG
, "wrong return\n");
1244 r
= MsiEnumFeaturesW(NULL
,0,NULL
,NULL
);
1245 ok( r
== ERROR_INVALID_PARAMETER
,"wrong error\n");
1247 r
= MsiConfigureFeatureW(NULL
, NULL
, 0);
1248 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error\n");
1250 r
= MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL
, 0);
1251 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error\n");
1253 r
= MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000001}", "foo", 0);
1254 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error %d\n", r
);
1256 r
= MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000002}", "foo", INSTALLSTATE_DEFAULT
);
1257 ok( r
== ERROR_UNKNOWN_PRODUCT
, "wrong error %d\n", r
);
1259 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
1260 * necessary registry values */
1262 /* empty product string */
1263 r
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, access
, &hkey
);
1264 if (r
== ERROR_ACCESS_DENIED
)
1266 skip("Not enough rights to perform tests\n");
1269 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1271 r
= RegQueryValueExA(hkey
, NULL
, 0, &dwType
, lpData
, &cbData
);
1272 ok ( r
== ERROR_SUCCESS
|| r
== ERROR_FILE_NOT_FOUND
, "wrong error %d\n", r
);
1273 if ( r
== ERROR_SUCCESS
)
1275 lpData
= HeapAlloc(GetProcessHeap(), 0, cbData
);
1277 skip("Out of memory\n");
1280 r
= RegQueryValueExA(hkey
, NULL
, 0, &dwType
, lpData
, &cbData
);
1281 ok ( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1285 r
= RegSetValueA(hkey
, NULL
, REG_SZ
, "test", strlen("test"));
1286 if (r
== ERROR_ACCESS_DENIED
)
1288 skip("Not enough rights to perform tests\n");
1289 HeapFree(GetProcessHeap(), 0, lpData
);
1293 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1295 r
= MsiGetProductInfoA("", "", NULL
, NULL
);
1296 ok ( r
== ERROR_INVALID_PARAMETER
, "wrong error %d\n", r
);
1300 r
= RegSetValueExA(hkey
, NULL
, 0, dwType
, lpData
, cbData
);
1301 ok ( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1303 HeapFree(GetProcessHeap(), 0, lpData
);
1307 r
= RegDeleteValueA(hkey
, NULL
);
1308 ok ( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1311 r
= RegCloseKey(hkey
);
1312 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1314 /* empty attribute */
1315 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1316 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
1317 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1319 r
= RegSetValueA(hkey
, NULL
, REG_SZ
, "test", strlen("test"));
1320 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1322 r
= MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL
, NULL
);
1323 ok ( r
== ERROR_UNKNOWN_PROPERTY
, "wrong error %d\n", r
);
1325 r
= RegCloseKey(hkey
);
1326 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1328 r
= delete_key(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1329 access
& KEY_WOW64_64KEY
);
1330 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1333 static void test_getcomponentpath(void)
1339 if(!pMsiGetComponentPathA
)
1342 r
= pMsiGetComponentPathA( NULL
, NULL
, NULL
, NULL
);
1343 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1345 r
= pMsiGetComponentPathA( "bogus", "bogus", NULL
, NULL
);
1346 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1348 r
= pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL
, NULL
);
1349 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1353 r
= pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer
, &sz
);
1354 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1356 r
= pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
1357 "{00000000-0000-0000-0000-000000000000}", buffer
, &sz
);
1358 ok( r
== INSTALLSTATE_UNKNOWN
, "wrong return value\n");
1360 r
= pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1361 "{00000000-0000-0000-0000-00000000}", buffer
, &sz
);
1362 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1364 r
= pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1365 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer
, &sz
);
1366 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1368 r
= pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
1369 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer
, &sz
);
1370 ok( r
== INSTALLSTATE_UNKNOWN
, "wrong return value\n");
1373 static void create_file(LPCSTR name
, LPCSTR data
, DWORD size
)
1378 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1379 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
1380 WriteFile(file
, data
, strlen(data
), &written
, NULL
);
1384 SetFilePointer(file
, size
, NULL
, FILE_BEGIN
);
1391 static void create_test_files(void)
1393 CreateDirectoryA("msitest", NULL
);
1394 create_file("msitest\\one.txt", "msitest\\one.txt", 100);
1395 CreateDirectoryA("msitest\\first", NULL
);
1396 create_file("msitest\\first\\two.txt", "msitest\\first\\two.txt", 100);
1397 CreateDirectoryA("msitest\\second", NULL
);
1398 create_file("msitest\\second\\three.txt", "msitest\\second\\three.txt", 100);
1400 create_file("four.txt", "four.txt", 100);
1401 create_file("five.txt", "five.txt", 100);
1402 create_cab_file("msitest.cab", MEDIA_SIZE
, "four.txt\0five.txt\0");
1404 create_file("msitest\\filename", "msitest\\filename", 100);
1405 create_file("msitest\\service.exe", "msitest\\service.exe", 100);
1407 DeleteFileA("four.txt");
1408 DeleteFileA("five.txt");
1411 static void delete_test_files(void)
1413 DeleteFileA("msitest.msi");
1414 DeleteFileA("msitest.cab");
1415 DeleteFileA("msitest\\second\\three.txt");
1416 DeleteFileA("msitest\\first\\two.txt");
1417 DeleteFileA("msitest\\one.txt");
1418 DeleteFileA("msitest\\service.exe");
1419 DeleteFileA("msitest\\filename");
1420 RemoveDirectoryA("msitest\\second");
1421 RemoveDirectoryA("msitest\\first");
1422 RemoveDirectoryA("msitest");
1425 #define HASHSIZE sizeof(MSIFILEHASHINFO)
1431 MSIFILEHASHINFO hash
;
1442 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
1446 { "C:\\Program Files\\msitest\\caesar\n", 0,
1448 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
1452 { "C:\\Program Files\\msitest\\caesar\n", 500,
1454 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
1459 static void test_MsiGetFileHash(void)
1461 const char name
[] = "msitest.bin";
1463 MSIFILEHASHINFO hash
;
1466 if (!pMsiGetFileHashA
)
1468 win_skip("MsiGetFileHash not implemented\n");
1472 hash
.dwFileHashInfoSize
= sizeof(MSIFILEHASHINFO
);
1474 /* szFilePath is NULL */
1475 r
= pMsiGetFileHashA(NULL
, 0, &hash
);
1476 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1478 /* szFilePath is empty */
1479 r
= pMsiGetFileHashA("", 0, &hash
);
1480 ok(r
== ERROR_PATH_NOT_FOUND
|| r
== ERROR_BAD_PATHNAME
,
1481 "Expected ERROR_PATH_NOT_FOUND or ERROR_BAD_PATHNAME, got %d\n", r
);
1483 /* szFilePath is nonexistent */
1484 r
= pMsiGetFileHashA(name
, 0, &hash
);
1485 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
1487 /* dwOptions is non-zero */
1488 r
= pMsiGetFileHashA(name
, 1, &hash
);
1489 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1491 /* pHash.dwFileHashInfoSize is not correct */
1492 hash
.dwFileHashInfoSize
= 0;
1493 r
= pMsiGetFileHashA(name
, 0, &hash
);
1494 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1497 r
= pMsiGetFileHashA(name
, 0, NULL
);
1498 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1500 for (i
= 0; i
< sizeof(hash_data
) / sizeof(hash_data
[0]); i
++)
1504 create_file(name
, hash_data
[i
].data
, hash_data
[i
].size
);
1506 memset(&hash
, 0, sizeof(MSIFILEHASHINFO
));
1507 hash
.dwFileHashInfoSize
= sizeof(MSIFILEHASHINFO
);
1509 r
= pMsiGetFileHashA(name
, 0, &hash
);
1510 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1512 ret
= memcmp(&hash
, &hash_data
[i
].hash
, HASHSIZE
);
1513 ok(!ret
, "Hash incorrect\n");
1519 /* copied from dlls/msi/registry.c */
1520 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
1525 if (FAILED(CLSIDFromString((LPCOLESTR
)in
, &guid
)))
1532 out
[11-i
] = in
[n
++];
1535 out
[15-i
] = in
[n
++];
1539 out
[17+i
*2] = in
[n
++];
1540 out
[16+i
*2] = in
[n
++];
1545 out
[17+i
*2] = in
[n
++];
1546 out
[16+i
*2] = in
[n
++];
1552 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
1554 WCHAR guidW
[MAX_PATH
];
1555 WCHAR squashedW
[MAX_PATH
];
1560 hr
= CoCreateGuid(&guid
);
1561 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
1563 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
1564 ok(size
== 39, "Expected 39, got %d\n", hr
);
1566 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
1569 squash_guid(guidW
, squashedW
);
1570 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
1574 static char *get_user_sid(void)
1579 char *usersid
= NULL
;
1581 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
1582 GetTokenInformation(token
, TokenUser
, NULL
, size
, &size
);
1584 user
= HeapAlloc(GetProcessHeap(), 0, size
);
1585 GetTokenInformation(token
, TokenUser
, user
, size
, &size
);
1586 pConvertSidToStringSidA(user
->User
.Sid
, &usersid
);
1587 HeapFree(GetProcessHeap(), 0, user
);
1593 static void test_MsiQueryProductState(void)
1595 CHAR prodcode
[MAX_PATH
];
1596 CHAR prod_squashed
[MAX_PATH
];
1597 CHAR keypath
[MAX_PATH
*2];
1601 HKEY userkey
, localkey
, props
;
1604 REGSAM access
= KEY_ALL_ACCESS
;
1606 create_test_guid(prodcode
, prod_squashed
);
1607 usersid
= get_user_sid();
1610 access
|= KEY_WOW64_64KEY
;
1613 SetLastError(0xdeadbeef);
1614 state
= MsiQueryProductStateA(NULL
);
1615 error
= GetLastError();
1616 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1617 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1619 /* empty prodcode */
1620 SetLastError(0xdeadbeef);
1621 state
= MsiQueryProductStateA("");
1622 error
= GetLastError();
1623 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1624 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1626 /* garbage prodcode */
1627 SetLastError(0xdeadbeef);
1628 state
= MsiQueryProductStateA("garbage");
1629 error
= GetLastError();
1630 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1631 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1633 /* guid without brackets */
1634 SetLastError(0xdeadbeef);
1635 state
= MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
1636 error
= GetLastError();
1637 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1638 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1640 /* guid with brackets */
1641 SetLastError(0xdeadbeef);
1642 state
= MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
1643 error
= GetLastError();
1644 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1645 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1646 "expected ERROR_SUCCESS, got %u\n", error
);
1648 /* same length as guid, but random */
1649 SetLastError(0xdeadbeef);
1650 state
= MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
1651 error
= GetLastError();
1652 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1653 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1655 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1657 SetLastError(0xdeadbeef);
1658 state
= MsiQueryProductStateA(prodcode
);
1659 error
= GetLastError();
1660 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1661 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1662 "expected ERROR_SUCCESS, got %u\n", error
);
1664 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
1665 lstrcatA(keypath
, prod_squashed
);
1667 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
1668 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1670 /* user product key exists */
1671 SetLastError(0xdeadbeef);
1672 state
= MsiQueryProductStateA(prodcode
);
1673 error
= GetLastError();
1674 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1675 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1676 "expected ERROR_SUCCESS, got %u\n", error
);
1678 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
1679 lstrcatA(keypath
, prodcode
);
1681 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1682 if (res
== ERROR_ACCESS_DENIED
)
1684 skip("Not enough rights to perform tests\n");
1685 RegDeleteKeyA(userkey
, "");
1689 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1691 /* local uninstall key exists */
1692 SetLastError(0xdeadbeef);
1693 state
= MsiQueryProductStateA(prodcode
);
1694 error
= GetLastError();
1695 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1696 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1697 "expected ERROR_SUCCESS, got %u\n", error
);
1700 res
= RegSetValueExA(localkey
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1701 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1703 /* WindowsInstaller value exists */
1704 SetLastError(0xdeadbeef);
1705 state
= MsiQueryProductStateA(prodcode
);
1706 error
= GetLastError();
1707 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1708 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1709 "expected ERROR_SUCCESS, got %u\n", error
);
1711 RegDeleteValueA(localkey
, "WindowsInstaller");
1712 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1714 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1715 lstrcatA(keypath
, usersid
);
1716 lstrcatA(keypath
, "\\Products\\");
1717 lstrcatA(keypath
, prod_squashed
);
1719 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1720 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1722 /* local product key exists */
1723 SetLastError(0xdeadbeef);
1724 state
= MsiQueryProductStateA(prodcode
);
1725 error
= GetLastError();
1726 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1727 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1728 "expected ERROR_SUCCESS, got %u\n", error
);
1730 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
1731 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1733 /* install properties key exists */
1734 SetLastError(0xdeadbeef);
1735 state
= MsiQueryProductStateA(prodcode
);
1736 error
= GetLastError();
1737 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1738 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1739 "expected ERROR_SUCCESS, got %u\n", error
);
1742 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1743 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1745 /* WindowsInstaller value exists */
1746 SetLastError(0xdeadbeef);
1747 state
= MsiQueryProductStateA(prodcode
);
1748 error
= GetLastError();
1749 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1750 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1751 "expected ERROR_SUCCESS, got %u\n", error
);
1754 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1755 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1757 /* WindowsInstaller value is not 1 */
1758 SetLastError(0xdeadbeef);
1759 state
= MsiQueryProductStateA(prodcode
);
1760 error
= GetLastError();
1761 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1762 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1763 "expected ERROR_SUCCESS, got %u\n", error
);
1765 RegDeleteKeyA(userkey
, "");
1767 /* user product key does not exist */
1768 SetLastError(0xdeadbeef);
1769 state
= MsiQueryProductStateA(prodcode
);
1770 error
= GetLastError();
1771 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1772 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1773 "expected ERROR_SUCCESS, got %u\n", error
);
1775 RegDeleteValueA(props
, "WindowsInstaller");
1776 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
1778 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1779 RegCloseKey(localkey
);
1780 RegDeleteKeyA(userkey
, "");
1781 RegCloseKey(userkey
);
1783 /* MSIINSTALLCONTEXT_USERMANAGED */
1785 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1786 lstrcatA(keypath
, usersid
);
1787 lstrcatA(keypath
, "\\Installer\\Products\\");
1788 lstrcatA(keypath
, prod_squashed
);
1790 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
1791 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1793 state
= MsiQueryProductStateA(prodcode
);
1794 ok(state
== INSTALLSTATE_ADVERTISED
,
1795 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1797 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1798 lstrcatA(keypath
, usersid
);
1799 lstrcatA(keypath
, "\\Products\\");
1800 lstrcatA(keypath
, prod_squashed
);
1802 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1803 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1805 state
= MsiQueryProductStateA(prodcode
);
1806 ok(state
== INSTALLSTATE_ADVERTISED
,
1807 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1809 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
1810 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1812 state
= MsiQueryProductStateA(prodcode
);
1813 ok(state
== INSTALLSTATE_ADVERTISED
,
1814 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1817 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1818 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1820 /* WindowsInstaller value exists */
1821 state
= MsiQueryProductStateA(prodcode
);
1822 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1824 RegDeleteValueA(props
, "WindowsInstaller");
1825 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
1827 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1828 RegCloseKey(localkey
);
1829 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
1830 RegCloseKey(prodkey
);
1832 /* MSIINSTALLCONTEXT_MACHINE */
1834 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
1835 lstrcatA(keypath
, prod_squashed
);
1837 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
1838 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1840 state
= MsiQueryProductStateA(prodcode
);
1841 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1843 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1844 lstrcatA(keypath
, "S-1-5-18\\Products\\");
1845 lstrcatA(keypath
, prod_squashed
);
1847 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1848 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1850 state
= MsiQueryProductStateA(prodcode
);
1851 ok(state
== INSTALLSTATE_ADVERTISED
,
1852 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1854 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
1855 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1857 state
= MsiQueryProductStateA(prodcode
);
1858 ok(state
== INSTALLSTATE_ADVERTISED
,
1859 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1862 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1863 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1865 /* WindowsInstaller value exists */
1866 state
= MsiQueryProductStateA(prodcode
);
1867 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1869 RegDeleteValueA(props
, "WindowsInstaller");
1870 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
1872 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1873 RegCloseKey(localkey
);
1874 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
1875 RegCloseKey(prodkey
);
1880 static const char table_enc85
[] =
1881 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
1882 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
1886 * Encodes a base85 guid given a GUID pointer
1887 * Caller should provide a 21 character buffer for the encoded string.
1889 static void encode_base85_guid( GUID
*guid
, LPWSTR str
)
1891 unsigned int x
, *p
, i
;
1893 p
= (unsigned int*) guid
;
1894 for( i
=0; i
<4; i
++ )
1897 *str
++ = table_enc85
[x
%85];
1899 *str
++ = table_enc85
[x
%85];
1901 *str
++ = table_enc85
[x
%85];
1903 *str
++ = table_enc85
[x
%85];
1905 *str
++ = table_enc85
[x
%85];
1910 static void compose_base85_guid(LPSTR component
, LPSTR comp_base85
, LPSTR squashed
)
1912 WCHAR guidW
[MAX_PATH
];
1913 WCHAR base85W
[MAX_PATH
];
1914 WCHAR squashedW
[MAX_PATH
];
1919 hr
= CoCreateGuid(&guid
);
1920 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
1922 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
1923 ok(size
== 39, "Expected 39, got %d\n", hr
);
1925 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, component
, MAX_PATH
, NULL
, NULL
);
1926 encode_base85_guid(&guid
, base85W
);
1927 WideCharToMultiByte(CP_ACP
, 0, base85W
, -1, comp_base85
, MAX_PATH
, NULL
, NULL
);
1928 squash_guid(guidW
, squashedW
);
1929 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
1932 static void test_MsiQueryFeatureState(void)
1934 HKEY userkey
, localkey
, compkey
, compkey2
;
1935 CHAR prodcode
[MAX_PATH
];
1936 CHAR prod_squashed
[MAX_PATH
];
1937 CHAR component
[MAX_PATH
];
1938 CHAR comp_base85
[MAX_PATH
];
1939 CHAR comp_squashed
[MAX_PATH
], comp_squashed2
[MAX_PATH
];
1940 CHAR keypath
[MAX_PATH
*2];
1944 REGSAM access
= KEY_ALL_ACCESS
;
1947 create_test_guid(prodcode
, prod_squashed
);
1948 compose_base85_guid(component
, comp_base85
, comp_squashed
);
1949 compose_base85_guid(component
, comp_base85
+ 20, comp_squashed2
);
1950 usersid
= get_user_sid();
1953 access
|= KEY_WOW64_64KEY
;
1956 SetLastError(0xdeadbeef);
1957 state
= MsiQueryFeatureStateA(NULL
, "feature");
1958 error
= GetLastError();
1959 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1960 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1962 /* empty prodcode */
1963 SetLastError(0xdeadbeef);
1964 state
= MsiQueryFeatureStateA("", "feature");
1965 error
= GetLastError();
1966 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1967 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1969 /* garbage prodcode */
1970 SetLastError(0xdeadbeef);
1971 state
= MsiQueryFeatureStateA("garbage", "feature");
1972 error
= GetLastError();
1973 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1974 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1976 /* guid without brackets */
1977 SetLastError(0xdeadbeef);
1978 state
= MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
1979 error
= GetLastError();
1980 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1981 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1983 /* guid with brackets */
1984 SetLastError(0xdeadbeef);
1985 state
= MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
1986 error
= GetLastError();
1987 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1988 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_ALREADY_EXISTS
) /* win2k */,
1989 "expected ERROR_SUCCESS, got %u\n", error
);
1991 /* same length as guid, but random */
1992 SetLastError(0xdeadbeef);
1993 state
= MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
1994 error
= GetLastError();
1995 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1996 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1998 /* NULL szFeature */
1999 SetLastError(0xdeadbeef);
2000 state
= MsiQueryFeatureStateA(prodcode
, NULL
);
2001 error
= GetLastError();
2002 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2003 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2005 /* empty szFeature */
2006 SetLastError(0xdeadbeef);
2007 state
= MsiQueryFeatureStateA(prodcode
, "");
2008 error
= GetLastError();
2009 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2010 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2011 "expected ERROR_SUCCESS, got %u\n", error
);
2013 /* feature key does not exist yet */
2014 SetLastError(0xdeadbeef);
2015 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2016 error
= GetLastError();
2017 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2018 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2019 "expected ERROR_SUCCESS, got %u\n", error
);
2021 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2023 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Features\\");
2024 lstrcatA(keypath
, prod_squashed
);
2026 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
2027 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2029 /* feature key exists */
2030 SetLastError(0xdeadbeef);
2031 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2032 error
= GetLastError();
2033 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2034 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2035 "expected ERROR_SUCCESS, got %u\n", error
);
2037 res
= RegSetValueExA(userkey
, "feature", 0, REG_SZ
, (const BYTE
*)"", 2);
2038 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2040 /* feature value exists */
2041 SetLastError(0xdeadbeef);
2042 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2043 error
= GetLastError();
2044 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2045 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2046 "expected ERROR_SUCCESS, got %u\n", error
);
2048 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2049 lstrcatA(keypath
, usersid
);
2050 lstrcatA(keypath
, "\\Products\\");
2051 lstrcatA(keypath
, prod_squashed
);
2052 lstrcatA(keypath
, "\\Features");
2054 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
2055 if (res
== ERROR_ACCESS_DENIED
)
2057 skip("Not enough rights to perform tests\n");
2058 RegDeleteKeyA(userkey
, "");
2059 RegCloseKey(userkey
);
2063 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2065 /* userdata features key exists */
2066 SetLastError(0xdeadbeef);
2067 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2068 error
= GetLastError();
2069 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2070 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2071 "expected ERROR_SUCCESS, got %u\n", error
);
2073 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaa", 20);
2074 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2076 SetLastError(0xdeadbeef);
2077 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2078 error
= GetLastError();
2079 ok(state
== INSTALLSTATE_BADCONFIG
, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state
);
2080 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2081 "expected ERROR_SUCCESS, got %u\n", error
);
2083 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaa", 21);
2084 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2086 SetLastError(0xdeadbeef);
2087 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2088 error
= GetLastError();
2089 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2090 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2091 "expected ERROR_SUCCESS, got %u\n", error
);
2093 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaaa", 22);
2094 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2096 SetLastError(0xdeadbeef);
2097 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2098 error
= GetLastError();
2099 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2100 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2101 "expected ERROR_SUCCESS, got %u\n", error
);
2103 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)comp_base85
, 41);
2104 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2106 SetLastError(0xdeadbeef);
2107 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2108 error
= GetLastError();
2109 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2110 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2111 "expected ERROR_SUCCESS, got %u\n", error
);
2113 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2114 lstrcatA(keypath
, usersid
);
2115 lstrcatA(keypath
, "\\Components\\");
2116 lstrcatA(keypath
, comp_squashed
);
2118 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2119 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2121 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2122 lstrcatA(keypath
, usersid
);
2123 lstrcatA(keypath
, "\\Components\\");
2124 lstrcatA(keypath
, comp_squashed2
);
2126 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey2
, NULL
);
2127 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2129 SetLastError(0xdeadbeef);
2130 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2131 error
= GetLastError();
2132 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2133 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2134 "expected ERROR_SUCCESS, got %u\n", error
);
2136 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 1);
2137 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2139 SetLastError(0xdeadbeef);
2140 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2141 error
= GetLastError();
2142 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2143 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2144 "expected ERROR_SUCCESS, got %u\n", error
);
2146 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"apple", 6);
2147 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2149 SetLastError(0xdeadbeef);
2150 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2151 error
= GetLastError();
2152 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2153 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2154 "expected ERROR_SUCCESS, got %u\n", error
);
2156 res
= RegSetValueExA(compkey2
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"orange", 7);
2157 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2159 /* INSTALLSTATE_LOCAL */
2160 SetLastError(0xdeadbeef);
2161 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2162 error
= GetLastError();
2163 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2164 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2165 "expected ERROR_SUCCESS, got %u\n", error
);
2167 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01\\", 4);
2168 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2170 /* INSTALLSTATE_SOURCE */
2171 SetLastError(0xdeadbeef);
2172 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2173 error
= GetLastError();
2174 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2175 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2176 "expected ERROR_SUCCESS, got %u\n", error
);
2178 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01", 3);
2179 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2181 /* bad INSTALLSTATE_SOURCE */
2182 SetLastError(0xdeadbeef);
2183 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2184 error
= GetLastError();
2185 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2186 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2187 "expected ERROR_SUCCESS, got %u\n", error
);
2189 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01a", 4);
2190 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2192 /* INSTALLSTATE_SOURCE */
2193 SetLastError(0xdeadbeef);
2194 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2195 error
= GetLastError();
2196 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2197 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2198 "expected ERROR_SUCCESS, got %u\n", error
);
2200 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01", 3);
2201 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2203 /* bad INSTALLSTATE_SOURCE */
2204 SetLastError(0xdeadbeef);
2205 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2206 error
= GetLastError();
2207 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2208 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2209 "expected ERROR_SUCCESS, got %u\n", error
);
2211 RegDeleteValueA(compkey
, prod_squashed
);
2212 RegDeleteValueA(compkey2
, prod_squashed
);
2213 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2214 delete_key(compkey2
, "", access
& KEY_WOW64_64KEY
);
2215 RegDeleteValueA(localkey
, "feature");
2216 RegDeleteValueA(userkey
, "feature");
2217 RegDeleteKeyA(userkey
, "");
2218 RegCloseKey(compkey
);
2219 RegCloseKey(compkey2
);
2220 RegCloseKey(localkey
);
2221 RegCloseKey(userkey
);
2223 /* MSIINSTALLCONTEXT_USERMANAGED */
2225 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2226 lstrcatA(keypath
, usersid
);
2227 lstrcatA(keypath
, "\\Installer\\Features\\");
2228 lstrcatA(keypath
, prod_squashed
);
2230 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
2231 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2233 /* feature key exists */
2234 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2235 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2237 res
= RegSetValueExA(userkey
, "feature", 0, REG_SZ
, (const BYTE
*)"", 1);
2238 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2240 /* feature value exists */
2241 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2242 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2244 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2245 lstrcatA(keypath
, usersid
);
2246 lstrcatA(keypath
, "\\Products\\");
2247 lstrcatA(keypath
, prod_squashed
);
2248 lstrcatA(keypath
, "\\Features");
2250 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
2251 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2253 /* userdata features key exists */
2254 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2255 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2257 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaa", 20);
2258 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2260 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2261 ok(state
== INSTALLSTATE_BADCONFIG
, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state
);
2263 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaa", 21);
2264 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2266 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2267 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2269 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaaa", 22);
2270 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2272 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2273 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2275 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)comp_base85
, 41);
2276 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2278 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2279 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2281 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2282 lstrcatA(keypath
, usersid
);
2283 lstrcatA(keypath
, "\\Components\\");
2284 lstrcatA(keypath
, comp_squashed
);
2286 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2287 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2289 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2290 lstrcatA(keypath
, usersid
);
2291 lstrcatA(keypath
, "\\Components\\");
2292 lstrcatA(keypath
, comp_squashed2
);
2294 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey2
, NULL
);
2295 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2297 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2298 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2300 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 1);
2301 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2303 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2304 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2306 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"apple", 6);
2307 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2309 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2310 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2312 res
= RegSetValueExA(compkey2
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"orange", 7);
2313 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2315 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2316 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2318 RegDeleteValueA(compkey
, prod_squashed
);
2319 RegDeleteValueA(compkey2
, prod_squashed
);
2320 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2321 delete_key(compkey2
, "", access
& KEY_WOW64_64KEY
);
2322 RegDeleteValueA(localkey
, "feature");
2323 RegDeleteValueA(userkey
, "feature");
2324 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
2325 RegCloseKey(compkey
);
2326 RegCloseKey(compkey2
);
2327 RegCloseKey(localkey
);
2328 RegCloseKey(userkey
);
2330 /* MSIINSTALLCONTEXT_MACHINE */
2332 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Features\\");
2333 lstrcatA(keypath
, prod_squashed
);
2335 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
2336 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2338 /* feature key exists */
2339 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2340 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2342 res
= RegSetValueExA(userkey
, "feature", 0, REG_SZ
, (const BYTE
*)"", 1);
2343 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2345 /* feature value exists */
2346 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2347 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2349 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2350 lstrcatA(keypath
, "S-1-5-18\\Products\\");
2351 lstrcatA(keypath
, prod_squashed
);
2352 lstrcatA(keypath
, "\\Features");
2354 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
2355 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2357 /* userdata features key exists */
2358 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2359 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2361 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaa", 20);
2362 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2364 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2365 ok(state
== INSTALLSTATE_BADCONFIG
, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state
);
2367 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaa", 21);
2368 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2370 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2371 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2373 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaaa", 22);
2374 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2376 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2377 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2379 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)comp_base85
, 41);
2380 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2382 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2383 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2385 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2386 lstrcatA(keypath
, "S-1-5-18\\Components\\");
2387 lstrcatA(keypath
, comp_squashed
);
2389 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2390 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2392 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2393 lstrcatA(keypath
, "S-1-5-18\\Components\\");
2394 lstrcatA(keypath
, comp_squashed2
);
2396 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey2
, NULL
);
2397 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2399 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2400 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2402 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 1);
2403 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2405 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2406 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2408 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"apple", 6);
2409 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2411 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2412 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2414 res
= RegSetValueExA(compkey2
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"orange", 7);
2415 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2417 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2418 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2420 RegDeleteValueA(compkey
, prod_squashed
);
2421 RegDeleteValueA(compkey2
, prod_squashed
);
2422 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2423 delete_key(compkey2
, "", access
& KEY_WOW64_64KEY
);
2424 RegDeleteValueA(localkey
, "feature");
2425 RegDeleteValueA(userkey
, "feature");
2426 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
2427 RegCloseKey(compkey
);
2428 RegCloseKey(compkey2
);
2429 RegCloseKey(localkey
);
2430 RegCloseKey(userkey
);
2434 static void test_MsiQueryComponentState(void)
2436 HKEY compkey
, prodkey
;
2437 CHAR prodcode
[MAX_PATH
];
2438 CHAR prod_squashed
[MAX_PATH
];
2439 CHAR component
[MAX_PATH
];
2440 CHAR comp_base85
[MAX_PATH
];
2441 CHAR comp_squashed
[MAX_PATH
];
2442 CHAR keypath
[MAX_PATH
];
2447 REGSAM access
= KEY_ALL_ACCESS
;
2450 static const INSTALLSTATE MAGIC_ERROR
= 0xdeadbeef;
2452 if (!pMsiQueryComponentStateA
)
2454 win_skip("MsiQueryComponentStateA not implemented\n");
2458 create_test_guid(prodcode
, prod_squashed
);
2459 compose_base85_guid(component
, comp_base85
, comp_squashed
);
2460 usersid
= get_user_sid();
2463 access
|= KEY_WOW64_64KEY
;
2465 /* NULL szProductCode */
2466 state
= MAGIC_ERROR
;
2467 SetLastError(0xdeadbeef);
2468 r
= pMsiQueryComponentStateA(NULL
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2469 error
= GetLastError();
2470 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2471 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2472 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2474 /* empty szProductCode */
2475 state
= MAGIC_ERROR
;
2476 SetLastError(0xdeadbeef);
2477 r
= pMsiQueryComponentStateA("", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2478 error
= GetLastError();
2479 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2480 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2481 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2483 /* random szProductCode */
2484 state
= MAGIC_ERROR
;
2485 SetLastError(0xdeadbeef);
2486 r
= pMsiQueryComponentStateA("random", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2487 error
= GetLastError();
2488 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2489 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2490 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2492 /* GUID-length szProductCode */
2493 state
= MAGIC_ERROR
;
2494 SetLastError(0xdeadbeef);
2495 r
= pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2496 error
= GetLastError();
2497 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2498 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2499 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2501 /* GUID-length with brackets */
2502 state
= MAGIC_ERROR
;
2503 SetLastError(0xdeadbeef);
2504 r
= pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2505 error
= GetLastError();
2506 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2507 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2508 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2511 state
= MAGIC_ERROR
;
2512 SetLastError(0xdeadbeef);
2513 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2514 error
= GetLastError();
2515 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2516 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2517 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2519 state
= MAGIC_ERROR
;
2520 SetLastError(0xdeadbeef);
2521 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2522 error
= GetLastError();
2523 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2524 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2525 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2527 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
2528 lstrcatA(keypath
, prod_squashed
);
2530 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2531 if (res
== ERROR_ACCESS_DENIED
)
2533 skip("Not enough rights to perform tests\n");
2537 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2539 state
= MAGIC_ERROR
;
2540 SetLastError(0xdeadbeef);
2541 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2542 error
= GetLastError();
2543 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2544 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2545 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2547 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2548 RegCloseKey(prodkey
);
2550 /* create local system product key */
2551 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
2552 lstrcatA(keypath
, prod_squashed
);
2553 lstrcatA(keypath
, "\\InstallProperties");
2555 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2556 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2558 /* local system product key exists */
2559 state
= MAGIC_ERROR
;
2560 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2561 error
= GetLastError();
2562 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2563 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2564 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2566 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (const BYTE
*)"msitest.msi", 11);
2567 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2569 /* LocalPackage value exists */
2570 state
= MAGIC_ERROR
;
2571 SetLastError(0xdeadbeef);
2572 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2573 error
= GetLastError();
2574 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2575 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2576 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2578 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
2579 lstrcatA(keypath
, comp_squashed
);
2581 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2582 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2584 /* component key exists */
2585 state
= MAGIC_ERROR
;
2586 SetLastError(0xdeadbeef);
2587 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2588 error
= GetLastError();
2589 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2590 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2591 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2593 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 0);
2594 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2596 /* component\product exists */
2597 state
= MAGIC_ERROR
;
2598 SetLastError(0xdeadbeef);
2599 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2600 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2601 error
= GetLastError();
2602 ok(state
== INSTALLSTATE_NOTUSED
|| state
== INSTALLSTATE_LOCAL
,
2603 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state
);
2604 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2606 /* NULL component, product exists */
2607 state
= MAGIC_ERROR
;
2608 SetLastError(0xdeadbeef);
2609 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, NULL
, &state
);
2610 error
= GetLastError();
2611 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2612 ok(state
== MAGIC_ERROR
, "Expected state not changed, got %d\n", state
);
2613 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2615 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"hi", 2);
2616 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2618 /* INSTALLSTATE_LOCAL */
2619 state
= MAGIC_ERROR
;
2620 SetLastError(0xdeadbeef);
2621 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2622 error
= GetLastError();
2623 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2624 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2625 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2627 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01\\", 4);
2628 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2630 /* INSTALLSTATE_SOURCE */
2631 state
= MAGIC_ERROR
;
2632 SetLastError(0xdeadbeef);
2633 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2634 error
= GetLastError();
2635 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2636 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2637 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2639 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01", 3);
2640 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2642 /* bad INSTALLSTATE_SOURCE */
2643 state
= MAGIC_ERROR
;
2644 SetLastError(0xdeadbeef);
2645 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2646 error
= GetLastError();
2647 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2648 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2649 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2651 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01a", 4);
2652 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2654 /* INSTALLSTATE_SOURCE */
2655 state
= MAGIC_ERROR
;
2656 SetLastError(0xdeadbeef);
2657 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2658 error
= GetLastError();
2659 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2660 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2661 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2663 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01:", 4);
2664 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2666 /* registry component */
2667 state
= MAGIC_ERROR
;
2668 SetLastError(0xdeadbeef);
2669 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2670 error
= GetLastError();
2671 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2672 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2673 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2675 RegDeleteValueA(prodkey
, "LocalPackage");
2676 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2677 RegDeleteValueA(compkey
, prod_squashed
);
2678 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2679 RegCloseKey(prodkey
);
2680 RegCloseKey(compkey
);
2682 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2684 state
= MAGIC_ERROR
;
2685 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2686 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2687 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2689 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
2690 lstrcatA(keypath
, prod_squashed
);
2692 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
2693 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2695 state
= MAGIC_ERROR
;
2696 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2697 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2698 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2700 RegDeleteKeyA(prodkey
, "");
2701 RegCloseKey(prodkey
);
2703 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2704 lstrcatA(keypath
, usersid
);
2705 lstrcatA(keypath
, "\\Products\\");
2706 lstrcatA(keypath
, prod_squashed
);
2707 lstrcatA(keypath
, "\\InstallProperties");
2709 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2710 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2712 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (const BYTE
*)"msitest.msi", 11);
2713 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2715 RegCloseKey(prodkey
);
2717 state
= MAGIC_ERROR
;
2718 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2719 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2720 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2722 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2723 lstrcatA(keypath
, usersid
);
2724 lstrcatA(keypath
, "\\Components\\");
2725 lstrcatA(keypath
, comp_squashed
);
2727 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2728 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2730 /* component key exists */
2731 state
= MAGIC_ERROR
;
2732 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2733 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2734 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2736 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 0);
2737 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2739 /* component\product exists */
2740 state
= MAGIC_ERROR
;
2741 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2742 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2743 ok(state
== INSTALLSTATE_NOTUSED
|| state
== INSTALLSTATE_LOCAL
,
2744 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state
);
2746 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"hi", 2);
2747 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2749 state
= MAGIC_ERROR
;
2750 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2751 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2752 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2754 /* MSIINSTALLCONTEXT_USERMANAGED */
2756 state
= MAGIC_ERROR
;
2757 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2758 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2759 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2761 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
2762 lstrcatA(keypath
, prod_squashed
);
2764 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
2765 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2767 state
= MAGIC_ERROR
;
2768 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2769 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2770 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2772 RegDeleteKeyA(prodkey
, "");
2773 RegCloseKey(prodkey
);
2775 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2776 lstrcatA(keypath
, usersid
);
2777 lstrcatA(keypath
, "\\Installer\\Products\\");
2778 lstrcatA(keypath
, prod_squashed
);
2780 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2781 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2783 state
= MAGIC_ERROR
;
2784 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2785 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2786 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2788 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2789 RegCloseKey(prodkey
);
2791 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2792 lstrcatA(keypath
, usersid
);
2793 lstrcatA(keypath
, "\\Products\\");
2794 lstrcatA(keypath
, prod_squashed
);
2795 lstrcatA(keypath
, "\\InstallProperties");
2797 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2798 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2800 res
= RegSetValueExA(prodkey
, "ManagedLocalPackage", 0, REG_SZ
, (const BYTE
*)"msitest.msi", 11);
2801 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2803 state
= MAGIC_ERROR
;
2804 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2805 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2806 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2808 RegDeleteValueA(prodkey
, "LocalPackage");
2809 RegDeleteValueA(prodkey
, "ManagedLocalPackage");
2810 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2811 RegDeleteValueA(compkey
, prod_squashed
);
2812 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2813 RegCloseKey(prodkey
);
2814 RegCloseKey(compkey
);
2818 static void test_MsiGetComponentPath(void)
2820 HKEY compkey
, prodkey
, installprop
;
2821 CHAR prodcode
[MAX_PATH
];
2822 CHAR prod_squashed
[MAX_PATH
];
2823 CHAR component
[MAX_PATH
];
2824 CHAR comp_base85
[MAX_PATH
];
2825 CHAR comp_squashed
[MAX_PATH
];
2826 CHAR keypath
[MAX_PATH
];
2827 CHAR path
[MAX_PATH
];
2831 REGSAM access
= KEY_ALL_ACCESS
;
2834 create_test_guid(prodcode
, prod_squashed
);
2835 compose_base85_guid(component
, comp_base85
, comp_squashed
);
2836 usersid
= get_user_sid();
2839 access
|= KEY_WOW64_64KEY
;
2841 /* NULL szProduct */
2843 state
= MsiGetComponentPathA(NULL
, component
, path
, &size
);
2844 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2845 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2847 /* NULL szComponent */
2849 state
= MsiGetComponentPathA(prodcode
, NULL
, path
, &size
);
2850 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2851 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2854 state
= MsiLocateComponentA(NULL
, path
, &size
);
2855 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2856 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2858 /* NULL lpPathBuf */
2860 state
= MsiGetComponentPathA(prodcode
, component
, NULL
, &size
);
2861 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2862 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2865 state
= MsiLocateComponentA(component
, NULL
, &size
);
2866 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2867 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2871 state
= MsiGetComponentPathA(prodcode
, component
, path
, NULL
);
2872 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2873 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2876 state
= MsiLocateComponentA(component
, path
, NULL
);
2877 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2878 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2880 /* all params valid */
2882 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2883 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2884 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2887 state
= MsiLocateComponentA(component
, path
, &size
);
2888 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2889 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2891 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2892 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
2893 lstrcatA(keypath
, comp_squashed
);
2895 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2896 if (res
== ERROR_ACCESS_DENIED
)
2898 skip("Not enough rights to perform tests\n");
2902 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2904 /* local system component key exists */
2906 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2907 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2908 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2911 state
= MsiLocateComponentA(component
, path
, &size
);
2912 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2913 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2915 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
2916 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2918 /* product value exists */
2921 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2922 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2923 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2924 ok(size
== 10, "Expected 10, got %d\n", size
);
2928 state
= MsiLocateComponentA(component
, path
, &size
);
2929 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2930 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2931 ok(size
== 10, "Expected 10, got %d\n", size
);
2933 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2934 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
2935 lstrcatA(keypath
, prod_squashed
);
2936 lstrcatA(keypath
, "\\InstallProperties");
2938 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &installprop
, NULL
);
2939 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2942 res
= RegSetValueExA(installprop
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
2943 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2945 /* install properties key exists */
2948 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2949 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2950 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2951 ok(size
== 10, "Expected 10, got %d\n", size
);
2955 state
= MsiLocateComponentA(component
, path
, &size
);
2956 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2957 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2958 ok(size
== 10, "Expected 10, got %d\n", size
);
2960 create_file("C:\\imapath", "C:\\imapath", 11);
2965 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2966 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2967 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2968 ok(size
== 10, "Expected 10, got %d\n", size
);
2972 state
= MsiLocateComponentA(component
, path
, &size
);
2973 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2974 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2975 ok(size
== 10, "Expected 10, got %d\n", size
);
2977 RegDeleteValueA(compkey
, prod_squashed
);
2978 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2979 RegDeleteValueA(installprop
, "WindowsInstaller");
2980 delete_key(installprop
, "", access
& KEY_WOW64_64KEY
);
2981 RegCloseKey(compkey
);
2982 RegCloseKey(installprop
);
2983 DeleteFileA("C:\\imapath");
2985 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2986 lstrcatA(keypath
, "Installer\\UserData\\");
2987 lstrcatA(keypath
, usersid
);
2988 lstrcatA(keypath
, "\\Components\\");
2989 lstrcatA(keypath
, comp_squashed
);
2991 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2992 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2994 /* user managed component key exists */
2996 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2997 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2998 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3001 state
= MsiLocateComponentA(component
, path
, &size
);
3002 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3003 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3005 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3006 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3008 /* product value exists */
3011 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3012 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3013 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3014 ok(size
== 10, "Expected 10, got %d\n", size
);
3018 state
= MsiLocateComponentA(component
, path
, &size
);
3019 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3020 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3021 ok(size
== 10, "Expected 10, got %d\n", size
);
3023 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3024 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
3025 lstrcatA(keypath
, prod_squashed
);
3026 lstrcatA(keypath
, "\\InstallProperties");
3028 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &installprop
, NULL
);
3029 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3032 res
= RegSetValueExA(installprop
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
3033 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3035 /* install properties key exists */
3038 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3039 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3040 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3041 ok(size
== 10, "Expected 10, got %d\n", size
);
3045 state
= MsiLocateComponentA(component
, path
, &size
);
3046 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3047 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3048 ok(size
== 10, "Expected 10, got %d\n", size
);
3050 create_file("C:\\imapath", "C:\\imapath", 11);
3055 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3056 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3057 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3058 ok(size
== 10, "Expected 10, got %d\n", size
);
3062 state
= MsiLocateComponentA(component
, path
, &size
);
3063 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3064 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3065 ok(size
== 10, "Expected 10, got %d\n", size
);
3067 RegDeleteValueA(compkey
, prod_squashed
);
3068 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3069 RegDeleteValueA(installprop
, "WindowsInstaller");
3070 delete_key(installprop
, "", access
& KEY_WOW64_64KEY
);
3071 RegCloseKey(compkey
);
3072 RegCloseKey(installprop
);
3073 DeleteFileA("C:\\imapath");
3075 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3076 lstrcatA(keypath
, "Installer\\Managed\\");
3077 lstrcatA(keypath
, usersid
);
3078 lstrcatA(keypath
, "\\Installer\\Products\\");
3079 lstrcatA(keypath
, prod_squashed
);
3081 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3082 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3084 /* user managed product key exists */
3086 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3087 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3088 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3091 state
= MsiLocateComponentA(component
, path
, &size
);
3092 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3093 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3095 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3096 lstrcatA(keypath
, "Installer\\UserData\\");
3097 lstrcatA(keypath
, usersid
);
3098 lstrcatA(keypath
, "\\Components\\");
3099 lstrcatA(keypath
, comp_squashed
);
3101 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3102 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3104 /* user managed component key exists */
3106 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3107 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3108 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3111 state
= MsiLocateComponentA(component
, path
, &size
);
3112 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3113 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3115 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3116 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3118 /* product value exists */
3121 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3122 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3123 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3124 ok(size
== 10, "Expected 10, got %d\n", size
);
3128 state
= MsiLocateComponentA(component
, path
, &size
);
3129 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3130 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3131 ok(size
== 10, "Expected 10, got %d\n", size
);
3133 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3134 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
3135 lstrcatA(keypath
, prod_squashed
);
3136 lstrcatA(keypath
, "\\InstallProperties");
3138 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &installprop
, NULL
);
3139 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3142 res
= RegSetValueExA(installprop
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
3143 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3145 /* install properties key exists */
3148 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3149 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3150 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3151 ok(size
== 10, "Expected 10, got %d\n", size
);
3155 state
= MsiLocateComponentA(component
, path
, &size
);
3156 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3157 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3158 ok(size
== 10, "Expected 10, got %d\n", size
);
3160 create_file("C:\\imapath", "C:\\imapath", 11);
3165 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3166 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3167 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3168 ok(size
== 10, "Expected 10, got %d\n", size
);
3172 state
= MsiLocateComponentA(component
, path
, &size
);
3173 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3174 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3175 ok(size
== 10, "Expected 10, got %d\n", size
);
3177 RegDeleteValueA(compkey
, prod_squashed
);
3178 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3179 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3180 RegDeleteValueA(installprop
, "WindowsInstaller");
3181 delete_key(installprop
, "", access
& KEY_WOW64_64KEY
);
3182 RegCloseKey(prodkey
);
3183 RegCloseKey(compkey
);
3184 RegCloseKey(installprop
);
3185 DeleteFileA("C:\\imapath");
3187 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3188 lstrcatA(keypath
, prod_squashed
);
3190 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
3191 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3193 /* user unmanaged product key exists */
3195 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3196 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3197 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3200 state
= MsiLocateComponentA(component
, path
, &size
);
3201 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3202 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3204 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3205 lstrcatA(keypath
, "Installer\\UserData\\");
3206 lstrcatA(keypath
, usersid
);
3207 lstrcatA(keypath
, "\\Components\\");
3208 lstrcatA(keypath
, comp_squashed
);
3210 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3211 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3213 /* user unmanaged component key exists */
3215 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3216 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3217 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3220 state
= MsiLocateComponentA(component
, path
, &size
);
3221 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3222 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3224 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3225 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3227 /* product value exists */
3230 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3231 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3232 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3233 ok(size
== 10, "Expected 10, got %d\n", size
);
3237 state
= MsiLocateComponentA(component
, path
, &size
);
3238 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3239 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3240 ok(size
== 10, "Expected 10, got %d\n", size
);
3242 create_file("C:\\imapath", "C:\\imapath", 11);
3247 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3248 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3249 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3250 ok(size
== 10, "Expected 10, got %d\n", size
);
3254 state
= MsiLocateComponentA(component
, path
, &size
);
3255 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3256 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3257 ok(size
== 10, "Expected 10, got %d\n", size
);
3259 RegDeleteValueA(compkey
, prod_squashed
);
3260 RegDeleteKeyA(prodkey
, "");
3261 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3262 RegCloseKey(prodkey
);
3263 RegCloseKey(compkey
);
3264 DeleteFileA("C:\\imapath");
3266 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3267 lstrcatA(keypath
, prod_squashed
);
3269 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3270 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3272 /* local classes product key exists */
3274 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3275 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3276 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3279 state
= MsiLocateComponentA(component
, path
, &size
);
3280 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3281 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3283 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3284 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
3285 lstrcatA(keypath
, comp_squashed
);
3287 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3288 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3290 /* local user component key exists */
3292 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3293 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3294 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3297 state
= MsiLocateComponentA(component
, path
, &size
);
3298 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3299 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3301 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3302 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3304 /* product value exists */
3307 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3308 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3309 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3310 ok(size
== 10, "Expected 10, got %d\n", size
);
3314 state
= MsiLocateComponentA(component
, path
, &size
);
3315 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3316 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3317 ok(size
== 10, "Expected 10, got %d\n", size
);
3319 create_file("C:\\imapath", "C:\\imapath", 11);
3324 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3325 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3326 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3327 ok(size
== 10, "Expected 10, got %d\n", size
);
3331 state
= MsiLocateComponentA(component
, path
, &size
);
3332 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3333 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3334 ok(size
== 10, "Expected 10, got %d\n", size
);
3336 RegDeleteValueA(compkey
, prod_squashed
);
3337 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3338 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3339 RegCloseKey(prodkey
);
3340 RegCloseKey(compkey
);
3341 DeleteFileA("C:\\imapath");
3345 static void test_MsiGetProductCode(void)
3347 HKEY compkey
, prodkey
;
3348 CHAR prodcode
[MAX_PATH
];
3349 CHAR prod_squashed
[MAX_PATH
];
3350 CHAR prodcode2
[MAX_PATH
];
3351 CHAR prod2_squashed
[MAX_PATH
];
3352 CHAR component
[MAX_PATH
];
3353 CHAR comp_base85
[MAX_PATH
];
3354 CHAR comp_squashed
[MAX_PATH
];
3355 CHAR keypath
[MAX_PATH
];
3356 CHAR product
[MAX_PATH
];
3360 REGSAM access
= KEY_ALL_ACCESS
;
3362 create_test_guid(prodcode
, prod_squashed
);
3363 create_test_guid(prodcode2
, prod2_squashed
);
3364 compose_base85_guid(component
, comp_base85
, comp_squashed
);
3365 usersid
= get_user_sid();
3368 access
|= KEY_WOW64_64KEY
;
3370 /* szComponent is NULL */
3371 lstrcpyA(product
, "prod");
3372 r
= MsiGetProductCodeA(NULL
, product
);
3373 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3374 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3376 /* szComponent is empty */
3377 lstrcpyA(product
, "prod");
3378 r
= MsiGetProductCodeA("", product
);
3379 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3380 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3382 /* garbage szComponent */
3383 lstrcpyA(product
, "prod");
3384 r
= MsiGetProductCodeA("garbage", product
);
3385 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3386 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3388 /* guid without brackets */
3389 lstrcpyA(product
, "prod");
3390 r
= MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product
);
3391 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3392 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3394 /* guid with brackets */
3395 lstrcpyA(product
, "prod");
3396 r
= MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product
);
3397 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3398 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3400 /* same length as guid, but random */
3401 lstrcpyA(product
, "prod");
3402 r
= MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product
);
3403 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3404 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3406 /* all params correct, szComponent not published */
3407 lstrcpyA(product
, "prod");
3408 r
= MsiGetProductCodeA(component
, product
);
3409 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3410 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3412 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3413 lstrcatA(keypath
, "Installer\\UserData\\");
3414 lstrcatA(keypath
, usersid
);
3415 lstrcatA(keypath
, "\\Components\\");
3416 lstrcatA(keypath
, comp_squashed
);
3418 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3419 if (res
== ERROR_ACCESS_DENIED
)
3421 skip("Not enough rights to perform tests\n");
3425 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3427 /* user unmanaged component key exists */
3428 lstrcpyA(product
, "prod");
3429 r
= MsiGetProductCodeA(component
, product
);
3430 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3431 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3433 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3434 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3436 /* product value exists */
3437 lstrcpyA(product
, "prod");
3438 r
= MsiGetProductCodeA(component
, product
);
3439 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3440 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3442 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3443 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3445 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3446 lstrcatA(keypath
, "Installer\\Managed\\");
3447 lstrcatA(keypath
, usersid
);
3448 lstrcatA(keypath
, "\\Installer\\Products\\");
3449 lstrcatA(keypath
, prod_squashed
);
3451 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3452 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3454 /* user managed product key of first product exists */
3455 lstrcpyA(product
, "prod");
3456 r
= MsiGetProductCodeA(component
, product
);
3457 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3458 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3460 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3461 RegCloseKey(prodkey
);
3463 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3464 lstrcatA(keypath
, prod_squashed
);
3466 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
3467 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3469 /* user unmanaged product key exists */
3470 lstrcpyA(product
, "prod");
3471 r
= MsiGetProductCodeA(component
, product
);
3472 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3473 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3475 RegDeleteKeyA(prodkey
, "");
3476 RegCloseKey(prodkey
);
3478 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3479 lstrcatA(keypath
, prod_squashed
);
3481 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3482 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3484 /* local classes product key exists */
3485 lstrcpyA(product
, "prod");
3486 r
= MsiGetProductCodeA(component
, product
);
3487 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3488 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3490 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3491 RegCloseKey(prodkey
);
3493 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3494 lstrcatA(keypath
, "Installer\\Managed\\");
3495 lstrcatA(keypath
, usersid
);
3496 lstrcatA(keypath
, "\\Installer\\Products\\");
3497 lstrcatA(keypath
, prod2_squashed
);
3499 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3500 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3502 /* user managed product key of second product exists */
3503 lstrcpyA(product
, "prod");
3504 r
= MsiGetProductCodeA(component
, product
);
3505 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3506 ok(!lstrcmpA(product
, prodcode2
), "Expected %s, got %s\n", prodcode2
, product
);
3508 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3509 RegCloseKey(prodkey
);
3510 RegDeleteValueA(compkey
, prod_squashed
);
3511 RegDeleteValueA(compkey
, prod2_squashed
);
3512 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3513 RegCloseKey(compkey
);
3515 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3516 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
3517 lstrcatA(keypath
, comp_squashed
);
3519 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3520 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3522 /* local user component key exists */
3523 lstrcpyA(product
, "prod");
3524 r
= MsiGetProductCodeA(component
, product
);
3525 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3526 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3528 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3529 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3531 /* product value exists */
3532 lstrcpyA(product
, "prod");
3533 r
= MsiGetProductCodeA(component
, product
);
3534 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3535 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3537 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3538 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3540 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3541 lstrcatA(keypath
, "Installer\\Managed\\");
3542 lstrcatA(keypath
, usersid
);
3543 lstrcatA(keypath
, "\\Installer\\Products\\");
3544 lstrcatA(keypath
, prod_squashed
);
3546 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3547 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3549 /* user managed product key of first product exists */
3550 lstrcpyA(product
, "prod");
3551 r
= MsiGetProductCodeA(component
, product
);
3552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3553 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3555 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3556 RegCloseKey(prodkey
);
3558 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3559 lstrcatA(keypath
, prod_squashed
);
3561 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
3562 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3564 /* user unmanaged product key exists */
3565 lstrcpyA(product
, "prod");
3566 r
= MsiGetProductCodeA(component
, product
);
3567 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3568 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3570 RegDeleteKeyA(prodkey
, "");
3571 RegCloseKey(prodkey
);
3573 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3574 lstrcatA(keypath
, prod_squashed
);
3576 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3577 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3579 /* local classes product key exists */
3580 lstrcpyA(product
, "prod");
3581 r
= MsiGetProductCodeA(component
, product
);
3582 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3583 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3585 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3586 RegCloseKey(prodkey
);
3588 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3589 lstrcatA(keypath
, "Installer\\Managed\\");
3590 lstrcatA(keypath
, usersid
);
3591 lstrcatA(keypath
, "\\Installer\\Products\\");
3592 lstrcatA(keypath
, prod2_squashed
);
3594 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3595 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3597 /* user managed product key of second product exists */
3598 lstrcpyA(product
, "prod");
3599 r
= MsiGetProductCodeA(component
, product
);
3600 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3601 ok(!lstrcmpA(product
, prodcode2
), "Expected %s, got %s\n", prodcode2
, product
);
3603 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3604 RegCloseKey(prodkey
);
3605 RegDeleteValueA(compkey
, prod_squashed
);
3606 RegDeleteValueA(compkey
, prod2_squashed
);
3607 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3608 RegCloseKey(compkey
);
3612 static void test_MsiEnumClients(void)
3615 CHAR prodcode
[MAX_PATH
];
3616 CHAR prod_squashed
[MAX_PATH
];
3617 CHAR prodcode2
[MAX_PATH
];
3618 CHAR prod2_squashed
[MAX_PATH
];
3619 CHAR component
[MAX_PATH
];
3620 CHAR comp_base85
[MAX_PATH
];
3621 CHAR comp_squashed
[MAX_PATH
];
3622 CHAR product
[MAX_PATH
];
3623 CHAR keypath
[MAX_PATH
];
3627 REGSAM access
= KEY_ALL_ACCESS
;
3629 create_test_guid(prodcode
, prod_squashed
);
3630 create_test_guid(prodcode2
, prod2_squashed
);
3631 compose_base85_guid(component
, comp_base85
, comp_squashed
);
3632 usersid
= get_user_sid();
3635 access
|= KEY_WOW64_64KEY
;
3637 /* NULL szComponent */
3639 r
= MsiEnumClientsA(NULL
, 0, product
);
3640 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3641 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3643 /* empty szComponent */
3645 r
= MsiEnumClientsA("", 0, product
);
3646 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3647 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3649 /* NULL lpProductBuf */
3650 r
= MsiEnumClientsA(component
, 0, NULL
);
3651 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3653 /* all params correct, component missing */
3655 r
= MsiEnumClientsA(component
, 0, product
);
3656 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3657 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3659 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3660 lstrcatA(keypath
, "Installer\\UserData\\");
3661 lstrcatA(keypath
, usersid
);
3662 lstrcatA(keypath
, "\\Components\\");
3663 lstrcatA(keypath
, comp_squashed
);
3665 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3666 if (res
== ERROR_ACCESS_DENIED
)
3668 skip("Not enough rights to perform tests\n");
3672 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3674 /* user unmanaged component key exists */
3676 r
= MsiEnumClientsA(component
, 0, product
);
3677 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3678 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3680 /* index > 0, no products exist */
3682 r
= MsiEnumClientsA(component
, 1, product
);
3683 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3684 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3686 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3687 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3689 /* product value exists */
3690 r
= MsiEnumClientsA(component
, 0, product
);
3691 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3692 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3694 /* try index 0 again */
3696 r
= MsiEnumClientsA(component
, 0, product
);
3697 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3698 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3700 /* try index 1, second product value does not exist */
3702 r
= MsiEnumClientsA(component
, 1, product
);
3703 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
3704 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3706 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3707 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3709 /* try index 1, second product value does exist */
3711 r
= MsiEnumClientsA(component
, 1, product
);
3714 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3715 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3718 /* start the enumeration over */
3720 r
= MsiEnumClientsA(component
, 0, product
);
3721 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3722 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3723 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3725 /* correctly query second product */
3727 r
= MsiEnumClientsA(component
, 1, product
);
3728 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3729 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3730 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3732 RegDeleteValueA(compkey
, prod_squashed
);
3733 RegDeleteValueA(compkey
, prod2_squashed
);
3734 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3735 RegCloseKey(compkey
);
3737 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3738 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
3739 lstrcatA(keypath
, comp_squashed
);
3741 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3742 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3744 /* user local component key exists */
3746 r
= MsiEnumClientsA(component
, 0, product
);
3747 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3748 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3750 /* index > 0, no products exist */
3752 r
= MsiEnumClientsA(component
, 1, product
);
3753 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3754 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3756 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3757 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3759 /* product value exists */
3761 r
= MsiEnumClientsA(component
, 0, product
);
3762 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3763 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3765 /* try index 0 again */
3767 r
= MsiEnumClientsA(component
, 0, product
);
3768 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3770 /* try index 1, second product value does not exist */
3772 r
= MsiEnumClientsA(component
, 1, product
);
3773 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
3774 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3776 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3777 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3779 /* try index 1, second product value does exist */
3781 r
= MsiEnumClientsA(component
, 1, product
);
3784 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3785 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3788 /* start the enumeration over */
3790 r
= MsiEnumClientsA(component
, 0, product
);
3791 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3792 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3793 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3795 /* correctly query second product */
3797 r
= MsiEnumClientsA(component
, 1, product
);
3798 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3799 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3800 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3802 RegDeleteValueA(compkey
, prod_squashed
);
3803 RegDeleteValueA(compkey
, prod2_squashed
);
3804 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3805 RegCloseKey(compkey
);
3809 static void get_version_info(LPSTR path
, LPSTR
*vercheck
, LPDWORD verchecksz
,
3810 LPSTR
*langcheck
, LPDWORD langchecksz
)
3813 VS_FIXEDFILEINFO
*ffi
;
3814 DWORD size
= GetFileVersionInfoSizeA(path
, NULL
);
3817 version
= HeapAlloc(GetProcessHeap(), 0, size
);
3818 GetFileVersionInfoA(path
, 0, size
, version
);
3820 VerQueryValueA(version
, "\\", (LPVOID
*)&ffi
, &size
);
3821 *vercheck
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
3822 sprintf(*vercheck
, "%d.%d.%d.%d", HIWORD(ffi
->dwFileVersionMS
),
3823 LOWORD(ffi
->dwFileVersionMS
), HIWORD(ffi
->dwFileVersionLS
),
3824 LOWORD(ffi
->dwFileVersionLS
));
3825 *verchecksz
= lstrlenA(*vercheck
);
3827 VerQueryValue(version
, "\\VarFileInfo\\Translation", (void **)&lang
, &size
);
3828 *langcheck
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
3829 sprintf(*langcheck
, "%d", *lang
);
3830 *langchecksz
= lstrlenA(*langcheck
);
3832 HeapFree(GetProcessHeap(), 0, version
);
3835 static void test_MsiGetFileVersion(void)
3838 DWORD versz
, langsz
;
3839 char version
[MAX_PATH
];
3840 char lang
[MAX_PATH
];
3841 char path
[MAX_PATH
];
3842 LPSTR vercheck
, langcheck
;
3843 DWORD verchecksz
, langchecksz
;
3845 /* NULL szFilePath */
3846 r
= MsiGetFileVersionA(NULL
, NULL
, NULL
, NULL
, NULL
);
3847 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3851 lstrcpyA(version
, "version");
3852 lstrcpyA(lang
, "lang");
3853 r
= MsiGetFileVersionA(NULL
, version
, &versz
, lang
, &langsz
);
3854 ok(r
== ERROR_INVALID_PARAMETER
,
3855 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3856 ok(!lstrcmpA(version
, "version"),
3857 "Expected version to be unchanged, got %s\n", version
);
3858 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3859 ok(!lstrcmpA(lang
, "lang"),
3860 "Expected lang to be unchanged, got %s\n", lang
);
3861 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3863 /* empty szFilePath */
3864 r
= MsiGetFileVersionA("", NULL
, NULL
, NULL
, NULL
);
3865 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3869 lstrcpyA(version
, "version");
3870 lstrcpyA(lang
, "lang");
3871 r
= MsiGetFileVersionA("", version
, &versz
, lang
, &langsz
);
3872 ok(r
== ERROR_FILE_NOT_FOUND
,
3873 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3874 ok(!lstrcmpA(version
, "version"),
3875 "Expected version to be unchanged, got %s\n", version
);
3876 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3877 ok(!lstrcmpA(lang
, "lang"),
3878 "Expected lang to be unchanged, got %s\n", lang
);
3879 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3881 /* nonexistent szFilePath */
3884 lstrcpyA(version
, "version");
3885 lstrcpyA(lang
, "lang");
3886 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, &langsz
);
3887 ok(r
== ERROR_FILE_NOT_FOUND
,
3888 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3889 ok(!lstrcmpA(version
, "version"),
3890 "Expected version to be unchanged, got %s\n", version
);
3891 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3892 ok(!lstrcmpA(lang
, "lang"),
3893 "Expected lang to be unchanged, got %s\n", lang
);
3894 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3896 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
3899 lstrcpyA(version
, "version");
3900 lstrcpyA(lang
, "lang");
3901 r
= MsiGetFileVersionA("nonexistent", version
, NULL
, lang
, &langsz
);
3902 ok(r
== ERROR_INVALID_PARAMETER
,
3903 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3904 ok(!lstrcmpA(version
, "version"),
3905 "Expected version to be unchanged, got %s\n", version
);
3906 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3907 ok(!lstrcmpA(lang
, "lang"),
3908 "Expected lang to be unchanged, got %s\n", lang
);
3909 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3911 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
3914 lstrcpyA(version
, "version");
3915 lstrcpyA(lang
, "lang");
3916 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, NULL
);
3917 ok(r
== ERROR_INVALID_PARAMETER
,
3918 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3919 ok(!lstrcmpA(version
, "version"),
3920 "Expected version to be unchanged, got %s\n", version
);
3921 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3922 ok(!lstrcmpA(lang
, "lang"),
3923 "Expected lang to be unchanged, got %s\n", lang
);
3924 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3926 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
3929 lstrcpyA(version
, "version");
3930 lstrcpyA(lang
, "lang");
3931 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, &langsz
);
3932 ok(r
== ERROR_FILE_NOT_FOUND
,
3933 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3934 ok(!lstrcmpA(version
, "version"),
3935 "Expected version to be unchanged, got %s\n", version
);
3936 ok(versz
== 0, "Expected 0, got %d\n", versz
);
3937 ok(!lstrcmpA(lang
, "lang"),
3938 "Expected lang to be unchanged, got %s\n", lang
);
3939 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3941 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
3944 lstrcpyA(version
, "version");
3945 lstrcpyA(lang
, "lang");
3946 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, &langsz
);
3947 ok(r
== ERROR_FILE_NOT_FOUND
,
3948 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3949 ok(!lstrcmpA(version
, "version"),
3950 "Expected version to be unchanged, got %s\n", version
);
3951 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3952 ok(!lstrcmpA(lang
, "lang"),
3953 "Expected lang to be unchanged, got %s\n", lang
);
3954 ok(langsz
== 0, "Expected 0, got %d\n", langsz
);
3956 /* nonexistent szFilePath, rest NULL */
3957 r
= MsiGetFileVersionA("nonexistent", NULL
, NULL
, NULL
, NULL
);
3958 ok(r
== ERROR_FILE_NOT_FOUND
,
3959 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3961 create_file("ver.txt", "ver.txt", 20);
3963 /* file exists, no version information */
3964 r
= MsiGetFileVersionA("ver.txt", NULL
, NULL
, NULL
, NULL
);
3965 ok(r
== ERROR_FILE_INVALID
, "Expected ERROR_FILE_INVALID, got %d\n", r
);
3969 lstrcpyA(version
, "version");
3970 lstrcpyA(lang
, "lang");
3971 r
= MsiGetFileVersionA("ver.txt", version
, &versz
, lang
, &langsz
);
3972 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3973 ok(!lstrcmpA(version
, "version"),
3974 "Expected version to be unchanged, got %s\n", version
);
3975 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3976 ok(!lstrcmpA(lang
, "lang"),
3977 "Expected lang to be unchanged, got %s\n", lang
);
3978 ok(r
== ERROR_FILE_INVALID
,
3979 "Expected ERROR_FILE_INVALID, got %d\n", r
);
3981 DeleteFileA("ver.txt");
3983 /* relative path, has version information */
3986 lstrcpyA(version
, "version");
3987 lstrcpyA(lang
, "lang");
3988 r
= MsiGetFileVersionA("kernel32.dll", version
, &versz
, lang
, &langsz
);
3991 ok(r
== ERROR_FILE_NOT_FOUND
,
3992 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3993 ok(!lstrcmpA(version
, "version"),
3994 "Expected version to be unchanged, got %s\n", version
);
3995 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3996 ok(!lstrcmpA(lang
, "lang"),
3997 "Expected lang to be unchanged, got %s\n", lang
);
3998 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
4001 GetSystemDirectoryA(path
, MAX_PATH
);
4002 lstrcatA(path
, "\\kernel32.dll");
4004 get_version_info(path
, &vercheck
, &verchecksz
, &langcheck
, &langchecksz
);
4006 /* absolute path, has version information */
4009 lstrcpyA(version
, "version");
4010 lstrcpyA(lang
, "lang");
4011 r
= MsiGetFileVersionA(path
, version
, &versz
, lang
, &langsz
);
4012 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4013 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4014 ok(strstr(lang
, langcheck
) != NULL
, "Expected %s in %s\n", langcheck
, lang
);
4015 ok(!lstrcmpA(version
, vercheck
),
4016 "Expected %s, got %s\n", vercheck
, version
);
4018 /* only check version */
4020 lstrcpyA(version
, "version");
4021 r
= MsiGetFileVersionA(path
, version
, &versz
, NULL
, NULL
);
4022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4023 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4024 ok(!lstrcmpA(version
, vercheck
),
4025 "Expected %s, got %s\n", vercheck
, version
);
4027 /* only check language */
4029 lstrcpyA(lang
, "lang");
4030 r
= MsiGetFileVersionA(path
, NULL
, NULL
, lang
, &langsz
);
4031 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4032 ok(strstr(lang
, langcheck
) != NULL
, "Expected %s in %s\n", langcheck
, lang
);
4034 /* check neither version nor language */
4035 r
= MsiGetFileVersionA(path
, NULL
, NULL
, NULL
, NULL
);
4036 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4038 /* get pcchVersionBuf */
4040 r
= MsiGetFileVersionA(path
, NULL
, &versz
, NULL
, NULL
);
4041 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4042 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4044 /* get pcchLangBuf */
4046 r
= MsiGetFileVersionA(path
, NULL
, NULL
, NULL
, &langsz
);
4047 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4048 ok(langsz
>= langchecksz
, "Expected %d >= %d\n", langsz
, langchecksz
);
4050 /* pcchVersionBuf not big enough */
4052 lstrcpyA(version
, "version");
4053 r
= MsiGetFileVersionA(path
, version
, &versz
, NULL
, NULL
);
4054 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4055 ok(!strncmp(version
, vercheck
, 4),
4056 "Expected first 4 characters of %s, got %s\n", vercheck
, version
);
4057 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4059 /* pcchLangBuf not big enough */
4061 lstrcpyA(lang
, "lang");
4062 r
= MsiGetFileVersionA(path
, NULL
, NULL
, lang
, &langsz
);
4063 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4064 ok(!strncmp(lang
, langcheck
, 2),
4065 "Expected first character of %s, got %s\n", langcheck
, lang
);
4066 ok(langsz
>= langchecksz
, "Expected %d >= %d\n", langsz
, langchecksz
);
4068 /* pcchVersionBuf big enough, pcchLangBuf not big enough */
4071 lstrcpyA(version
, "version");
4072 r
= MsiGetFileVersionA(path
, version
, &versz
, NULL
, &langsz
);
4073 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4074 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4075 ok(!lstrcmpA(version
, vercheck
), "Expected %s, got %s\n", vercheck
, version
);
4076 ok(langsz
>= langchecksz
&& langsz
< MAX_PATH
, "Expected %d >= %d\n", langsz
, langchecksz
);
4078 /* pcchVersionBuf not big enough, pcchLangBuf big enough */
4081 lstrcpyA(lang
, "lang");
4082 r
= MsiGetFileVersionA(path
, NULL
, &versz
, lang
, &langsz
);
4083 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4084 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4085 ok(langsz
>= langchecksz
&& langsz
< MAX_PATH
, "Expected %d >= %d\n", langsz
, langchecksz
);
4086 ok(lstrcmpA(lang
, "lang"), "lang buffer not modified\n");
4088 /* NULL pcchVersionBuf and pcchLangBuf */
4089 r
= MsiGetFileVersionA(path
, version
, NULL
, lang
, NULL
);
4090 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4092 /* All NULL except szFilePath */
4093 r
= MsiGetFileVersionA(path
, NULL
, NULL
, NULL
, NULL
);
4094 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4096 HeapFree(GetProcessHeap(), 0, vercheck
);
4097 HeapFree(GetProcessHeap(), 0, langcheck
);
4100 static void test_MsiGetProductInfo(void)
4104 HKEY propkey
, source
;
4105 HKEY prodkey
, localkey
;
4106 CHAR prodcode
[MAX_PATH
];
4107 CHAR prod_squashed
[MAX_PATH
];
4108 CHAR packcode
[MAX_PATH
];
4109 CHAR pack_squashed
[MAX_PATH
];
4111 CHAR keypath
[MAX_PATH
];
4114 REGSAM access
= KEY_ALL_ACCESS
;
4116 create_test_guid(prodcode
, prod_squashed
);
4117 create_test_guid(packcode
, pack_squashed
);
4118 usersid
= get_user_sid();
4121 access
|= KEY_WOW64_64KEY
;
4123 /* NULL szProduct */
4125 lstrcpyA(buf
, "apple");
4126 r
= MsiGetProductInfoA(NULL
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4127 ok(r
== ERROR_INVALID_PARAMETER
,
4128 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4129 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4130 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4132 /* empty szProduct */
4134 lstrcpyA(buf
, "apple");
4135 r
= MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4136 ok(r
== ERROR_INVALID_PARAMETER
,
4137 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4138 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4139 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4141 /* garbage szProduct */
4143 lstrcpyA(buf
, "apple");
4144 r
= MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4145 ok(r
== ERROR_INVALID_PARAMETER
,
4146 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4147 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4148 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4150 /* guid without brackets */
4152 lstrcpyA(buf
, "apple");
4153 r
= MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
4154 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4155 ok(r
== ERROR_INVALID_PARAMETER
,
4156 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4157 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4158 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4160 /* guid with brackets */
4162 lstrcpyA(buf
, "apple");
4163 r
= MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
4164 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4165 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4166 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4167 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4168 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4170 /* same length as guid, but random */
4172 lstrcpyA(buf
, "apple");
4173 r
= MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
4174 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4175 ok(r
== ERROR_INVALID_PARAMETER
,
4176 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4177 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4178 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4180 /* not installed, NULL szAttribute */
4182 lstrcpyA(buf
, "apple");
4183 r
= MsiGetProductInfoA(prodcode
, NULL
, buf
, &sz
);
4184 ok(r
== ERROR_INVALID_PARAMETER
,
4185 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4186 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4187 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4189 /* not installed, NULL lpValueBuf */
4191 lstrcpyA(buf
, "apple");
4192 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, NULL
, &sz
);
4193 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4194 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4195 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4196 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4198 /* not installed, NULL pcchValueBuf */
4200 lstrcpyA(buf
, "apple");
4201 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, NULL
);
4202 ok(r
== ERROR_INVALID_PARAMETER
,
4203 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4204 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4205 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4207 /* created guid cannot possibly be an installed product code */
4209 lstrcpyA(buf
, "apple");
4210 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4211 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4212 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4213 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4214 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4216 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4217 lstrcatA(keypath
, usersid
);
4218 lstrcatA(keypath
, "\\Installer\\Products\\");
4219 lstrcatA(keypath
, prod_squashed
);
4221 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
4222 if (res
== ERROR_ACCESS_DENIED
)
4224 skip("Not enough rights to perform tests\n");
4228 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4230 /* managed product code exists */
4232 lstrcpyA(buf
, "apple");
4233 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4234 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4235 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4236 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4237 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4239 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
4240 RegCloseKey(prodkey
);
4242 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4243 lstrcatA(keypath
, usersid
);
4244 lstrcatA(keypath
, "\\Products\\");
4245 lstrcatA(keypath
, prod_squashed
);
4247 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4248 if (res
== ERROR_ACCESS_DENIED
)
4250 skip("Not enough rights to perform tests\n");
4254 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4256 /* local user product code exists */
4258 lstrcpyA(buf
, "apple");
4259 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4260 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4261 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4262 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4263 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4265 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4266 lstrcatA(keypath
, usersid
);
4267 lstrcatA(keypath
, "\\Installer\\Products\\");
4268 lstrcatA(keypath
, prod_squashed
);
4270 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
4271 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4273 /* both local and managed product code exist */
4275 lstrcpyA(buf
, "apple");
4276 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4277 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4278 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4279 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4280 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4282 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4283 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4285 /* InstallProperties key exists */
4287 lstrcpyA(buf
, "apple");
4288 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4289 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4290 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4291 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4293 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
4294 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4296 /* HelpLink value exists */
4298 lstrcpyA(buf
, "apple");
4299 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4300 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4301 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
4302 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4304 /* pcchBuf is NULL */
4305 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, NULL
, NULL
);
4306 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4308 /* lpValueBuf is NULL */
4310 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, NULL
, &sz
);
4311 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4312 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4314 /* lpValueBuf is NULL, pcchValueBuf is too small */
4316 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, NULL
, &sz
);
4317 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4318 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4320 /* lpValueBuf is non-NULL, pcchValueBuf is too small */
4322 lstrcpyA(buf
, "apple");
4323 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4324 ok(!lstrcmpA(buf
, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf
);
4325 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4326 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4328 /* lpValueBuf is non-NULL, pcchValueBuf is exactly 4 */
4330 lstrcpyA(buf
, "apple");
4331 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4332 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4333 ok(!lstrcmpA(buf
, "apple"),
4334 "Expected buf to remain unchanged, got \"%s\"\n", buf
);
4335 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4337 res
= RegSetValueExA(propkey
, "IMadeThis", 0, REG_SZ
, (LPBYTE
)"random", 7);
4338 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4340 /* random property not supported by MSI, value exists */
4342 lstrcpyA(buf
, "apple");
4343 r
= MsiGetProductInfoA(prodcode
, "IMadeThis", buf
, &sz
);
4344 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4345 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4346 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4347 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4349 RegDeleteValueA(propkey
, "IMadeThis");
4350 RegDeleteValueA(propkey
, "HelpLink");
4351 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
4352 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
4353 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
4354 RegCloseKey(propkey
);
4355 RegCloseKey(localkey
);
4356 RegCloseKey(prodkey
);
4358 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
4359 lstrcatA(keypath
, prod_squashed
);
4361 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
4362 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4364 /* user product key exists */
4366 lstrcpyA(buf
, "apple");
4367 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4368 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4369 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4370 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4371 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4373 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4374 lstrcatA(keypath
, usersid
);
4375 lstrcatA(keypath
, "\\Products\\");
4376 lstrcatA(keypath
, prod_squashed
);
4378 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4379 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4381 /* local user product key exists */
4383 lstrcpyA(buf
, "apple");
4384 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4385 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4386 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4387 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4388 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4390 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4391 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4393 /* InstallProperties key exists */
4395 lstrcpyA(buf
, "apple");
4396 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4397 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4398 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4399 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4401 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
4402 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4404 /* HelpLink value exists */
4406 lstrcpyA(buf
, "apple");
4407 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4408 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4409 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
4410 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4412 RegDeleteValueA(propkey
, "HelpLink");
4413 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
4414 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
4415 RegDeleteKeyA(prodkey
, "");
4416 RegCloseKey(propkey
);
4417 RegCloseKey(localkey
);
4418 RegCloseKey(prodkey
);
4420 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
4421 lstrcatA(keypath
, prod_squashed
);
4423 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
4424 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4426 /* classes product key exists */
4428 lstrcpyA(buf
, "apple");
4429 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4430 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4431 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4432 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4433 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4435 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4436 lstrcatA(keypath
, usersid
);
4437 lstrcatA(keypath
, "\\Products\\");
4438 lstrcatA(keypath
, prod_squashed
);
4440 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4441 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4443 /* local user product key exists */
4445 lstrcpyA(buf
, "apple");
4446 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4447 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4448 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4449 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4450 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4452 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4453 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4455 /* InstallProperties key exists */
4457 lstrcpyA(buf
, "apple");
4458 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4459 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4460 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4461 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4462 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4464 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
4465 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
4466 RegCloseKey(propkey
);
4467 RegCloseKey(localkey
);
4469 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4470 lstrcatA(keypath
, "S-1-5-18\\\\Products\\");
4471 lstrcatA(keypath
, prod_squashed
);
4473 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4474 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4476 /* Local System product key exists */
4478 lstrcpyA(buf
, "apple");
4479 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4480 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4481 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4482 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4483 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4485 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4486 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4488 /* InstallProperties key exists */
4490 lstrcpyA(buf
, "apple");
4491 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4492 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4493 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4494 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4496 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
4497 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4499 /* HelpLink value exists */
4501 lstrcpyA(buf
, "apple");
4502 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4503 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4504 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
4505 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4507 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_DWORD
,
4508 (const BYTE
*)&val
, sizeof(DWORD
));
4509 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4511 /* HelpLink type is REG_DWORD */
4513 lstrcpyA(buf
, "apple");
4514 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
4515 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4516 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4517 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4519 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
4520 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4522 /* DisplayName value exists */
4524 lstrcpyA(buf
, "apple");
4525 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
4526 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4527 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
4528 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4530 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_DWORD
,
4531 (const BYTE
*)&val
, sizeof(DWORD
));
4532 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4534 /* DisplayName type is REG_DWORD */
4536 lstrcpyA(buf
, "apple");
4537 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
4538 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4539 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4540 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4542 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"1.1.1", 6);
4543 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4545 /* DisplayVersion value exists */
4547 lstrcpyA(buf
, "apple");
4548 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
4549 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4550 ok(!lstrcmpA(buf
, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf
);
4551 ok(sz
== 5, "Expected 5, got %d\n", sz
);
4553 res
= RegSetValueExA(propkey
, "DisplayVersion", 0,
4554 REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
4555 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4557 /* DisplayVersion type is REG_DWORD */
4559 lstrcpyA(buf
, "apple");
4560 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
4561 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4562 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4563 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4565 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"tele", 5);
4566 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4568 /* HelpTelephone value exists */
4570 lstrcpyA(buf
, "apple");
4571 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
4572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4573 ok(!lstrcmpA(buf
, "tele"), "Expected \"tele\", got \"%s\"\n", buf
);
4574 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4576 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_DWORD
,
4577 (const BYTE
*)&val
, sizeof(DWORD
));
4578 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4580 /* HelpTelephone type is REG_DWORD */
4582 lstrcpyA(buf
, "apple");
4583 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
4584 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4585 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4586 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4588 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
4589 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4591 /* InstallLocation value exists */
4593 lstrcpyA(buf
, "apple");
4594 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
4595 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4596 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
4597 ok(sz
== 3, "Expected 3, got %d\n", sz
);
4599 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_DWORD
,
4600 (const BYTE
*)&val
, sizeof(DWORD
));
4601 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4603 /* InstallLocation type is REG_DWORD */
4605 lstrcpyA(buf
, "apple");
4606 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
4607 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4608 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4609 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4611 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
4612 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4614 /* InstallSource value exists */
4616 lstrcpyA(buf
, "apple");
4617 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
4618 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4619 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
4620 ok(sz
== 6, "Expected 6, got %d\n", sz
);
4622 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_DWORD
,
4623 (const BYTE
*)&val
, sizeof(DWORD
));
4624 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4626 /* InstallSource type is REG_DWORD */
4628 lstrcpyA(buf
, "apple");
4629 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
4630 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4631 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4632 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4634 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
4635 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4637 /* InstallDate value exists */
4639 lstrcpyA(buf
, "apple");
4640 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
4641 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4642 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
4643 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4645 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_DWORD
,
4646 (const BYTE
*)&val
, sizeof(DWORD
));
4647 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4649 /* InstallDate type is REG_DWORD */
4651 lstrcpyA(buf
, "apple");
4652 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
4653 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4654 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4655 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4657 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
4658 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4660 /* Publisher value exists */
4662 lstrcpyA(buf
, "apple");
4663 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
4664 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4665 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
4666 ok(sz
== 3, "Expected 3, got %d\n", sz
);
4668 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_DWORD
,
4669 (const BYTE
*)&val
, sizeof(DWORD
));
4670 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4672 /* Publisher type is REG_DWORD */
4674 lstrcpyA(buf
, "apple");
4675 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
4676 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4677 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4678 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4680 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"pack", 5);
4681 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4683 /* LocalPackage value exists */
4685 lstrcpyA(buf
, "apple");
4686 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
4687 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4688 ok(!lstrcmpA(buf
, "pack"), "Expected \"pack\", got \"%s\"\n", buf
);
4689 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4691 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_DWORD
,
4692 (const BYTE
*)&val
, sizeof(DWORD
));
4693 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4695 /* LocalPackage type is REG_DWORD */
4697 lstrcpyA(buf
, "apple");
4698 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
4699 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4700 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4701 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4703 res
= RegSetValueExA(propkey
, "UrlInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
4704 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4706 /* UrlInfoAbout value exists */
4708 lstrcpyA(buf
, "apple");
4709 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
4710 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4711 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
4712 ok(sz
== 5, "Expected 5, got %d\n", sz
);
4714 res
= RegSetValueExA(propkey
, "UrlInfoAbout", 0, REG_DWORD
,
4715 (const BYTE
*)&val
, sizeof(DWORD
));
4716 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4718 /* UrlInfoAbout type is REG_DWORD */
4720 lstrcpyA(buf
, "apple");
4721 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
4722 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4723 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4724 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4726 res
= RegSetValueExA(propkey
, "UrlUpdateInfo", 0, REG_SZ
, (LPBYTE
)"info", 5);
4727 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4729 /* UrlUpdateInfo value exists */
4731 lstrcpyA(buf
, "apple");
4732 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
4733 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4734 ok(!lstrcmpA(buf
, "info"), "Expected \"info\", got \"%s\"\n", buf
);
4735 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4737 res
= RegSetValueExA(propkey
, "UrlUpdateInfo", 0, REG_DWORD
,
4738 (const BYTE
*)&val
, sizeof(DWORD
));
4739 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4741 /* UrlUpdateInfo type is REG_DWORD */
4743 lstrcpyA(buf
, "apple");
4744 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
4745 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4746 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4747 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4749 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"1", 2);
4750 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4752 /* VersionMinor value exists */
4754 lstrcpyA(buf
, "apple");
4755 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
4756 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4757 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
4758 ok(sz
== 1, "Expected 1, got %d\n", sz
);
4760 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_DWORD
,
4761 (const BYTE
*)&val
, sizeof(DWORD
));
4762 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4764 /* VersionMinor type is REG_DWORD */
4766 lstrcpyA(buf
, "apple");
4767 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
4768 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4769 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4770 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4772 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"1", 2);
4773 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4775 /* VersionMajor value exists */
4777 lstrcpyA(buf
, "apple");
4778 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
4779 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4780 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
4781 ok(sz
== 1, "Expected 1, got %d\n", sz
);
4783 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_DWORD
,
4784 (const BYTE
*)&val
, sizeof(DWORD
));
4785 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4787 /* VersionMajor type is REG_DWORD */
4789 lstrcpyA(buf
, "apple");
4790 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
4791 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4792 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4793 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4795 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
4796 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4798 /* ProductID value exists */
4800 lstrcpyA(buf
, "apple");
4801 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
4802 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4803 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
4804 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4806 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_DWORD
,
4807 (const BYTE
*)&val
, sizeof(DWORD
));
4808 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4810 /* ProductID type is REG_DWORD */
4812 lstrcpyA(buf
, "apple");
4813 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
4814 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4815 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4816 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4818 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
4819 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4821 /* RegCompany value exists */
4823 lstrcpyA(buf
, "apple");
4824 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
4825 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4826 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
4827 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4829 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_DWORD
,
4830 (const BYTE
*)&val
, sizeof(DWORD
));
4831 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4833 /* RegCompany type is REG_DWORD */
4835 lstrcpyA(buf
, "apple");
4836 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
4837 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4838 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4839 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4841 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"own", 4);
4842 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4844 /* RegOwner value exists */
4846 lstrcpyA(buf
, "apple");
4847 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
4848 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4849 ok(!lstrcmpA(buf
, "own"), "Expected \"own\", got \"%s\"\n", buf
);
4850 ok(sz
== 3, "Expected 3, got %d\n", sz
);
4852 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_DWORD
,
4853 (const BYTE
*)&val
, sizeof(DWORD
));
4854 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4856 /* RegOwner type is REG_DWORD */
4858 lstrcpyA(buf
, "apple");
4859 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
4860 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4861 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4862 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4864 res
= RegSetValueExA(propkey
, "InstanceType", 0, REG_SZ
, (LPBYTE
)"type", 5);
4865 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4867 /* InstanceType value exists */
4869 lstrcpyA(buf
, "apple");
4870 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPE
, buf
, &sz
);
4871 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4872 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4873 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4875 res
= RegSetValueExA(propkey
, "InstanceType", 0, REG_DWORD
,
4876 (const BYTE
*)&val
, sizeof(DWORD
));
4877 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4879 /* InstanceType type is REG_DWORD */
4881 lstrcpyA(buf
, "apple");
4882 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPE
, buf
, &sz
);
4883 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4884 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4885 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4887 res
= RegSetValueExA(prodkey
, "InstanceType", 0, REG_SZ
, (LPBYTE
)"type", 5);
4888 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4890 /* InstanceType value exists */
4892 lstrcpyA(buf
, "apple");
4893 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPE
, buf
, &sz
);
4894 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4895 ok(!lstrcmpA(buf
, "type"), "Expected \"type\", got \"%s\"\n", buf
);
4896 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4898 res
= RegSetValueExA(prodkey
, "InstanceType", 0, REG_DWORD
,
4899 (const BYTE
*)&val
, sizeof(DWORD
));
4900 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4902 /* InstanceType type is REG_DWORD */
4904 lstrcpyA(buf
, "apple");
4905 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPE
, buf
, &sz
);
4906 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4907 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4908 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4910 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"tforms", 7);
4911 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4913 /* Transforms value exists */
4915 lstrcpyA(buf
, "apple");
4916 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
4917 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4918 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4919 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4921 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_DWORD
,
4922 (const BYTE
*)&val
, sizeof(DWORD
));
4923 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4925 /* Transforms type is REG_DWORD */
4927 lstrcpyA(buf
, "apple");
4928 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
4929 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4930 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4931 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4933 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"tforms", 7);
4934 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4936 /* Transforms value exists */
4938 lstrcpyA(buf
, "apple");
4939 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
4940 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4941 ok(!lstrcmpA(buf
, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf
);
4942 ok(sz
== 6, "Expected 6, got %d\n", sz
);
4944 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_DWORD
,
4945 (const BYTE
*)&val
, sizeof(DWORD
));
4946 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4948 /* Transforms type is REG_DWORD */
4950 lstrcpyA(buf
, "apple");
4951 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
4952 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4953 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4954 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4956 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
4957 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4959 /* Language value exists */
4961 lstrcpyA(buf
, "apple");
4962 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
4963 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4964 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4965 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4967 res
= RegSetValueExA(propkey
, "Language", 0, REG_DWORD
,
4968 (const BYTE
*)&val
, sizeof(DWORD
));
4969 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4971 /* Language type is REG_DWORD */
4973 lstrcpyA(buf
, "apple");
4974 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
4975 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4976 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4977 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4979 res
= RegSetValueExA(prodkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
4980 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4982 /* Language value exists */
4984 lstrcpyA(buf
, "apple");
4985 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
4986 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4987 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
4988 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4990 res
= RegSetValueExA(prodkey
, "Language", 0, REG_DWORD
,
4991 (const BYTE
*)&val
, sizeof(DWORD
));
4992 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4994 /* Language type is REG_DWORD */
4996 lstrcpyA(buf
, "apple");
4997 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
4998 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4999 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5000 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5002 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5003 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5005 /* ProductName value exists */
5007 lstrcpyA(buf
, "apple");
5008 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
5009 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5010 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5011 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5013 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_DWORD
,
5014 (const BYTE
*)&val
, sizeof(DWORD
));
5015 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5017 /* ProductName type is REG_DWORD */
5019 lstrcpyA(buf
, "apple");
5020 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
5021 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5022 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5023 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5025 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5026 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5028 /* ProductName value exists */
5030 lstrcpyA(buf
, "apple");
5031 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
5032 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5033 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
5034 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5036 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_DWORD
,
5037 (const BYTE
*)&val
, sizeof(DWORD
));
5038 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5040 /* ProductName type is REG_DWORD */
5042 lstrcpyA(buf
, "apple");
5043 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
5044 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5045 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5046 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5048 res
= RegSetValueExA(propkey
, "Assignment", 0, REG_SZ
, (LPBYTE
)"at", 3);
5049 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5051 /* Assignment value exists */
5053 lstrcpyA(buf
, "apple");
5054 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
5055 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5056 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5057 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5059 res
= RegSetValueExA(propkey
, "Assignment", 0, REG_DWORD
,
5060 (const BYTE
*)&val
, sizeof(DWORD
));
5061 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5063 /* Assignment type is REG_DWORD */
5065 lstrcpyA(buf
, "apple");
5066 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
5067 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5068 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5069 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5071 res
= RegSetValueExA(prodkey
, "Assignment", 0, REG_SZ
, (LPBYTE
)"at", 3);
5072 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5074 /* Assignment value exists */
5076 lstrcpyA(buf
, "apple");
5077 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
5078 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5079 ok(!lstrcmpA(buf
, "at"), "Expected \"at\", got \"%s\"\n", buf
);
5080 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5082 res
= RegSetValueExA(prodkey
, "Assignment", 0, REG_DWORD
,
5083 (const BYTE
*)&val
, sizeof(DWORD
));
5084 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5086 /* Assignment type is REG_DWORD */
5088 lstrcpyA(buf
, "apple");
5089 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
5090 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5091 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5092 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5094 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
5095 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5097 /* PackageCode value exists */
5099 lstrcpyA(buf
, "apple");
5100 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
5101 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5102 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5103 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5105 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_DWORD
,
5106 (const BYTE
*)&val
, sizeof(DWORD
));
5107 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5109 /* PackageCode type is REG_DWORD */
5111 lstrcpyA(buf
, "apple");
5112 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
5113 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5114 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5115 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5117 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
5118 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5120 /* PackageCode value exists */
5122 lstrcpyA(buf
, "apple");
5123 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
5124 ok(r
== ERROR_BAD_CONFIGURATION
,
5125 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
5126 ok(!lstrcmpA(buf
, "code"), "Expected \"code\", got \"%s\"\n", buf
);
5127 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5129 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_DWORD
,
5130 (const BYTE
*)&val
, sizeof(DWORD
));
5131 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5133 /* PackageCode type is REG_DWORD */
5135 lstrcpyA(buf
, "apple");
5136 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
5137 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5138 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5139 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5141 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)pack_squashed
, 33);
5142 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5144 /* PackageCode value exists */
5146 lstrcpyA(buf
, "apple");
5147 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
5148 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5149 ok(!lstrcmpA(buf
, packcode
), "Expected \"%s\", got \"%s\"\n", packcode
, buf
);
5150 ok(sz
== 38, "Expected 38, got %d\n", sz
);
5152 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
5153 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5155 /* Version value exists */
5157 lstrcpyA(buf
, "apple");
5158 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSION
, buf
, &sz
);
5159 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5160 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5161 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5163 res
= RegSetValueExA(propkey
, "Version", 0, REG_DWORD
,
5164 (const BYTE
*)&val
, sizeof(DWORD
));
5165 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5167 /* Version type is REG_DWORD */
5169 lstrcpyA(buf
, "apple");
5170 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSION
, buf
, &sz
);
5171 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5172 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5173 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5175 res
= RegSetValueExA(prodkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
5176 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5178 /* Version value exists */
5180 lstrcpyA(buf
, "apple");
5181 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSION
, buf
, &sz
);
5182 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5183 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
5184 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5186 res
= RegSetValueExA(prodkey
, "Version", 0, REG_DWORD
,
5187 (const BYTE
*)&val
, sizeof(DWORD
));
5188 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5190 /* Version type is REG_DWORD */
5192 lstrcpyA(buf
, "apple");
5193 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSION
, buf
, &sz
);
5194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5195 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5196 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5198 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"ico", 4);
5199 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5201 /* ProductIcon value exists */
5203 lstrcpyA(buf
, "apple");
5204 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
5205 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5206 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5207 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5209 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_DWORD
,
5210 (const BYTE
*)&val
, sizeof(DWORD
));
5211 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5213 /* ProductIcon type is REG_DWORD */
5215 lstrcpyA(buf
, "apple");
5216 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
5217 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5218 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5219 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5221 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"ico", 4);
5222 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5224 /* ProductIcon value exists */
5226 lstrcpyA(buf
, "apple");
5227 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
5228 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5229 ok(!lstrcmpA(buf
, "ico"), "Expected \"ico\", got \"%s\"\n", buf
);
5230 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5232 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_DWORD
,
5233 (const BYTE
*)&val
, sizeof(DWORD
));
5234 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5236 /* ProductIcon type is REG_DWORD */
5238 lstrcpyA(buf
, "apple");
5239 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
5240 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5241 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5242 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5244 /* SourceList key does not exist */
5246 lstrcpyA(buf
, "apple");
5247 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
5248 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5249 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5250 ok(!lstrcmpA(buf
, "apple"),
5251 "Expected buf to be unchanged, got \"%s\"\n", buf
);
5252 ok(sz
== MAX_PATH
, "Expected sz to be unchanged, got %d\n", sz
);
5254 res
= RegCreateKeyExA(prodkey
, "SourceList", 0, NULL
, 0, access
, NULL
, &source
, NULL
);
5255 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5257 /* SourceList key exists, but PackageName val does not exist */
5259 lstrcpyA(buf
, "apple");
5260 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
5261 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5262 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5263 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5265 res
= RegSetValueExA(source
, "PackageName", 0, REG_SZ
, (LPBYTE
)"packname", 9);
5266 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5268 /* PackageName val exists */
5270 lstrcpyA(buf
, "apple");
5271 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
5272 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5273 ok(!lstrcmpA(buf
, "packname"), "Expected \"packname\", got \"%s\"\n", buf
);
5274 ok(sz
== 8, "Expected 8, got %d\n", sz
);
5276 res
= RegSetValueExA(source
, "PackageName", 0, REG_DWORD
,
5277 (const BYTE
*)&val
, sizeof(DWORD
));
5278 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5280 /* PackageName type is REG_DWORD */
5282 lstrcpyA(buf
, "apple");
5283 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
5284 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5285 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5286 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5288 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
5289 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5291 /* Authorized value exists */
5293 lstrcpyA(buf
, "apple");
5294 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
5295 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5297 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5298 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5299 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5302 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_DWORD
,
5303 (const BYTE
*)&val
, sizeof(DWORD
));
5304 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5306 /* AuthorizedLUAApp type is REG_DWORD */
5308 lstrcpyA(buf
, "apple");
5309 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
5310 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5312 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5313 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5314 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5317 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
5318 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5320 /* Authorized value exists */
5322 lstrcpyA(buf
, "apple");
5323 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
5324 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5326 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5327 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
5328 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5331 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_DWORD
,
5332 (const BYTE
*)&val
, sizeof(DWORD
));
5333 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5335 /* AuthorizedLUAApp type is REG_DWORD */
5337 lstrcpyA(buf
, "apple");
5338 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
5339 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5341 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5342 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5343 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5346 RegDeleteValueA(propkey
, "HelpLink");
5347 RegDeleteValueA(propkey
, "DisplayName");
5348 RegDeleteValueA(propkey
, "DisplayVersion");
5349 RegDeleteValueA(propkey
, "HelpTelephone");
5350 RegDeleteValueA(propkey
, "InstallLocation");
5351 RegDeleteValueA(propkey
, "InstallSource");
5352 RegDeleteValueA(propkey
, "InstallDate");
5353 RegDeleteValueA(propkey
, "Publisher");
5354 RegDeleteValueA(propkey
, "LocalPackage");
5355 RegDeleteValueA(propkey
, "UrlInfoAbout");
5356 RegDeleteValueA(propkey
, "UrlUpdateInfo");
5357 RegDeleteValueA(propkey
, "VersionMinor");
5358 RegDeleteValueA(propkey
, "VersionMajor");
5359 RegDeleteValueA(propkey
, "ProductID");
5360 RegDeleteValueA(propkey
, "RegCompany");
5361 RegDeleteValueA(propkey
, "RegOwner");
5362 RegDeleteValueA(propkey
, "InstanceType");
5363 RegDeleteValueA(propkey
, "Transforms");
5364 RegDeleteValueA(propkey
, "Language");
5365 RegDeleteValueA(propkey
, "ProductName");
5366 RegDeleteValueA(propkey
, "Assignment");
5367 RegDeleteValueA(propkey
, "PackageCode");
5368 RegDeleteValueA(propkey
, "Version");
5369 RegDeleteValueA(propkey
, "ProductIcon");
5370 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
5371 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
5372 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
5373 RegDeleteValueA(prodkey
, "InstanceType");
5374 RegDeleteValueA(prodkey
, "Transforms");
5375 RegDeleteValueA(prodkey
, "Language");
5376 RegDeleteValueA(prodkey
, "ProductName");
5377 RegDeleteValueA(prodkey
, "Assignment");
5378 RegDeleteValueA(prodkey
, "PackageCode");
5379 RegDeleteValueA(prodkey
, "Version");
5380 RegDeleteValueA(prodkey
, "ProductIcon");
5381 RegDeleteValueA(prodkey
, "AuthorizedLUAApp");
5382 RegDeleteValueA(source
, "PackageName");
5383 delete_key(source
, "", access
& KEY_WOW64_64KEY
);
5384 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
5385 RegCloseKey(propkey
);
5386 RegCloseKey(localkey
);
5387 RegCloseKey(source
);
5388 RegCloseKey(prodkey
);
5392 static void test_MsiGetProductInfoEx(void)
5396 HKEY propkey
, userkey
;
5397 HKEY prodkey
, localkey
;
5398 CHAR prodcode
[MAX_PATH
];
5399 CHAR prod_squashed
[MAX_PATH
];
5400 CHAR packcode
[MAX_PATH
];
5401 CHAR pack_squashed
[MAX_PATH
];
5403 CHAR keypath
[MAX_PATH
];
5406 REGSAM access
= KEY_ALL_ACCESS
;
5408 if (!pMsiGetProductInfoExA
)
5410 win_skip("MsiGetProductInfoExA is not available\n");
5414 create_test_guid(prodcode
, prod_squashed
);
5415 create_test_guid(packcode
, pack_squashed
);
5416 usersid
= get_user_sid();
5419 access
|= KEY_WOW64_64KEY
;
5421 /* NULL szProductCode */
5423 lstrcpyA(buf
, "apple");
5424 r
= pMsiGetProductInfoExA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
5425 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5426 ok(r
== ERROR_INVALID_PARAMETER
,
5427 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5428 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5429 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5431 /* empty szProductCode */
5433 lstrcpyA(buf
, "apple");
5434 r
= pMsiGetProductInfoExA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
5435 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5436 ok(r
== ERROR_INVALID_PARAMETER
,
5437 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5438 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5439 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5441 /* garbage szProductCode */
5443 lstrcpyA(buf
, "apple");
5444 r
= pMsiGetProductInfoExA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
5445 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5446 ok(r
== ERROR_INVALID_PARAMETER
,
5447 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5448 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5449 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5451 /* guid without brackets */
5453 lstrcpyA(buf
, "apple");
5454 r
= pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid
,
5455 MSIINSTALLCONTEXT_USERUNMANAGED
,
5456 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5457 ok(r
== ERROR_INVALID_PARAMETER
,
5458 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5459 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5460 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5462 /* guid with brackets */
5464 lstrcpyA(buf
, "apple");
5465 r
= pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid
,
5466 MSIINSTALLCONTEXT_USERUNMANAGED
,
5467 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5468 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5469 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5470 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5471 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5473 /* szValue is non-NULL while pcchValue is NULL */
5474 lstrcpyA(buf
, "apple");
5475 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5476 MSIINSTALLCONTEXT_USERUNMANAGED
,
5477 INSTALLPROPERTY_PRODUCTSTATE
, buf
, NULL
);
5478 ok(r
== ERROR_INVALID_PARAMETER
,
5479 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5480 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5482 /* dwContext is out of range */
5484 lstrcpyA(buf
, "apple");
5485 r
= pMsiGetProductInfoExA(prodcode
, usersid
, 42,
5486 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5487 ok(r
== ERROR_INVALID_PARAMETER
,
5488 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5489 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5490 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5492 /* szProperty is NULL */
5494 lstrcpyA(buf
, "apple");
5495 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5496 MSIINSTALLCONTEXT_USERUNMANAGED
,
5498 ok(r
== ERROR_INVALID_PARAMETER
,
5499 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5500 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5501 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5503 /* szProperty is empty */
5505 lstrcpyA(buf
, "apple");
5506 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5507 MSIINSTALLCONTEXT_USERUNMANAGED
,
5509 ok(r
== ERROR_INVALID_PARAMETER
,
5510 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5511 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5512 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5514 /* szProperty is not a valid property */
5516 lstrcpyA(buf
, "apple");
5517 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5518 MSIINSTALLCONTEXT_USERUNMANAGED
,
5519 "notvalid", buf
, &sz
);
5520 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5521 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5522 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5523 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5525 /* same length as guid, but random */
5527 lstrcpyA(buf
, "apple");
5528 r
= pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid
,
5529 MSIINSTALLCONTEXT_USERUNMANAGED
,
5530 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5531 ok(r
== ERROR_INVALID_PARAMETER
,
5532 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5533 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5534 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5536 /* MSIINSTALLCONTEXT_USERUNMANAGED */
5538 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
5539 lstrcatA(keypath
, usersid
);
5540 lstrcatA(keypath
, "\\Products\\");
5541 lstrcatA(keypath
, prod_squashed
);
5543 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
5544 if (res
== ERROR_ACCESS_DENIED
)
5546 skip("Not enough rights to perform tests\n");
5550 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5552 /* local user product key exists */
5554 lstrcpyA(buf
, "apple");
5555 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5556 MSIINSTALLCONTEXT_USERUNMANAGED
,
5557 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5558 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5559 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5560 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5561 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5563 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
5564 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5566 /* InstallProperties key exists */
5568 lstrcpyA(buf
, "apple");
5569 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5570 MSIINSTALLCONTEXT_USERUNMANAGED
,
5571 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5572 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5573 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5574 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5575 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5577 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
5578 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5580 /* LocalPackage value exists */
5582 lstrcpyA(buf
, "apple");
5583 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5584 MSIINSTALLCONTEXT_USERUNMANAGED
,
5585 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
5586 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5587 ok(!lstrcmpA(buf
, "5"), "Expected \"5\", got \"%s\"\n", buf
);
5588 ok(sz
== 1, "Expected 1, got %d\n", sz
);
5590 RegDeleteValueA(propkey
, "LocalPackage");
5592 /* LocalPackage value must exist */
5594 lstrcpyA(buf
, "apple");
5595 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5596 MSIINSTALLCONTEXT_USERUNMANAGED
,
5597 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
5598 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5599 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5600 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5601 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5603 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
5604 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5606 /* LocalPackage exists, but HelpLink does not exist */
5608 lstrcpyA(buf
, "apple");
5609 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5610 MSIINSTALLCONTEXT_USERUNMANAGED
,
5611 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
5612 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5613 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5614 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5616 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
5617 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5619 /* HelpLink value exists */
5621 lstrcpyA(buf
, "apple");
5622 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5623 MSIINSTALLCONTEXT_USERUNMANAGED
,
5624 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
5625 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5626 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
5627 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5629 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
5630 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5632 /* HelpTelephone value exists */
5634 lstrcpyA(buf
, "apple");
5635 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5636 MSIINSTALLCONTEXT_USERUNMANAGED
,
5637 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
5638 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5639 ok(!lstrcmpA(buf
, "phone"), "Expected \"phone\", got \"%s\"\n", buf
);
5640 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5642 /* szValue and pcchValue are NULL */
5643 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5644 MSIINSTALLCONTEXT_USERUNMANAGED
,
5645 INSTALLPROPERTY_HELPTELEPHONE
, NULL
, NULL
);
5646 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5648 /* pcchValue is exactly 5 */
5650 lstrcpyA(buf
, "apple");
5651 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5652 MSIINSTALLCONTEXT_USERUNMANAGED
,
5653 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
5654 ok(r
== ERROR_MORE_DATA
,
5655 "Expected ERROR_MORE_DATA, got %d\n", r
);
5656 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5658 /* szValue is NULL, pcchValue is exactly 5 */
5660 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5661 MSIINSTALLCONTEXT_USERUNMANAGED
,
5662 INSTALLPROPERTY_HELPTELEPHONE
, NULL
, &sz
);
5663 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5664 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5666 /* szValue is NULL, pcchValue is MAX_PATH */
5668 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5669 MSIINSTALLCONTEXT_USERUNMANAGED
,
5670 INSTALLPROPERTY_HELPTELEPHONE
, NULL
, &sz
);
5671 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5672 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5674 /* pcchValue is exactly 0 */
5676 lstrcpyA(buf
, "apple");
5677 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5678 MSIINSTALLCONTEXT_USERUNMANAGED
,
5679 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
5680 ok(r
== ERROR_MORE_DATA
,
5681 "Expected ERROR_MORE_DATA, got %d\n", r
);
5682 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
5683 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5685 res
= RegSetValueExA(propkey
, "notvalid", 0, REG_SZ
, (LPBYTE
)"invalid", 8);
5686 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5688 /* szProperty is not a valid property */
5690 lstrcpyA(buf
, "apple");
5691 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5692 MSIINSTALLCONTEXT_USERUNMANAGED
,
5693 "notvalid", buf
, &sz
);
5694 ok(r
== ERROR_UNKNOWN_PROPERTY
,
5695 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
5696 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5697 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5699 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
5700 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5702 /* InstallDate value exists */
5704 lstrcpyA(buf
, "apple");
5705 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5706 MSIINSTALLCONTEXT_USERUNMANAGED
,
5707 INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
5708 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5709 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
5710 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5712 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5713 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5715 /* DisplayName value exists */
5717 lstrcpyA(buf
, "apple");
5718 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5719 MSIINSTALLCONTEXT_USERUNMANAGED
,
5720 INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
5721 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5722 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
5723 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5725 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
5726 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5728 /* InstallLocation value exists */
5730 lstrcpyA(buf
, "apple");
5731 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5732 MSIINSTALLCONTEXT_USERUNMANAGED
,
5733 INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
5734 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5735 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
5736 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5738 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
5739 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5741 /* InstallSource value exists */
5743 lstrcpyA(buf
, "apple");
5744 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5745 MSIINSTALLCONTEXT_USERUNMANAGED
,
5746 INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
5747 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5748 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
5749 ok(sz
== 6, "Expected 6, got %d\n", sz
);
5751 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
5752 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5754 /* LocalPackage value exists */
5756 lstrcpyA(buf
, "apple");
5757 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5758 MSIINSTALLCONTEXT_USERUNMANAGED
,
5759 INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
5760 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5761 ok(!lstrcmpA(buf
, "local"), "Expected \"local\", got \"%s\"\n", buf
);
5762 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5764 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
5765 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5767 /* Publisher value exists */
5769 lstrcpyA(buf
, "apple");
5770 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5771 MSIINSTALLCONTEXT_USERUNMANAGED
,
5772 INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
5773 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5774 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
5775 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5777 res
= RegSetValueExA(propkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
5778 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5780 /* URLInfoAbout value exists */
5782 lstrcpyA(buf
, "apple");
5783 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5784 MSIINSTALLCONTEXT_USERUNMANAGED
,
5785 INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
5786 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5787 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
5788 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5790 res
= RegSetValueExA(propkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
5791 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5793 /* URLUpdateInfo value exists */
5795 lstrcpyA(buf
, "apple");
5796 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5797 MSIINSTALLCONTEXT_USERUNMANAGED
,
5798 INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
5799 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5800 ok(!lstrcmpA(buf
, "update"), "Expected \"update\", got \"%s\"\n", buf
);
5801 ok(sz
== 6, "Expected 6, got %d\n", sz
);
5803 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
5804 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5806 /* VersionMinor value exists */
5808 lstrcpyA(buf
, "apple");
5809 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5810 MSIINSTALLCONTEXT_USERUNMANAGED
,
5811 INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
5812 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5813 ok(!lstrcmpA(buf
, "2"), "Expected \"2\", got \"%s\"\n", buf
);
5814 ok(sz
== 1, "Expected 1, got %d\n", sz
);
5816 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
5817 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5819 /* VersionMajor value exists */
5821 lstrcpyA(buf
, "apple");
5822 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5823 MSIINSTALLCONTEXT_USERUNMANAGED
,
5824 INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
5825 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5826 ok(!lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5827 ok(sz
== 1, "Expected 1, got %d\n", sz
);
5829 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
5830 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5832 /* DisplayVersion value exists */
5834 lstrcpyA(buf
, "apple");
5835 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5836 MSIINSTALLCONTEXT_USERUNMANAGED
,
5837 INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
5838 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5839 ok(!lstrcmpA(buf
, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf
);
5840 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5842 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
5843 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5845 /* ProductID value exists */
5847 lstrcpyA(buf
, "apple");
5848 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5849 MSIINSTALLCONTEXT_USERUNMANAGED
,
5850 INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
5851 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5852 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
5853 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5855 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
5856 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5858 /* RegCompany value exists */
5860 lstrcpyA(buf
, "apple");
5861 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5862 MSIINSTALLCONTEXT_USERUNMANAGED
,
5863 INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
5864 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5865 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
5866 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5868 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
5869 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5871 /* RegOwner value exists */
5873 lstrcpyA(buf
, "apple");
5874 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5875 MSIINSTALLCONTEXT_USERUNMANAGED
,
5876 INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
5877 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5878 ok(!lstrcmpA(buf
, "owner"), "Expected \"owner\", got \"%s\"\n", buf
);
5879 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5881 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
5882 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5884 /* Transforms value exists */
5886 lstrcpyA(buf
, "apple");
5887 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5888 MSIINSTALLCONTEXT_USERUNMANAGED
,
5889 INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
5890 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5891 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5892 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5893 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5895 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
5896 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5898 /* Language value exists */
5900 lstrcpyA(buf
, "apple");
5901 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5902 MSIINSTALLCONTEXT_USERUNMANAGED
,
5903 INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
5904 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5905 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5906 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5907 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5909 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5910 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5912 /* ProductName value exists */
5914 lstrcpyA(buf
, "apple");
5915 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5916 MSIINSTALLCONTEXT_USERUNMANAGED
,
5917 INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
5918 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5919 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5920 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5921 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5923 res
= RegSetValueExA(propkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
5924 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5928 /* AssignmentType value exists */
5930 lstrcpyA(buf
, "apple");
5931 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5932 MSIINSTALLCONTEXT_USERUNMANAGED
,
5933 INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
5934 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5935 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5936 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5937 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5939 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
5940 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5942 /* PackageCode value exists */
5944 lstrcpyA(buf
, "apple");
5945 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5946 MSIINSTALLCONTEXT_USERUNMANAGED
,
5947 INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
5948 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5949 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5950 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5951 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5953 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
5954 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5956 /* Version value exists */
5958 lstrcpyA(buf
, "apple");
5959 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5960 MSIINSTALLCONTEXT_USERUNMANAGED
,
5961 INSTALLPROPERTY_VERSION
, buf
, &sz
);
5962 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5963 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5964 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5965 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5967 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
5968 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5970 /* ProductIcon value exists */
5972 lstrcpyA(buf
, "apple");
5973 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5974 MSIINSTALLCONTEXT_USERUNMANAGED
,
5975 INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
5976 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5977 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5978 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5979 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5981 res
= RegSetValueExA(propkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5982 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5984 /* PackageName value exists */
5986 lstrcpyA(buf
, "apple");
5987 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5988 MSIINSTALLCONTEXT_USERUNMANAGED
,
5989 INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
5990 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5991 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5992 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5993 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5995 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
5996 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5998 /* AuthorizedLUAApp value exists */
6000 lstrcpyA(buf
, "apple");
6001 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6002 MSIINSTALLCONTEXT_USERUNMANAGED
,
6003 INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
6004 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6005 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6006 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6007 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6009 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
6010 RegDeleteValueA(propkey
, "PackageName");
6011 RegDeleteValueA(propkey
, "ProductIcon");
6012 RegDeleteValueA(propkey
, "Version");
6013 RegDeleteValueA(propkey
, "PackageCode");
6014 RegDeleteValueA(propkey
, "AssignmentType");
6015 RegDeleteValueA(propkey
, "ProductName");
6016 RegDeleteValueA(propkey
, "Language");
6017 RegDeleteValueA(propkey
, "Transforms");
6018 RegDeleteValueA(propkey
, "RegOwner");
6019 RegDeleteValueA(propkey
, "RegCompany");
6020 RegDeleteValueA(propkey
, "ProductID");
6021 RegDeleteValueA(propkey
, "DisplayVersion");
6022 RegDeleteValueA(propkey
, "VersionMajor");
6023 RegDeleteValueA(propkey
, "VersionMinor");
6024 RegDeleteValueA(propkey
, "URLUpdateInfo");
6025 RegDeleteValueA(propkey
, "URLInfoAbout");
6026 RegDeleteValueA(propkey
, "Publisher");
6027 RegDeleteValueA(propkey
, "LocalPackage");
6028 RegDeleteValueA(propkey
, "InstallSource");
6029 RegDeleteValueA(propkey
, "InstallLocation");
6030 RegDeleteValueA(propkey
, "DisplayName");
6031 RegDeleteValueA(propkey
, "InstallDate");
6032 RegDeleteValueA(propkey
, "HelpTelephone");
6033 RegDeleteValueA(propkey
, "HelpLink");
6034 RegDeleteValueA(propkey
, "LocalPackage");
6035 RegDeleteKeyA(propkey
, "");
6036 RegCloseKey(propkey
);
6037 RegDeleteKeyA(localkey
, "");
6038 RegCloseKey(localkey
);
6040 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6041 lstrcatA(keypath
, usersid
);
6042 lstrcatA(keypath
, "\\Installer\\Products\\");
6043 lstrcatA(keypath
, prod_squashed
);
6045 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
6046 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6048 /* user product key exists */
6050 lstrcpyA(buf
, "apple");
6051 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6052 MSIINSTALLCONTEXT_USERUNMANAGED
,
6053 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6054 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6055 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6056 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6057 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6059 RegDeleteKeyA(userkey
, "");
6060 RegCloseKey(userkey
);
6062 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
6063 lstrcatA(keypath
, prod_squashed
);
6065 res
= RegCreateKeyExA(HKEY_CURRENT_USER
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
6066 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6069 lstrcpyA(buf
, "apple");
6070 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6071 MSIINSTALLCONTEXT_USERUNMANAGED
,
6072 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6073 ok(r
== ERROR_SUCCESS
|| broken(r
== ERROR_UNKNOWN_PRODUCT
), "Expected ERROR_SUCCESS, got %d\n", r
);
6074 if (r
== ERROR_UNKNOWN_PRODUCT
)
6076 win_skip("skipping remaining tests for MsiGetProductInfoEx\n");
6077 delete_key(prodkey
, "", access
);
6078 RegCloseKey(prodkey
);
6081 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
6082 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6084 res
= RegSetValueExA(prodkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6085 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6087 /* HelpLink value exists */
6089 lstrcpyA(buf
, "apple");
6090 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6091 MSIINSTALLCONTEXT_USERUNMANAGED
,
6092 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
6093 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6094 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6095 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6096 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6098 res
= RegSetValueExA(prodkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
6099 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6101 /* HelpTelephone value exists */
6103 lstrcpyA(buf
, "apple");
6104 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6105 MSIINSTALLCONTEXT_USERUNMANAGED
,
6106 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
6107 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6108 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6109 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6110 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6112 res
= RegSetValueExA(prodkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
6113 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6115 /* InstallDate value exists */
6117 lstrcpyA(buf
, "apple");
6118 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6119 MSIINSTALLCONTEXT_USERUNMANAGED
,
6120 INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
6121 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6122 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6123 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6124 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6126 res
= RegSetValueExA(prodkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6127 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6129 /* DisplayName value exists */
6131 lstrcpyA(buf
, "apple");
6132 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6133 MSIINSTALLCONTEXT_USERUNMANAGED
,
6134 INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
6135 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6136 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6137 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6138 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6140 res
= RegSetValueExA(prodkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
6141 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6143 /* InstallLocation value exists */
6145 lstrcpyA(buf
, "apple");
6146 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6147 MSIINSTALLCONTEXT_USERUNMANAGED
,
6148 INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
6149 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6150 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6151 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6152 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6154 res
= RegSetValueExA(prodkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
6155 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6157 /* InstallSource value exists */
6159 lstrcpyA(buf
, "apple");
6160 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6161 MSIINSTALLCONTEXT_USERUNMANAGED
,
6162 INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
6163 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6164 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6165 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6166 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6168 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
6169 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6171 /* LocalPackage value exists */
6173 lstrcpyA(buf
, "apple");
6174 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6175 MSIINSTALLCONTEXT_USERUNMANAGED
,
6176 INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
6177 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6178 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6179 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6180 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6182 res
= RegSetValueExA(prodkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
6183 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6185 /* Publisher value exists */
6187 lstrcpyA(buf
, "apple");
6188 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6189 MSIINSTALLCONTEXT_USERUNMANAGED
,
6190 INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
6191 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6192 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6193 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6194 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6196 res
= RegSetValueExA(prodkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
6197 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6199 /* URLInfoAbout value exists */
6201 lstrcpyA(buf
, "apple");
6202 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6203 MSIINSTALLCONTEXT_USERUNMANAGED
,
6204 INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
6205 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6206 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6207 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6208 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6210 res
= RegSetValueExA(prodkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
6211 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6213 /* URLUpdateInfo value exists */
6215 lstrcpyA(buf
, "apple");
6216 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6217 MSIINSTALLCONTEXT_USERUNMANAGED
,
6218 INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
6219 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6220 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6221 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6222 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6224 res
= RegSetValueExA(prodkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
6225 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6227 /* VersionMinor value exists */
6229 lstrcpyA(buf
, "apple");
6230 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6231 MSIINSTALLCONTEXT_USERUNMANAGED
,
6232 INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
6233 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6234 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6235 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6236 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6238 res
= RegSetValueExA(prodkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
6239 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6241 /* VersionMajor value exists */
6243 lstrcpyA(buf
, "apple");
6244 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6245 MSIINSTALLCONTEXT_USERUNMANAGED
,
6246 INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
6247 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6248 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6249 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6250 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6252 res
= RegSetValueExA(prodkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
6253 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6255 /* DisplayVersion value exists */
6257 lstrcpyA(buf
, "apple");
6258 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6259 MSIINSTALLCONTEXT_USERUNMANAGED
,
6260 INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
6261 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6262 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6263 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6264 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6266 res
= RegSetValueExA(prodkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
6267 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6269 /* ProductID value exists */
6271 lstrcpyA(buf
, "apple");
6272 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6273 MSIINSTALLCONTEXT_USERUNMANAGED
,
6274 INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
6275 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6276 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6277 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6278 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6280 res
= RegSetValueExA(prodkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
6281 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6283 /* RegCompany value exists */
6285 lstrcpyA(buf
, "apple");
6286 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6287 MSIINSTALLCONTEXT_USERUNMANAGED
,
6288 INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
6289 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6290 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6291 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6292 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6294 res
= RegSetValueExA(prodkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
6295 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6297 /* RegOwner value exists */
6299 lstrcpyA(buf
, "apple");
6300 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6301 MSIINSTALLCONTEXT_USERUNMANAGED
,
6302 INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
6303 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6304 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6305 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6306 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6308 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
6309 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6311 /* Transforms value exists */
6313 lstrcpyA(buf
, "apple");
6314 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6315 MSIINSTALLCONTEXT_USERUNMANAGED
,
6316 INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
6317 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6318 ok(!lstrcmpA(buf
, "trans"), "Expected \"trans\", got \"%s\"\n", buf
);
6319 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6321 res
= RegSetValueExA(prodkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
6322 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6324 /* Language value exists */
6326 lstrcpyA(buf
, "apple");
6327 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6328 MSIINSTALLCONTEXT_USERUNMANAGED
,
6329 INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
6330 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6331 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
6332 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6334 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6335 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6337 /* ProductName value exists */
6339 lstrcpyA(buf
, "apple");
6340 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6341 MSIINSTALLCONTEXT_USERUNMANAGED
,
6342 INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
6343 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6344 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
6345 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6347 res
= RegSetValueExA(prodkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
6348 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6352 /* AssignmentType value exists */
6354 lstrcpyA(buf
, "apple");
6355 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6356 MSIINSTALLCONTEXT_USERUNMANAGED
,
6357 INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
6358 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6359 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
6360 ok(sz
== 0, "Expected 0, got %d\n", sz
);
6362 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
6363 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6367 /* PackageCode value exists */
6369 lstrcpyA(buf
, "apple");
6370 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6371 MSIINSTALLCONTEXT_USERUNMANAGED
,
6372 INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
6375 ok(r
== ERROR_BAD_CONFIGURATION
,
6376 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
6377 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6378 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6381 res
= RegSetValueExA(prodkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
6382 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6384 /* Version value exists */
6386 lstrcpyA(buf
, "apple");
6387 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6388 MSIINSTALLCONTEXT_USERUNMANAGED
,
6389 INSTALLPROPERTY_VERSION
, buf
, &sz
);
6390 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6391 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
6392 ok(sz
== 3, "Expected 3, got %d\n", sz
);
6394 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
6395 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6397 /* ProductIcon value exists */
6399 lstrcpyA(buf
, "apple");
6400 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6401 MSIINSTALLCONTEXT_USERUNMANAGED
,
6402 INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
6403 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6404 ok(!lstrcmpA(buf
, "icon"), "Expected \"icon\", got \"%s\"\n", buf
);
6405 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6407 res
= RegSetValueExA(prodkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6408 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6410 /* PackageName value exists */
6412 lstrcpyA(buf
, "apple");
6413 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6414 MSIINSTALLCONTEXT_USERUNMANAGED
,
6415 INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
6418 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6419 "Expected ERROR_UNKNOWN_PRODUCT, 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
);
6424 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
6425 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6427 /* AuthorizedLUAApp value exists */
6429 lstrcpyA(buf
, "apple");
6430 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6431 MSIINSTALLCONTEXT_USERUNMANAGED
,
6432 INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
6433 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6434 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
6435 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6437 RegDeleteValueA(prodkey
, "AuthorizedLUAApp");
6438 RegDeleteValueA(prodkey
, "PackageName");
6439 RegDeleteValueA(prodkey
, "ProductIcon");
6440 RegDeleteValueA(prodkey
, "Version");
6441 RegDeleteValueA(prodkey
, "PackageCode");
6442 RegDeleteValueA(prodkey
, "AssignmentType");
6443 RegDeleteValueA(prodkey
, "ProductName");
6444 RegDeleteValueA(prodkey
, "Language");
6445 RegDeleteValueA(prodkey
, "Transforms");
6446 RegDeleteValueA(prodkey
, "RegOwner");
6447 RegDeleteValueA(prodkey
, "RegCompany");
6448 RegDeleteValueA(prodkey
, "ProductID");
6449 RegDeleteValueA(prodkey
, "DisplayVersion");
6450 RegDeleteValueA(prodkey
, "VersionMajor");
6451 RegDeleteValueA(prodkey
, "VersionMinor");
6452 RegDeleteValueA(prodkey
, "URLUpdateInfo");
6453 RegDeleteValueA(prodkey
, "URLInfoAbout");
6454 RegDeleteValueA(prodkey
, "Publisher");
6455 RegDeleteValueA(prodkey
, "LocalPackage");
6456 RegDeleteValueA(prodkey
, "InstallSource");
6457 RegDeleteValueA(prodkey
, "InstallLocation");
6458 RegDeleteValueA(prodkey
, "DisplayName");
6459 RegDeleteValueA(prodkey
, "InstallDate");
6460 RegDeleteValueA(prodkey
, "HelpTelephone");
6461 RegDeleteValueA(prodkey
, "HelpLink");
6462 RegDeleteValueA(prodkey
, "LocalPackage");
6463 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
6464 RegCloseKey(prodkey
);
6466 /* MSIINSTALLCONTEXT_USERMANAGED */
6468 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
6469 lstrcatA(keypath
, usersid
);
6470 lstrcatA(keypath
, "\\Products\\");
6471 lstrcatA(keypath
, prod_squashed
);
6473 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
6474 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6476 /* local user product key exists */
6478 lstrcpyA(buf
, "apple");
6479 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6480 MSIINSTALLCONTEXT_USERMANAGED
,
6481 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6482 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6483 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6484 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6485 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6487 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
6488 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6490 /* InstallProperties key exists */
6492 lstrcpyA(buf
, "apple");
6493 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6494 MSIINSTALLCONTEXT_USERMANAGED
,
6495 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6496 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6497 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6498 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6499 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6501 res
= RegSetValueExA(propkey
, "ManagedLocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
6502 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6504 /* ManagedLocalPackage value exists */
6506 lstrcpyA(buf
, "apple");
6507 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6508 MSIINSTALLCONTEXT_USERMANAGED
,
6509 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6510 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6511 ok(!lstrcmpA(buf
, "5"), "Expected \"5\", got \"%s\"\n", buf
);
6512 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6514 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6515 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6517 /* HelpLink value exists */
6519 lstrcpyA(buf
, "apple");
6520 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6521 MSIINSTALLCONTEXT_USERMANAGED
,
6522 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
6523 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6524 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
6525 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6527 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
6528 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6530 /* HelpTelephone value exists */
6532 lstrcpyA(buf
, "apple");
6533 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6534 MSIINSTALLCONTEXT_USERMANAGED
,
6535 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
6536 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6537 ok(!lstrcmpA(buf
, "phone"), "Expected \"phone\", got \"%s\"\n", buf
);
6538 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6540 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
6541 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6543 /* InstallDate value exists */
6545 lstrcpyA(buf
, "apple");
6546 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6547 MSIINSTALLCONTEXT_USERMANAGED
,
6548 INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
6549 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6550 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
6551 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6553 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6554 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6556 /* DisplayName value exists */
6558 lstrcpyA(buf
, "apple");
6559 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6560 MSIINSTALLCONTEXT_USERMANAGED
,
6561 INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
6562 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6563 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
6564 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6566 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
6567 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6569 /* InstallLocation value exists */
6571 lstrcpyA(buf
, "apple");
6572 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6573 MSIINSTALLCONTEXT_USERMANAGED
,
6574 INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
6575 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6576 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
6577 ok(sz
== 3, "Expected 3, got %d\n", sz
);
6579 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
6580 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6582 /* InstallSource value exists */
6584 lstrcpyA(buf
, "apple");
6585 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6586 MSIINSTALLCONTEXT_USERMANAGED
,
6587 INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
6588 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6589 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
6590 ok(sz
== 6, "Expected 6, got %d\n", sz
);
6592 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
6593 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6595 /* LocalPackage value exists */
6597 lstrcpyA(buf
, "apple");
6598 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6599 MSIINSTALLCONTEXT_USERMANAGED
,
6600 INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
6601 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6602 ok(!lstrcmpA(buf
, "local"), "Expected \"local\", got \"%s\"\n", buf
);
6603 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6605 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
6606 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6608 /* Publisher value exists */
6610 lstrcpyA(buf
, "apple");
6611 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6612 MSIINSTALLCONTEXT_USERMANAGED
,
6613 INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
6614 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6615 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
6616 ok(sz
== 3, "Expected 3, got %d\n", sz
);
6618 res
= RegSetValueExA(propkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
6619 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6621 /* URLInfoAbout value exists */
6623 lstrcpyA(buf
, "apple");
6624 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6625 MSIINSTALLCONTEXT_USERMANAGED
,
6626 INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
6627 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6628 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
6629 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6631 res
= RegSetValueExA(propkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
6632 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6634 /* URLUpdateInfo value exists */
6636 lstrcpyA(buf
, "apple");
6637 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6638 MSIINSTALLCONTEXT_USERMANAGED
,
6639 INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
6640 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6641 ok(!lstrcmpA(buf
, "update"), "Expected \"update\", got \"%s\"\n", buf
);
6642 ok(sz
== 6, "Expected 6, got %d\n", sz
);
6644 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
6645 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6647 /* VersionMinor value exists */
6649 lstrcpyA(buf
, "apple");
6650 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6651 MSIINSTALLCONTEXT_USERMANAGED
,
6652 INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
6653 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6654 ok(!lstrcmpA(buf
, "2"), "Expected \"2\", got \"%s\"\n", buf
);
6655 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6657 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
6658 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6660 /* VersionMajor value exists */
6662 lstrcpyA(buf
, "apple");
6663 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6664 MSIINSTALLCONTEXT_USERMANAGED
,
6665 INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
6666 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6667 ok(!lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
6668 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6670 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
6671 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6673 /* DisplayVersion value exists */
6675 lstrcpyA(buf
, "apple");
6676 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6677 MSIINSTALLCONTEXT_USERMANAGED
,
6678 INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
6679 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6680 ok(!lstrcmpA(buf
, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf
);
6681 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6683 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
6684 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6686 /* ProductID value exists */
6688 lstrcpyA(buf
, "apple");
6689 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6690 MSIINSTALLCONTEXT_USERMANAGED
,
6691 INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
6692 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6693 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
6694 ok(sz
== 2, "Expected 2, got %d\n", sz
);
6696 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
6697 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6699 /* RegCompany value exists */
6701 lstrcpyA(buf
, "apple");
6702 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6703 MSIINSTALLCONTEXT_USERMANAGED
,
6704 INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
6705 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6706 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
6707 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6709 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
6710 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6712 /* RegOwner value exists */
6714 lstrcpyA(buf
, "apple");
6715 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6716 MSIINSTALLCONTEXT_USERMANAGED
,
6717 INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
6718 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6719 ok(!lstrcmpA(buf
, "owner"), "Expected \"owner\", got \"%s\"\n", buf
);
6720 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6722 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
6723 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6725 /* Transforms value exists */
6727 lstrcpyA(buf
, "apple");
6728 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6729 MSIINSTALLCONTEXT_USERMANAGED
,
6730 INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
6731 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6732 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6733 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6734 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6736 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
6737 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6739 /* Language value exists */
6741 lstrcpyA(buf
, "apple");
6742 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6743 MSIINSTALLCONTEXT_USERMANAGED
,
6744 INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
6745 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6746 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6747 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6748 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6750 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6751 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6753 /* ProductName value exists */
6755 lstrcpyA(buf
, "apple");
6756 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6757 MSIINSTALLCONTEXT_USERMANAGED
,
6758 INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
6759 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6760 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6761 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6762 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6764 res
= RegSetValueExA(propkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
6765 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6769 /* AssignmentType value exists */
6771 lstrcpyA(buf
, "apple");
6772 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6773 MSIINSTALLCONTEXT_USERMANAGED
,
6774 INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
6775 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6776 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6777 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6778 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6780 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
6781 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6783 /* PackageCode value exists */
6785 lstrcpyA(buf
, "apple");
6786 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6787 MSIINSTALLCONTEXT_USERMANAGED
,
6788 INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
6789 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6790 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6791 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6792 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6794 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
6795 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6797 /* Version value exists */
6799 lstrcpyA(buf
, "apple");
6800 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6801 MSIINSTALLCONTEXT_USERMANAGED
,
6802 INSTALLPROPERTY_VERSION
, buf
, &sz
);
6803 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6804 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6805 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6806 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6808 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
6809 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6811 /* ProductIcon value exists */
6813 lstrcpyA(buf
, "apple");
6814 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6815 MSIINSTALLCONTEXT_USERMANAGED
,
6816 INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
6817 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6818 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6819 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6820 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6822 res
= RegSetValueExA(propkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6823 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6825 /* PackageName value exists */
6827 lstrcpyA(buf
, "apple");
6828 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6829 MSIINSTALLCONTEXT_USERMANAGED
,
6830 INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
6831 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6832 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6833 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6834 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6836 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
6837 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6839 /* AuthorizedLUAApp value exists */
6841 lstrcpyA(buf
, "apple");
6842 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6843 MSIINSTALLCONTEXT_USERMANAGED
,
6844 INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
6845 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6846 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6847 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6848 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6850 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
6851 RegDeleteValueA(propkey
, "PackageName");
6852 RegDeleteValueA(propkey
, "ProductIcon");
6853 RegDeleteValueA(propkey
, "Version");
6854 RegDeleteValueA(propkey
, "PackageCode");
6855 RegDeleteValueA(propkey
, "AssignmentType");
6856 RegDeleteValueA(propkey
, "ProductName");
6857 RegDeleteValueA(propkey
, "Language");
6858 RegDeleteValueA(propkey
, "Transforms");
6859 RegDeleteValueA(propkey
, "RegOwner");
6860 RegDeleteValueA(propkey
, "RegCompany");
6861 RegDeleteValueA(propkey
, "ProductID");
6862 RegDeleteValueA(propkey
, "DisplayVersion");
6863 RegDeleteValueA(propkey
, "VersionMajor");
6864 RegDeleteValueA(propkey
, "VersionMinor");
6865 RegDeleteValueA(propkey
, "URLUpdateInfo");
6866 RegDeleteValueA(propkey
, "URLInfoAbout");
6867 RegDeleteValueA(propkey
, "Publisher");
6868 RegDeleteValueA(propkey
, "LocalPackage");
6869 RegDeleteValueA(propkey
, "InstallSource");
6870 RegDeleteValueA(propkey
, "InstallLocation");
6871 RegDeleteValueA(propkey
, "DisplayName");
6872 RegDeleteValueA(propkey
, "InstallDate");
6873 RegDeleteValueA(propkey
, "HelpTelephone");
6874 RegDeleteValueA(propkey
, "HelpLink");
6875 RegDeleteValueA(propkey
, "ManagedLocalPackage");
6876 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
6877 RegCloseKey(propkey
);
6878 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
6879 RegCloseKey(localkey
);
6881 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6882 lstrcatA(keypath
, usersid
);
6883 lstrcatA(keypath
, "\\Installer\\Products\\");
6884 lstrcatA(keypath
, prod_squashed
);
6886 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
6887 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6889 /* user product key exists */
6891 lstrcpyA(buf
, "apple");
6892 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6893 MSIINSTALLCONTEXT_USERMANAGED
,
6894 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6895 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6896 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
6897 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6899 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
6900 RegCloseKey(userkey
);
6902 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
6903 lstrcatA(keypath
, prod_squashed
);
6905 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
6906 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6908 /* current user product key exists */
6910 lstrcpyA(buf
, "apple");
6911 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6912 MSIINSTALLCONTEXT_USERMANAGED
,
6913 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
6914 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6915 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6916 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6917 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6919 res
= RegSetValueExA(prodkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6920 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6922 /* HelpLink value exists, user product key does not exist */
6924 lstrcpyA(buf
, "apple");
6925 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6926 MSIINSTALLCONTEXT_USERMANAGED
,
6927 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
6928 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6929 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6930 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6931 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6933 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6934 lstrcatA(keypath
, usersid
);
6935 lstrcatA(keypath
, "\\Installer\\Products\\");
6936 lstrcatA(keypath
, prod_squashed
);
6938 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
6939 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6941 res
= RegSetValueExA(userkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6942 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6944 /* HelpLink value exists, user product key does exist */
6946 lstrcpyA(buf
, "apple");
6947 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6948 MSIINSTALLCONTEXT_USERMANAGED
,
6949 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
6950 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6951 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6952 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6953 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6955 res
= RegSetValueExA(userkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
6956 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6958 /* HelpTelephone value exists */
6960 lstrcpyA(buf
, "apple");
6961 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6962 MSIINSTALLCONTEXT_USERMANAGED
,
6963 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
6964 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6965 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6966 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6967 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6969 res
= RegSetValueExA(userkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
6970 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6972 /* InstallDate value exists */
6974 lstrcpyA(buf
, "apple");
6975 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6976 MSIINSTALLCONTEXT_USERMANAGED
,
6977 INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
6978 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6979 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6980 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6981 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6983 res
= RegSetValueExA(userkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6984 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6986 /* DisplayName value exists */
6988 lstrcpyA(buf
, "apple");
6989 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6990 MSIINSTALLCONTEXT_USERMANAGED
,
6991 INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
6992 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6993 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6994 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6995 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6997 res
= RegSetValueExA(userkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
6998 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7000 /* InstallLocation value exists */
7002 lstrcpyA(buf
, "apple");
7003 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7004 MSIINSTALLCONTEXT_USERMANAGED
,
7005 INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
7006 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7007 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7008 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7009 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7011 res
= RegSetValueExA(userkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
7012 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7014 /* InstallSource value exists */
7016 lstrcpyA(buf
, "apple");
7017 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7018 MSIINSTALLCONTEXT_USERMANAGED
,
7019 INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
7020 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7021 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7022 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7023 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7025 res
= RegSetValueExA(userkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7026 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7028 /* LocalPackage value exists */
7030 lstrcpyA(buf
, "apple");
7031 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7032 MSIINSTALLCONTEXT_USERMANAGED
,
7033 INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
7034 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7035 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7036 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7037 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7039 res
= RegSetValueExA(userkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
7040 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7042 /* Publisher value exists */
7044 lstrcpyA(buf
, "apple");
7045 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7046 MSIINSTALLCONTEXT_USERMANAGED
,
7047 INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
7048 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7049 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7050 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7051 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7053 res
= RegSetValueExA(userkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
7054 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7056 /* URLInfoAbout value exists */
7058 lstrcpyA(buf
, "apple");
7059 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7060 MSIINSTALLCONTEXT_USERMANAGED
,
7061 INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
7062 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7063 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7064 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7065 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7067 res
= RegSetValueExA(userkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
7068 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7070 /* URLUpdateInfo value exists */
7072 lstrcpyA(buf
, "apple");
7073 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7074 MSIINSTALLCONTEXT_USERMANAGED
,
7075 INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
7076 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7077 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7078 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7079 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7081 res
= RegSetValueExA(userkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
7082 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7084 /* VersionMinor value exists */
7086 lstrcpyA(buf
, "apple");
7087 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7088 MSIINSTALLCONTEXT_USERMANAGED
,
7089 INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
7090 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7091 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7092 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7093 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7095 res
= RegSetValueExA(userkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
7096 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7098 /* VersionMajor value exists */
7100 lstrcpyA(buf
, "apple");
7101 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7102 MSIINSTALLCONTEXT_USERMANAGED
,
7103 INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
7104 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7105 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7106 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7107 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7109 res
= RegSetValueExA(userkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
7110 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7112 /* DisplayVersion value exists */
7114 lstrcpyA(buf
, "apple");
7115 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7116 MSIINSTALLCONTEXT_USERMANAGED
,
7117 INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
7118 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7119 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7120 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7121 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7123 res
= RegSetValueExA(userkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
7124 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7126 /* ProductID value exists */
7128 lstrcpyA(buf
, "apple");
7129 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7130 MSIINSTALLCONTEXT_USERMANAGED
,
7131 INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
7132 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7133 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7134 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7135 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7137 res
= RegSetValueExA(userkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
7138 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7140 /* RegCompany value exists */
7142 lstrcpyA(buf
, "apple");
7143 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7144 MSIINSTALLCONTEXT_USERMANAGED
,
7145 INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
7146 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7147 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7148 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7149 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7151 res
= RegSetValueExA(userkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
7152 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7154 /* RegOwner value exists */
7156 lstrcpyA(buf
, "apple");
7157 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7158 MSIINSTALLCONTEXT_USERMANAGED
,
7159 INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
7160 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7161 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7162 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7163 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7165 res
= RegSetValueExA(userkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
7166 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7168 /* Transforms value exists */
7170 lstrcpyA(buf
, "apple");
7171 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7172 MSIINSTALLCONTEXT_USERMANAGED
,
7173 INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
7174 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7175 ok(!lstrcmpA(buf
, "trans"), "Expected \"trans\", got \"%s\"\n", buf
);
7176 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7178 res
= RegSetValueExA(userkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
7179 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7181 /* Language value exists */
7183 lstrcpyA(buf
, "apple");
7184 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7185 MSIINSTALLCONTEXT_USERMANAGED
,
7186 INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
7187 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7188 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
7189 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7191 res
= RegSetValueExA(userkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7192 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7194 /* ProductName value exists */
7196 lstrcpyA(buf
, "apple");
7197 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7198 MSIINSTALLCONTEXT_USERMANAGED
,
7199 INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
7200 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7201 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
7202 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7204 res
= RegSetValueExA(userkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
7205 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7209 /* AssignmentType value exists */
7211 lstrcpyA(buf
, "apple");
7212 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7213 MSIINSTALLCONTEXT_USERMANAGED
,
7214 INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
7215 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7216 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
7217 ok(sz
== 0, "Expected 0, got %d\n", sz
);
7219 res
= RegSetValueExA(userkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
7220 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7224 /* PackageCode value exists */
7226 lstrcpyA(buf
, "apple");
7227 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7228 MSIINSTALLCONTEXT_USERMANAGED
,
7229 INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
7232 ok(r
== ERROR_BAD_CONFIGURATION
,
7233 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
7234 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7235 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7238 res
= RegSetValueExA(userkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
7239 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7241 /* Version value exists */
7243 lstrcpyA(buf
, "apple");
7244 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7245 MSIINSTALLCONTEXT_USERMANAGED
,
7246 INSTALLPROPERTY_VERSION
, buf
, &sz
);
7247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7248 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
7249 ok(sz
== 3, "Expected 3, got %d\n", sz
);
7251 res
= RegSetValueExA(userkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
7252 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7254 /* ProductIcon value exists */
7256 lstrcpyA(buf
, "apple");
7257 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7258 MSIINSTALLCONTEXT_USERMANAGED
,
7259 INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
7260 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7261 ok(!lstrcmpA(buf
, "icon"), "Expected \"icon\", got \"%s\"\n", buf
);
7262 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7264 res
= RegSetValueExA(userkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7265 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7267 /* PackageName value exists */
7269 lstrcpyA(buf
, "apple");
7270 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7271 MSIINSTALLCONTEXT_USERMANAGED
,
7272 INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
7275 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7276 "Expected ERROR_UNKNOWN_PRODUCT, 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
);
7281 res
= RegSetValueExA(userkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
7282 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7284 /* AuthorizedLUAApp value exists */
7286 lstrcpyA(buf
, "apple");
7287 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7288 MSIINSTALLCONTEXT_USERMANAGED
,
7289 INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
7290 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7291 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
7292 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7294 RegDeleteValueA(userkey
, "AuthorizedLUAApp");
7295 RegDeleteValueA(userkey
, "PackageName");
7296 RegDeleteValueA(userkey
, "ProductIcon");
7297 RegDeleteValueA(userkey
, "Version");
7298 RegDeleteValueA(userkey
, "PackageCode");
7299 RegDeleteValueA(userkey
, "AssignmentType");
7300 RegDeleteValueA(userkey
, "ProductName");
7301 RegDeleteValueA(userkey
, "Language");
7302 RegDeleteValueA(userkey
, "Transforms");
7303 RegDeleteValueA(userkey
, "RegOwner");
7304 RegDeleteValueA(userkey
, "RegCompany");
7305 RegDeleteValueA(userkey
, "ProductID");
7306 RegDeleteValueA(userkey
, "DisplayVersion");
7307 RegDeleteValueA(userkey
, "VersionMajor");
7308 RegDeleteValueA(userkey
, "VersionMinor");
7309 RegDeleteValueA(userkey
, "URLUpdateInfo");
7310 RegDeleteValueA(userkey
, "URLInfoAbout");
7311 RegDeleteValueA(userkey
, "Publisher");
7312 RegDeleteValueA(userkey
, "LocalPackage");
7313 RegDeleteValueA(userkey
, "InstallSource");
7314 RegDeleteValueA(userkey
, "InstallLocation");
7315 RegDeleteValueA(userkey
, "DisplayName");
7316 RegDeleteValueA(userkey
, "InstallDate");
7317 RegDeleteValueA(userkey
, "HelpTelephone");
7318 RegDeleteValueA(userkey
, "HelpLink");
7319 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
7320 RegCloseKey(userkey
);
7321 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
7322 RegCloseKey(prodkey
);
7324 /* MSIINSTALLCONTEXT_MACHINE */
7326 /* szUserSid is non-NULL */
7328 lstrcpyA(buf
, "apple");
7329 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7330 MSIINSTALLCONTEXT_MACHINE
,
7331 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
7332 ok(r
== ERROR_INVALID_PARAMETER
,
7333 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
7334 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7335 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7337 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
7338 lstrcatA(keypath
, prod_squashed
);
7340 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
7341 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7343 /* local system product key exists */
7345 lstrcpyA(buf
, "apple");
7346 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7347 MSIINSTALLCONTEXT_MACHINE
,
7348 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
7349 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7350 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7351 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7352 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7354 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
7355 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7357 /* InstallProperties key exists */
7359 lstrcpyA(buf
, "apple");
7360 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7361 MSIINSTALLCONTEXT_MACHINE
,
7362 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
7363 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7364 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7365 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7366 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7368 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7369 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7371 /* LocalPackage value exists */
7373 lstrcpyA(buf
, "apple");
7374 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7375 MSIINSTALLCONTEXT_MACHINE
,
7376 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
7377 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7378 ok(!lstrcmpA(buf
, "5"), "Expected \"5\", got \"%s\"\n", buf
);
7379 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7381 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
7382 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7384 /* HelpLink value exists */
7386 lstrcpyA(buf
, "apple");
7387 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7388 MSIINSTALLCONTEXT_MACHINE
,
7389 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
7390 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7391 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
7392 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7394 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
7395 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7397 /* HelpTelephone value exists */
7399 lstrcpyA(buf
, "apple");
7400 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7401 MSIINSTALLCONTEXT_MACHINE
,
7402 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
7403 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7404 ok(!lstrcmpA(buf
, "phone"), "Expected \"phone\", got \"%s\"\n", buf
);
7405 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7407 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
7408 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7410 /* InstallDate value exists */
7412 lstrcpyA(buf
, "apple");
7413 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7414 MSIINSTALLCONTEXT_MACHINE
,
7415 INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
7416 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7417 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
7418 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7420 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7421 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7423 /* DisplayName value exists */
7425 lstrcpyA(buf
, "apple");
7426 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7427 MSIINSTALLCONTEXT_MACHINE
,
7428 INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
7429 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7430 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
7431 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7433 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
7434 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7436 /* InstallLocation value exists */
7438 lstrcpyA(buf
, "apple");
7439 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7440 MSIINSTALLCONTEXT_MACHINE
,
7441 INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
7442 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7443 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
7444 ok(sz
== 3, "Expected 3, got %d\n", sz
);
7446 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
7447 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7449 /* InstallSource value exists */
7451 lstrcpyA(buf
, "apple");
7452 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7453 MSIINSTALLCONTEXT_MACHINE
,
7454 INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
7455 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7456 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
7457 ok(sz
== 6, "Expected 6, got %d\n", sz
);
7459 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7460 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7462 /* LocalPackage value exists */
7464 lstrcpyA(buf
, "apple");
7465 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7466 MSIINSTALLCONTEXT_MACHINE
,
7467 INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
7468 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7469 ok(!lstrcmpA(buf
, "local"), "Expected \"local\", got \"%s\"\n", buf
);
7470 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7472 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
7473 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7475 /* Publisher value exists */
7477 lstrcpyA(buf
, "apple");
7478 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7479 MSIINSTALLCONTEXT_MACHINE
,
7480 INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
7481 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7482 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
7483 ok(sz
== 3, "Expected 3, got %d\n", sz
);
7485 res
= RegSetValueExA(propkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
7486 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7488 /* URLInfoAbout value exists */
7490 lstrcpyA(buf
, "apple");
7491 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7492 MSIINSTALLCONTEXT_MACHINE
,
7493 INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
7494 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7495 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
7496 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7498 res
= RegSetValueExA(propkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
7499 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7501 /* URLUpdateInfo value exists */
7503 lstrcpyA(buf
, "apple");
7504 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7505 MSIINSTALLCONTEXT_MACHINE
,
7506 INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
7507 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7508 ok(!lstrcmpA(buf
, "update"), "Expected \"update\", got \"%s\"\n", buf
);
7509 ok(sz
== 6, "Expected 6, got %d\n", sz
);
7511 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
7512 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7514 /* VersionMinor value exists */
7516 lstrcpyA(buf
, "apple");
7517 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7518 MSIINSTALLCONTEXT_MACHINE
,
7519 INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
7520 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7521 ok(!lstrcmpA(buf
, "2"), "Expected \"2\", got \"%s\"\n", buf
);
7522 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7524 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
7525 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7527 /* VersionMajor value exists */
7529 lstrcpyA(buf
, "apple");
7530 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7531 MSIINSTALLCONTEXT_MACHINE
,
7532 INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
7533 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7534 ok(!lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
7535 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7537 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
7538 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7540 /* DisplayVersion value exists */
7542 lstrcpyA(buf
, "apple");
7543 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7544 MSIINSTALLCONTEXT_MACHINE
,
7545 INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
7546 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7547 ok(!lstrcmpA(buf
, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf
);
7548 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7550 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
7551 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7553 /* ProductID value exists */
7555 lstrcpyA(buf
, "apple");
7556 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7557 MSIINSTALLCONTEXT_MACHINE
,
7558 INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
7559 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7560 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
7561 ok(sz
== 2, "Expected 2, got %d\n", sz
);
7563 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
7564 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7566 /* RegCompany value exists */
7568 lstrcpyA(buf
, "apple");
7569 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7570 MSIINSTALLCONTEXT_MACHINE
,
7571 INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
7572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7573 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
7574 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7576 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
7577 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7579 /* RegOwner value exists */
7581 lstrcpyA(buf
, "apple");
7582 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7583 MSIINSTALLCONTEXT_MACHINE
,
7584 INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
7585 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7586 ok(!lstrcmpA(buf
, "owner"), "Expected \"owner\", got \"%s\"\n", buf
);
7587 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7589 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
7590 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7592 /* Transforms value exists */
7594 lstrcpyA(buf
, "apple");
7595 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7596 MSIINSTALLCONTEXT_MACHINE
,
7597 INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
7598 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7599 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7600 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7601 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7603 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
7604 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7606 /* Language value exists */
7608 lstrcpyA(buf
, "apple");
7609 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7610 MSIINSTALLCONTEXT_MACHINE
,
7611 INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
7612 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7613 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7614 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7615 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7617 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7618 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7620 /* ProductName value exists */
7622 lstrcpyA(buf
, "apple");
7623 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7624 MSIINSTALLCONTEXT_MACHINE
,
7625 INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
7626 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7627 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7628 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7629 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7631 res
= RegSetValueExA(propkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
7632 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7636 /* AssignmentType value exists */
7638 lstrcpyA(buf
, "apple");
7639 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7640 MSIINSTALLCONTEXT_MACHINE
,
7641 INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
7642 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7643 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7644 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7645 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7647 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
7648 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7650 /* PackageCode value exists */
7652 lstrcpyA(buf
, "apple");
7653 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7654 MSIINSTALLCONTEXT_MACHINE
,
7655 INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
7656 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7657 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7658 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7659 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7661 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
7662 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7664 /* Version value exists */
7666 lstrcpyA(buf
, "apple");
7667 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7668 MSIINSTALLCONTEXT_MACHINE
,
7669 INSTALLPROPERTY_VERSION
, buf
, &sz
);
7670 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7671 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7672 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7673 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7675 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
7676 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7678 /* ProductIcon value exists */
7680 lstrcpyA(buf
, "apple");
7681 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7682 MSIINSTALLCONTEXT_MACHINE
,
7683 INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
7684 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7685 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7686 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7687 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7689 res
= RegSetValueExA(propkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7690 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7692 /* PackageName value exists */
7694 lstrcpyA(buf
, "apple");
7695 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7696 MSIINSTALLCONTEXT_MACHINE
,
7697 INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
7698 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7699 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7700 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7701 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7703 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
7704 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7706 /* AuthorizedLUAApp value exists */
7708 lstrcpyA(buf
, "apple");
7709 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7710 MSIINSTALLCONTEXT_MACHINE
,
7711 INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
7712 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7713 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7714 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7715 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7717 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
7718 RegDeleteValueA(propkey
, "PackageName");
7719 RegDeleteValueA(propkey
, "ProductIcon");
7720 RegDeleteValueA(propkey
, "Version");
7721 RegDeleteValueA(propkey
, "PackageCode");
7722 RegDeleteValueA(propkey
, "AssignmentType");
7723 RegDeleteValueA(propkey
, "ProductName");
7724 RegDeleteValueA(propkey
, "Language");
7725 RegDeleteValueA(propkey
, "Transforms");
7726 RegDeleteValueA(propkey
, "RegOwner");
7727 RegDeleteValueA(propkey
, "RegCompany");
7728 RegDeleteValueA(propkey
, "ProductID");
7729 RegDeleteValueA(propkey
, "DisplayVersion");
7730 RegDeleteValueA(propkey
, "VersionMajor");
7731 RegDeleteValueA(propkey
, "VersionMinor");
7732 RegDeleteValueA(propkey
, "URLUpdateInfo");
7733 RegDeleteValueA(propkey
, "URLInfoAbout");
7734 RegDeleteValueA(propkey
, "Publisher");
7735 RegDeleteValueA(propkey
, "LocalPackage");
7736 RegDeleteValueA(propkey
, "InstallSource");
7737 RegDeleteValueA(propkey
, "InstallLocation");
7738 RegDeleteValueA(propkey
, "DisplayName");
7739 RegDeleteValueA(propkey
, "InstallDate");
7740 RegDeleteValueA(propkey
, "HelpTelephone");
7741 RegDeleteValueA(propkey
, "HelpLink");
7742 RegDeleteValueA(propkey
, "LocalPackage");
7743 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
7744 RegCloseKey(propkey
);
7745 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
7746 RegCloseKey(localkey
);
7748 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
7749 lstrcatA(keypath
, prod_squashed
);
7751 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
7752 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7754 /* local classes product key exists */
7756 lstrcpyA(buf
, "apple");
7757 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7758 MSIINSTALLCONTEXT_MACHINE
,
7759 INSTALLPROPERTY_PRODUCTSTATE
, buf
, &sz
);
7760 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7761 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
7762 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7764 res
= RegSetValueExA(prodkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
7765 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7767 /* HelpLink value exists */
7769 lstrcpyA(buf
, "apple");
7770 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7771 MSIINSTALLCONTEXT_MACHINE
,
7772 INSTALLPROPERTY_HELPLINK
, buf
, &sz
);
7773 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7774 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7775 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7776 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7778 res
= RegSetValueExA(prodkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
7779 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7781 /* HelpTelephone value exists */
7783 lstrcpyA(buf
, "apple");
7784 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7785 MSIINSTALLCONTEXT_MACHINE
,
7786 INSTALLPROPERTY_HELPTELEPHONE
, buf
, &sz
);
7787 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7788 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7789 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7790 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7792 res
= RegSetValueExA(prodkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
7793 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7795 /* InstallDate value exists */
7797 lstrcpyA(buf
, "apple");
7798 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7799 MSIINSTALLCONTEXT_MACHINE
,
7800 INSTALLPROPERTY_INSTALLDATE
, buf
, &sz
);
7801 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7802 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7803 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7804 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7806 res
= RegSetValueExA(prodkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7807 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7809 /* DisplayName value exists */
7811 lstrcpyA(buf
, "apple");
7812 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7813 MSIINSTALLCONTEXT_MACHINE
,
7814 INSTALLPROPERTY_INSTALLEDPRODUCTNAME
, buf
, &sz
);
7815 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7816 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7817 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7818 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7820 res
= RegSetValueExA(prodkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
7821 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7823 /* InstallLocation value exists */
7825 lstrcpyA(buf
, "apple");
7826 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7827 MSIINSTALLCONTEXT_MACHINE
,
7828 INSTALLPROPERTY_INSTALLLOCATION
, buf
, &sz
);
7829 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7830 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7831 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7832 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7834 res
= RegSetValueExA(prodkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
7835 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7837 /* InstallSource value exists */
7839 lstrcpyA(buf
, "apple");
7840 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7841 MSIINSTALLCONTEXT_MACHINE
,
7842 INSTALLPROPERTY_INSTALLSOURCE
, buf
, &sz
);
7843 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7844 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7845 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7846 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7848 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7849 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7851 /* LocalPackage value exists */
7853 lstrcpyA(buf
, "apple");
7854 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7855 MSIINSTALLCONTEXT_MACHINE
,
7856 INSTALLPROPERTY_LOCALPACKAGE
, buf
, &sz
);
7857 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7858 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7859 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7860 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7862 res
= RegSetValueExA(prodkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
7863 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7865 /* Publisher value exists */
7867 lstrcpyA(buf
, "apple");
7868 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7869 MSIINSTALLCONTEXT_MACHINE
,
7870 INSTALLPROPERTY_PUBLISHER
, buf
, &sz
);
7871 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7872 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7873 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7874 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7876 res
= RegSetValueExA(prodkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
7877 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7879 /* URLInfoAbout value exists */
7881 lstrcpyA(buf
, "apple");
7882 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7883 MSIINSTALLCONTEXT_MACHINE
,
7884 INSTALLPROPERTY_URLINFOABOUT
, buf
, &sz
);
7885 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7886 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7887 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7888 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7890 res
= RegSetValueExA(prodkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
7891 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7893 /* URLUpdateInfo value exists */
7895 lstrcpyA(buf
, "apple");
7896 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7897 MSIINSTALLCONTEXT_MACHINE
,
7898 INSTALLPROPERTY_URLUPDATEINFO
, buf
, &sz
);
7899 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7900 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7901 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7902 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7904 res
= RegSetValueExA(prodkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
7905 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7907 /* VersionMinor value exists */
7909 lstrcpyA(buf
, "apple");
7910 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7911 MSIINSTALLCONTEXT_MACHINE
,
7912 INSTALLPROPERTY_VERSIONMINOR
, buf
, &sz
);
7913 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7914 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7915 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7916 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7918 res
= RegSetValueExA(prodkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
7919 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7921 /* VersionMajor value exists */
7923 lstrcpyA(buf
, "apple");
7924 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7925 MSIINSTALLCONTEXT_MACHINE
,
7926 INSTALLPROPERTY_VERSIONMAJOR
, buf
, &sz
);
7927 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7928 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7929 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7930 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7932 res
= RegSetValueExA(prodkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
7933 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7935 /* DisplayVersion value exists */
7937 lstrcpyA(buf
, "apple");
7938 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7939 MSIINSTALLCONTEXT_MACHINE
,
7940 INSTALLPROPERTY_VERSIONSTRING
, buf
, &sz
);
7941 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7942 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7943 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7944 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7946 res
= RegSetValueExA(prodkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
7947 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7949 /* ProductID value exists */
7951 lstrcpyA(buf
, "apple");
7952 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7953 MSIINSTALLCONTEXT_MACHINE
,
7954 INSTALLPROPERTY_PRODUCTID
, buf
, &sz
);
7955 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7956 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7957 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7958 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7960 res
= RegSetValueExA(prodkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
7961 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7963 /* RegCompany value exists */
7965 lstrcpyA(buf
, "apple");
7966 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7967 MSIINSTALLCONTEXT_MACHINE
,
7968 INSTALLPROPERTY_REGCOMPANY
, buf
, &sz
);
7969 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7970 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7971 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7972 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7974 res
= RegSetValueExA(prodkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
7975 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7977 /* RegOwner value exists */
7979 lstrcpyA(buf
, "apple");
7980 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7981 MSIINSTALLCONTEXT_MACHINE
,
7982 INSTALLPROPERTY_REGOWNER
, buf
, &sz
);
7983 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7984 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7985 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7986 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7988 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
7989 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7991 /* Transforms value exists */
7993 lstrcpyA(buf
, "apple");
7994 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7995 MSIINSTALLCONTEXT_MACHINE
,
7996 INSTALLPROPERTY_TRANSFORMS
, buf
, &sz
);
7997 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7998 ok(!lstrcmpA(buf
, "trans"), "Expected \"trans\", got \"%s\"\n", buf
);
7999 ok(sz
== 5, "Expected 5, got %d\n", sz
);
8001 res
= RegSetValueExA(prodkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
8002 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8004 /* Language value exists */
8006 lstrcpyA(buf
, "apple");
8007 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8008 MSIINSTALLCONTEXT_MACHINE
,
8009 INSTALLPROPERTY_LANGUAGE
, buf
, &sz
);
8010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8011 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
8012 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8014 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
8015 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8017 /* ProductName value exists */
8019 lstrcpyA(buf
, "apple");
8020 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8021 MSIINSTALLCONTEXT_MACHINE
,
8022 INSTALLPROPERTY_PRODUCTNAME
, buf
, &sz
);
8023 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8024 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
8025 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8027 res
= RegSetValueExA(prodkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
8028 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8032 /* AssignmentType value exists */
8034 lstrcpyA(buf
, "apple");
8035 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8036 MSIINSTALLCONTEXT_MACHINE
,
8037 INSTALLPROPERTY_ASSIGNMENTTYPE
, buf
, &sz
);
8038 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8039 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8040 ok(sz
== 0, "Expected 0, got %d\n", sz
);
8042 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
8043 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8047 /* PackageCode value exists */
8049 lstrcpyA(buf
, "apple");
8050 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8051 MSIINSTALLCONTEXT_MACHINE
,
8052 INSTALLPROPERTY_PACKAGECODE
, buf
, &sz
);
8055 ok(r
== ERROR_BAD_CONFIGURATION
,
8056 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
8057 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
8058 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8061 res
= RegSetValueExA(prodkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
8062 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8064 /* Version value exists */
8066 lstrcpyA(buf
, "apple");
8067 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8068 MSIINSTALLCONTEXT_MACHINE
,
8069 INSTALLPROPERTY_VERSION
, buf
, &sz
);
8070 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8071 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
8072 ok(sz
== 3, "Expected 3, got %d\n", sz
);
8074 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
8075 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8077 /* ProductIcon value exists */
8079 lstrcpyA(buf
, "apple");
8080 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8081 MSIINSTALLCONTEXT_MACHINE
,
8082 INSTALLPROPERTY_PRODUCTICON
, buf
, &sz
);
8083 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8084 ok(!lstrcmpA(buf
, "icon"), "Expected \"icon\", got \"%s\"\n", buf
);
8085 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8087 res
= RegSetValueExA(prodkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
8088 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8090 /* PackageName value exists */
8092 lstrcpyA(buf
, "apple");
8093 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8094 MSIINSTALLCONTEXT_MACHINE
,
8095 INSTALLPROPERTY_PACKAGENAME
, buf
, &sz
);
8098 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8099 "Expected ERROR_UNKNOWN_PRODUCT, 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
);
8104 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
8105 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8107 /* AuthorizedLUAApp value exists */
8109 lstrcpyA(buf
, "apple");
8110 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8111 MSIINSTALLCONTEXT_MACHINE
,
8112 INSTALLPROPERTY_AUTHORIZED_LUA_APP
, buf
, &sz
);
8113 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8114 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
8115 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8117 RegDeleteValueA(prodkey
, "AuthorizedLUAApp");
8118 RegDeleteValueA(prodkey
, "PackageName");
8119 RegDeleteValueA(prodkey
, "ProductIcon");
8120 RegDeleteValueA(prodkey
, "Version");
8121 RegDeleteValueA(prodkey
, "PackageCode");
8122 RegDeleteValueA(prodkey
, "AssignmentType");
8123 RegDeleteValueA(prodkey
, "ProductName");
8124 RegDeleteValueA(prodkey
, "Language");
8125 RegDeleteValueA(prodkey
, "Transforms");
8126 RegDeleteValueA(prodkey
, "RegOwner");
8127 RegDeleteValueA(prodkey
, "RegCompany");
8128 RegDeleteValueA(prodkey
, "ProductID");
8129 RegDeleteValueA(prodkey
, "DisplayVersion");
8130 RegDeleteValueA(prodkey
, "VersionMajor");
8131 RegDeleteValueA(prodkey
, "VersionMinor");
8132 RegDeleteValueA(prodkey
, "URLUpdateInfo");
8133 RegDeleteValueA(prodkey
, "URLInfoAbout");
8134 RegDeleteValueA(prodkey
, "Publisher");
8135 RegDeleteValueA(prodkey
, "LocalPackage");
8136 RegDeleteValueA(prodkey
, "InstallSource");
8137 RegDeleteValueA(prodkey
, "InstallLocation");
8138 RegDeleteValueA(prodkey
, "DisplayName");
8139 RegDeleteValueA(prodkey
, "InstallDate");
8140 RegDeleteValueA(prodkey
, "HelpTelephone");
8141 RegDeleteValueA(prodkey
, "HelpLink");
8142 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8143 RegCloseKey(prodkey
);
8147 #define INIT_USERINFO() \
8148 lstrcpyA(user, "apple"); \
8149 lstrcpyA(org, "orange"); \
8150 lstrcpyA(serial, "banana"); \
8151 usersz = orgsz = serialsz = MAX_PATH;
8153 static void test_MsiGetUserInfo(void)
8155 USERINFOSTATE state
;
8156 CHAR user
[MAX_PATH
];
8158 CHAR serial
[MAX_PATH
];
8159 DWORD usersz
, orgsz
, serialsz
;
8160 CHAR keypath
[MAX_PATH
* 2];
8161 CHAR prodcode
[MAX_PATH
];
8162 CHAR prod_squashed
[MAX_PATH
];
8163 HKEY prodkey
, userprod
, props
;
8166 REGSAM access
= KEY_ALL_ACCESS
;
8168 create_test_guid(prodcode
, prod_squashed
);
8169 usersid
= get_user_sid();
8172 access
|= KEY_WOW64_64KEY
;
8174 /* NULL szProduct */
8176 state
= MsiGetUserInfoA(NULL
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8177 ok(state
== USERINFOSTATE_INVALIDARG
,
8178 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8179 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8180 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8181 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8182 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8183 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8184 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8186 /* empty szProductCode */
8188 state
= MsiGetUserInfoA("", user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8189 ok(state
== USERINFOSTATE_INVALIDARG
,
8190 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8191 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8192 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8193 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8194 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8195 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8196 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8198 /* garbage szProductCode */
8200 state
= MsiGetUserInfoA("garbage", user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8201 ok(state
== USERINFOSTATE_INVALIDARG
,
8202 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8203 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8204 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8205 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8206 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8207 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8208 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8210 /* guid without brackets */
8212 state
= MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
8213 user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8214 ok(state
== USERINFOSTATE_INVALIDARG
,
8215 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8216 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8217 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8218 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8219 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8220 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8221 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8223 /* guid with brackets */
8225 state
= MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
8226 user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8227 ok(state
== USERINFOSTATE_UNKNOWN
,
8228 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8229 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8230 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8231 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8232 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8233 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8234 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8236 /* NULL lpUserNameBuf */
8238 state
= MsiGetUserInfoA(prodcode
, NULL
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8239 ok(state
== USERINFOSTATE_UNKNOWN
,
8240 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8241 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8242 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8243 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8244 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8245 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8247 /* NULL pcchUserNameBuf */
8249 state
= MsiGetUserInfoA(prodcode
, user
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8250 ok(state
== USERINFOSTATE_INVALIDARG
,
8251 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8252 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8253 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8254 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8255 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8256 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8258 /* both lpUserNameBuf and pcchUserNameBuf NULL */
8260 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8261 ok(state
== USERINFOSTATE_UNKNOWN
,
8262 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8263 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8264 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8265 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8266 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8268 /* NULL lpOrgNameBuf */
8270 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, NULL
, &orgsz
, serial
, &serialsz
);
8271 ok(state
== USERINFOSTATE_UNKNOWN
,
8272 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8273 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8274 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8275 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8276 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8277 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8279 /* NULL pcchOrgNameBuf */
8281 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, NULL
, serial
, &serialsz
);
8282 ok(state
== USERINFOSTATE_INVALIDARG
,
8283 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8284 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8285 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8286 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8287 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8288 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8290 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
8292 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, NULL
, NULL
, serial
, &serialsz
);
8293 ok(state
== USERINFOSTATE_UNKNOWN
,
8294 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8295 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8296 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8297 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8298 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8300 /* NULL lpSerialBuf */
8302 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, NULL
, &serialsz
);
8303 ok(state
== USERINFOSTATE_UNKNOWN
,
8304 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8305 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8306 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8307 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8308 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8309 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8311 /* NULL pcchSerialBuf */
8313 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, NULL
);
8314 ok(state
== USERINFOSTATE_INVALIDARG
,
8315 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8316 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8317 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8318 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8319 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8320 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8322 /* both lpSerialBuf and pcchSerialBuf NULL */
8324 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, NULL
, NULL
);
8325 ok(state
== USERINFOSTATE_UNKNOWN
,
8326 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8327 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8328 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8329 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8330 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8332 /* MSIINSTALLCONTEXT_USERMANAGED */
8334 /* create local system product key */
8335 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
8336 lstrcatA(keypath
, usersid
);
8337 lstrcatA(keypath
, "\\Installer\\Products\\");
8338 lstrcatA(keypath
, prod_squashed
);
8340 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8341 if (res
== ERROR_ACCESS_DENIED
)
8343 skip("Not enough rights to perform tests\n");
8347 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8349 /* managed product key exists */
8351 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8352 ok(state
== USERINFOSTATE_ABSENT
,
8353 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8354 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8355 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8356 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8357 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8358 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8359 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8361 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8362 lstrcatA(keypath
, "Installer\\UserData\\");
8363 lstrcatA(keypath
, usersid
);
8364 lstrcatA(keypath
, "\\Products\\");
8365 lstrcatA(keypath
, prod_squashed
);
8367 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userprod
, NULL
);
8368 if (res
== ERROR_ACCESS_DENIED
)
8370 skip("Not enough rights to perform tests\n");
8374 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8376 res
= RegCreateKeyExA(userprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8377 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8379 /* InstallProperties key exists */
8381 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8382 ok(state
== USERINFOSTATE_ABSENT
,
8383 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8384 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8385 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8386 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8387 ok(usersz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", usersz
);
8388 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8389 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8391 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8393 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8394 ok(state
== USERINFOSTATE_ABSENT
,
8395 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8396 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8397 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8398 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8399 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8401 /* RegOwner, RegCompany don't exist, out params are NULL */
8403 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, NULL
, NULL
, serial
, &serialsz
);
8404 ok(state
== USERINFOSTATE_ABSENT
,
8405 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8406 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8407 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8409 res
= RegSetValueExA(props
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8410 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8412 /* RegOwner value exists */
8414 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8415 ok(state
== USERINFOSTATE_ABSENT
,
8416 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8417 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8418 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8419 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8420 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8421 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8422 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8424 res
= RegSetValueExA(props
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"company", 8);
8425 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8427 /* RegCompany value exists */
8429 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8430 ok(state
== USERINFOSTATE_ABSENT
,
8431 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8432 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8433 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8434 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8435 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8436 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8437 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8439 res
= RegSetValueExA(props
, "ProductID", 0, REG_SZ
, (LPBYTE
)"ID", 3);
8440 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8442 /* ProductID value exists */
8444 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8445 ok(state
== USERINFOSTATE_PRESENT
,
8446 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8447 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8448 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8449 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8450 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8451 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8452 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8454 /* pcchUserNameBuf is too small */
8457 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8458 ok(state
== USERINFOSTATE_MOREDATA
,
8459 "Expected USERINFOSTATE_MOREDATA, got %d\n", state
);
8460 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8461 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8462 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8463 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8464 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8465 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8467 /* pcchUserNameBuf has no room for NULL terminator */
8470 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8471 ok(state
== USERINFOSTATE_MOREDATA
,
8472 "Expected USERINFOSTATE_MOREDATA, got %d\n", state
);
8475 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(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8479 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8480 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8481 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8483 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
8486 state
= MsiGetUserInfoA(prodcode
, NULL
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8487 ok(state
== USERINFOSTATE_PRESENT
,
8488 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8489 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8490 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8491 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8492 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8493 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8494 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8496 RegDeleteValueA(props
, "ProductID");
8497 RegDeleteValueA(props
, "RegCompany");
8498 RegDeleteValueA(props
, "RegOwner");
8499 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8501 delete_key(userprod
, "", access
& KEY_WOW64_64KEY
);
8502 RegCloseKey(userprod
);
8503 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8504 RegCloseKey(prodkey
);
8506 /* MSIINSTALLCONTEXT_USERUNMANAGED */
8508 /* create local system product key */
8509 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
8510 lstrcatA(keypath
, prod_squashed
);
8512 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
8513 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8515 /* product key exists */
8517 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8518 ok(state
== USERINFOSTATE_ABSENT
,
8519 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8520 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8521 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8522 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8523 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8524 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8525 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8527 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8528 lstrcatA(keypath
, "Installer\\UserData\\");
8529 lstrcatA(keypath
, usersid
);
8530 lstrcatA(keypath
, "\\Products\\");
8531 lstrcatA(keypath
, prod_squashed
);
8533 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userprod
, NULL
);
8534 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8536 res
= RegCreateKeyExA(userprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8537 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8539 /* InstallProperties key exists */
8541 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8542 ok(state
== USERINFOSTATE_ABSENT
,
8543 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8544 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8545 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8546 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8547 ok(usersz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", usersz
);
8548 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8549 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8551 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8553 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8554 ok(state
== USERINFOSTATE_ABSENT
,
8555 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8556 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8557 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8558 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8559 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8561 /* RegOwner, RegCompany don't exist, out params are NULL */
8563 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, NULL
, NULL
, serial
, &serialsz
);
8564 ok(state
== USERINFOSTATE_ABSENT
,
8565 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8566 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8567 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8569 res
= RegSetValueExA(props
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8570 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8572 /* RegOwner value exists */
8574 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8575 ok(state
== USERINFOSTATE_ABSENT
,
8576 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8577 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8578 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8579 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8580 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8581 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8582 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8584 res
= RegSetValueExA(props
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"company", 8);
8585 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8587 /* RegCompany value exists */
8589 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8590 ok(state
== USERINFOSTATE_ABSENT
,
8591 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8592 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8593 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8594 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8595 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8596 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8597 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8599 res
= RegSetValueExA(props
, "ProductID", 0, REG_SZ
, (LPBYTE
)"ID", 3);
8600 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8602 /* ProductID value exists */
8604 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8605 ok(state
== USERINFOSTATE_PRESENT
,
8606 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8607 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8608 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8609 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8610 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8611 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8612 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8614 RegDeleteValueA(props
, "ProductID");
8615 RegDeleteValueA(props
, "RegCompany");
8616 RegDeleteValueA(props
, "RegOwner");
8617 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8619 delete_key(userprod
, "", access
& KEY_WOW64_64KEY
);
8620 RegCloseKey(userprod
);
8621 RegDeleteKeyA(prodkey
, "");
8622 RegCloseKey(prodkey
);
8624 /* MSIINSTALLCONTEXT_MACHINE */
8626 /* create local system product key */
8627 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8628 lstrcatA(keypath
, prod_squashed
);
8630 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8631 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8633 /* product key exists */
8635 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8636 ok(state
== USERINFOSTATE_ABSENT
,
8637 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8638 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8639 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8640 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8641 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8642 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8643 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8645 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8646 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18");
8647 lstrcatA(keypath
, "\\Products\\");
8648 lstrcatA(keypath
, prod_squashed
);
8650 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userprod
, NULL
);
8651 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8653 res
= RegCreateKeyExA(userprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8654 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8656 /* InstallProperties key exists */
8658 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8659 ok(state
== USERINFOSTATE_ABSENT
,
8660 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8661 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8662 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8663 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8664 ok(usersz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", usersz
);
8665 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8666 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8668 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8670 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8671 ok(state
== USERINFOSTATE_ABSENT
,
8672 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8673 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8674 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8675 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8676 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8678 /* RegOwner, RegCompany don't exist, out params are NULL */
8680 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, NULL
, NULL
, serial
, &serialsz
);
8681 ok(state
== USERINFOSTATE_ABSENT
,
8682 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8683 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8684 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8686 res
= RegSetValueExA(props
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8687 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8689 /* RegOwner value exists */
8691 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8692 ok(state
== USERINFOSTATE_ABSENT
,
8693 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8694 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8695 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8696 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8697 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8698 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8699 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8701 res
= RegSetValueExA(props
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"company", 8);
8702 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8704 /* RegCompany value exists */
8706 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8707 ok(state
== USERINFOSTATE_ABSENT
,
8708 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8709 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8710 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8711 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8712 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8713 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8714 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8716 res
= RegSetValueExA(props
, "ProductID", 0, REG_SZ
, (LPBYTE
)"ID", 3);
8717 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8719 /* ProductID value exists */
8721 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8722 ok(state
== USERINFOSTATE_PRESENT
,
8723 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8724 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8725 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8726 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8727 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8728 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8729 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8731 RegDeleteValueA(props
, "ProductID");
8732 RegDeleteValueA(props
, "RegCompany");
8733 RegDeleteValueA(props
, "RegOwner");
8734 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8736 delete_key(userprod
, "", access
& KEY_WOW64_64KEY
);
8737 RegCloseKey(userprod
);
8738 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8739 RegCloseKey(prodkey
);
8743 static void test_MsiOpenProduct(void)
8745 MSIHANDLE hprod
, hdb
;
8747 CHAR path
[MAX_PATH
];
8748 CHAR keypath
[MAX_PATH
*2];
8749 CHAR prodcode
[MAX_PATH
];
8750 CHAR prod_squashed
[MAX_PATH
];
8751 HKEY prodkey
, userkey
, props
;
8756 REGSAM access
= KEY_ALL_ACCESS
;
8758 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
8760 GetCurrentDirectoryA(MAX_PATH
, path
);
8761 lstrcatA(path
, "\\");
8763 create_test_guid(prodcode
, prod_squashed
);
8764 usersid
= get_user_sid();
8767 access
|= KEY_WOW64_64KEY
;
8769 hdb
= create_package_db(prodcode
);
8770 MsiCloseHandle(hdb
);
8772 /* NULL szProduct */
8774 r
= MsiOpenProductA(NULL
, &hprod
);
8775 ok(r
== ERROR_INVALID_PARAMETER
,
8776 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8777 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8779 /* empty szProduct */
8781 r
= MsiOpenProductA("", &hprod
);
8782 ok(r
== ERROR_INVALID_PARAMETER
,
8783 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8784 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8786 /* garbage szProduct */
8788 r
= MsiOpenProductA("garbage", &hprod
);
8789 ok(r
== ERROR_INVALID_PARAMETER
,
8790 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8791 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8793 /* guid without brackets */
8795 r
= MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod
);
8796 ok(r
== ERROR_INVALID_PARAMETER
,
8797 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8798 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8800 /* guid with brackets */
8802 r
= MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod
);
8803 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8804 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8805 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8807 /* same length as guid, but random */
8809 r
= MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod
);
8810 ok(r
== ERROR_INVALID_PARAMETER
,
8811 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8812 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8814 /* hProduct is NULL */
8816 r
= MsiOpenProductA(prodcode
, NULL
);
8817 ok(r
== ERROR_INVALID_PARAMETER
,
8818 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8819 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8821 /* MSIINSTALLCONTEXT_USERMANAGED */
8823 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8824 lstrcatA(keypath
, "Installer\\Managed\\");
8825 lstrcatA(keypath
, usersid
);
8826 lstrcatA(keypath
, "\\Installer\\Products\\");
8827 lstrcatA(keypath
, prod_squashed
);
8829 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8830 if (res
== ERROR_ACCESS_DENIED
)
8832 skip("Not enough rights to perform tests\n");
8836 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8838 /* managed product key exists */
8840 r
= MsiOpenProductA(prodcode
, &hprod
);
8841 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8842 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8843 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8845 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8846 lstrcatA(keypath
, "Installer\\UserData\\");
8847 lstrcatA(keypath
, usersid
);
8848 lstrcatA(keypath
, "\\Products\\");
8849 lstrcatA(keypath
, prod_squashed
);
8851 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8852 if (res
== ERROR_ACCESS_DENIED
)
8854 skip("Not enough rights to perform tests\n");
8858 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8860 /* user product key exists */
8862 r
= MsiOpenProductA(prodcode
, &hprod
);
8863 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8864 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8865 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8867 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8868 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8870 /* InstallProperties key exists */
8872 r
= MsiOpenProductA(prodcode
, &hprod
);
8873 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8874 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8875 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8877 lstrcpyA(val
, path
);
8878 lstrcatA(val
, "\\winetest.msi");
8879 res
= RegSetValueExA(props
, "ManagedLocalPackage", 0, REG_SZ
,
8880 (const BYTE
*)val
, lstrlenA(val
) + 1);
8881 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8883 /* ManagedLocalPackage value exists */
8885 r
= MsiOpenProductA(prodcode
, &hprod
);
8886 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8887 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8890 r
= MsiGetPropertyA(hprod
, "ProductCode", val
, &size
);
8891 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8892 ok(!lstrcmpA(val
, prodcode
), "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8893 ok(size
== lstrlenA(prodcode
), "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8895 MsiCloseHandle(hprod
);
8897 RegDeleteValueA(props
, "ManagedLocalPackage");
8898 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8900 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
8901 RegCloseKey(userkey
);
8902 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8903 RegCloseKey(prodkey
);
8905 /* MSIINSTALLCONTEXT_USERUNMANAGED */
8907 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
8908 lstrcatA(keypath
, prod_squashed
);
8910 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
8911 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8913 /* unmanaged product key exists */
8915 r
= MsiOpenProductA(prodcode
, &hprod
);
8916 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8917 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8918 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8920 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8921 lstrcatA(keypath
, "Installer\\UserData\\");
8922 lstrcatA(keypath
, usersid
);
8923 lstrcatA(keypath
, "\\Products\\");
8924 lstrcatA(keypath
, prod_squashed
);
8926 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8927 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8929 /* user product key exists */
8931 r
= MsiOpenProductA(prodcode
, &hprod
);
8932 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8933 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8934 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8936 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8937 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8939 /* InstallProperties key exists */
8941 r
= MsiOpenProductA(prodcode
, &hprod
);
8942 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8943 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8944 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8946 lstrcpyA(val
, path
);
8947 lstrcatA(val
, "\\winetest.msi");
8948 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
8949 (const BYTE
*)val
, lstrlenA(val
) + 1);
8950 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8952 /* LocalPackage value exists */
8954 r
= MsiOpenProductA(prodcode
, &hprod
);
8955 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8956 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8959 r
= MsiGetPropertyA(hprod
, "ProductCode", val
, &size
);
8960 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8961 ok(!lstrcmpA(val
, prodcode
), "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8962 ok(size
== lstrlenA(prodcode
), "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8964 MsiCloseHandle(hprod
);
8966 RegDeleteValueA(props
, "LocalPackage");
8967 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8969 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
8970 RegCloseKey(userkey
);
8971 RegDeleteKeyA(prodkey
, "");
8972 RegCloseKey(prodkey
);
8974 /* MSIINSTALLCONTEXT_MACHINE */
8976 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8977 lstrcatA(keypath
, prod_squashed
);
8979 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8980 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8982 /* managed product key exists */
8984 r
= MsiOpenProductA(prodcode
, &hprod
);
8985 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8986 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8987 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8989 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8990 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
8991 lstrcatA(keypath
, prod_squashed
);
8993 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8994 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8996 /* user product key exists */
8998 r
= MsiOpenProductA(prodcode
, &hprod
);
8999 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9000 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9001 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9003 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
9004 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9006 /* InstallProperties key exists */
9008 r
= MsiOpenProductA(prodcode
, &hprod
);
9009 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9010 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9011 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9013 lstrcpyA(val
, path
);
9014 lstrcatA(val
, "\\winetest.msi");
9015 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9016 (const BYTE
*)val
, lstrlenA(val
) + 1);
9017 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9019 /* LocalPackage value exists */
9021 r
= MsiOpenProductA(prodcode
, &hprod
);
9022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9023 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
9026 r
= MsiGetPropertyA(hprod
, "ProductCode", val
, &size
);
9027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9028 ok(!lstrcmpA(val
, prodcode
), "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
9029 ok(size
== lstrlenA(prodcode
), "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
9031 MsiCloseHandle(hprod
);
9033 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9034 (const BYTE
*)"winetest.msi", 13);
9035 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9037 lstrcpyA(val
, path
);
9038 lstrcatA(val
, "\\winetest.msi");
9039 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9040 (const BYTE
*)val
, lstrlenA(val
) + 1);
9041 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9043 DeleteFileA(msifile
);
9045 /* local package does not exist */
9047 r
= MsiOpenProductA(prodcode
, &hprod
);
9048 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9049 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9050 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9052 RegDeleteValueA(props
, "LocalPackage");
9053 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
9055 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
9056 RegCloseKey(userkey
);
9057 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
9058 RegCloseKey(prodkey
);
9060 DeleteFileA(msifile
);
9064 static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid
, LPCSTR expectedsid
)
9066 MSIINSTALLCONTEXT context
;
9067 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
9068 CHAR patch_squashed
[MAX_PATH
], patchcode
[MAX_PATH
];
9069 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
9070 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
9071 HKEY prodkey
, patches
, udprod
, udpatch
, hpatch
;
9075 REGSAM access
= KEY_ALL_ACCESS
;
9077 create_test_guid(prodcode
, prod_squashed
);
9078 create_test_guid(patch
, patch_squashed
);
9081 access
|= KEY_WOW64_64KEY
;
9083 /* MSIPATCHSTATE_APPLIED */
9085 lstrcpyA(patchcode
, "apple");
9086 lstrcpyA(targetprod
, "banana");
9087 context
= 0xdeadbeef;
9088 lstrcpyA(targetsid
, "kiwi");
9090 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9091 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9092 &context
, targetsid
, &size
);
9093 if (r
== ERROR_ACCESS_DENIED
)
9095 skip("Not enough rights to perform tests\n");
9098 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9099 ok(!lstrcmpA(patchcode
, "apple"),
9100 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9101 ok(!lstrcmpA(targetprod
, "banana"),
9102 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9103 ok(context
== 0xdeadbeef,
9104 "Expected context to be unchanged, got %d\n", context
);
9105 ok(!lstrcmpA(targetsid
, "kiwi"),
9106 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9107 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9109 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
9110 lstrcatA(keypath
, expectedsid
);
9111 lstrcatA(keypath
, "\\Installer\\Products\\");
9112 lstrcatA(keypath
, prod_squashed
);
9114 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
9115 if (res
== ERROR_ACCESS_DENIED
)
9117 skip("Not enough rights to perform tests\n");
9120 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9122 /* managed product key exists */
9123 lstrcpyA(patchcode
, "apple");
9124 lstrcpyA(targetprod
, "banana");
9125 context
= 0xdeadbeef;
9126 lstrcpyA(targetsid
, "kiwi");
9128 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9129 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9130 &context
, targetsid
, &size
);
9131 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9132 ok(!lstrcmpA(patchcode
, "apple"),
9133 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9134 ok(!lstrcmpA(targetprod
, "banana"),
9135 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9136 ok(context
== 0xdeadbeef,
9137 "Expected context to be unchanged, got %d\n", context
);
9138 ok(!lstrcmpA(targetsid
, "kiwi"),
9139 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9140 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9142 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
9143 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9145 /* patches key exists */
9146 lstrcpyA(patchcode
, "apple");
9147 lstrcpyA(targetprod
, "banana");
9148 context
= 0xdeadbeef;
9149 lstrcpyA(targetsid
, "kiwi");
9151 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9152 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9153 &context
, targetsid
, &size
);
9154 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9155 ok(!lstrcmpA(patchcode
, "apple"),
9156 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9157 ok(!lstrcmpA(targetprod
, "banana"),
9158 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9159 ok(context
== 0xdeadbeef,
9160 "Expected context to be unchanged, got %d\n", context
);
9161 ok(!lstrcmpA(targetsid
, "kiwi"),
9162 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9163 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9165 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
9166 (const BYTE
*)patch_squashed
,
9167 lstrlenA(patch_squashed
) + 1);
9168 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9170 /* Patches value exists, is not REG_MULTI_SZ */
9171 lstrcpyA(patchcode
, "apple");
9172 lstrcpyA(targetprod
, "banana");
9173 context
= 0xdeadbeef;
9174 lstrcpyA(targetsid
, "kiwi");
9176 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9177 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9178 &context
, targetsid
, &size
);
9179 ok(r
== ERROR_BAD_CONFIGURATION
,
9180 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9181 ok(!lstrcmpA(patchcode
, "apple"),
9182 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9183 ok(!lstrcmpA(targetprod
, "banana"),
9184 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9185 ok(context
== 0xdeadbeef,
9186 "Expected context to be unchanged, got %d\n", context
);
9187 ok(!lstrcmpA(targetsid
, "kiwi"),
9188 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9189 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9191 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9192 (const BYTE
*)"a\0b\0c\0\0", 7);
9193 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9195 /* Patches value exists, is not a squashed guid */
9196 lstrcpyA(patchcode
, "apple");
9197 lstrcpyA(targetprod
, "banana");
9198 context
= 0xdeadbeef;
9199 lstrcpyA(targetsid
, "kiwi");
9201 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9202 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9203 &context
, targetsid
, &size
);
9204 ok(r
== ERROR_BAD_CONFIGURATION
,
9205 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9206 ok(!lstrcmpA(patchcode
, "apple"),
9207 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9208 ok(!lstrcmpA(targetprod
, "banana"),
9209 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9210 ok(context
== 0xdeadbeef,
9211 "Expected context to be unchanged, got %d\n", context
);
9212 ok(!lstrcmpA(targetsid
, "kiwi"),
9213 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9214 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9216 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
9217 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9218 (const BYTE
*)patch_squashed
,
9219 lstrlenA(patch_squashed
) + 2);
9220 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9222 /* Patches value exists */
9223 lstrcpyA(patchcode
, "apple");
9224 lstrcpyA(targetprod
, "banana");
9225 context
= 0xdeadbeef;
9226 lstrcpyA(targetsid
, "kiwi");
9228 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9229 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9230 &context
, targetsid
, &size
);
9231 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9232 ok(!lstrcmpA(patchcode
, "apple"),
9233 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9234 ok(!lstrcmpA(targetprod
, "banana"),
9235 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9236 ok(context
== 0xdeadbeef,
9237 "Expected context to be unchanged, got %d\n", context
);
9238 ok(!lstrcmpA(targetsid
, "kiwi"),
9239 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9240 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9242 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
9243 (const BYTE
*)"whatever", 9);
9244 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9246 /* patch squashed value exists */
9247 lstrcpyA(patchcode
, "apple");
9248 lstrcpyA(targetprod
, "banana");
9249 context
= 0xdeadbeef;
9250 lstrcpyA(targetsid
, "kiwi");
9252 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9253 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9254 &context
, targetsid
, &size
);
9255 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9256 ok(!lstrcmpA(patchcode
, patch
),
9257 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9258 ok(!lstrcmpA(targetprod
, prodcode
),
9259 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9260 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9261 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9262 ok(!lstrcmpA(targetsid
, expectedsid
),
9263 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9264 ok(size
== lstrlenA(expectedsid
),
9265 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9267 /* increase the index */
9268 lstrcpyA(patchcode
, "apple");
9269 lstrcpyA(targetprod
, "banana");
9270 context
= 0xdeadbeef;
9271 lstrcpyA(targetsid
, "kiwi");
9273 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9274 MSIPATCHSTATE_APPLIED
, 1, patchcode
, targetprod
,
9275 &context
, targetsid
, &size
);
9276 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9277 ok(!lstrcmpA(patchcode
, "apple"),
9278 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9279 ok(!lstrcmpA(targetprod
, "banana"),
9280 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9281 ok(context
== 0xdeadbeef,
9282 "Expected context to be unchanged, got %d\n", context
);
9283 ok(!lstrcmpA(targetsid
, "kiwi"),
9284 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9285 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9287 /* increase again */
9288 lstrcpyA(patchcode
, "apple");
9289 lstrcpyA(targetprod
, "banana");
9290 context
= 0xdeadbeef;
9291 lstrcpyA(targetsid
, "kiwi");
9293 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9294 MSIPATCHSTATE_APPLIED
, 2, patchcode
, targetprod
,
9295 &context
, targetsid
, &size
);
9296 ok(r
== ERROR_INVALID_PARAMETER
,
9297 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
9298 ok(!lstrcmpA(patchcode
, "apple"),
9299 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9300 ok(!lstrcmpA(targetprod
, "banana"),
9301 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9302 ok(context
== 0xdeadbeef,
9303 "Expected context to be unchanged, got %d\n", context
);
9304 ok(!lstrcmpA(targetsid
, "kiwi"),
9305 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9306 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9308 /* szPatchCode is NULL */
9309 lstrcpyA(targetprod
, "banana");
9310 context
= 0xdeadbeef;
9311 lstrcpyA(targetsid
, "kiwi");
9313 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9314 MSIPATCHSTATE_APPLIED
, 0, NULL
, targetprod
,
9315 &context
, targetsid
, &size
);
9316 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9317 ok(!lstrcmpA(targetprod
, prodcode
),
9318 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9319 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9320 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9321 ok(!lstrcmpA(targetsid
, expectedsid
),
9322 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9323 ok(size
== lstrlenA(expectedsid
),
9324 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9326 /* szTargetProductCode is NULL */
9327 lstrcpyA(patchcode
, "apple");
9328 context
= 0xdeadbeef;
9329 lstrcpyA(targetsid
, "kiwi");
9331 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9332 MSIPATCHSTATE_APPLIED
, 0, patchcode
, NULL
,
9333 &context
, targetsid
, &size
);
9334 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9335 ok(!lstrcmpA(patchcode
, patch
),
9336 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9337 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9338 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9339 ok(!lstrcmpA(targetsid
, expectedsid
),
9340 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9341 ok(size
== lstrlenA(expectedsid
),
9342 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9344 /* pdwTargetProductContext is NULL */
9345 lstrcpyA(patchcode
, "apple");
9346 lstrcpyA(targetprod
, "banana");
9347 lstrcpyA(targetsid
, "kiwi");
9349 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9350 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9351 NULL
, targetsid
, &size
);
9352 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9353 ok(!lstrcmpA(patchcode
, patch
),
9354 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9355 ok(!lstrcmpA(targetprod
, prodcode
),
9356 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9357 ok(!lstrcmpA(targetsid
, expectedsid
),
9358 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9359 ok(size
== lstrlenA(expectedsid
),
9360 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9362 /* szTargetUserSid is NULL */
9363 lstrcpyA(patchcode
, "apple");
9364 lstrcpyA(targetprod
, "banana");
9365 context
= 0xdeadbeef;
9367 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9368 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9369 &context
, NULL
, &size
);
9370 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9371 ok(!lstrcmpA(patchcode
, patch
),
9372 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9373 ok(!lstrcmpA(targetprod
, prodcode
),
9374 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9375 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9376 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9377 ok(size
== lstrlenA(expectedsid
) * sizeof(WCHAR
),
9378 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid
), size
);
9380 /* pcchTargetUserSid is exactly the length of szTargetUserSid */
9381 lstrcpyA(patchcode
, "apple");
9382 lstrcpyA(targetprod
, "banana");
9383 context
= 0xdeadbeef;
9384 lstrcpyA(targetsid
, "kiwi");
9385 size
= lstrlenA(expectedsid
);
9386 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9387 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9388 &context
, targetsid
, &size
);
9389 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
9390 ok(!lstrcmpA(patchcode
, patch
),
9391 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9392 ok(!lstrcmpA(targetprod
, prodcode
),
9393 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9394 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9395 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9396 ok(!strncmp(targetsid
, expectedsid
, lstrlenA(expectedsid
) - 1),
9397 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9398 ok(size
== lstrlenA(expectedsid
) * sizeof(WCHAR
),
9399 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid
), size
);
9401 /* pcchTargetUserSid has enough room for NULL terminator */
9402 lstrcpyA(patchcode
, "apple");
9403 lstrcpyA(targetprod
, "banana");
9404 context
= 0xdeadbeef;
9405 lstrcpyA(targetsid
, "kiwi");
9406 size
= lstrlenA(expectedsid
) + 1;
9407 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9408 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9409 &context
, targetsid
, &size
);
9410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9411 ok(!lstrcmpA(patchcode
, patch
),
9412 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9413 ok(!lstrcmpA(targetprod
, prodcode
),
9414 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9415 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9416 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9417 ok(!lstrcmpA(targetsid
, expectedsid
),
9418 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9419 ok(size
== lstrlenA(expectedsid
),
9420 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9422 /* both szTargetuserSid and pcchTargetUserSid are NULL */
9423 lstrcpyA(patchcode
, "apple");
9424 lstrcpyA(targetprod
, "banana");
9425 context
= 0xdeadbeef;
9426 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9427 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9428 &context
, NULL
, NULL
);
9429 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9430 ok(!lstrcmpA(patchcode
, patch
),
9431 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9432 ok(!lstrcmpA(targetprod
, prodcode
),
9433 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9434 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9435 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9437 /* MSIPATCHSTATE_SUPERSEDED */
9439 lstrcpyA(patchcode
, "apple");
9440 lstrcpyA(targetprod
, "banana");
9441 context
= 0xdeadbeef;
9442 lstrcpyA(targetsid
, "kiwi");
9444 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9445 MSIPATCHSTATE_SUPERSEDED
, 0, 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 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9459 lstrcatA(keypath
, expectedsid
);
9460 lstrcatA(keypath
, "\\Products\\");
9461 lstrcatA(keypath
, prod_squashed
);
9463 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
9464 if (res
== ERROR_ACCESS_DENIED
)
9466 skip("Not enough rights to perform tests\n");
9469 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9471 /* UserData product key exists */
9472 lstrcpyA(patchcode
, "apple");
9473 lstrcpyA(targetprod
, "banana");
9474 context
= 0xdeadbeef;
9475 lstrcpyA(targetsid
, "kiwi");
9477 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9478 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9479 &context
, targetsid
, &size
);
9480 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9481 ok(!lstrcmpA(patchcode
, "apple"),
9482 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9483 ok(!lstrcmpA(targetprod
, "banana"),
9484 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9485 ok(context
== 0xdeadbeef,
9486 "Expected context to be unchanged, got %d\n", context
);
9487 ok(!lstrcmpA(targetsid
, "kiwi"),
9488 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9489 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9491 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
9492 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9494 /* UserData patches key exists */
9495 lstrcpyA(patchcode
, "apple");
9496 lstrcpyA(targetprod
, "banana");
9497 context
= 0xdeadbeef;
9498 lstrcpyA(targetsid
, "kiwi");
9500 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9501 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9502 &context
, targetsid
, &size
);
9503 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9504 ok(!lstrcmpA(patchcode
, "apple"),
9505 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9506 ok(!lstrcmpA(targetprod
, "banana"),
9507 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9508 ok(context
== 0xdeadbeef,
9509 "Expected context to be unchanged, got %d\n", context
);
9510 ok(!lstrcmpA(targetsid
, "kiwi"),
9511 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9512 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9514 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
9515 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9517 /* specific UserData patch key exists */
9518 lstrcpyA(patchcode
, "apple");
9519 lstrcpyA(targetprod
, "banana");
9520 context
= 0xdeadbeef;
9521 lstrcpyA(targetsid
, "kiwi");
9523 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9524 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9525 &context
, targetsid
, &size
);
9526 ok(r
== ERROR_BAD_CONFIGURATION
,
9527 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9528 ok(!lstrcmpA(patchcode
, "apple"),
9529 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9530 ok(!lstrcmpA(targetprod
, "banana"),
9531 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9532 ok(context
== 0xdeadbeef,
9533 "Expected context to be unchanged, got %d\n", context
);
9534 ok(!lstrcmpA(targetsid
, "kiwi"),
9535 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9536 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9538 data
= MSIPATCHSTATE_SUPERSEDED
;
9539 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
9540 (const BYTE
*)&data
, sizeof(DWORD
));
9541 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9543 /* State value exists */
9544 lstrcpyA(patchcode
, "apple");
9545 lstrcpyA(targetprod
, "banana");
9546 context
= 0xdeadbeef;
9547 lstrcpyA(targetsid
, "kiwi");
9549 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9550 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9551 &context
, targetsid
, &size
);
9552 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9553 ok(!lstrcmpA(patchcode
, patch
),
9554 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9555 ok(!lstrcmpA(targetprod
, prodcode
),
9556 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9557 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9558 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9559 ok(!lstrcmpA(targetsid
, expectedsid
),
9560 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9561 ok(size
== lstrlenA(expectedsid
),
9562 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9564 /* MSIPATCHSTATE_OBSOLETED */
9566 lstrcpyA(patchcode
, "apple");
9567 lstrcpyA(targetprod
, "banana");
9568 context
= 0xdeadbeef;
9569 lstrcpyA(targetsid
, "kiwi");
9571 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9572 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
9573 &context
, targetsid
, &size
);
9574 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9575 ok(!lstrcmpA(patchcode
, "apple"),
9576 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9577 ok(!lstrcmpA(targetprod
, "banana"),
9578 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9579 ok(context
== 0xdeadbeef,
9580 "Expected context to be unchanged, got %d\n", context
);
9581 ok(!lstrcmpA(targetsid
, "kiwi"),
9582 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9583 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9585 data
= MSIPATCHSTATE_OBSOLETED
;
9586 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
9587 (const BYTE
*)&data
, sizeof(DWORD
));
9588 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9590 /* State value is obsoleted */
9591 lstrcpyA(patchcode
, "apple");
9592 lstrcpyA(targetprod
, "banana");
9593 context
= 0xdeadbeef;
9594 lstrcpyA(targetsid
, "kiwi");
9596 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9597 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
9598 &context
, targetsid
, &size
);
9599 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9600 ok(!lstrcmpA(patchcode
, patch
),
9601 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9602 ok(!lstrcmpA(targetprod
, prodcode
),
9603 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9604 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9605 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9606 ok(!lstrcmpA(targetsid
, expectedsid
),
9607 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9608 ok(size
== lstrlenA(expectedsid
),
9609 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9611 /* MSIPATCHSTATE_REGISTERED */
9614 /* MSIPATCHSTATE_ALL */
9617 lstrcpyA(patchcode
, "apple");
9618 lstrcpyA(targetprod
, "banana");
9619 context
= 0xdeadbeef;
9620 lstrcpyA(targetsid
, "kiwi");
9622 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9623 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
9624 &context
, targetsid
, &size
);
9625 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9626 ok(!lstrcmpA(patchcode
, patch
),
9627 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9628 ok(!lstrcmpA(targetprod
, prodcode
),
9629 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9630 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9631 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9632 ok(!lstrcmpA(targetsid
, expectedsid
),
9633 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9634 ok(size
== lstrlenA(expectedsid
),
9635 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9637 /* same patch in multiple places, only one is enumerated */
9638 lstrcpyA(patchcode
, "apple");
9639 lstrcpyA(targetprod
, "banana");
9640 context
= 0xdeadbeef;
9641 lstrcpyA(targetsid
, "kiwi");
9643 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9644 MSIPATCHSTATE_ALL
, 1, patchcode
, targetprod
,
9645 &context
, targetsid
, &size
);
9646 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9647 ok(!lstrcmpA(patchcode
, "apple"),
9648 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9649 ok(!lstrcmpA(targetprod
, "banana"),
9650 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9651 ok(context
== 0xdeadbeef,
9652 "Expected context to be unchanged, got %d\n", context
);
9653 ok(!lstrcmpA(targetsid
, "kiwi"),
9654 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9655 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9657 RegDeleteValueA(hpatch
, "State");
9658 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
9659 RegCloseKey(hpatch
);
9660 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
9661 RegCloseKey(udpatch
);
9662 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
9663 RegCloseKey(udprod
);
9664 RegDeleteValueA(patches
, "Patches");
9665 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
9666 RegCloseKey(patches
);
9667 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
9668 RegCloseKey(prodkey
);
9671 static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid
, LPCSTR expectedsid
)
9673 MSIINSTALLCONTEXT context
;
9674 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
9675 CHAR patch_squashed
[MAX_PATH
], patchcode
[MAX_PATH
];
9676 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
9677 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
9678 HKEY prodkey
, patches
, udprod
, udpatch
;
9679 HKEY userkey
, hpatch
;
9683 REGSAM access
= KEY_ALL_ACCESS
;
9685 create_test_guid(prodcode
, prod_squashed
);
9686 create_test_guid(patch
, patch_squashed
);
9689 access
|= KEY_WOW64_64KEY
;
9691 /* MSIPATCHSTATE_APPLIED */
9693 lstrcpyA(patchcode
, "apple");
9694 lstrcpyA(targetprod
, "banana");
9695 context
= 0xdeadbeef;
9696 lstrcpyA(targetsid
, "kiwi");
9698 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9699 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9700 &context
, targetsid
, &size
);
9701 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9702 ok(!lstrcmpA(patchcode
, "apple"),
9703 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9704 ok(!lstrcmpA(targetprod
, "banana"),
9705 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9706 ok(context
== 0xdeadbeef,
9707 "Expected context to be unchanged, got %d\n", context
);
9708 ok(!lstrcmpA(targetsid
, "kiwi"),
9709 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9710 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9712 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
9713 lstrcatA(keypath
, prod_squashed
);
9715 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
9716 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9718 /* current user product key exists */
9719 lstrcpyA(patchcode
, "apple");
9720 lstrcpyA(targetprod
, "banana");
9721 context
= 0xdeadbeef;
9722 lstrcpyA(targetsid
, "kiwi");
9724 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9725 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9726 &context
, targetsid
, &size
);
9727 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9728 ok(!lstrcmpA(patchcode
, "apple"),
9729 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9730 ok(!lstrcmpA(targetprod
, "banana"),
9731 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9732 ok(context
== 0xdeadbeef,
9733 "Expected context to be unchanged, got %d\n", context
);
9734 ok(!lstrcmpA(targetsid
, "kiwi"),
9735 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9736 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9738 res
= RegCreateKeyA(prodkey
, "Patches", &patches
);
9739 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9741 /* Patches key exists */
9742 lstrcpyA(patchcode
, "apple");
9743 lstrcpyA(targetprod
, "banana");
9744 context
= 0xdeadbeef;
9745 lstrcpyA(targetsid
, "kiwi");
9747 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9748 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9749 &context
, targetsid
, &size
);
9750 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9751 ok(!lstrcmpA(patchcode
, "apple"),
9752 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9753 ok(!lstrcmpA(targetprod
, "banana"),
9754 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9755 ok(context
== 0xdeadbeef,
9756 "Expected context to be unchanged, got %d\n", context
);
9757 ok(!lstrcmpA(targetsid
, "kiwi"),
9758 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9759 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9761 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
9762 (const BYTE
*)patch_squashed
,
9763 lstrlenA(patch_squashed
) + 1);
9764 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9766 /* Patches value exists, is not REG_MULTI_SZ */
9767 lstrcpyA(patchcode
, "apple");
9768 lstrcpyA(targetprod
, "banana");
9769 context
= 0xdeadbeef;
9770 lstrcpyA(targetsid
, "kiwi");
9772 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9773 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9774 &context
, targetsid
, &size
);
9775 ok(r
== ERROR_BAD_CONFIGURATION
,
9776 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9777 ok(!lstrcmpA(patchcode
, "apple"),
9778 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9779 ok(!lstrcmpA(targetprod
, "banana"),
9780 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9781 ok(context
== 0xdeadbeef,
9782 "Expected context to be unchanged, got %d\n", context
);
9783 ok(!lstrcmpA(targetsid
, "kiwi"),
9784 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9785 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9787 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9788 (const BYTE
*)"a\0b\0c\0\0", 7);
9789 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9791 /* Patches value exists, is not a squashed guid */
9792 lstrcpyA(patchcode
, "apple");
9793 lstrcpyA(targetprod
, "banana");
9794 context
= 0xdeadbeef;
9795 lstrcpyA(targetsid
, "kiwi");
9797 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9798 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9799 &context
, targetsid
, &size
);
9800 ok(r
== ERROR_BAD_CONFIGURATION
,
9801 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9802 ok(!lstrcmpA(patchcode
, "apple"),
9803 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9804 ok(!lstrcmpA(targetprod
, "banana"),
9805 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9806 ok(context
== 0xdeadbeef,
9807 "Expected context to be unchanged, got %d\n", context
);
9808 ok(!lstrcmpA(targetsid
, "kiwi"),
9809 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9810 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9812 patch_squashed
[lstrlenA(patch_squashed
) + 1] = 0;
9813 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9814 (const BYTE
*)patch_squashed
,
9815 lstrlenA(patch_squashed
) + 2);
9816 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9818 /* Patches value exists */
9819 lstrcpyA(patchcode
, "apple");
9820 lstrcpyA(targetprod
, "banana");
9821 context
= 0xdeadbeef;
9822 lstrcpyA(targetsid
, "kiwi");
9824 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9825 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9826 &context
, targetsid
, &size
);
9827 ok(r
== ERROR_NO_MORE_ITEMS
||
9828 broken(r
== ERROR_BAD_CONFIGURATION
), /* Windows Installer 3.0 */
9829 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9830 ok(!lstrcmpA(patchcode
, "apple"),
9831 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9832 ok(!lstrcmpA(targetprod
, "banana"),
9833 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9834 ok(context
== 0xdeadbeef,
9835 "Expected context to be unchanged, got %d\n", context
);
9836 ok(!lstrcmpA(targetsid
, "kiwi"),
9837 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9838 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9840 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
9841 (const BYTE
*)"whatever", 9);
9842 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9844 /* patch code value exists */
9845 lstrcpyA(patchcode
, "apple");
9846 lstrcpyA(targetprod
, "banana");
9847 context
= 0xdeadbeef;
9848 lstrcpyA(targetsid
, "kiwi");
9850 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9851 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9852 &context
, targetsid
, &size
);
9853 ok(r
== ERROR_NO_MORE_ITEMS
||
9854 broken(r
== ERROR_BAD_CONFIGURATION
), /* Windows Installer 3.0 */
9855 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9856 ok(!lstrcmpA(patchcode
, "apple"),
9857 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9858 ok(!lstrcmpA(targetprod
, "banana"),
9859 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9860 ok(context
== 0xdeadbeef,
9861 "Expected context to be unchanged, got %d\n", context
);
9862 ok(!lstrcmpA(targetsid
, "kiwi"),
9863 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9864 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9866 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9867 lstrcatA(keypath
, expectedsid
);
9868 lstrcatA(keypath
, "\\Patches\\");
9869 lstrcatA(keypath
, patch_squashed
);
9871 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
9872 if (res
== ERROR_ACCESS_DENIED
)
9874 skip("Not enough rights to perform tests\n");
9877 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9879 /* userdata patch key exists */
9880 lstrcpyA(patchcode
, "apple");
9881 lstrcpyA(targetprod
, "banana");
9882 context
= 0xdeadbeef;
9883 lstrcpyA(targetsid
, "kiwi");
9885 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9886 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9887 &context
, targetsid
, &size
);
9888 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9889 ok(!lstrcmpA(patchcode
, patch
),
9890 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9891 ok(!lstrcmpA(targetprod
, prodcode
),
9892 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9893 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
9894 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
9895 ok(!lstrcmpA(targetsid
, expectedsid
),
9896 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9897 ok(size
== lstrlenA(expectedsid
),
9898 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9900 /* MSIPATCHSTATE_SUPERSEDED */
9902 lstrcpyA(patchcode
, "apple");
9903 lstrcpyA(targetprod
, "banana");
9904 context
= 0xdeadbeef;
9905 lstrcpyA(targetsid
, "kiwi");
9907 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9908 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9909 &context
, targetsid
, &size
);
9910 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9911 ok(!lstrcmpA(patchcode
, "apple"),
9912 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9913 ok(!lstrcmpA(targetprod
, "banana"),
9914 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9915 ok(context
== 0xdeadbeef,
9916 "Expected context to be unchanged, got %d\n", context
);
9917 ok(!lstrcmpA(targetsid
, "kiwi"),
9918 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9919 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9921 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9922 lstrcatA(keypath
, expectedsid
);
9923 lstrcatA(keypath
, "\\Products\\");
9924 lstrcatA(keypath
, prod_squashed
);
9926 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
9927 if (res
== ERROR_ACCESS_DENIED
)
9929 skip("Not enough rights to perform tests\n");
9932 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9934 /* UserData product key exists */
9935 lstrcpyA(patchcode
, "apple");
9936 lstrcpyA(targetprod
, "banana");
9937 context
= 0xdeadbeef;
9938 lstrcpyA(targetsid
, "kiwi");
9940 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9941 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9942 &context
, targetsid
, &size
);
9943 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9944 ok(!lstrcmpA(patchcode
, "apple"),
9945 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9946 ok(!lstrcmpA(targetprod
, "banana"),
9947 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9948 ok(context
== 0xdeadbeef,
9949 "Expected context to be unchanged, got %d\n", context
);
9950 ok(!lstrcmpA(targetsid
, "kiwi"),
9951 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9952 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9954 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
9955 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9957 /* UserData patches key exists */
9958 lstrcpyA(patchcode
, "apple");
9959 lstrcpyA(targetprod
, "banana");
9960 context
= 0xdeadbeef;
9961 lstrcpyA(targetsid
, "kiwi");
9963 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9964 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9965 &context
, targetsid
, &size
);
9966 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9967 ok(!lstrcmpA(patchcode
, "apple"),
9968 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9969 ok(!lstrcmpA(targetprod
, "banana"),
9970 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9971 ok(context
== 0xdeadbeef,
9972 "Expected context to be unchanged, got %d\n", context
);
9973 ok(!lstrcmpA(targetsid
, "kiwi"),
9974 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9975 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9977 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
9978 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9980 /* specific UserData patch key exists */
9981 lstrcpyA(patchcode
, "apple");
9982 lstrcpyA(targetprod
, "banana");
9983 context
= 0xdeadbeef;
9984 lstrcpyA(targetsid
, "kiwi");
9986 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9987 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9988 &context
, targetsid
, &size
);
9989 ok(r
== ERROR_BAD_CONFIGURATION
,
9990 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9991 ok(!lstrcmpA(patchcode
, "apple"),
9992 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9993 ok(!lstrcmpA(targetprod
, "banana"),
9994 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9995 ok(context
== 0xdeadbeef,
9996 "Expected context to be unchanged, got %d\n", context
);
9997 ok(!lstrcmpA(targetsid
, "kiwi"),
9998 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9999 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10001 data
= MSIPATCHSTATE_SUPERSEDED
;
10002 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10003 (const BYTE
*)&data
, sizeof(DWORD
));
10004 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10006 /* State value exists */
10007 lstrcpyA(patchcode
, "apple");
10008 lstrcpyA(targetprod
, "banana");
10009 context
= 0xdeadbeef;
10010 lstrcpyA(targetsid
, "kiwi");
10012 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10013 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10014 &context
, targetsid
, &size
);
10015 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10016 ok(!lstrcmpA(patchcode
, patch
),
10017 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10018 ok(!lstrcmpA(targetprod
, prodcode
),
10019 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10020 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
10021 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
10022 ok(!lstrcmpA(targetsid
, expectedsid
),
10023 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
10024 ok(size
== lstrlenA(expectedsid
),
10025 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
10027 /* MSIPATCHSTATE_OBSOLETED */
10029 lstrcpyA(patchcode
, "apple");
10030 lstrcpyA(targetprod
, "banana");
10031 context
= 0xdeadbeef;
10032 lstrcpyA(targetsid
, "kiwi");
10034 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10035 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10036 &context
, targetsid
, &size
);
10037 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10038 ok(!lstrcmpA(patchcode
, "apple"),
10039 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10040 ok(!lstrcmpA(targetprod
, "banana"),
10041 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10042 ok(context
== 0xdeadbeef,
10043 "Expected context to be unchanged, got %d\n", context
);
10044 ok(!lstrcmpA(targetsid
, "kiwi"),
10045 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10046 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10048 data
= MSIPATCHSTATE_OBSOLETED
;
10049 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10050 (const BYTE
*)&data
, sizeof(DWORD
));
10051 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10053 /* State value is obsoleted */
10054 lstrcpyA(patchcode
, "apple");
10055 lstrcpyA(targetprod
, "banana");
10056 context
= 0xdeadbeef;
10057 lstrcpyA(targetsid
, "kiwi");
10059 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10060 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10061 &context
, targetsid
, &size
);
10062 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10063 ok(!lstrcmpA(patchcode
, patch
),
10064 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10065 ok(!lstrcmpA(targetprod
, prodcode
),
10066 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10067 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
10068 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
10069 ok(!lstrcmpA(targetsid
, expectedsid
),
10070 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
10071 ok(size
== lstrlenA(expectedsid
),
10072 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
10074 /* MSIPATCHSTATE_REGISTERED */
10077 /* MSIPATCHSTATE_ALL */
10080 lstrcpyA(patchcode
, "apple");
10081 lstrcpyA(targetprod
, "banana");
10082 context
= 0xdeadbeef;
10083 lstrcpyA(targetsid
, "kiwi");
10085 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10086 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10087 &context
, targetsid
, &size
);
10088 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10089 ok(!lstrcmpA(patchcode
, patch
),
10090 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10091 ok(!lstrcmpA(targetprod
, prodcode
),
10092 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10093 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
10094 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
10095 ok(!lstrcmpA(targetsid
, expectedsid
),
10096 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
10097 ok(size
== lstrlenA(expectedsid
),
10098 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
10100 /* same patch in multiple places, only one is enumerated */
10101 lstrcpyA(patchcode
, "apple");
10102 lstrcpyA(targetprod
, "banana");
10103 context
= 0xdeadbeef;
10104 lstrcpyA(targetsid
, "kiwi");
10106 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10107 MSIPATCHSTATE_ALL
, 1, patchcode
, targetprod
,
10108 &context
, targetsid
, &size
);
10109 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10110 ok(!lstrcmpA(patchcode
, "apple"),
10111 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10112 ok(!lstrcmpA(targetprod
, "banana"),
10113 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10114 ok(context
== 0xdeadbeef,
10115 "Expected context to be unchanged, got %d\n", context
);
10116 ok(!lstrcmpA(targetsid
, "kiwi"),
10117 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10118 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10120 RegDeleteValueA(hpatch
, "State");
10121 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
10122 RegCloseKey(hpatch
);
10123 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
10124 RegCloseKey(udpatch
);
10125 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
10126 RegCloseKey(udprod
);
10127 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
10128 RegCloseKey(userkey
);
10129 RegDeleteValueA(patches
, patch_squashed
);
10130 RegDeleteValueA(patches
, "Patches");
10133 RegDeleteKeyA(patches
, "");
10134 RegCloseKey(patches
);
10135 RegDeleteKeyA(prodkey
, "");
10136 RegCloseKey(prodkey
);
10139 static void test_MsiEnumPatchesEx_machine(void)
10141 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
10142 CHAR patch_squashed
[MAX_PATH
], patchcode
[MAX_PATH
];
10143 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
10144 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
10145 HKEY prodkey
, patches
, udprod
, udpatch
;
10147 MSIINSTALLCONTEXT context
;
10151 REGSAM access
= KEY_ALL_ACCESS
;
10153 create_test_guid(prodcode
, prod_squashed
);
10154 create_test_guid(patch
, patch_squashed
);
10157 access
|= KEY_WOW64_64KEY
;
10159 /* MSIPATCHSTATE_APPLIED */
10161 lstrcpyA(patchcode
, "apple");
10162 lstrcpyA(targetprod
, "banana");
10163 context
= 0xdeadbeef;
10164 lstrcpyA(targetsid
, "kiwi");
10166 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10167 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10168 &context
, targetsid
, &size
);
10169 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10170 ok(!lstrcmpA(patchcode
, "apple"),
10171 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10172 ok(!lstrcmpA(targetprod
, "banana"),
10173 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10174 ok(context
== 0xdeadbeef,
10175 "Expected context to be unchanged, got %d\n", context
);
10176 ok(!lstrcmpA(targetsid
, "kiwi"),
10177 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10178 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10180 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
10181 lstrcatA(keypath
, prod_squashed
);
10183 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
10184 if (res
== ERROR_ACCESS_DENIED
)
10186 skip("Not enough rights to perform tests\n");
10189 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10191 /* local product key exists */
10192 lstrcpyA(patchcode
, "apple");
10193 lstrcpyA(targetprod
, "banana");
10194 context
= 0xdeadbeef;
10195 lstrcpyA(targetsid
, "kiwi");
10197 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10198 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10199 &context
, targetsid
, &size
);
10200 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10201 ok(!lstrcmpA(patchcode
, "apple"),
10202 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10203 ok(!lstrcmpA(targetprod
, "banana"),
10204 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10205 ok(context
== 0xdeadbeef,
10206 "Expected context to be unchanged, got %d\n", context
);
10207 ok(!lstrcmpA(targetsid
, "kiwi"),
10208 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10209 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10211 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
10212 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10214 /* Patches key exists */
10215 lstrcpyA(patchcode
, "apple");
10216 lstrcpyA(targetprod
, "banana");
10217 context
= 0xdeadbeef;
10218 lstrcpyA(targetsid
, "kiwi");
10220 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10221 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10222 &context
, targetsid
, &size
);
10223 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10224 ok(!lstrcmpA(patchcode
, "apple"),
10225 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10226 ok(!lstrcmpA(targetprod
, "banana"),
10227 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10228 ok(context
== 0xdeadbeef,
10229 "Expected context to be unchanged, got %d\n", context
);
10230 ok(!lstrcmpA(targetsid
, "kiwi"),
10231 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10232 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10234 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
10235 (const BYTE
*)patch_squashed
,
10236 lstrlenA(patch_squashed
) + 1);
10237 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10239 /* Patches value exists, is not REG_MULTI_SZ */
10240 lstrcpyA(patchcode
, "apple");
10241 lstrcpyA(targetprod
, "banana");
10242 context
= 0xdeadbeef;
10243 lstrcpyA(targetsid
, "kiwi");
10245 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10246 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10247 &context
, targetsid
, &size
);
10248 ok(r
== ERROR_BAD_CONFIGURATION
,
10249 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
10250 ok(!lstrcmpA(patchcode
, "apple"),
10251 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10252 ok(!lstrcmpA(targetprod
, "banana"),
10253 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10254 ok(context
== 0xdeadbeef,
10255 "Expected context to be unchanged, got %d\n", context
);
10256 ok(!lstrcmpA(targetsid
, "kiwi"),
10257 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10258 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10260 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
10261 (const BYTE
*)"a\0b\0c\0\0", 7);
10262 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10264 /* Patches value exists, is not a squashed guid */
10265 lstrcpyA(patchcode
, "apple");
10266 lstrcpyA(targetprod
, "banana");
10267 context
= 0xdeadbeef;
10268 lstrcpyA(targetsid
, "kiwi");
10270 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10271 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10272 &context
, targetsid
, &size
);
10273 ok(r
== ERROR_BAD_CONFIGURATION
,
10274 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
10275 ok(!lstrcmpA(patchcode
, "apple"),
10276 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10277 ok(!lstrcmpA(targetprod
, "banana"),
10278 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10279 ok(context
== 0xdeadbeef,
10280 "Expected context to be unchanged, got %d\n", context
);
10281 ok(!lstrcmpA(targetsid
, "kiwi"),
10282 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10283 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10285 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
10286 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
10287 (const BYTE
*)patch_squashed
,
10288 lstrlenA(patch_squashed
) + 2);
10289 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10291 /* Patches value exists */
10292 lstrcpyA(patchcode
, "apple");
10293 lstrcpyA(targetprod
, "banana");
10294 context
= 0xdeadbeef;
10295 lstrcpyA(targetsid
, "kiwi");
10297 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10298 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10299 &context
, targetsid
, &size
);
10300 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10301 ok(!lstrcmpA(patchcode
, "apple"),
10302 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10303 ok(!lstrcmpA(targetprod
, "banana"),
10304 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10305 ok(context
== 0xdeadbeef,
10306 "Expected context to be unchanged, got %d\n", context
);
10307 ok(!lstrcmpA(targetsid
, "kiwi"),
10308 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10309 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10311 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
10312 (const BYTE
*)"whatever", 9);
10313 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10315 /* patch code value exists */
10316 lstrcpyA(patchcode
, "apple");
10317 lstrcpyA(targetprod
, "banana");
10318 context
= 0xdeadbeef;
10319 lstrcpyA(targetsid
, "kiwi");
10321 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10322 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10323 &context
, targetsid
, &size
);
10324 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10325 ok(!lstrcmpA(patchcode
, patch
),
10326 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10327 ok(!lstrcmpA(targetprod
, prodcode
),
10328 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10329 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10330 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10331 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10332 ok(size
== 0, "Expected 0, got %d\n", size
);
10334 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
10335 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
10336 lstrcatA(keypath
, prod_squashed
);
10338 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
10339 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10341 /* local UserData product key exists */
10342 lstrcpyA(patchcode
, "apple");
10343 lstrcpyA(targetprod
, "banana");
10344 context
= 0xdeadbeef;
10345 lstrcpyA(targetsid
, "kiwi");
10347 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10348 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10349 &context
, targetsid
, &size
);
10350 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10351 ok(!lstrcmpA(patchcode
, patch
),
10352 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10353 ok(!lstrcmpA(targetprod
, prodcode
),
10354 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10355 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10356 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10357 ok(!lstrcmpA(targetsid
, ""),
10358 "Expected \"\", got \"%s\"\n", targetsid
);
10359 ok(size
== 0, "Expected 0, got %d\n", size
);
10361 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
10362 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10364 /* local UserData Patches key exists */
10365 lstrcpyA(patchcode
, "apple");
10366 lstrcpyA(targetprod
, "banana");
10367 context
= 0xdeadbeef;
10368 lstrcpyA(targetsid
, "kiwi");
10370 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10371 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10372 &context
, targetsid
, &size
);
10373 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10374 ok(!lstrcmpA(patchcode
, patch
),
10375 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10376 ok(!lstrcmpA(targetprod
, prodcode
),
10377 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10378 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10379 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10380 ok(!lstrcmpA(targetsid
, ""),
10381 "Expected \"\", got \"%s\"\n", targetsid
);
10382 ok(size
== 0, "Expected 0, got %d\n", size
);
10384 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
10385 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10387 /* local UserData Product patch key exists */
10388 lstrcpyA(patchcode
, "apple");
10389 lstrcpyA(targetprod
, "banana");
10390 context
= 0xdeadbeef;
10391 lstrcpyA(targetsid
, "kiwi");
10393 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10394 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10395 &context
, targetsid
, &size
);
10396 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10397 ok(!lstrcmpA(patchcode
, "apple"),
10398 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10399 ok(!lstrcmpA(targetprod
, "banana"),
10400 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10401 ok(context
== 0xdeadbeef,
10402 "Expected context to be unchanged, got %d\n", context
);
10403 ok(!lstrcmpA(targetsid
, "kiwi"),
10404 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10405 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10407 data
= MSIPATCHSTATE_APPLIED
;
10408 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10409 (const BYTE
*)&data
, sizeof(DWORD
));
10410 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10412 /* State value exists */
10413 lstrcpyA(patchcode
, "apple");
10414 lstrcpyA(targetprod
, "banana");
10415 context
= 0xdeadbeef;
10416 lstrcpyA(targetsid
, "kiwi");
10418 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10419 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10420 &context
, targetsid
, &size
);
10421 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10422 ok(!lstrcmpA(patchcode
, patch
),
10423 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10424 ok(!lstrcmpA(targetprod
, prodcode
),
10425 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10426 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10427 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10428 ok(!lstrcmpA(targetsid
, ""),
10429 "Expected \"\", got \"%s\"\n", targetsid
);
10430 ok(size
== 0, "Expected 0, got %d\n", size
);
10432 /* MSIPATCHSTATE_SUPERSEDED */
10434 lstrcpyA(patchcode
, "apple");
10435 lstrcpyA(targetprod
, "banana");
10436 context
= 0xdeadbeef;
10437 lstrcpyA(targetsid
, "kiwi");
10439 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10440 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10441 &context
, targetsid
, &size
);
10442 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10443 ok(!lstrcmpA(patchcode
, "apple"),
10444 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10445 ok(!lstrcmpA(targetprod
, "banana"),
10446 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10447 ok(context
== 0xdeadbeef,
10448 "Expected context to be unchanged, got %d\n", context
);
10449 ok(!lstrcmpA(targetsid
, "kiwi"),
10450 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10451 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10453 data
= MSIPATCHSTATE_SUPERSEDED
;
10454 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10455 (const BYTE
*)&data
, sizeof(DWORD
));
10456 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10458 /* State value is MSIPATCHSTATE_SUPERSEDED */
10459 lstrcpyA(patchcode
, "apple");
10460 lstrcpyA(targetprod
, "banana");
10461 context
= 0xdeadbeef;
10462 lstrcpyA(targetsid
, "kiwi");
10464 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10465 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10466 &context
, targetsid
, &size
);
10467 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10468 ok(!lstrcmpA(patchcode
, patch
),
10469 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10470 ok(!lstrcmpA(targetprod
, prodcode
),
10471 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10472 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10473 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10474 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10475 ok(size
== 0, "Expected 0, got %d\n", size
);
10477 /* MSIPATCHSTATE_OBSOLETED */
10479 lstrcpyA(patchcode
, "apple");
10480 lstrcpyA(targetprod
, "banana");
10481 context
= 0xdeadbeef;
10482 lstrcpyA(targetsid
, "kiwi");
10484 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10485 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10486 &context
, targetsid
, &size
);
10487 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10488 ok(!lstrcmpA(patchcode
, "apple"),
10489 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10490 ok(!lstrcmpA(targetprod
, "banana"),
10491 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10492 ok(context
== 0xdeadbeef,
10493 "Expected context to be unchanged, got %d\n", context
);
10494 ok(!lstrcmpA(targetsid
, "kiwi"),
10495 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10496 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10498 data
= MSIPATCHSTATE_OBSOLETED
;
10499 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10500 (const BYTE
*)&data
, sizeof(DWORD
));
10501 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10503 /* State value is obsoleted */
10504 lstrcpyA(patchcode
, "apple");
10505 lstrcpyA(targetprod
, "banana");
10506 context
= 0xdeadbeef;
10507 lstrcpyA(targetsid
, "kiwi");
10509 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10510 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10511 &context
, targetsid
, &size
);
10512 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10513 ok(!lstrcmpA(patchcode
, patch
),
10514 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10515 ok(!lstrcmpA(targetprod
, prodcode
),
10516 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10517 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10518 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10519 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10520 ok(size
== 0, "Expected 0, got %d\n", size
);
10522 /* MSIPATCHSTATE_REGISTERED */
10525 /* MSIPATCHSTATE_ALL */
10528 lstrcpyA(patchcode
, "apple");
10529 lstrcpyA(targetprod
, "banana");
10530 context
= 0xdeadbeef;
10531 lstrcpyA(targetsid
, "kiwi");
10533 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10534 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10535 &context
, targetsid
, &size
);
10536 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10537 ok(!lstrcmpA(patchcode
, patch
),
10538 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10539 ok(!lstrcmpA(targetprod
, prodcode
),
10540 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10541 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10542 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10543 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10544 ok(size
== 0, "Expected 0, got %d\n", size
);
10546 /* same patch in multiple places, only one is enumerated */
10547 lstrcpyA(patchcode
, "apple");
10548 lstrcpyA(targetprod
, "banana");
10549 context
= 0xdeadbeef;
10550 lstrcpyA(targetsid
, "kiwi");
10552 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10553 MSIPATCHSTATE_ALL
, 1, patchcode
, targetprod
,
10554 &context
, targetsid
, &size
);
10555 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10556 ok(!lstrcmpA(patchcode
, "apple"),
10557 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10558 ok(!lstrcmpA(targetprod
, "banana"),
10559 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10560 ok(context
== 0xdeadbeef,
10561 "Expected context to be unchanged, got %d\n", context
);
10562 ok(!lstrcmpA(targetsid
, "kiwi"),
10563 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10564 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10566 RegDeleteValueA(patches
, patch_squashed
);
10567 RegDeleteValueA(patches
, "Patches");
10568 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
10569 RegCloseKey(patches
);
10570 RegDeleteValueA(hpatch
, "State");
10571 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
10572 RegCloseKey(hpatch
);
10573 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
10574 RegCloseKey(udpatch
);
10575 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
10576 RegCloseKey(udprod
);
10577 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
10578 RegCloseKey(prodkey
);
10581 static void test_MsiEnumPatchesEx(void)
10583 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
10584 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
10585 CHAR patchcode
[MAX_PATH
];
10586 MSIINSTALLCONTEXT context
;
10591 if (!pMsiEnumPatchesExA
)
10593 win_skip("MsiEnumPatchesExA not implemented\n");
10597 create_test_guid(prodcode
, prod_squashed
);
10598 usersid
= get_user_sid();
10600 /* empty szProductCode */
10601 lstrcpyA(patchcode
, "apple");
10602 lstrcpyA(targetprod
, "banana");
10603 context
= 0xdeadbeef;
10604 lstrcpyA(targetsid
, "kiwi");
10606 r
= pMsiEnumPatchesExA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10607 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
, &context
,
10609 ok(r
== ERROR_INVALID_PARAMETER
,
10610 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10611 ok(!lstrcmpA(patchcode
, "apple"),
10612 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10613 ok(!lstrcmpA(targetprod
, "banana"),
10614 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10615 ok(context
== 0xdeadbeef,
10616 "Expected context to be unchanged, got %d\n", context
);
10617 ok(!lstrcmpA(targetsid
, "kiwi"),
10618 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10619 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10621 /* garbage szProductCode */
10622 lstrcpyA(patchcode
, "apple");
10623 lstrcpyA(targetprod
, "banana");
10624 context
= 0xdeadbeef;
10625 lstrcpyA(targetsid
, "kiwi");
10627 r
= pMsiEnumPatchesExA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10628 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
, &context
,
10630 ok(r
== ERROR_INVALID_PARAMETER
,
10631 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10632 ok(!lstrcmpA(patchcode
, "apple"),
10633 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10634 ok(!lstrcmpA(targetprod
, "banana"),
10635 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10636 ok(context
== 0xdeadbeef,
10637 "Expected context to be unchanged, got %d\n", context
);
10638 ok(!lstrcmpA(targetsid
, "kiwi"),
10639 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10640 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10642 /* guid without brackets */
10643 lstrcpyA(patchcode
, "apple");
10644 lstrcpyA(targetprod
, "banana");
10645 context
= 0xdeadbeef;
10646 lstrcpyA(targetsid
, "kiwi");
10648 r
= pMsiEnumPatchesExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid
,
10649 MSIINSTALLCONTEXT_USERUNMANAGED
, MSIPATCHSTATE_ALL
,
10650 0, patchcode
, targetprod
, &context
,
10652 ok(r
== ERROR_INVALID_PARAMETER
,
10653 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10654 ok(!lstrcmpA(patchcode
, "apple"),
10655 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10656 ok(!lstrcmpA(targetprod
, "banana"),
10657 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10658 ok(context
== 0xdeadbeef,
10659 "Expected context to be unchanged, got %d\n", context
);
10660 ok(!lstrcmpA(targetsid
, "kiwi"),
10661 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10662 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10664 /* guid with brackets */
10665 lstrcpyA(patchcode
, "apple");
10666 lstrcpyA(targetprod
, "banana");
10667 context
= 0xdeadbeef;
10668 lstrcpyA(targetsid
, "kiwi");
10670 r
= pMsiEnumPatchesExA("{6700E8CF-95AB-4D9C-BC2C-15840DDA7A5D}", usersid
,
10671 MSIINSTALLCONTEXT_USERUNMANAGED
, MSIPATCHSTATE_ALL
,
10672 0, patchcode
, targetprod
, &context
,
10674 ok(r
== ERROR_NO_MORE_ITEMS
,
10675 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10676 ok(!lstrcmpA(patchcode
, "apple"),
10677 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10678 ok(!lstrcmpA(targetprod
, "banana"),
10679 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10680 ok(context
== 0xdeadbeef,
10681 "Expected context to be unchanged, got %d\n", context
);
10682 ok(!lstrcmpA(targetsid
, "kiwi"),
10683 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10684 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10686 /* szUserSid is S-1-5-18 */
10687 lstrcpyA(patchcode
, "apple");
10688 lstrcpyA(targetprod
, "banana");
10689 context
= 0xdeadbeef;
10690 lstrcpyA(targetsid
, "kiwi");
10692 r
= pMsiEnumPatchesExA(prodcode
, "S-1-5-18",
10693 MSIINSTALLCONTEXT_USERUNMANAGED
, MSIPATCHSTATE_ALL
,
10694 0, patchcode
, targetprod
, &context
,
10696 ok(r
== ERROR_INVALID_PARAMETER
,
10697 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10698 ok(!lstrcmpA(patchcode
, "apple"),
10699 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10700 ok(!lstrcmpA(targetprod
, "banana"),
10701 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10702 ok(context
== 0xdeadbeef,
10703 "Expected context to be unchanged, got %d\n", context
);
10704 ok(!lstrcmpA(targetsid
, "kiwi"),
10705 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10706 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10708 /* dwContext is MSIINSTALLCONTEXT_MACHINE, but szUserSid is non-NULL */
10709 lstrcpyA(patchcode
, "apple");
10710 lstrcpyA(targetprod
, "banana");
10711 context
= 0xdeadbeef;
10712 lstrcpyA(targetsid
, "kiwi");
10714 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_MACHINE
,
10715 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10716 &context
, targetsid
, &size
);
10717 ok(r
== ERROR_INVALID_PARAMETER
,
10718 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10719 ok(!lstrcmpA(patchcode
, "apple"),
10720 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10721 ok(!lstrcmpA(targetprod
, "banana"),
10722 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10723 ok(context
== 0xdeadbeef,
10724 "Expected context to be unchanged, got %d\n", context
);
10725 ok(!lstrcmpA(targetsid
, "kiwi"),
10726 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10727 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10729 /* dwContext is out of bounds */
10730 lstrcpyA(patchcode
, "apple");
10731 lstrcpyA(targetprod
, "banana");
10732 context
= 0xdeadbeef;
10733 lstrcpyA(targetsid
, "kiwi");
10735 r
= pMsiEnumPatchesExA(prodcode
, usersid
, 0,
10736 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10737 &context
, targetsid
, &size
);
10738 ok(r
== ERROR_INVALID_PARAMETER
,
10739 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10740 ok(!lstrcmpA(patchcode
, "apple"),
10741 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10742 ok(!lstrcmpA(targetprod
, "banana"),
10743 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10744 ok(context
== 0xdeadbeef,
10745 "Expected context to be unchanged, got %d\n", context
);
10746 ok(!lstrcmpA(targetsid
, "kiwi"),
10747 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10748 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10750 /* dwContext is out of bounds */
10751 lstrcpyA(patchcode
, "apple");
10752 lstrcpyA(targetprod
, "banana");
10753 context
= 0xdeadbeef;
10754 lstrcpyA(targetsid
, "kiwi");
10756 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_ALL
+ 1,
10757 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10758 &context
, targetsid
, &size
);
10759 ok(r
== ERROR_INVALID_PARAMETER
,
10760 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10761 ok(!lstrcmpA(patchcode
, "apple"),
10762 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10763 ok(!lstrcmpA(targetprod
, "banana"),
10764 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10765 ok(context
== 0xdeadbeef,
10766 "Expected context to be unchanged, got %d\n", context
);
10767 ok(!lstrcmpA(targetsid
, "kiwi"),
10768 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10769 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10771 /* dwFilter is out of bounds */
10772 lstrcpyA(patchcode
, "apple");
10773 lstrcpyA(targetprod
, "banana");
10774 context
= 0xdeadbeef;
10775 lstrcpyA(targetsid
, "kiwi");
10777 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10778 MSIPATCHSTATE_INVALID
, 0, patchcode
, targetprod
,
10779 &context
, targetsid
, &size
);
10780 ok(r
== ERROR_INVALID_PARAMETER
,
10781 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10782 ok(!lstrcmpA(patchcode
, "apple"),
10783 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10784 ok(!lstrcmpA(targetprod
, "banana"),
10785 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10786 ok(context
== 0xdeadbeef,
10787 "Expected context to be unchanged, got %d\n", context
);
10788 ok(!lstrcmpA(targetsid
, "kiwi"),
10789 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10790 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10792 /* dwFilter is out of bounds */
10793 lstrcpyA(patchcode
, "apple");
10794 lstrcpyA(targetprod
, "banana");
10795 context
= 0xdeadbeef;
10796 lstrcpyA(targetsid
, "kiwi");
10798 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10799 MSIPATCHSTATE_ALL
+ 1, 0, patchcode
, targetprod
,
10800 &context
, targetsid
, &size
);
10801 ok(r
== ERROR_INVALID_PARAMETER
,
10802 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10803 ok(!lstrcmpA(patchcode
, "apple"),
10804 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10805 ok(!lstrcmpA(targetprod
, "banana"),
10806 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10807 ok(context
== 0xdeadbeef,
10808 "Expected context to be unchanged, got %d\n", context
);
10809 ok(!lstrcmpA(targetsid
, "kiwi"),
10810 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10811 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10813 /* pcchTargetUserSid is NULL while szTargetUserSid is non-NULL */
10814 lstrcpyA(patchcode
, "apple");
10815 lstrcpyA(targetprod
, "banana");
10816 context
= 0xdeadbeef;
10817 lstrcpyA(targetsid
, "kiwi");
10818 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10819 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10820 &context
, targetsid
, NULL
);
10821 ok(r
== ERROR_INVALID_PARAMETER
,
10822 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10823 ok(!lstrcmpA(patchcode
, "apple"),
10824 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10825 ok(!lstrcmpA(targetprod
, "banana"),
10826 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10827 ok(context
== 0xdeadbeef,
10828 "Expected context to be unchanged, got %d\n", context
);
10829 ok(!lstrcmpA(targetsid
, "kiwi"),
10830 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10832 test_MsiEnumPatchesEx_usermanaged(usersid
, usersid
);
10833 test_MsiEnumPatchesEx_usermanaged(NULL
, usersid
);
10834 test_MsiEnumPatchesEx_usermanaged("S-1-2-34", "S-1-2-34");
10835 test_MsiEnumPatchesEx_userunmanaged(usersid
, usersid
);
10836 test_MsiEnumPatchesEx_userunmanaged(NULL
, usersid
);
10837 /* FIXME: Successfully test userunmanaged with a different user */
10838 test_MsiEnumPatchesEx_machine();
10839 LocalFree(usersid
);
10842 static void test_MsiEnumPatches(void)
10844 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
10845 CHAR patchcode
[MAX_PATH
], patch_squashed
[MAX_PATH
];
10846 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
10847 CHAR transforms
[MAX_PATH
];
10848 WCHAR patchW
[MAX_PATH
], prodcodeW
[MAX_PATH
], transformsW
[MAX_PATH
];
10849 HKEY prodkey
, patches
, udprod
;
10850 HKEY userkey
, hpatch
, udpatch
;
10855 REGSAM access
= KEY_ALL_ACCESS
;
10857 create_test_guid(prodcode
, prod_squashed
);
10858 create_test_guid(patchcode
, patch_squashed
);
10859 usersid
= get_user_sid();
10862 access
|= KEY_WOW64_64KEY
;
10864 /* NULL szProduct */
10866 lstrcpyA(patch
, "apple");
10867 lstrcpyA(transforms
, "banana");
10868 r
= MsiEnumPatchesA(NULL
, 0, patch
, transforms
, &size
);
10869 ok(r
== ERROR_INVALID_PARAMETER
,
10870 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10871 ok(!lstrcmpA(patch
, "apple"),
10872 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10873 ok(!lstrcmpA(transforms
, "banana"),
10874 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10875 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10877 /* empty szProduct */
10879 lstrcpyA(patch
, "apple");
10880 lstrcpyA(transforms
, "banana");
10881 r
= MsiEnumPatchesA("", 0, patch
, transforms
, &size
);
10882 ok(r
== ERROR_INVALID_PARAMETER
,
10883 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10884 ok(!lstrcmpA(patch
, "apple"),
10885 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10886 ok(!lstrcmpA(transforms
, "banana"),
10887 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10888 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10890 /* garbage szProduct */
10892 lstrcpyA(patch
, "apple");
10893 lstrcpyA(transforms
, "banana");
10894 r
= MsiEnumPatchesA("garbage", 0, patch
, transforms
, &size
);
10895 ok(r
== ERROR_INVALID_PARAMETER
,
10896 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10897 ok(!lstrcmpA(patch
, "apple"),
10898 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10899 ok(!lstrcmpA(transforms
, "banana"),
10900 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10901 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10903 /* guid without brackets */
10905 lstrcpyA(patch
, "apple");
10906 lstrcpyA(transforms
, "banana");
10907 r
= MsiEnumPatchesA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", 0, patch
,
10908 transforms
, &size
);
10909 ok(r
== ERROR_INVALID_PARAMETER
,
10910 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10911 ok(!lstrcmpA(patch
, "apple"),
10912 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10913 ok(!lstrcmpA(transforms
, "banana"),
10914 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10915 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10917 /* guid with brackets */
10919 lstrcpyA(patch
, "apple");
10920 lstrcpyA(transforms
, "banana");
10921 r
= MsiEnumPatchesA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", 0, patch
,
10922 transforms
, &size
);
10923 ok(r
== ERROR_UNKNOWN_PRODUCT
,
10924 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
10925 ok(!lstrcmpA(patch
, "apple"),
10926 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10927 ok(!lstrcmpA(transforms
, "banana"),
10928 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10929 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10931 /* same length as guid, but random */
10933 lstrcpyA(patch
, "apple");
10934 lstrcpyA(transforms
, "banana");
10935 r
= MsiEnumPatchesA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", 0, patch
,
10936 transforms
, &size
);
10937 ok(r
== ERROR_INVALID_PARAMETER
,
10938 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10939 ok(!lstrcmpA(patch
, "apple"),
10940 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10941 ok(!lstrcmpA(transforms
, "banana"),
10942 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10943 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10945 /* MSIINSTALLCONTEXT_USERMANAGED */
10948 lstrcpyA(patch
, "apple");
10949 lstrcpyA(transforms
, "banana");
10950 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
10951 ok(r
== ERROR_UNKNOWN_PRODUCT
,
10952 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
10953 ok(!lstrcmpA(patch
, "apple"),
10954 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10955 ok(!lstrcmpA(transforms
, "banana"),
10956 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10957 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10959 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
10960 lstrcatA(keypath
, usersid
);
10961 lstrcatA(keypath
, "\\Installer\\Products\\");
10962 lstrcatA(keypath
, prod_squashed
);
10964 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
10965 if (res
== ERROR_ACCESS_DENIED
)
10967 skip("Not enough rights to perform tests\n");
10968 LocalFree(usersid
);
10971 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10973 /* managed product key exists */
10975 lstrcpyA(patch
, "apple");
10976 lstrcpyA(transforms
, "banana");
10977 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
10978 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10979 ok(!lstrcmpA(patch
, "apple"),
10980 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10981 ok(!lstrcmpA(transforms
, "banana"),
10982 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10983 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10985 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
10986 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10988 /* patches key exists */
10990 lstrcpyA(patch
, "apple");
10991 lstrcpyA(transforms
, "banana");
10992 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
10993 ok(r
== ERROR_NO_MORE_ITEMS
||
10994 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
10995 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10996 ok(!lstrcmpA(patch
, "apple"),
10997 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10998 ok(!lstrcmpA(transforms
, "banana"),
10999 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11000 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11002 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
11003 (const BYTE
*)patch_squashed
,
11004 lstrlenA(patch_squashed
) + 1);
11005 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11007 /* Patches value exists, is not REG_MULTI_SZ */
11009 lstrcpyA(patch
, "apple");
11010 lstrcpyA(transforms
, "banana");
11011 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11012 ok(r
== ERROR_BAD_CONFIGURATION
||
11013 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11014 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11015 ok(!lstrcmpA(patch
, "apple"),
11016 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11017 ok(!lstrcmpA(transforms
, "banana"),
11018 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11019 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11021 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11022 (const BYTE
*)"a\0b\0c\0\0", 7);
11023 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11025 /* Patches value exists, is not a squashed guid */
11027 lstrcpyA(patch
, "apple");
11028 lstrcpyA(transforms
, "banana");
11029 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11030 ok(r
== ERROR_BAD_CONFIGURATION
,
11031 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11032 ok(!lstrcmpA(patch
, "apple"),
11033 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11034 ok(!lstrcmpA(transforms
, "banana"),
11035 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11036 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11038 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
11039 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11040 (const BYTE
*)patch_squashed
,
11041 lstrlenA(patch_squashed
) + 2);
11042 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11044 /* Patches value exists */
11046 lstrcpyA(patch
, "apple");
11047 lstrcpyA(transforms
, "banana");
11048 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11049 ok(r
== ERROR_NO_MORE_ITEMS
||
11050 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11051 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11052 ok(!lstrcmpA(patch
, "apple") ||
11053 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11054 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11055 ok(!lstrcmpA(transforms
, "banana"),
11056 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11057 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11059 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
11060 (const BYTE
*)"whatever", 9);
11061 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11063 /* patch squashed value exists */
11065 lstrcpyA(patch
, "apple");
11066 lstrcpyA(transforms
, "banana");
11067 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11068 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11069 ok(!lstrcmpA(patch
, patchcode
),
11070 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11071 ok(!lstrcmpA(transforms
, "whatever"),
11072 "Expected \"whatever\", got \"%s\"\n", transforms
);
11073 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11075 /* lpPatchBuf is NULL */
11077 lstrcpyA(transforms
, "banana");
11078 r
= MsiEnumPatchesA(prodcode
, 0, NULL
, transforms
, &size
);
11079 ok(r
== ERROR_INVALID_PARAMETER
,
11080 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11081 ok(!lstrcmpA(transforms
, "banana"),
11082 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11083 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11085 /* lpTransformsBuf is NULL, pcchTransformsBuf is not */
11087 lstrcpyA(patch
, "apple");
11088 r
= MsiEnumPatchesA(prodcode
, 0, patch
, NULL
, &size
);
11089 ok(r
== ERROR_INVALID_PARAMETER
,
11090 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11091 ok(!lstrcmpA(patch
, "apple"),
11092 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11093 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11095 /* pcchTransformsBuf is NULL, lpTransformsBuf is not */
11096 lstrcpyA(patch
, "apple");
11097 lstrcpyA(transforms
, "banana");
11098 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, NULL
);
11099 ok(r
== ERROR_INVALID_PARAMETER
,
11100 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11101 ok(!lstrcmpA(patch
, "apple"),
11102 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11103 ok(!lstrcmpA(transforms
, "banana"),
11104 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11106 /* pcchTransformsBuf is too small */
11108 lstrcpyA(patch
, "apple");
11109 lstrcpyA(transforms
, "banana");
11110 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11111 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
11112 ok(!lstrcmpA(patch
, patchcode
),
11113 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11114 ok(!lstrcmpA(transforms
, "whate") ||
11115 broken(!lstrcmpA(transforms
, "banana")), /* Windows Installer < 3.0 */
11116 "Expected \"whate\", got \"%s\"\n", transforms
);
11117 ok(size
== 8 || size
== 16, "Expected 8 or 16, got %d\n", size
);
11119 /* increase the index */
11121 lstrcpyA(patch
, "apple");
11122 lstrcpyA(transforms
, "banana");
11123 r
= MsiEnumPatchesA(prodcode
, 1, patch
, transforms
, &size
);
11124 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11125 ok(!lstrcmpA(patch
, "apple"),
11126 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11127 ok(!lstrcmpA(transforms
, "banana"),
11128 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11129 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11131 /* increase again */
11133 lstrcpyA(patch
, "apple");
11134 lstrcpyA(transforms
, "banana");
11135 r
= MsiEnumPatchesA(prodcode
, 2, patch
, transforms
, &size
);
11136 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11137 ok(!lstrcmpA(patch
, "apple"),
11138 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11139 ok(!lstrcmpA(transforms
, "banana"),
11140 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11141 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11143 RegDeleteValueA(patches
, "Patches");
11144 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
11145 RegCloseKey(patches
);
11146 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
11147 RegCloseKey(prodkey
);
11149 /* MSIINSTALLCONTEXT_USERUNMANAGED */
11152 lstrcpyA(patch
, "apple");
11153 lstrcpyA(transforms
, "banana");
11154 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11155 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11156 "Expected ERROR_UNKNOWN_PRODUCT, 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 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
11164 lstrcatA(keypath
, prod_squashed
);
11166 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
11167 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11169 /* current user product key exists */
11171 lstrcpyA(patch
, "apple");
11172 lstrcpyA(transforms
, "banana");
11173 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11174 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11175 ok(!lstrcmpA(patch
, "apple"),
11176 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11177 ok(!lstrcmpA(transforms
, "banana"),
11178 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11179 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11181 res
= RegCreateKeyA(prodkey
, "Patches", &patches
);
11182 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11184 /* Patches key exists */
11186 lstrcpyA(patch
, "apple");
11187 lstrcpyA(transforms
, "banana");
11188 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11189 ok(r
== ERROR_NO_MORE_ITEMS
||
11190 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11191 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11192 ok(!lstrcmpA(patch
, "apple"),
11193 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11194 ok(!lstrcmpA(transforms
, "banana"),
11195 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11196 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11198 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
11199 (const BYTE
*)patch_squashed
,
11200 lstrlenA(patch_squashed
) + 1);
11201 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11203 /* Patches value exists, is not REG_MULTI_SZ */
11205 lstrcpyA(patch
, "apple");
11206 lstrcpyA(transforms
, "banana");
11207 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11208 ok(r
== ERROR_BAD_CONFIGURATION
||
11209 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11210 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11211 ok(!lstrcmpA(patch
, "apple"),
11212 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11213 ok(!lstrcmpA(transforms
, "banana"),
11214 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11215 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11217 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11218 (const BYTE
*)"a\0b\0c\0\0", 7);
11219 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11221 /* Patches value exists, is not a squashed guid */
11223 lstrcpyA(patch
, "apple");
11224 lstrcpyA(transforms
, "banana");
11225 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11226 ok(r
== ERROR_BAD_CONFIGURATION
,
11227 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11228 ok(!lstrcmpA(patch
, "apple"),
11229 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11230 ok(!lstrcmpA(transforms
, "banana"),
11231 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11232 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11234 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
11235 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11236 (const BYTE
*)patch_squashed
,
11237 lstrlenA(patch_squashed
) + 2);
11238 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11240 /* Patches value exists */
11242 lstrcpyA(patch
, "apple");
11243 lstrcpyA(transforms
, "banana");
11244 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11245 ok(r
== ERROR_NO_MORE_ITEMS
||
11246 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11247 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11248 ok(!lstrcmpA(patch
, "apple") ||
11249 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11250 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11251 ok(!lstrcmpA(transforms
, "banana"),
11252 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11253 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11255 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
11256 (const BYTE
*)"whatever", 9);
11257 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11259 /* patch code value exists */
11261 lstrcpyA(patch
, "apple");
11262 lstrcpyA(transforms
, "banana");
11263 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11264 ok(r
== ERROR_NO_MORE_ITEMS
||
11265 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11266 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11267 ok(!lstrcmpA(patch
, "apple") ||
11268 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11269 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11270 ok(!lstrcmpA(transforms
, "banana") ||
11271 broken(!lstrcmpA(transforms
, "whatever")), /* Windows Installer < 3.0 */
11272 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11273 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11275 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11276 lstrcatA(keypath
, usersid
);
11277 lstrcatA(keypath
, "\\Patches\\");
11278 lstrcatA(keypath
, patch_squashed
);
11280 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
11281 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11283 /* userdata patch key exists */
11285 lstrcpyA(patch
, "apple");
11286 lstrcpyA(transforms
, "banana");
11287 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11288 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11289 ok(!lstrcmpA(patch
, patchcode
),
11290 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11291 ok(!lstrcmpA(transforms
, "whatever"),
11292 "Expected \"whatever\", got \"%s\"\n", transforms
);
11293 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11295 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
11296 RegCloseKey(userkey
);
11297 RegDeleteValueA(patches
, patch_squashed
);
11298 RegDeleteValueA(patches
, "Patches");
11299 RegDeleteKeyA(patches
, "");
11300 RegCloseKey(patches
);
11301 RegDeleteKeyA(prodkey
, "");
11302 RegCloseKey(prodkey
);
11304 /* MSIINSTALLCONTEXT_MACHINE */
11307 lstrcpyA(patch
, "apple");
11308 lstrcpyA(transforms
, "banana");
11309 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11310 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11311 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11312 ok(!lstrcmpA(patch
, "apple"),
11313 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11314 ok(!lstrcmpA(transforms
, "banana"),
11315 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11316 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11318 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
11319 lstrcatA(keypath
, prod_squashed
);
11321 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
11322 if (res
== ERROR_ACCESS_DENIED
)
11324 skip("Not enough rights to perform tests\n");
11325 LocalFree(usersid
);
11328 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11330 /* local product key exists */
11332 lstrcpyA(patch
, "apple");
11333 lstrcpyA(transforms
, "banana");
11334 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11335 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11336 ok(!lstrcmpA(patch
, "apple"),
11337 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11338 ok(!lstrcmpA(transforms
, "banana"),
11339 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11340 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11342 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
11343 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11345 /* Patches key exists */
11347 lstrcpyA(patch
, "apple");
11348 lstrcpyA(transforms
, "banana");
11349 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11350 ok(r
== ERROR_NO_MORE_ITEMS
||
11351 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11352 "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
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
11360 (const BYTE
*)patch_squashed
,
11361 lstrlenA(patch_squashed
) + 1);
11362 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11364 /* Patches value exists, is not REG_MULTI_SZ */
11366 lstrcpyA(patch
, "apple");
11367 lstrcpyA(transforms
, "banana");
11368 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11369 ok(r
== ERROR_BAD_CONFIGURATION
||
11370 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11371 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11372 ok(!lstrcmpA(patch
, "apple"),
11373 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11374 ok(!lstrcmpA(transforms
, "banana"),
11375 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11376 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11378 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11379 (const BYTE
*)"a\0b\0c\0\0", 7);
11380 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11382 /* Patches value exists, is not a squashed guid */
11384 lstrcpyA(patch
, "apple");
11385 lstrcpyA(transforms
, "banana");
11386 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11387 ok(r
== ERROR_BAD_CONFIGURATION
,
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 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
11396 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11397 (const BYTE
*)patch_squashed
,
11398 lstrlenA(patch_squashed
) + 2);
11399 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11401 /* Patches value exists */
11403 lstrcpyA(patch
, "apple");
11404 lstrcpyA(transforms
, "banana");
11405 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11406 ok(r
== ERROR_NO_MORE_ITEMS
||
11407 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11408 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11409 ok(!lstrcmpA(patch
, "apple") ||
11410 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11411 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11412 ok(!lstrcmpA(transforms
, "banana"),
11413 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11414 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11416 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
11417 (const BYTE
*)"whatever", 9);
11418 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11420 /* patch code value exists */
11422 lstrcpyA(patch
, "apple");
11423 lstrcpyA(transforms
, "banana");
11424 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11426 ok(!lstrcmpA(patch
, patchcode
),
11427 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11428 ok(!lstrcmpA(transforms
, "whatever"),
11429 "Expected \"whatever\", got \"%s\"\n", transforms
);
11430 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11432 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11433 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
11434 lstrcatA(keypath
, prod_squashed
);
11436 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
11437 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11439 /* local UserData product key exists */
11441 lstrcpyA(patch
, "apple");
11442 lstrcpyA(transforms
, "banana");
11443 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11444 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11445 ok(!lstrcmpA(patch
, patchcode
),
11446 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11447 ok(!lstrcmpA(transforms
, "whatever"),
11448 "Expected \"whatever\", got \"%s\"\n", transforms
);
11449 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11451 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
11452 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11454 /* local UserData Patches key exists */
11456 lstrcpyA(patch
, "apple");
11457 lstrcpyA(transforms
, "banana");
11458 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11459 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11460 ok(!lstrcmpA(patch
, patchcode
),
11461 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11462 ok(!lstrcmpA(transforms
, "whatever"),
11463 "Expected \"whatever\", got \"%s\"\n", transforms
);
11464 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11466 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
11467 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11469 /* local UserData Product patch key exists */
11471 lstrcpyA(patch
, "apple");
11472 lstrcpyA(transforms
, "banana");
11473 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11474 ok(r
== ERROR_NO_MORE_ITEMS
||
11475 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11476 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11477 ok(!lstrcmpA(patch
, "apple") ||
11478 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11479 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11480 ok(!lstrcmpA(transforms
, "banana") ||
11481 broken(!lstrcmpA(transforms
, "whatever")), /* Windows Installer < 3.0 */
11482 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11483 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11485 data
= MSIPATCHSTATE_APPLIED
;
11486 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
11487 (const BYTE
*)&data
, sizeof(DWORD
));
11488 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11490 /* State value exists */
11492 lstrcpyA(patch
, "apple");
11493 lstrcpyA(transforms
, "banana");
11494 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11495 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11496 ok(!lstrcmpA(patch
, patchcode
),
11497 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11498 ok(!lstrcmpA(transforms
, "whatever"),
11499 "Expected \"whatever\", got \"%s\"\n", transforms
);
11500 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11502 /* now duplicate some of the tests for the W version */
11504 /* pcchTransformsBuf is too small */
11506 MultiByteToWideChar( CP_ACP
, 0, prodcode
, -1, prodcodeW
, MAX_PATH
);
11507 MultiByteToWideChar( CP_ACP
, 0, "apple", -1, patchW
, MAX_PATH
);
11508 MultiByteToWideChar( CP_ACP
, 0, "banana", -1, transformsW
, MAX_PATH
);
11509 r
= MsiEnumPatchesW(prodcodeW
, 0, patchW
, transformsW
, &size
);
11510 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
11511 WideCharToMultiByte( CP_ACP
, 0, patchW
, -1, patch
, MAX_PATH
, NULL
, NULL
);
11512 WideCharToMultiByte( CP_ACP
, 0, transformsW
, -1, transforms
, MAX_PATH
, NULL
, NULL
);
11513 ok(!lstrcmpA(patch
, patchcode
),
11514 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11515 ok(!lstrcmpA(transforms
, "whate") ||
11516 broken(!lstrcmpA(transforms
, "banana")), /* Windows Installer < 3.0 */
11517 "Expected \"whate\", got \"%s\"\n", transforms
);
11518 ok(size
== 8, "Expected 8, got %d\n", size
);
11520 /* patch code value exists */
11522 MultiByteToWideChar( CP_ACP
, 0, "apple", -1, patchW
, MAX_PATH
);
11523 MultiByteToWideChar( CP_ACP
, 0, "banana", -1, transformsW
, MAX_PATH
);
11524 r
= MsiEnumPatchesW(prodcodeW
, 0, patchW
, transformsW
, &size
);
11525 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11526 WideCharToMultiByte( CP_ACP
, 0, patchW
, -1, patch
, MAX_PATH
, NULL
, NULL
);
11527 WideCharToMultiByte( CP_ACP
, 0, transformsW
, -1, transforms
, MAX_PATH
, NULL
, NULL
);
11528 ok(!lstrcmpA(patch
, patchcode
),
11529 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11530 ok(!lstrcmpA(transforms
, "whatever"),
11531 "Expected \"whatever\", got \"%s\"\n", transforms
);
11532 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11534 RegDeleteValueA(patches
, patch_squashed
);
11535 RegDeleteValueA(patches
, "Patches");
11536 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
11537 RegCloseKey(patches
);
11538 RegDeleteValueA(hpatch
, "State");
11539 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
11540 RegCloseKey(hpatch
);
11541 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
11542 RegCloseKey(udpatch
);
11543 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
11544 RegCloseKey(udprod
);
11545 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
11546 RegCloseKey(prodkey
);
11547 LocalFree(usersid
);
11550 static void test_MsiGetPatchInfoEx(void)
11552 CHAR keypath
[MAX_PATH
], val
[MAX_PATH
];
11553 CHAR patchcode
[MAX_PATH
], patch_squashed
[MAX_PATH
];
11554 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
11555 HKEY prodkey
, patches
, udprod
, props
;
11556 HKEY hpatch
, udpatch
, prodpatches
;
11561 REGSAM access
= KEY_ALL_ACCESS
;
11563 if (!pMsiGetPatchInfoExA
)
11565 win_skip("MsiGetPatchInfoEx not implemented\n");
11569 create_test_guid(prodcode
, prod_squashed
);
11570 create_test_guid(patchcode
, patch_squashed
);
11571 usersid
= get_user_sid();
11574 access
|= KEY_WOW64_64KEY
;
11576 /* NULL szPatchCode */
11577 lstrcpyA(val
, "apple");
11579 r
= pMsiGetPatchInfoExA(NULL
, prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11580 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11581 ok(r
== ERROR_INVALID_PARAMETER
,
11582 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11583 ok(!lstrcmpA(val
, "apple"),
11584 "Expected val to be unchanged, got \"%s\"\n", val
);
11585 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11587 /* empty szPatchCode */
11589 lstrcpyA(val
, "apple");
11590 r
= pMsiGetPatchInfoExA("", prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11591 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11592 ok(r
== ERROR_INVALID_PARAMETER
,
11593 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11594 ok(!lstrcmpA(val
, "apple"),
11595 "Expected val to be unchanged, got \"%s\"\n", val
);
11596 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11598 /* garbage szPatchCode */
11600 lstrcpyA(val
, "apple");
11601 r
= pMsiGetPatchInfoExA("garbage", prodcode
, NULL
,
11602 MSIINSTALLCONTEXT_USERMANAGED
,
11603 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11604 ok(r
== ERROR_INVALID_PARAMETER
,
11605 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11606 ok(!lstrcmpA(val
, "apple"),
11607 "Expected val to be unchanged, got \"%s\"\n", val
);
11608 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11610 /* guid without brackets */
11612 lstrcpyA(val
, "apple");
11613 r
= pMsiGetPatchInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", prodcode
,
11614 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11615 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11616 ok(r
== ERROR_INVALID_PARAMETER
,
11617 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11618 ok(!lstrcmpA(val
, "apple"),
11619 "Expected val to be unchanged, got \"%s\"\n", val
);
11620 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11622 /* guid with brackets */
11624 lstrcpyA(val
, "apple");
11625 r
= pMsiGetPatchInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", prodcode
,
11626 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11627 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11628 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11629 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11630 ok(!lstrcmpA(val
, "apple"),
11631 "Expected val to be unchanged, got \"%s\"\n", val
);
11632 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11634 /* same length as guid, but random */
11636 lstrcpyA(val
, "apple");
11637 r
= pMsiGetPatchInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", prodcode
,
11638 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11639 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11640 ok(r
== ERROR_INVALID_PARAMETER
,
11641 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11642 ok(!lstrcmpA(val
, "apple"),
11643 "Expected val to be unchanged, got \"%s\"\n", val
);
11644 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11646 /* NULL szProductCode */
11647 lstrcpyA(val
, "apple");
11649 r
= pMsiGetPatchInfoExA(patchcode
, NULL
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11650 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11651 ok(r
== ERROR_INVALID_PARAMETER
,
11652 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11653 ok(!lstrcmpA(val
, "apple"),
11654 "Expected val to be unchanged, got \"%s\"\n", val
);
11655 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11657 /* empty szProductCode */
11659 lstrcpyA(val
, "apple");
11660 r
= pMsiGetPatchInfoExA(patchcode
, "", NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11661 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11662 ok(r
== ERROR_INVALID_PARAMETER
,
11663 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11664 ok(!lstrcmpA(val
, "apple"),
11665 "Expected val to be unchanged, got \"%s\"\n", val
);
11666 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11668 /* garbage szProductCode */
11670 lstrcpyA(val
, "apple");
11671 r
= pMsiGetPatchInfoExA(patchcode
, "garbage", NULL
,
11672 MSIINSTALLCONTEXT_USERMANAGED
,
11673 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11674 ok(r
== ERROR_INVALID_PARAMETER
,
11675 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11676 ok(!lstrcmpA(val
, "apple"),
11677 "Expected val to be unchanged, got \"%s\"\n", val
);
11678 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11680 /* guid without brackets */
11682 lstrcpyA(val
, "apple");
11683 r
= pMsiGetPatchInfoExA(patchcode
, "6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
11684 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11685 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11686 ok(r
== ERROR_INVALID_PARAMETER
,
11687 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11688 ok(!lstrcmpA(val
, "apple"),
11689 "Expected val to be unchanged, got \"%s\"\n", val
);
11690 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11692 /* guid with brackets */
11694 lstrcpyA(val
, "apple");
11695 r
= pMsiGetPatchInfoExA(patchcode
, "{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
11696 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11697 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11698 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11699 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11700 ok(!lstrcmpA(val
, "apple"),
11701 "Expected val to be unchanged, got \"%s\"\n", val
);
11702 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11704 /* same length as guid, but random */
11706 lstrcpyA(val
, "apple");
11707 r
= pMsiGetPatchInfoExA(patchcode
, "A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
11708 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11709 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11710 ok(r
== ERROR_INVALID_PARAMETER
,
11711 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11712 ok(!lstrcmpA(val
, "apple"),
11713 "Expected val to be unchanged, got \"%s\"\n", val
);
11714 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11716 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERMANAGED */
11718 lstrcpyA(val
, "apple");
11719 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, "S-1-5-18",
11720 MSIINSTALLCONTEXT_USERMANAGED
,
11721 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11722 ok(r
== ERROR_INVALID_PARAMETER
,
11723 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11724 ok(!lstrcmpA(val
, "apple"),
11725 "Expected val to be unchanged, got \"%s\"\n", val
);
11726 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11728 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERUNMANAGED */
11730 lstrcpyA(val
, "apple");
11731 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, "S-1-5-18",
11732 MSIINSTALLCONTEXT_USERUNMANAGED
,
11733 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11734 ok(r
== ERROR_INVALID_PARAMETER
,
11735 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11736 ok(!lstrcmpA(val
, "apple"),
11737 "Expected val to be unchanged, got \"%s\"\n", val
);
11738 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11740 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_MACHINE */
11742 lstrcpyA(val
, "apple");
11743 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, "S-1-5-18",
11744 MSIINSTALLCONTEXT_MACHINE
,
11745 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11746 ok(r
== ERROR_INVALID_PARAMETER
,
11747 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11748 ok(!lstrcmpA(val
, "apple"),
11749 "Expected val to be unchanged, got \"%s\"\n", val
);
11750 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11752 /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
11754 lstrcpyA(val
, "apple");
11755 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11756 MSIINSTALLCONTEXT_MACHINE
,
11757 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11758 ok(r
== ERROR_INVALID_PARAMETER
,
11759 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11760 ok(!lstrcmpA(val
, "apple"),
11761 "Expected val to be unchanged, got \"%s\"\n", val
);
11762 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11764 /* dwContext is out of range */
11766 lstrcpyA(val
, "apple");
11767 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11768 MSIINSTALLCONTEXT_NONE
,
11769 INSTALLPROPERTY_LOCALPACKAGE
, 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 /* dwContext is out of range */
11778 lstrcpyA(val
, "apple");
11779 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11780 MSIINSTALLCONTEXT_ALL
,
11781 INSTALLPROPERTY_LOCALPACKAGE
, 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 /* dwContext is invalid */
11790 lstrcpyA(val
, "apple");
11791 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
, 3,
11792 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11793 ok(r
== ERROR_INVALID_PARAMETER
,
11794 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11795 ok(!lstrcmpA(val
, "apple"),
11796 "Expected val to be unchanged, got \"%s\"\n", val
);
11797 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11799 /* MSIINSTALLCONTEXT_USERMANAGED */
11802 lstrcpyA(val
, "apple");
11803 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11804 MSIINSTALLCONTEXT_USERMANAGED
,
11805 INSTALLPROPERTY_LOCALPACKAGE
, 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 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11813 lstrcatA(keypath
, usersid
);
11814 lstrcatA(keypath
, "\\Products\\");
11815 lstrcatA(keypath
, prod_squashed
);
11817 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
11818 if (res
== ERROR_ACCESS_DENIED
)
11820 skip("Not enough rights to perform tests\n");
11821 LocalFree(usersid
);
11824 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11826 /* local UserData product key exists */
11828 lstrcpyA(val
, "apple");
11829 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11830 MSIINSTALLCONTEXT_USERMANAGED
,
11831 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11832 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11833 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11834 ok(!lstrcmpA(val
, "apple"),
11835 "Expected val to be unchanged, got \"%s\"\n", val
);
11836 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11838 res
= RegCreateKeyExA(udprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
11839 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11841 /* InstallProperties key exists */
11843 lstrcpyA(val
, "apple");
11844 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11845 MSIINSTALLCONTEXT_USERMANAGED
,
11846 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11847 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11848 ok(!lstrcmpA(val
, "apple"),
11849 "Expected val to be unchanged, got \"%s\"\n", val
);
11850 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11852 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
11853 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11855 /* Patches key exists */
11857 lstrcpyA(val
, "apple");
11858 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11859 MSIINSTALLCONTEXT_USERMANAGED
,
11860 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11861 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11862 ok(!lstrcmpA(val
, "apple"),
11863 "Expected val to be unchanged, got \"%s\"\n", val
);
11864 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11866 res
= RegCreateKeyExA(patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
11867 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11869 /* Patches key exists */
11871 lstrcpyA(val
, "apple");
11872 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11873 MSIINSTALLCONTEXT_USERMANAGED
,
11874 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11875 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11876 ok(!lstrcmpA(val
, "apple"),
11877 "Expected val to be unchanged, got \"%s\"\n", val
);
11878 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11880 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
11881 lstrcatA(keypath
, usersid
);
11882 lstrcatA(keypath
, "\\Installer\\Products\\");
11883 lstrcatA(keypath
, prod_squashed
);
11885 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
11886 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11888 /* managed product key exists */
11890 lstrcpyA(val
, "apple");
11891 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11892 MSIINSTALLCONTEXT_USERMANAGED
,
11893 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11894 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11895 ok(!lstrcmpA(val
, "apple"),
11896 "Expected val to be unchanged, got \"%s\"\n", val
);
11897 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11899 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &prodpatches
, NULL
);
11900 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11902 /* Patches key exists */
11904 lstrcpyA(val
, "apple");
11905 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11906 MSIINSTALLCONTEXT_USERMANAGED
,
11907 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11908 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11909 ok(!lstrcmpA(val
, "apple"),
11910 "Expected val to be unchanged, got \"%s\"\n", val
);
11911 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11913 res
= RegSetValueExA(prodpatches
, patch_squashed
, 0, REG_SZ
,
11914 (const BYTE
*)"transforms", 11);
11915 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11917 /* specific patch value exists */
11919 lstrcpyA(val
, "apple");
11920 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11921 MSIINSTALLCONTEXT_USERMANAGED
,
11922 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11923 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11924 ok(!lstrcmpA(val
, "apple"),
11925 "Expected val to be unchanged, got \"%s\"\n", val
);
11926 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11928 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11929 lstrcatA(keypath
, usersid
);
11930 lstrcatA(keypath
, "\\Patches\\");
11931 lstrcatA(keypath
, patch_squashed
);
11933 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
11934 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11936 /* UserData Patches key exists */
11938 lstrcpyA(val
, "apple");
11939 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11940 MSIINSTALLCONTEXT_USERMANAGED
,
11941 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11942 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11943 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
11944 ok(size
== 0, "Expected 0, got %d\n", size
);
11946 res
= RegSetValueExA(udpatch
, "ManagedLocalPackage", 0, REG_SZ
,
11947 (const BYTE
*)"pack", 5);
11948 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11950 /* ManagedLocalPatch value exists */
11952 lstrcpyA(val
, "apple");
11953 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11954 MSIINSTALLCONTEXT_USERMANAGED
,
11955 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
11956 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11957 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
11958 ok(size
== 4, "Expected 4, got %d\n", size
);
11961 lstrcpyA(val
, "apple");
11962 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11963 MSIINSTALLCONTEXT_USERMANAGED
,
11964 INSTALLPROPERTY_TRANSFORMS
, val
, &size
);
11965 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11966 ok(!lstrcmpA(val
, "transforms"), "Expected \"transforms\", got \"%s\"\n", val
);
11967 ok(size
== 10, "Expected 10, got %d\n", size
);
11969 res
= RegSetValueExA(hpatch
, "Installed", 0, REG_SZ
,
11970 (const BYTE
*)"mydate", 7);
11971 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11973 /* Installed value exists */
11975 lstrcpyA(val
, "apple");
11976 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11977 MSIINSTALLCONTEXT_USERMANAGED
,
11978 INSTALLPROPERTY_INSTALLDATE
, val
, &size
);
11979 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11980 ok(!lstrcmpA(val
, "mydate"), "Expected \"mydate\", got \"%s\"\n", val
);
11981 ok(size
== 6, "Expected 6, got %d\n", size
);
11983 res
= RegSetValueExA(hpatch
, "Uninstallable", 0, REG_SZ
,
11984 (const BYTE
*)"yes", 4);
11985 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11987 /* Uninstallable value exists */
11989 lstrcpyA(val
, "apple");
11990 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11991 MSIINSTALLCONTEXT_USERMANAGED
,
11992 INSTALLPROPERTY_UNINSTALLABLE
, val
, &size
);
11993 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11994 ok(!lstrcmpA(val
, "yes"), "Expected \"yes\", got \"%s\"\n", val
);
11995 ok(size
== 3, "Expected 3, got %d\n", size
);
11997 res
= RegSetValueExA(hpatch
, "State", 0, REG_SZ
,
11998 (const BYTE
*)"good", 5);
11999 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12001 /* State value exists */
12003 lstrcpyA(val
, "apple");
12004 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12005 MSIINSTALLCONTEXT_USERMANAGED
,
12006 INSTALLPROPERTY_PATCHSTATE
, val
, &size
);
12007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12008 ok(!lstrcmpA(val
, "good"), "Expected \"good\", got \"%s\"\n", val
);
12009 ok(size
== 4, "Expected 4, got %d\n", size
);
12012 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
12013 (const BYTE
*)&size
, sizeof(DWORD
));
12014 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12016 /* State value exists */
12018 lstrcpyA(val
, "apple");
12019 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12020 MSIINSTALLCONTEXT_USERMANAGED
,
12021 INSTALLPROPERTY_PATCHSTATE
, val
, &size
);
12022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12023 todo_wine
ok(!lstrcmpA(val
, "1"), "Expected \"1\", got \"%s\"\n", val
);
12024 ok(size
== 1, "Expected 1, got %d\n", size
);
12026 res
= RegSetValueExA(hpatch
, "DisplayName", 0, REG_SZ
,
12027 (const BYTE
*)"display", 8);
12028 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12030 /* DisplayName value exists */
12032 lstrcpyA(val
, "apple");
12033 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12034 MSIINSTALLCONTEXT_USERMANAGED
,
12035 INSTALLPROPERTY_DISPLAYNAME
, val
, &size
);
12036 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12037 ok(!lstrcmpA(val
, "display"), "Expected \"display\", got \"%s\"\n", val
);
12038 ok(size
== 7, "Expected 7, got %d\n", size
);
12040 res
= RegSetValueExA(hpatch
, "MoreInfoURL", 0, REG_SZ
,
12041 (const BYTE
*)"moreinfo", 9);
12042 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12044 /* MoreInfoURL value exists */
12046 lstrcpyA(val
, "apple");
12047 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12048 MSIINSTALLCONTEXT_USERMANAGED
,
12049 INSTALLPROPERTY_MOREINFOURL
, val
, &size
);
12050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12051 ok(!lstrcmpA(val
, "moreinfo"), "Expected \"moreinfo\", got \"%s\"\n", val
);
12052 ok(size
== 8, "Expected 8, got %d\n", size
);
12054 /* szProperty is invalid */
12056 lstrcpyA(val
, "apple");
12057 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12058 MSIINSTALLCONTEXT_USERMANAGED
,
12059 "IDontExist", val
, &size
);
12060 ok(r
== ERROR_UNKNOWN_PROPERTY
,
12061 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
12062 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12063 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12065 /* lpValue is NULL, while pcchValue is non-NULL */
12067 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12068 MSIINSTALLCONTEXT_USERMANAGED
,
12069 INSTALLPROPERTY_MOREINFOURL
, NULL
, &size
);
12070 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12071 ok(size
== 16, "Expected 16, got %d\n", size
);
12073 /* pcchValue is NULL, while lpValue is non-NULL */
12074 lstrcpyA(val
, "apple");
12075 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12076 MSIINSTALLCONTEXT_USERMANAGED
,
12077 INSTALLPROPERTY_MOREINFOURL
, val
, NULL
);
12078 ok(r
== ERROR_INVALID_PARAMETER
,
12079 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
12080 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12082 /* both lpValue and pcchValue are NULL */
12083 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12084 MSIINSTALLCONTEXT_USERMANAGED
,
12085 INSTALLPROPERTY_MOREINFOURL
, NULL
, NULL
);
12086 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12088 /* pcchValue doesn't have enough room for NULL terminator */
12090 lstrcpyA(val
, "apple");
12091 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12092 MSIINSTALLCONTEXT_USERMANAGED
,
12093 INSTALLPROPERTY_MOREINFOURL
, val
, &size
);
12094 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
12095 ok(!lstrcmpA(val
, "moreinf"),
12096 "Expected \"moreinf\", got \"%s\"\n", val
);
12097 ok(size
== 16, "Expected 16, got %d\n", size
);
12099 /* pcchValue has exactly enough room for NULL terminator */
12101 lstrcpyA(val
, "apple");
12102 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12103 MSIINSTALLCONTEXT_USERMANAGED
,
12104 INSTALLPROPERTY_MOREINFOURL
, val
, &size
);
12105 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12106 ok(!lstrcmpA(val
, "moreinfo"),
12107 "Expected \"moreinfo\", got \"%s\"\n", val
);
12108 ok(size
== 8, "Expected 8, got %d\n", size
);
12110 /* pcchValue is too small, lpValue is NULL */
12112 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12113 MSIINSTALLCONTEXT_USERMANAGED
,
12114 INSTALLPROPERTY_MOREINFOURL
, NULL
, &size
);
12115 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12116 ok(size
== 16, "Expected 16, got %d\n", size
);
12118 RegDeleteValueA(prodpatches
, patch_squashed
);
12119 delete_key(prodpatches
, "", access
& KEY_WOW64_64KEY
);
12120 RegCloseKey(prodpatches
);
12121 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
12122 RegCloseKey(prodkey
);
12124 /* UserData is sufficient for all properties
12125 * except INSTALLPROPERTY_TRANSFORMS
12128 lstrcpyA(val
, "apple");
12129 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12130 MSIINSTALLCONTEXT_USERMANAGED
,
12131 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12132 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12133 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12134 ok(size
== 4, "Expected 4, got %d\n", size
);
12136 /* UserData is sufficient for all properties
12137 * except INSTALLPROPERTY_TRANSFORMS
12140 lstrcpyA(val
, "apple");
12141 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12142 MSIINSTALLCONTEXT_USERMANAGED
,
12143 INSTALLPROPERTY_TRANSFORMS
, val
, &size
);
12144 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12145 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12146 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12148 RegDeleteValueA(hpatch
, "MoreInfoURL");
12149 RegDeleteValueA(hpatch
, "Display");
12150 RegDeleteValueA(hpatch
, "State");
12151 RegDeleteValueA(hpatch
, "Uninstallable");
12152 RegDeleteValueA(hpatch
, "Installed");
12153 RegDeleteValueA(udpatch
, "ManagedLocalPackage");
12154 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
12155 RegCloseKey(udpatch
);
12156 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
12157 RegCloseKey(hpatch
);
12158 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
12159 RegCloseKey(patches
);
12160 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
12161 RegCloseKey(props
);
12162 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
12163 RegCloseKey(udprod
);
12165 /* MSIINSTALLCONTEXT_USERUNMANAGED */
12168 lstrcpyA(val
, "apple");
12169 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12170 MSIINSTALLCONTEXT_USERUNMANAGED
,
12171 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12172 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12173 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12174 ok(!lstrcmpA(val
, "apple"),
12175 "Expected val to be unchanged, got \"%s\"\n", val
);
12176 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12178 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12179 lstrcatA(keypath
, usersid
);
12180 lstrcatA(keypath
, "\\Products\\");
12181 lstrcatA(keypath
, prod_squashed
);
12183 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
12184 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12186 /* local UserData product key exists */
12188 lstrcpyA(val
, "apple");
12189 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12190 MSIINSTALLCONTEXT_USERUNMANAGED
,
12191 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12192 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12193 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12194 ok(!lstrcmpA(val
, "apple"),
12195 "Expected val to be unchanged, got \"%s\"\n", val
);
12196 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12198 res
= RegCreateKeyExA(udprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
12199 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12201 /* InstallProperties key exists */
12203 lstrcpyA(val
, "apple");
12204 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12205 MSIINSTALLCONTEXT_USERUNMANAGED
,
12206 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12207 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12208 ok(!lstrcmpA(val
, "apple"),
12209 "Expected val to be unchanged, got \"%s\"\n", val
);
12210 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12212 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
12213 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12215 /* Patches key exists */
12217 lstrcpyA(val
, "apple");
12218 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12219 MSIINSTALLCONTEXT_USERUNMANAGED
,
12220 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12221 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12222 ok(!lstrcmpA(val
, "apple"),
12223 "Expected val to be unchanged, got \"%s\"\n", val
);
12224 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12226 res
= RegCreateKeyExA(patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
12227 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12229 /* Patches key exists */
12231 lstrcpyA(val
, "apple");
12232 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12233 MSIINSTALLCONTEXT_USERUNMANAGED
,
12234 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12235 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12236 ok(!lstrcmpA(val
, "apple"),
12237 "Expected val to be unchanged, got \"%s\"\n", val
);
12238 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12240 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
12241 lstrcatA(keypath
, prod_squashed
);
12243 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
12244 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12246 /* current user product key exists */
12248 lstrcpyA(val
, "apple");
12249 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12250 MSIINSTALLCONTEXT_USERUNMANAGED
,
12251 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12252 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12253 ok(!lstrcmpA(val
, "apple"),
12254 "Expected val to be unchanged, got \"%s\"\n", val
);
12255 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12257 res
= RegCreateKeyA(prodkey
, "Patches", &prodpatches
);
12258 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12260 /* Patches key exists */
12262 lstrcpyA(val
, "apple");
12263 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12264 MSIINSTALLCONTEXT_USERUNMANAGED
,
12265 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12266 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12267 ok(!lstrcmpA(val
, "apple"),
12268 "Expected val to be unchanged, got \"%s\"\n", val
);
12269 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12271 res
= RegSetValueExA(prodpatches
, patch_squashed
, 0, REG_SZ
,
12272 (const BYTE
*)"transforms", 11);
12273 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12275 /* specific patch value exists */
12277 lstrcpyA(val
, "apple");
12278 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12279 MSIINSTALLCONTEXT_USERUNMANAGED
,
12280 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12281 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12282 ok(!lstrcmpA(val
, "apple"),
12283 "Expected val to be unchanged, got \"%s\"\n", val
);
12284 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12286 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12287 lstrcatA(keypath
, usersid
);
12288 lstrcatA(keypath
, "\\Patches\\");
12289 lstrcatA(keypath
, patch_squashed
);
12291 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
12292 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12294 /* UserData Patches key exists */
12296 lstrcpyA(val
, "apple");
12297 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12298 MSIINSTALLCONTEXT_USERUNMANAGED
,
12299 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12300 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12301 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
12302 ok(size
== 0, "Expected 0, got %d\n", size
);
12304 res
= RegSetValueExA(udpatch
, "LocalPackage", 0, REG_SZ
,
12305 (const BYTE
*)"pack", 5);
12306 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12308 /* LocalPatch value exists */
12310 lstrcpyA(val
, "apple");
12311 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12312 MSIINSTALLCONTEXT_USERUNMANAGED
,
12313 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12314 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12315 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12316 ok(size
== 4, "Expected 4, got %d\n", size
);
12319 lstrcpyA(val
, "apple");
12320 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12321 MSIINSTALLCONTEXT_USERUNMANAGED
,
12322 INSTALLPROPERTY_TRANSFORMS
, val
, &size
);
12323 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12324 ok(!lstrcmpA(val
, "transforms"), "Expected \"transforms\", got \"%s\"\n", val
);
12325 ok(size
== 10, "Expected 10, got %d\n", size
);
12327 RegDeleteValueA(prodpatches
, patch_squashed
);
12328 delete_key(prodpatches
, "", access
& KEY_WOW64_64KEY
);
12329 RegCloseKey(prodpatches
);
12330 RegDeleteKeyA(prodkey
, "");
12331 RegCloseKey(prodkey
);
12333 /* UserData is sufficient for all properties
12334 * except INSTALLPROPERTY_TRANSFORMS
12337 lstrcpyA(val
, "apple");
12338 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12339 MSIINSTALLCONTEXT_USERUNMANAGED
,
12340 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12341 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12342 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12343 ok(size
== 4, "Expected 4, got %d\n", size
);
12345 /* UserData is sufficient for all properties
12346 * except INSTALLPROPERTY_TRANSFORMS
12349 lstrcpyA(val
, "apple");
12350 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12351 MSIINSTALLCONTEXT_USERUNMANAGED
,
12352 INSTALLPROPERTY_TRANSFORMS
, val
, &size
);
12353 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12354 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12355 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12357 RegDeleteValueA(udpatch
, "LocalPackage");
12358 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
12359 RegCloseKey(udpatch
);
12360 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
12361 RegCloseKey(hpatch
);
12362 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
12363 RegCloseKey(patches
);
12364 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
12365 RegCloseKey(props
);
12366 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
12367 RegCloseKey(udprod
);
12369 /* MSIINSTALLCONTEXT_MACHINE */
12372 lstrcpyA(val
, "apple");
12373 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12374 MSIINSTALLCONTEXT_MACHINE
,
12375 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12376 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12377 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12378 ok(!lstrcmpA(val
, "apple"),
12379 "Expected val to be unchanged, got \"%s\"\n", val
);
12380 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12382 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12383 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Products\\");
12384 lstrcatA(keypath
, prod_squashed
);
12386 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
12387 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12389 /* local UserData product key exists */
12391 lstrcpyA(val
, "apple");
12392 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12393 MSIINSTALLCONTEXT_MACHINE
,
12394 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12395 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12396 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12397 ok(!lstrcmpA(val
, "apple"),
12398 "Expected val to be unchanged, got \"%s\"\n", val
);
12399 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12401 res
= RegCreateKeyExA(udprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
12402 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12404 /* InstallProperties key exists */
12406 lstrcpyA(val
, "apple");
12407 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12408 MSIINSTALLCONTEXT_MACHINE
,
12409 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12410 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12411 ok(!lstrcmpA(val
, "apple"),
12412 "Expected val to be unchanged, got \"%s\"\n", val
);
12413 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12415 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
12416 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12418 /* Patches key exists */
12420 lstrcpyA(val
, "apple");
12421 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12422 MSIINSTALLCONTEXT_MACHINE
,
12423 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12424 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12425 ok(!lstrcmpA(val
, "apple"),
12426 "Expected val to be unchanged, got \"%s\"\n", val
);
12427 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12429 res
= RegCreateKeyExA(patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
12430 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12432 /* Patches key exists */
12434 lstrcpyA(val
, "apple");
12435 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12436 MSIINSTALLCONTEXT_MACHINE
,
12437 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12438 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12439 ok(!lstrcmpA(val
, "apple"),
12440 "Expected val to be unchanged, got \"%s\"\n", val
);
12441 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12443 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
12444 lstrcatA(keypath
, prod_squashed
);
12446 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
12447 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12449 /* local product key exists */
12451 lstrcpyA(val
, "apple");
12452 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12453 MSIINSTALLCONTEXT_MACHINE
,
12454 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12455 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12456 ok(!lstrcmpA(val
, "apple"),
12457 "Expected val to be unchanged, got \"%s\"\n", val
);
12458 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12460 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &prodpatches
, NULL
);
12461 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12463 /* Patches key exists */
12465 lstrcpyA(val
, "apple");
12466 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12467 MSIINSTALLCONTEXT_MACHINE
,
12468 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12469 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12470 ok(!lstrcmpA(val
, "apple"),
12471 "Expected val to be unchanged, got \"%s\"\n", val
);
12472 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12474 res
= RegSetValueExA(prodpatches
, patch_squashed
, 0, REG_SZ
,
12475 (const BYTE
*)"transforms", 11);
12476 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12478 /* specific patch value exists */
12480 lstrcpyA(val
, "apple");
12481 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12482 MSIINSTALLCONTEXT_MACHINE
,
12483 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12484 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12485 ok(!lstrcmpA(val
, "apple"),
12486 "Expected val to be unchanged, got \"%s\"\n", val
);
12487 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12489 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12490 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Patches\\");
12491 lstrcatA(keypath
, patch_squashed
);
12493 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
12494 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12496 /* UserData Patches key exists */
12498 lstrcpyA(val
, "apple");
12499 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12500 MSIINSTALLCONTEXT_MACHINE
,
12501 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12502 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12503 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
12504 ok(size
== 0, "Expected 0, got %d\n", size
);
12506 res
= RegSetValueExA(udpatch
, "LocalPackage", 0, REG_SZ
,
12507 (const BYTE
*)"pack", 5);
12508 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12510 /* LocalPatch value exists */
12512 lstrcpyA(val
, "apple");
12513 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12514 MSIINSTALLCONTEXT_MACHINE
,
12515 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12516 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12517 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12518 ok(size
== 4, "Expected 4, got %d\n", size
);
12521 lstrcpyA(val
, "apple");
12522 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12523 MSIINSTALLCONTEXT_MACHINE
,
12524 INSTALLPROPERTY_TRANSFORMS
, val
, &size
);
12525 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12526 ok(!lstrcmpA(val
, "transforms"), "Expected \"transforms\", got \"%s\"\n", val
);
12527 ok(size
== 10, "Expected 10, got %d\n", size
);
12529 RegDeleteValueA(prodpatches
, patch_squashed
);
12530 delete_key(prodpatches
, "", access
& KEY_WOW64_64KEY
);
12531 RegCloseKey(prodpatches
);
12532 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
12533 RegCloseKey(prodkey
);
12535 /* UserData is sufficient for all properties
12536 * except INSTALLPROPERTY_TRANSFORMS
12539 lstrcpyA(val
, "apple");
12540 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12541 MSIINSTALLCONTEXT_MACHINE
,
12542 INSTALLPROPERTY_LOCALPACKAGE
, val
, &size
);
12543 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12544 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12545 ok(size
== 4, "Expected 4, got %d\n", size
);
12547 /* UserData is sufficient for all properties
12548 * except INSTALLPROPERTY_TRANSFORMS
12551 lstrcpyA(val
, "apple");
12552 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12553 MSIINSTALLCONTEXT_MACHINE
,
12554 INSTALLPROPERTY_TRANSFORMS
, val
, &size
);
12555 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12556 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12557 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12559 RegDeleteValueA(udpatch
, "LocalPackage");
12560 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
12561 RegCloseKey(udpatch
);
12562 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
12563 RegCloseKey(hpatch
);
12564 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
12565 RegCloseKey(patches
);
12566 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
12567 RegCloseKey(props
);
12568 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
12569 RegCloseKey(udprod
);
12570 LocalFree(usersid
);
12573 static void test_MsiGetPatchInfo(void)
12576 char prod_code
[MAX_PATH
], prod_squashed
[MAX_PATH
], val
[MAX_PATH
];
12577 char patch_code
[MAX_PATH
], patch_squashed
[MAX_PATH
], keypath
[MAX_PATH
];
12578 WCHAR valW
[MAX_PATH
], patch_codeW
[MAX_PATH
];
12579 HKEY hkey_product
, hkey_patch
, hkey_patches
, hkey_udprops
, hkey_udproduct
;
12580 HKEY hkey_udpatch
, hkey_udpatches
, hkey_udproductpatches
, hkey_udproductpatch
;
12583 REGSAM access
= KEY_ALL_ACCESS
;
12585 create_test_guid(patch_code
, patch_squashed
);
12586 create_test_guid(prod_code
, prod_squashed
);
12587 MultiByteToWideChar(CP_ACP
, 0, patch_code
, -1, patch_codeW
, MAX_PATH
);
12590 access
|= KEY_WOW64_64KEY
;
12592 r
= MsiGetPatchInfoA(NULL
, NULL
, NULL
, NULL
);
12593 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12595 r
= MsiGetPatchInfoA(patch_code
, NULL
, NULL
, NULL
);
12596 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12598 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, NULL
, NULL
);
12599 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
12602 r
= MsiGetPatchInfoA(patch_code
, NULL
, NULL
, &size
);
12603 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12605 r
= MsiGetPatchInfoA(patch_code
, "", NULL
, &size
);
12606 ok(r
== ERROR_UNKNOWN_PROPERTY
, "expected ERROR_UNKNOWN_PROPERTY, got %u\n", r
);
12608 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
12609 lstrcatA(keypath
, prod_squashed
);
12611 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &hkey_product
, NULL
);
12612 if (res
== ERROR_ACCESS_DENIED
)
12614 skip("Not enough rights to perform tests\n");
12617 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12619 /* product key exists */
12621 lstrcpyA(val
, "apple");
12622 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12623 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12624 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged, got \"%s\"\n", val
);
12625 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12627 res
= RegCreateKeyExA(hkey_product
, "Patches", 0, NULL
, 0, access
, NULL
, &hkey_patches
, NULL
);
12628 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12630 /* patches key exists */
12632 lstrcpyA(val
, "apple");
12633 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12634 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12635 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12636 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12638 res
= RegCreateKeyExA(hkey_patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hkey_patch
, NULL
);
12639 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12641 /* patch key exists */
12643 lstrcpyA(val
, "apple");
12644 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12645 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12646 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12647 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12649 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12650 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Products\\");
12651 lstrcatA(keypath
, prod_squashed
);
12653 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &hkey_udproduct
, NULL
);
12654 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
12656 /* UserData product key exists */
12658 lstrcpyA(val
, "apple");
12659 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12660 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12661 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12662 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12664 res
= RegCreateKeyExA(hkey_udproduct
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &hkey_udprops
, NULL
);
12665 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12667 /* InstallProperties key exists */
12669 lstrcpyA(val
, "apple");
12670 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12671 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12672 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged, got \"%s\"\n", val
);
12673 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12675 res
= RegCreateKeyExA(hkey_udproduct
, "Patches", 0, NULL
, 0, access
, NULL
, &hkey_udpatches
, NULL
);
12676 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12678 /* UserData Patches key exists */
12680 lstrcpyA(val
, "apple");
12681 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12682 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12683 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12684 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12686 res
= RegCreateKeyExA(hkey_udproduct
, "Patches", 0, NULL
, 0, access
, NULL
, &hkey_udproductpatches
, NULL
);
12687 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12689 res
= RegCreateKeyExA(hkey_udproductpatches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hkey_udproductpatch
, NULL
);
12690 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12692 /* UserData product patch key exists */
12694 lstrcpyA(val
, "apple");
12695 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12696 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12697 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12698 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12700 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12701 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Patches\\");
12702 lstrcatA(keypath
, patch_squashed
);
12704 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &hkey_udpatch
, NULL
);
12705 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12707 res
= RegSetValueExA(hkey_udpatch
, "LocalPackage", 0, REG_SZ
, (const BYTE
*)"c:\\test.msp", 12);
12708 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12710 /* UserData Patch key exists */
12712 lstrcpyA(val
, "apple");
12713 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12714 ok(r
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", r
);
12715 ok(!lstrcmpA(val
, "apple"), "expected \"apple\", got \"%s\"\n", val
);
12716 ok(size
== 11, "expected 11 got %u\n", size
);
12719 lstrcpyA(val
, "apple");
12720 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12721 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %u\n", r
);
12722 ok(!lstrcmpA(val
, "c:\\test.msp"), "expected \"c:\\test.msp\", got \"%s\"\n", val
);
12723 ok(size
== 11, "expected 11 got %u\n", size
);
12727 r
= MsiGetPatchInfoW(patch_codeW
, INSTALLPROPERTY_LOCALPACKAGEW
, valW
, &size
);
12728 ok(r
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", r
);
12729 ok(!valW
[0], "expected 0 got %u\n", valW
[0]);
12730 ok(size
== 11, "expected 11 got %u\n", size
);
12734 r
= MsiGetPatchInfoW(patch_codeW
, INSTALLPROPERTY_LOCALPACKAGEW
, valW
, &size
);
12735 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %u\n", r
);
12736 ok(valW
[0], "expected > 0 got %u\n", valW
[0]);
12737 ok(size
== 11, "expected 11 got %u\n", size
);
12739 delete_key(hkey_udproductpatch
, "", access
& KEY_WOW64_64KEY
);
12740 RegCloseKey(hkey_udproductpatch
);
12741 delete_key(hkey_udproductpatches
, "", access
& KEY_WOW64_64KEY
);
12742 RegCloseKey(hkey_udproductpatches
);
12743 delete_key(hkey_udpatch
, "", access
& KEY_WOW64_64KEY
);
12744 RegCloseKey(hkey_udpatch
);
12745 delete_key(hkey_patches
, "", access
& KEY_WOW64_64KEY
);
12746 RegCloseKey(hkey_patches
);
12747 delete_key(hkey_product
, "", access
& KEY_WOW64_64KEY
);
12748 RegCloseKey(hkey_product
);
12749 delete_key(hkey_patch
, "", access
& KEY_WOW64_64KEY
);
12750 RegCloseKey(hkey_patch
);
12751 delete_key(hkey_udpatches
, "", access
& KEY_WOW64_64KEY
);
12752 RegCloseKey(hkey_udpatches
);
12753 delete_key(hkey_udprops
, "", access
& KEY_WOW64_64KEY
);
12754 RegCloseKey(hkey_udprops
);
12755 delete_key(hkey_udproduct
, "", access
& KEY_WOW64_64KEY
);
12756 RegCloseKey(hkey_udproduct
);
12759 static void test_MsiEnumProducts(void)
12762 int found1
, found2
, found3
;
12764 char product1
[39], product2
[39], product3
[39], guid
[39];
12765 char product_squashed1
[33], product_squashed2
[33], product_squashed3
[33];
12766 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
], keypath3
[MAX_PATH
];
12768 HKEY key1
, key2
, key3
;
12769 REGSAM access
= KEY_ALL_ACCESS
;
12771 create_test_guid(product1
, product_squashed1
);
12772 create_test_guid(product2
, product_squashed2
);
12773 create_test_guid(product3
, product_squashed3
);
12774 usersid
= get_user_sid();
12777 access
|= KEY_WOW64_64KEY
;
12779 strcpy(keypath1
, "Software\\Classes\\Installer\\Products\\");
12780 strcat(keypath1
, product_squashed1
);
12782 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
12783 if (r
== ERROR_ACCESS_DENIED
)
12785 skip("Not enough rights to perform tests\n");
12786 LocalFree(usersid
);
12789 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12791 strcpy(keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
12792 strcat(keypath2
, usersid
);
12793 strcat(keypath2
, "\\Installer\\Products\\");
12794 strcat(keypath2
, product_squashed2
);
12796 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
12797 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12799 strcpy(keypath3
, "Software\\Microsoft\\Installer\\Products\\");
12800 strcat(keypath3
, product_squashed3
);
12802 r
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath3
, &key3
);
12803 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12806 r
= MsiEnumProductsA(index
, guid
);
12807 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
12809 r
= MsiEnumProductsA(index
, NULL
);
12810 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12813 r
= MsiEnumProductsA(index
, guid
);
12814 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12817 r
= MsiEnumProductsA(index
, guid
);
12818 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
12820 found1
= found2
= found3
= 0;
12821 while ((r
= MsiEnumProductsA(index
, guid
)) == ERROR_SUCCESS
)
12823 if (!strcmp(product1
, guid
)) found1
= 1;
12824 if (!strcmp(product2
, guid
)) found2
= 1;
12825 if (!strcmp(product3
, guid
)) found3
= 1;
12828 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
12829 ok(found1
, "product1 not found\n");
12830 ok(found2
, "product2 not found\n");
12831 ok(found3
, "product3 not found\n");
12833 delete_key(key1
, "", access
& KEY_WOW64_64KEY
);
12834 delete_key(key2
, "", access
& KEY_WOW64_64KEY
);
12835 RegDeleteKeyA(key3
, "");
12839 LocalFree(usersid
);
12842 static void test_MsiGetFileSignatureInformation(void)
12845 const CERT_CONTEXT
*cert
;
12848 hr
= MsiGetFileSignatureInformationA( NULL
, 0, NULL
, NULL
, NULL
);
12849 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12851 hr
= MsiGetFileSignatureInformationA( NULL
, 0, NULL
, NULL
, &len
);
12852 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12854 hr
= MsiGetFileSignatureInformationA( NULL
, 0, &cert
, NULL
, &len
);
12855 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12857 hr
= MsiGetFileSignatureInformationA( "", 0, NULL
, NULL
, NULL
);
12858 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12860 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, NULL
);
12861 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12863 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, &len
);
12864 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12866 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, &cert
, NULL
, &len
);
12867 todo_wine
ok(hr
== CRYPT_E_FILE_ERROR
, "expected CRYPT_E_FILE_ERROR got 0x%08x\n", hr
);
12869 create_file( "signature.bin", "signature", sizeof("signature") );
12871 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, NULL
);
12872 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12874 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, &len
);
12875 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12877 cert
= (const CERT_CONTEXT
*)0xdeadbeef;
12878 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, &cert
, NULL
, &len
);
12879 todo_wine
ok(hr
== HRESULT_FROM_WIN32(ERROR_FUNCTION_FAILED
), "got 0x%08x\n", hr
);
12880 ok(cert
== NULL
, "got %p\n", cert
);
12882 DeleteFileA( "signature.bin" );
12885 static void test_MsiEnumProductsEx(void)
12889 MSIINSTALLCONTEXT context
;
12890 char product0
[39], product1
[39], product2
[39], product3
[39], guid
[39], sid
[128];
12891 char product_squashed1
[33], product_squashed2
[33], product_squashed3
[33];
12892 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
], keypath3
[MAX_PATH
];
12893 HKEY key1
= NULL
, key2
= NULL
, key3
= NULL
;
12894 REGSAM access
= KEY_ALL_ACCESS
;
12895 char *usersid
= get_user_sid();
12897 if (!pMsiEnumProductsExA
)
12899 win_skip("MsiEnumProductsExA not implemented\n");
12903 create_test_guid( product0
, NULL
);
12904 create_test_guid( product1
, product_squashed1
);
12905 create_test_guid( product2
, product_squashed2
);
12906 create_test_guid( product3
, product_squashed3
);
12908 if (is_wow64
) access
|= KEY_WOW64_64KEY
;
12910 strcpy( keypath1
, "Software\\Classes\\Installer\\Products\\" );
12911 strcat( keypath1
, product_squashed1
);
12913 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
12914 if (r
== ERROR_ACCESS_DENIED
)
12916 skip( "insufficient rights\n" );
12919 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12921 strcpy( keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\" );
12922 strcat( keypath2
, usersid
);
12923 strcat( keypath2
, "\\Installer\\Products\\" );
12924 strcat( keypath2
, product_squashed2
);
12926 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
12927 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12929 strcpy( keypath3
, usersid
);
12930 strcat( keypath3
, "\\Software\\Microsoft\\Installer\\Products\\" );
12931 strcat( keypath3
, product_squashed3
);
12933 r
= RegCreateKeyExA( HKEY_USERS
, keypath3
, 0, NULL
, 0, access
, NULL
, &key3
, NULL
);
12934 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12936 r
= pMsiEnumProductsExA( NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
);
12937 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
12940 r
= pMsiEnumProductsExA( NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, &len
);
12941 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
12942 ok( len
== sizeof(sid
), "got %u\n", len
);
12944 r
= pMsiEnumProductsExA( NULL
, NULL
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, NULL
, NULL
);
12945 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12949 r
= pMsiEnumProductsExA( product0
, NULL
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, sid
, &len
);
12950 ok( r
== ERROR_NO_MORE_ITEMS
, "got %u\n", r
);
12951 ok( len
== sizeof(sid
), "got %u\n", len
);
12952 ok( !sid
[0], "got %s\n", sid
);
12956 r
= pMsiEnumProductsExA( product0
, usersid
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, sid
, &len
);
12957 ok( r
== ERROR_NO_MORE_ITEMS
, "got %u\n", r
);
12958 ok( len
== sizeof(sid
), "got %u\n", len
);
12959 ok( !sid
[0], "got %s\n", sid
);
12963 r
= pMsiEnumProductsExA( NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
, 0, NULL
, NULL
, sid
, &len
);
12964 ok( r
== ERROR_MORE_DATA
, "got %u\n", r
);
12965 ok( len
, "length unchanged\n" );
12966 ok( !sid
[0], "got %s\n", sid
);
12969 context
= 0xdeadbeef;
12972 r
= pMsiEnumProductsExA( NULL
, NULL
, MSIINSTALLCONTEXT_ALL
, 0, guid
, &context
, sid
, &len
);
12973 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12974 ok( guid
[0], "empty guid\n" );
12975 ok( context
!= 0xdeadbeef, "context unchanged\n" );
12976 ok( !len
, "got %u\n", len
);
12977 ok( !sid
[0], "got %s\n", sid
);
12980 context
= 0xdeadbeef;
12983 r
= pMsiEnumProductsExA( NULL
, usersid
, MSIINSTALLCONTEXT_ALL
, 0, guid
, &context
, sid
, &len
);
12984 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12985 ok( guid
[0], "empty guid\n" );
12986 ok( context
!= 0xdeadbeef, "context unchanged\n" );
12987 ok( !len
, "got %u\n", len
);
12988 ok( !sid
[0], "got %s\n", sid
);
12991 context
= 0xdeadbeef;
12994 r
= pMsiEnumProductsExA( NULL
, "S-1-1-0", MSIINSTALLCONTEXT_ALL
, 0, guid
, &context
, sid
, &len
);
12995 if (r
== ERROR_ACCESS_DENIED
)
12997 skip( "insufficient rights\n" );
13000 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13001 ok( guid
[0], "empty guid\n" );
13002 ok( context
!= 0xdeadbeef, "context unchanged\n" );
13003 ok( !len
, "got %u\n", len
);
13004 ok( !sid
[0], "got %s\n", sid
);
13008 context
= 0xdeadbeef;
13011 while (!pMsiEnumProductsExA( NULL
, "S-1-1-0", MSIINSTALLCONTEXT_ALL
, index
, guid
, &context
, sid
, &len
))
13013 if (!strcmp( product1
, guid
))
13015 ok( context
== MSIINSTALLCONTEXT_MACHINE
, "got %u\n", context
);
13016 ok( !sid
[0], "got \"%s\"\n", sid
);
13017 ok( !len
, "unexpected length %u\n", len
);
13019 if (!strcmp( product2
, guid
))
13021 ok( context
== MSIINSTALLCONTEXT_USERMANAGED
, "got %u\n", context
);
13022 ok( sid
[0], "empty sid\n" );
13023 ok( len
== strlen(sid
), "unexpected length %u\n", len
);
13025 if (!strcmp( product3
, guid
))
13027 ok( context
== MSIINSTALLCONTEXT_USERUNMANAGED
, "got %u\n", context
);
13028 ok( sid
[0], "empty sid\n" );
13029 ok( len
== strlen(sid
), "unexpected length %u\n", len
);
13033 context
= 0xdeadbeef;
13039 delete_key( key1
, "", access
);
13040 delete_key( key2
, "", access
);
13041 delete_key( key3
, "", access
);
13042 RegCloseKey( key1
);
13043 RegCloseKey( key2
);
13044 RegCloseKey( key3
);
13045 LocalFree( usersid
);
13048 static void test_MsiEnumComponents(void)
13051 int found1
, found2
;
13053 char comp1
[39], comp2
[39], guid
[39];
13054 char comp_squashed1
[33], comp_squashed2
[33];
13055 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
];
13056 REGSAM access
= KEY_ALL_ACCESS
;
13057 char *usersid
= get_user_sid();
13058 HKEY key1
= NULL
, key2
= NULL
;
13060 create_test_guid( comp1
, comp_squashed1
);
13061 create_test_guid( comp2
, comp_squashed2
);
13063 if (is_wow64
) access
|= KEY_WOW64_64KEY
;
13065 strcpy( keypath1
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13066 strcat( keypath1
, "S-1-5-18\\Components\\" );
13067 strcat( keypath1
, comp_squashed1
);
13069 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
13070 if (r
== ERROR_ACCESS_DENIED
)
13072 skip( "insufficient rights\n" );
13075 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13077 strcpy( keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13078 strcat( keypath2
, usersid
);
13079 strcat( keypath2
, "\\Components\\" );
13080 strcat( keypath2
, comp_squashed2
);
13082 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
13083 if (r
== ERROR_ACCESS_DENIED
)
13085 skip( "insufficient rights\n" );
13089 r
= MsiEnumComponentsA( 0, NULL
);
13090 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13094 found1
= found2
= 0;
13095 while (!MsiEnumComponentsA( index
, guid
))
13097 if (!strcmp( guid
, comp1
)) found1
= 1;
13098 if (!strcmp( guid
, comp2
)) found2
= 1;
13099 ok( guid
[0], "empty guid\n" );
13103 ok( found1
, "comp1 not found\n" );
13104 ok( found2
, "comp2 not found\n" );
13107 delete_key( key1
, "", access
);
13108 delete_key( key2
, "", access
);
13109 RegCloseKey( key1
);
13110 RegCloseKey( key2
);
13111 LocalFree( usersid
);
13114 static void test_MsiEnumComponentsEx(void)
13117 int found1
, found2
;
13119 MSIINSTALLCONTEXT context
;
13120 char comp1
[39], comp2
[39], guid
[39], sid
[128];
13121 char comp_squashed1
[33], comp_squashed2
[33];
13122 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
];
13123 HKEY key1
= NULL
, key2
= NULL
;
13124 REGSAM access
= KEY_ALL_ACCESS
;
13125 char *usersid
= get_user_sid();
13127 if (!pMsiEnumComponentsExA
)
13129 win_skip( "MsiEnumComponentsExA not implemented\n" );
13132 create_test_guid( comp1
, comp_squashed1
);
13133 create_test_guid( comp2
, comp_squashed2
);
13135 if (is_wow64
) access
|= KEY_WOW64_64KEY
;
13137 strcpy( keypath1
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13138 strcat( keypath1
, "S-1-5-18\\Components\\" );
13139 strcat( keypath1
, comp_squashed1
);
13141 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
13142 if (r
== ERROR_ACCESS_DENIED
)
13144 skip( "insufficient rights\n" );
13147 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13149 strcpy( keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13150 strcat( keypath2
, usersid
);
13151 strcat( keypath2
, "\\Components\\" );
13152 strcat( keypath2
, comp_squashed2
);
13154 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
13155 if (r
== ERROR_ACCESS_DENIED
)
13157 skip( "insufficient rights\n" );
13160 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13161 r
= RegSetValueExA( key2
, comp_squashed2
, 0, REG_SZ
, (const BYTE
*)"c:\\doesnotexist",
13162 sizeof("c:\\doesnotexist"));
13163 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13167 context
= 0xdeadbeef;
13170 found1
= found2
= 0;
13171 while (!pMsiEnumComponentsExA( "S-1-1-0", MSIINSTALLCONTEXT_ALL
, index
, guid
, &context
, sid
, &len
))
13173 if (!strcmp( comp1
, guid
))
13175 ok( context
== MSIINSTALLCONTEXT_MACHINE
, "got %u\n", context
);
13176 ok( !sid
[0], "got \"%s\"\n", sid
);
13177 ok( !len
, "unexpected length %u\n", len
);
13180 if (!strcmp( comp2
, guid
))
13182 ok( context
== MSIINSTALLCONTEXT_USERUNMANAGED
, "got %u\n", context
);
13183 ok( sid
[0], "empty sid\n" );
13184 ok( len
== strlen(sid
), "unexpected length %u\n", len
);
13189 context
= 0xdeadbeef;
13193 ok( found1
, "comp1 not found\n" );
13194 ok( found2
, "comp2 not found\n" );
13196 r
= pMsiEnumComponentsExA( NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
);
13197 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13199 r
= pMsiEnumComponentsExA( NULL
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, sid
, NULL
);
13200 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13203 RegDeleteValueA( key2
, comp_squashed2
);
13204 delete_key( key1
, "", access
);
13205 delete_key( key2
, "", access
);
13206 RegCloseKey( key1
);
13207 RegCloseKey( key2
);
13208 LocalFree( usersid
);
13211 static void test_MsiConfigureProductEx(void)
13216 HKEY props
, source
;
13217 CHAR keypath
[MAX_PATH
* 2], localpackage
[MAX_PATH
], packagename
[MAX_PATH
];
13218 REGSAM access
= KEY_ALL_ACCESS
;
13220 if (is_process_limited())
13222 skip("process is limited\n");
13226 CreateDirectoryA("msitest", NULL
);
13227 create_file("msitest\\hydrogen", "hydrogen", 500);
13228 create_file("msitest\\helium", "helium", 500);
13229 create_file("msitest\\lithium", "lithium", 500);
13231 create_database(msifile
, mcp_tables
, sizeof(mcp_tables
) / sizeof(msi_table
));
13234 access
|= KEY_WOW64_64KEY
;
13236 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
13238 /* NULL szProduct */
13239 r
= MsiConfigureProductExA(NULL
, INSTALLLEVEL_DEFAULT
,
13240 INSTALLSTATE_DEFAULT
, "PROPVAR=42");
13241 ok(r
== ERROR_INVALID_PARAMETER
,
13242 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13244 /* empty szProduct */
13245 r
= MsiConfigureProductExA("", INSTALLLEVEL_DEFAULT
,
13246 INSTALLSTATE_DEFAULT
, "PROPVAR=42");
13247 ok(r
== ERROR_INVALID_PARAMETER
,
13248 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13250 /* garbage szProduct */
13251 r
= MsiConfigureProductExA("garbage", INSTALLLEVEL_DEFAULT
,
13252 INSTALLSTATE_DEFAULT
, "PROPVAR=42");
13253 ok(r
== ERROR_INVALID_PARAMETER
,
13254 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13256 /* guid without brackets */
13257 r
= MsiConfigureProductExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
13258 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13260 ok(r
== ERROR_INVALID_PARAMETER
,
13261 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13263 /* guid with brackets */
13264 r
= MsiConfigureProductExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
13265 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13267 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13268 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
13270 /* same length as guid, but random */
13271 r
= MsiConfigureProductExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
13272 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13274 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13275 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
13277 /* product not installed yet */
13278 r
= MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
13279 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13281 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13282 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
13284 /* install the product, per-user unmanaged */
13285 r
= MsiInstallProductA(msifile
, "INSTALLLEVEL=10 PROPVAR=42");
13286 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13288 skip("Not enough rights to perform tests\n");
13291 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13292 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13293 ok(pf_exists("msitest\\helium"), "File not installed\n");
13294 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13295 ok(pf_exists("msitest"), "File not installed\n");
13297 /* product is installed per-user managed, remove it */
13298 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13299 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13301 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13302 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13303 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13304 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13305 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13307 /* product has been removed */
13308 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13309 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13311 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13312 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13314 /* install the product, machine */
13315 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13316 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13317 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13318 ok(pf_exists("msitest\\helium"), "File not installed\n");
13319 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13320 ok(pf_exists("msitest"), "File not installed\n");
13322 /* product is installed machine, remove it */
13323 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13324 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13326 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13327 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13328 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13329 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13330 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13332 /* product has been removed */
13333 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13334 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13336 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13337 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13339 /* install the product, machine */
13340 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13341 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13342 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13343 ok(pf_exists("msitest\\helium"), "File not installed\n");
13344 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13345 ok(pf_exists("msitest"), "File not installed\n");
13347 DeleteFileA(msifile
);
13349 /* msifile is removed */
13350 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13351 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13353 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13354 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13355 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13356 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13357 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13359 create_database(msifile
, mcp_tables
, sizeof(mcp_tables
) / sizeof(msi_table
));
13361 /* install the product, machine */
13362 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13363 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13364 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13365 ok(pf_exists("msitest\\helium"), "File not installed\n");
13366 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13367 ok(pf_exists("msitest"), "File not installed\n");
13369 DeleteFileA(msifile
);
13371 lstrcpyA(keypath
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13372 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
13373 lstrcatA(keypath
, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13375 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, access
, &props
);
13376 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13380 res
= RegQueryValueExA(props
, "LocalPackage", NULL
, &type
,
13381 (LPBYTE
)localpackage
, &size
);
13382 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13384 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
13385 (const BYTE
*)"C:\\idontexist.msi", 18);
13386 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13388 /* LocalPackage is used to find the cached msi package */
13389 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13390 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13392 ok(r
== ERROR_INSTALL_SOURCE_ABSENT
,
13393 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r
);
13394 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13395 ok(pf_exists("msitest\\helium"), "File not installed\n");
13396 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13397 ok(pf_exists("msitest"), "File not installed\n");
13399 RegCloseKey(props
);
13400 create_database(msifile
, mcp_tables
, sizeof(mcp_tables
) / sizeof(msi_table
));
13402 /* LastUsedSource can be used as a last resort */
13403 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13404 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13406 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13407 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13408 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13409 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13410 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13411 DeleteFileA( localpackage
);
13413 /* install the product, machine */
13414 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13415 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13416 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13417 ok(pf_exists("msitest\\helium"), "File not installed\n");
13418 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13419 ok(pf_exists("msitest"), "File not installed\n");
13421 lstrcpyA(keypath
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13422 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
13423 lstrcatA(keypath
, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13425 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, access
, &props
);
13426 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13430 res
= RegQueryValueExA(props
, "LocalPackage", NULL
, &type
,
13431 (LPBYTE
)localpackage
, &size
);
13432 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13434 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
13435 (const BYTE
*)"C:\\idontexist.msi", 18);
13436 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13438 lstrcpyA(keypath
, "SOFTWARE\\Classes\\Installer\\Products\\");
13439 lstrcatA(keypath
, "83374883CBB1401418CAF2AA7CCEDDDC\\SourceList");
13441 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, access
, &source
);
13442 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13446 res
= RegQueryValueExA(source
, "PackageName", NULL
, &type
,
13447 (LPBYTE
)packagename
, &size
);
13448 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13450 res
= RegSetValueExA(source
, "PackageName", 0, REG_SZ
,
13451 (const BYTE
*)"idontexist.msi", 15);
13452 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13454 /* SourceList is altered */
13455 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13456 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13458 ok(r
== ERROR_INSTALL_SOURCE_ABSENT
,
13459 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r
);
13460 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13461 ok(pf_exists("msitest\\helium"), "File not installed\n");
13462 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13463 ok(pf_exists("msitest"), "File not installed\n");
13465 /* restore PackageName */
13466 res
= RegSetValueExA(source
, "PackageName", 0, REG_SZ
,
13467 (const BYTE
*)packagename
, lstrlenA(packagename
) + 1);
13468 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13470 /* restore LocalPackage */
13471 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
13472 (const BYTE
*)localpackage
, lstrlenA(localpackage
) + 1);
13473 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13475 /* finally remove the product */
13476 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13477 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13479 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13480 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13481 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13482 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13483 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13485 RegCloseKey(source
);
13486 RegCloseKey(props
);
13489 DeleteFileA("msitest\\hydrogen");
13490 DeleteFileA("msitest\\helium");
13491 DeleteFileA("msitest\\lithium");
13492 RemoveDirectoryA("msitest");
13493 DeleteFileA(msifile
);
13496 static void test_MsiSetFeatureAttributes(void)
13500 char path
[MAX_PATH
];
13503 if (is_process_limited())
13505 skip("process is limited\n");
13508 create_database( msifile
, tables
, sizeof(tables
) / sizeof(tables
[0]) );
13510 strcpy( path
, CURR_DIR
);
13511 strcat( path
, "\\" );
13512 strcat( path
, msifile
);
13514 r
= MsiOpenPackage( path
, &package
);
13515 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13517 skip("Not enough rights to perform tests\n");
13518 DeleteFileA( msifile
);
13521 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13523 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13524 ok(r
== ERROR_FUNCTION_FAILED
, "Expected ERROR_FUNCTION_FAILED, got %u\n", r
);
13526 r
= MsiDoAction( package
, "CostInitialize" );
13527 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13529 r
= MsiSetFeatureAttributesA( 0, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13530 ok(r
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %u\n", r
);
13532 r
= MsiSetFeatureAttributesA( package
, "", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13533 ok(r
== ERROR_UNKNOWN_FEATURE
, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
13535 r
= MsiSetFeatureAttributesA( package
, NULL
, INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13536 ok(r
== ERROR_UNKNOWN_FEATURE
, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
13538 r
= MsiSetFeatureAttributesA( package
, "One", 0 );
13539 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13541 attrs
= 0xdeadbeef;
13542 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, NULL
, NULL
, NULL
, NULL
);
13543 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13544 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
,
13545 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs
);
13547 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13548 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13551 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, NULL
, NULL
, NULL
, NULL
);
13552 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13553 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
,
13554 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs
);
13556 r
= MsiDoAction( package
, "FileCost" );
13557 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13559 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORSOURCE
);
13560 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13563 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, NULL
, NULL
, NULL
, NULL
);
13564 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13565 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORSOURCE
,
13566 "expected INSTALLFEATUREATTRIBUTE_FAVORSOURCE, got 0x%08x\n", attrs
);
13568 r
= MsiDoAction( package
, "CostFinalize" );
13569 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13571 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13572 ok(r
== ERROR_FUNCTION_FAILED
, "expected ERROR_FUNCTION_FAILED, got %u\n", r
);
13574 MsiCloseHandle( package
);
13575 DeleteFileA( msifile
);
13578 static void test_MsiGetFeatureInfo(void)
13582 char title
[32], help
[32], path
[MAX_PATH
];
13583 DWORD attrs
, title_len
, help_len
;
13585 if (is_process_limited())
13587 skip("process is limited\n");
13590 create_database( msifile
, tables
, sizeof(tables
) / sizeof(tables
[0]) );
13592 strcpy( path
, CURR_DIR
);
13593 strcat( path
, "\\" );
13594 strcat( path
, msifile
);
13596 r
= MsiOpenPackage( path
, &package
);
13597 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13599 skip("Not enough rights to perform tests\n");
13600 DeleteFileA( msifile
);
13603 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13605 r
= MsiGetFeatureInfoA( 0, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
13606 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
13608 r
= MsiGetFeatureInfoA( package
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
13609 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
13611 r
= MsiGetFeatureInfoA( package
, "", NULL
, NULL
, NULL
, NULL
, NULL
);
13612 ok(r
== ERROR_UNKNOWN_FEATURE
, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
13614 r
= MsiGetFeatureInfoA( package
, "One", NULL
, NULL
, NULL
, NULL
, NULL
);
13615 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13617 r
= MsiGetFeatureInfoA( 0, "One", NULL
, NULL
, NULL
, NULL
, NULL
);
13618 ok(r
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %u\n", r
);
13620 title_len
= help_len
= 0;
13621 r
= MsiGetFeatureInfoA( package
, "One", NULL
, NULL
, &title_len
, NULL
, &help_len
);
13622 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13623 ok(title_len
== 3, "expected 3, got %u\n", title_len
);
13624 ok(help_len
== 3, "expected 3, got %u\n", help_len
);
13626 title
[0] = help
[0] = 0;
13627 title_len
= help_len
= 0;
13628 r
= MsiGetFeatureInfoA( package
, "One", NULL
, title
, &title_len
, help
, &help_len
);
13629 ok(r
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %u\n", r
);
13630 ok(title_len
== 3, "expected 3, got %u\n", title_len
);
13631 ok(help_len
== 3, "expected 3, got %u\n", help_len
);
13634 title
[0] = help
[0] = 0;
13635 title_len
= sizeof(title
);
13636 help_len
= sizeof(help
);
13637 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, title
, &title_len
, help
, &help_len
);
13638 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13639 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs
);
13640 ok(title_len
== 3, "expected 3, got %u\n", title_len
);
13641 ok(help_len
== 3, "expected 3, got %u\n", help_len
);
13642 ok(!strcmp(title
, "One"), "expected \"One\", got \"%s\"\n", title
);
13643 ok(!strcmp(help
, "One"), "expected \"One\", got \"%s\"\n", help
);
13646 title
[0] = help
[0] = 0;
13647 title_len
= sizeof(title
);
13648 help_len
= sizeof(help
);
13649 r
= MsiGetFeatureInfoA( package
, "Two", &attrs
, title
, &title_len
, help
, &help_len
);
13650 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13651 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs
);
13652 ok(!title_len
, "expected 0, got %u\n", title_len
);
13653 ok(!help_len
, "expected 0, got %u\n", help_len
);
13654 ok(!title
[0], "expected \"\", got \"%s\"\n", title
);
13655 ok(!help
[0], "expected \"\", got \"%s\"\n", help
);
13657 MsiCloseHandle( package
);
13658 DeleteFileA( msifile
);
13661 static INT CALLBACK
handler_a(LPVOID context
, UINT type
, LPCSTR msg
)
13666 static INT CALLBACK
handler_w(LPVOID context
, UINT type
, LPCWSTR msg
)
13671 static INT CALLBACK
handler_record(LPVOID context
, UINT type
, MSIHANDLE record
)
13676 static void test_MsiSetExternalUI(void)
13678 INSTALLUI_HANDLERA ret_a
;
13679 INSTALLUI_HANDLERW ret_w
;
13680 INSTALLUI_HANDLER_RECORD prev
;
13683 ret_a
= MsiSetExternalUIA(handler_a
, INSTALLLOGMODE_ERROR
, NULL
);
13684 ok(ret_a
== NULL
, "expected NULL, got %p\n", ret_a
);
13686 ret_a
= MsiSetExternalUIA(NULL
, 0, NULL
);
13687 ok(ret_a
== handler_a
, "expected %p, got %p\n", handler_a
, ret_a
);
13689 /* Not present before Installer 3.1 */
13690 if (!pMsiSetExternalUIRecord
) {
13691 win_skip("MsiSetExternalUIRecord is not available\n");
13695 error
= pMsiSetExternalUIRecord(handler_record
, INSTALLLOGMODE_ERROR
, NULL
, &prev
);
13696 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13697 ok(prev
== NULL
, "expected NULL, got %p\n", prev
);
13699 prev
= (INSTALLUI_HANDLER_RECORD
)0xdeadbeef;
13700 error
= pMsiSetExternalUIRecord(NULL
, INSTALLLOGMODE_ERROR
, NULL
, &prev
);
13701 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13702 ok(prev
== handler_record
, "expected %p, got %p\n", handler_record
, prev
);
13704 ret_w
= MsiSetExternalUIW(handler_w
, INSTALLLOGMODE_ERROR
, NULL
);
13705 ok(ret_w
== NULL
, "expected NULL, got %p\n", ret_w
);
13707 ret_w
= MsiSetExternalUIW(NULL
, 0, NULL
);
13708 ok(ret_w
== handler_w
, "expected %p, got %p\n", handler_w
, ret_w
);
13710 ret_a
= MsiSetExternalUIA(handler_a
, INSTALLLOGMODE_ERROR
, NULL
);
13711 ok(ret_a
== NULL
, "expected NULL, got %p\n", ret_a
);
13713 ret_w
= MsiSetExternalUIW(handler_w
, INSTALLLOGMODE_ERROR
, NULL
);
13714 ok(ret_w
== NULL
, "expected NULL, got %p\n", ret_w
);
13716 prev
= (INSTALLUI_HANDLER_RECORD
)0xdeadbeef;
13717 error
= pMsiSetExternalUIRecord(handler_record
, INSTALLLOGMODE_ERROR
, NULL
, &prev
);
13718 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13719 ok(prev
== NULL
, "expected NULL, got %p\n", prev
);
13721 ret_a
= MsiSetExternalUIA(NULL
, 0, NULL
);
13722 ok(ret_a
== NULL
, "expected NULL, got %p\n", ret_a
);
13724 ret_w
= MsiSetExternalUIW(NULL
, 0, NULL
);
13725 ok(ret_w
== NULL
, "expected NULL, got %p\n", ret_w
);
13727 prev
= (INSTALLUI_HANDLER_RECORD
)0xdeadbeef;
13728 error
= pMsiSetExternalUIRecord(NULL
, 0, NULL
, &prev
);
13729 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13730 ok(prev
== handler_record
, "expected %p, got %p\n", handler_record
, prev
);
13732 error
= pMsiSetExternalUIRecord(handler_record
, INSTALLLOGMODE_ERROR
, NULL
, NULL
);
13733 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13735 error
= pMsiSetExternalUIRecord(NULL
, 0, NULL
, NULL
);
13736 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13739 static void test_lastusedsource(void)
13741 static char prodcode
[] = "{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}";
13742 char value
[MAX_PATH
], path
[MAX_PATH
];
13746 if (!pMsiSourceListGetInfoA
)
13748 win_skip("MsiSourceListGetInfoA is not available\n");
13752 CreateDirectoryA("msitest", NULL
);
13753 create_file("maximus", "maximus", 500);
13754 create_cab_file("test1.cab", MEDIA_SIZE
, "maximus\0");
13755 DeleteFile("maximus");
13757 create_database("msifile0.msi", lus0_tables
, sizeof(lus0_tables
) / sizeof(msi_table
));
13758 create_database("msifile1.msi", lus1_tables
, sizeof(lus1_tables
) / sizeof(msi_table
));
13759 create_database("msifile2.msi", lus2_tables
, sizeof(lus2_tables
) / sizeof(msi_table
));
13761 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
13763 /* no cabinet file */
13766 lstrcpyA(value
, "aaa");
13767 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13768 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13769 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13770 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13772 r
= MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1");
13773 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13775 skip("Not enough rights to perform tests\n");
13778 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13780 lstrcpyA(path
, CURR_DIR
);
13781 lstrcatA(path
, "\\");
13784 lstrcpyA(value
, "aaa");
13785 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13786 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13787 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13788 ok(!lstrcmpA(value
, path
), "expected \"%s\", got \"%s\"\n", path
, value
);
13789 ok(size
== lstrlenA(path
), "expected %d, got %d\n", lstrlenA(path
), size
);
13791 r
= MsiInstallProductA("msifile0.msi", "REMOVE=ALL");
13792 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13794 /* separate cabinet file */
13797 lstrcpyA(value
, "aaa");
13798 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13799 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13800 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13801 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13803 r
= MsiInstallProductA("msifile1.msi", "PUBLISH_PRODUCT=1");
13804 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13806 lstrcpyA(path
, CURR_DIR
);
13807 lstrcatA(path
, "\\");
13810 lstrcpyA(value
, "aaa");
13811 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13812 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13813 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13814 ok(!lstrcmpA(value
, path
), "expected \"%s\", got \"%s\"\n", path
, value
);
13815 ok(size
== lstrlenA(path
), "expected %d, got %d\n", lstrlenA(path
), size
);
13817 r
= MsiInstallProductA("msifile1.msi", "REMOVE=ALL");
13818 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13821 lstrcpyA(value
, "aaa");
13822 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13823 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13824 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13825 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13827 /* embedded cabinet stream */
13829 add_cabinet_storage("msifile2.msi", "test1.cab");
13831 r
= MsiInstallProductA("msifile2.msi", "PUBLISH_PRODUCT=1");
13832 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13835 lstrcpyA(value
, "aaa");
13836 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13837 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13838 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13839 ok(!lstrcmpA(value
, path
), "expected \"%s\", got \"%s\"\n", path
, value
);
13840 ok(size
== lstrlenA(path
), "expected %d, got %d\n", lstrlenA(path
), size
);
13842 r
= MsiInstallProductA("msifile2.msi", "REMOVE=ALL");
13843 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13846 lstrcpyA(value
, "aaa");
13847 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13848 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCE
, value
, &size
);
13849 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13850 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13853 delete_cab_files();
13854 DeleteFile("msitest\\maximus");
13855 RemoveDirectory("msitest");
13856 DeleteFile("msifile0.msi");
13857 DeleteFile("msifile1.msi");
13858 DeleteFile("msifile2.msi");
13861 static void test_setpropertyfolder(void)
13864 CHAR path
[MAX_PATH
];
13867 if (is_process_limited())
13869 skip("process is limited\n");
13873 lstrcpyA(path
, PROG_FILES_DIR
);
13874 lstrcatA(path
, "\\msitest\\added");
13876 CreateDirectoryA("msitest", NULL
);
13877 create_file("msitest\\maximus", "msitest\\maximus", 500);
13879 create_database(msifile
, spf_tables
, sizeof(spf_tables
) / sizeof(msi_table
));
13881 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
13883 r
= MsiInstallProductA(msifile
, NULL
);
13884 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13886 skip("Not enough rights to perform tests\n");
13889 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13890 attr
= GetFileAttributesA(path
);
13891 if (attr
!= INVALID_FILE_ATTRIBUTES
&& (attr
& FILE_ATTRIBUTE_DIRECTORY
))
13893 ok(delete_pf("msitest\\added\\maximus", TRUE
), "File not installed\n");
13894 ok(delete_pf("msitest\\added", FALSE
), "Directory not created\n");
13895 ok(delete_pf("msitest", FALSE
), "Directory not created\n");
13899 trace("changing folder property not supported\n");
13900 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
13901 ok(delete_pf("msitest", FALSE
), "Directory not created\n");
13905 DeleteFile(msifile
);
13906 DeleteFile("msitest\\maximus");
13907 RemoveDirectory("msitest");
13910 static void test_sourcedir_props(void)
13914 if (is_process_limited())
13916 skip("process is limited\n");
13920 create_test_files();
13921 create_file("msitest\\sourcedir.txt", "msitest\\sourcedir.txt", 1000);
13922 create_database(msifile
, sd_tables
, sizeof(sd_tables
) / sizeof(msi_table
));
13924 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
13926 /* full UI, no ResolveSource action */
13927 r
= MsiInstallProductA(msifile
, NULL
);
13928 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13930 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
13931 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13933 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
13934 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
13936 /* full UI, ResolveSource action */
13937 r
= MsiInstallProductA(msifile
, "ResolveSource=1");
13938 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13940 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
13941 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13943 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
13944 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
13946 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
13948 /* no UI, no ResolveSource action */
13949 r
= MsiInstallProductA(msifile
, NULL
);
13950 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13952 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
13953 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13955 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
13956 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
13958 /* no UI, ResolveSource action */
13959 r
= MsiInstallProductA(msifile
, "ResolveSource=1");
13960 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13962 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
13963 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13965 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
13966 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
13968 DeleteFileA("msitest\\sourcedir.txt");
13969 delete_test_files();
13970 DeleteFile(msifile
);
13973 static void test_concurrentinstall(void)
13976 CHAR path
[MAX_PATH
];
13978 if (is_process_limited())
13980 skip("process is limited\n");
13984 CreateDirectoryA("msitest", NULL
);
13985 CreateDirectoryA("msitest\\msitest", NULL
);
13986 create_file("msitest\\maximus", "msitest\\maximus", 500);
13987 create_file("msitest\\msitest\\augustus", "msitest\\msitest\\augustus", 500);
13989 create_database(msifile
, ci_tables
, sizeof(ci_tables
) / sizeof(msi_table
));
13991 lstrcpyA(path
, CURR_DIR
);
13992 lstrcatA(path
, "\\msitest\\concurrent.msi");
13993 create_database(path
, ci2_tables
, sizeof(ci2_tables
) / sizeof(msi_table
));
13995 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
13997 r
= MsiInstallProductA(msifile
, NULL
);
13998 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
14000 skip("Not enough rights to perform tests\n");
14004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14005 if (!delete_pf("msitest\\augustus", TRUE
))
14006 trace("concurrent installs not supported\n");
14007 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
14008 ok(delete_pf("msitest", FALSE
), "Directory not created\n");
14010 r
= MsiConfigureProductA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", INSTALLLEVEL_DEFAULT
,
14011 INSTALLSTATE_ABSENT
);
14012 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14017 DeleteFile(msifile
);
14018 DeleteFile("msitest\\msitest\\augustus");
14019 DeleteFile("msitest\\maximus");
14020 RemoveDirectory("msitest\\msitest");
14021 RemoveDirectory("msitest");
14024 static void test_command_line_parsing(void)
14029 if (is_process_limited())
14031 skip("process is limited\n");
14035 create_test_files();
14036 create_database(msifile
, cl_tables
, sizeof(cl_tables
)/sizeof(msi_table
));
14038 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
14041 r
= MsiInstallProductA(msifile
, cmd
);
14042 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14045 r
= MsiInstallProductA(msifile
, cmd
);
14046 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14049 r
= MsiInstallProductA(msifile
, cmd
);
14050 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14053 r
= MsiInstallProductA(msifile
, cmd
);
14054 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14057 r
= MsiInstallProductA(msifile
, cmd
);
14058 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14061 r
= MsiInstallProductA(msifile
, cmd
);
14062 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14065 r
= MsiInstallProductA(msifile
, cmd
);
14066 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14069 r
= MsiInstallProductA(msifile
, cmd
);
14070 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14073 r
= MsiInstallProductA(msifile
, cmd
);
14074 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14077 r
= MsiInstallProductA(msifile
, cmd
);
14078 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14081 r
= MsiInstallProductA(msifile
, cmd
);
14082 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14084 cmd
= "P=\"\"\"\"";
14085 r
= MsiInstallProductA(msifile
, cmd
);
14086 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14089 r
= MsiInstallProductA(msifile
, cmd
);
14090 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14093 r
= MsiInstallProductA(msifile
, cmd
);
14094 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14097 r
= MsiInstallProductA(msifile
, cmd
);
14098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14101 r
= MsiInstallProductA(msifile
, cmd
);
14102 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14105 r
= MsiInstallProductA(msifile
, cmd
);
14106 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14109 r
= MsiInstallProductA(msifile
, cmd
);
14110 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14113 r
= MsiInstallProductA(msifile
, cmd
);
14114 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14117 r
= MsiInstallProductA(msifile
, cmd
);
14118 todo_wine
ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14121 r
= MsiInstallProductA(msifile
, cmd
);
14122 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14124 cmd
= "P= \"one\" ";
14125 r
= MsiInstallProductA(msifile
, cmd
);
14126 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14128 cmd
= "P=\"one\"\"";
14129 r
= MsiInstallProductA(msifile
, cmd
);
14130 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14132 cmd
= "P=\"\"one\"";
14133 r
= MsiInstallProductA(msifile
, cmd
);
14134 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14136 cmd
= "P=\"\"one\"\"";
14137 r
= MsiInstallProductA(msifile
, cmd
);
14138 todo_wine
ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14140 cmd
= "P=\"one two\"";
14141 r
= MsiInstallProductA(msifile
, cmd
);
14142 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14144 cmd
= "P=\"\"\"one\"\" two\"";
14145 r
= MsiInstallProductA(msifile
, cmd
);
14146 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14148 cmd
= "P=\"\"\"one\"\" two\" Q=three";
14149 r
= MsiInstallProductA(msifile
, cmd
);
14150 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14152 cmd
= "P=\"\" Q=\"two\"";
14153 r
= MsiInstallProductA(msifile
, cmd
);
14154 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14156 cmd
= "P=\"one\" Q=\"two\"";
14157 r
= MsiInstallProductA(msifile
, cmd
);
14158 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14160 cmd
= "P=\"one=two\"";
14161 r
= MsiInstallProductA(msifile
, cmd
);
14162 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14164 cmd
= "Q=\"\" P=\"one\"";
14165 r
= MsiInstallProductA(msifile
, cmd
);
14166 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14168 cmd
= "P=\"\"\"one\"\"\" Q=\"two\"";
14169 r
= MsiInstallProductA(msifile
, cmd
);
14170 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14172 cmd
= "P=\"one \"\"two\"\"\" Q=\"three\"";
14173 r
= MsiInstallProductA(msifile
, cmd
);
14174 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14176 cmd
= "P=\"\"\"one\"\" two\" Q=\"three\"";
14177 r
= MsiInstallProductA(msifile
, cmd
);
14178 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14180 DeleteFile(msifile
);
14181 delete_test_files();
14187 char temp_path
[MAX_PATH
], prev_path
[MAX_PATH
];
14189 init_functionpointers();
14191 if (pIsWow64Process
)
14192 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
14194 GetCurrentDirectoryA(MAX_PATH
, prev_path
);
14195 GetTempPath(MAX_PATH
, temp_path
);
14196 SetCurrentDirectoryA(temp_path
);
14198 lstrcpyA(CURR_DIR
, temp_path
);
14199 len
= lstrlenA(CURR_DIR
);
14201 if(len
&& (CURR_DIR
[len
- 1] == '\\'))
14202 CURR_DIR
[len
- 1] = 0;
14204 ok(get_system_dirs(), "failed to retrieve system dirs\n");
14208 test_getcomponentpath();
14209 test_MsiGetFileHash();
14211 if (!pConvertSidToStringSidA
)
14212 win_skip("ConvertSidToStringSidA not implemented\n");
14215 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
14216 test_MsiQueryProductState();
14217 test_MsiQueryFeatureState();
14218 test_MsiQueryComponentState();
14219 test_MsiGetComponentPath();
14220 test_MsiGetProductCode();
14221 test_MsiEnumClients();
14222 test_MsiGetProductInfo();
14223 test_MsiGetProductInfoEx();
14224 test_MsiGetUserInfo();
14225 test_MsiOpenProduct();
14226 test_MsiEnumPatchesEx();
14227 test_MsiEnumPatches();
14228 test_MsiGetPatchInfoEx();
14229 test_MsiGetPatchInfo();
14230 test_MsiEnumProducts();
14231 test_MsiEnumProductsEx();
14232 test_MsiEnumComponents();
14233 test_MsiEnumComponentsEx();
14235 test_MsiGetFileVersion();
14236 test_MsiGetFileSignatureInformation();
14237 test_MsiConfigureProductEx();
14238 test_MsiSetFeatureAttributes();
14239 test_MsiGetFeatureInfo();
14240 test_MsiSetExternalUI();
14241 test_lastusedsource();
14242 test_setpropertyfolder();
14243 test_sourcedir_props();
14244 test_concurrentinstall();
14245 test_command_line_parsing();
14247 SetCurrentDirectoryA(prev_path
);