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
34 #include "wine/test.h"
37 static const char msifile
[] = "winetest.msi";
38 static const WCHAR msifileW
[] = {'w','i','n','e','t','e','s','t','.','m','s','i',0};
39 static char CURR_DIR
[MAX_PATH
];
40 static char PROG_FILES_DIR
[MAX_PATH
];
41 static char PROG_FILES_DIR_NATIVE
[MAX_PATH
];
42 static char COMMON_FILES_DIR
[MAX_PATH
];
43 static char WINDOWS_DIR
[MAX_PATH
];
45 static BOOL (WINAPI
*pCheckTokenMembership
)(HANDLE
,PSID
,PBOOL
);
46 static BOOL (WINAPI
*pConvertSidToStringSidA
)(PSID
, LPSTR
*);
47 static BOOL (WINAPI
*pOpenProcessToken
)( HANDLE
, DWORD
, PHANDLE
);
48 static LONG (WINAPI
*pRegDeleteKeyExA
)(HKEY
, LPCSTR
, REGSAM
, DWORD
);
49 static BOOL (WINAPI
*pIsWow64Process
)(HANDLE
, PBOOL
);
51 static INSTALLSTATE (WINAPI
*pMsiGetComponentPathA
)
52 (LPCSTR
, LPCSTR
, LPSTR
, DWORD
*);
53 static UINT (WINAPI
*pMsiGetFileHashA
)
54 (LPCSTR
, DWORD
, PMSIFILEHASHINFO
);
55 static UINT (WINAPI
*pMsiGetProductInfoExA
)
56 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPCSTR
, LPSTR
, LPDWORD
);
57 static UINT (WINAPI
*pMsiOpenPackageExA
)
58 (LPCSTR
, DWORD
, MSIHANDLE
*);
59 static UINT (WINAPI
*pMsiOpenPackageExW
)
60 (LPCWSTR
, DWORD
, MSIHANDLE
*);
61 static UINT (WINAPI
*pMsiEnumPatchesExA
)
62 (LPCSTR
, LPCSTR
, DWORD
, DWORD
, DWORD
, LPSTR
, LPSTR
,
63 MSIINSTALLCONTEXT
*, LPSTR
, LPDWORD
);
64 static UINT (WINAPI
*pMsiQueryComponentStateA
)
65 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPCSTR
, INSTALLSTATE
*);
66 static INSTALLSTATE (WINAPI
*pMsiUseFeatureExA
)
67 (LPCSTR
, LPCSTR
,DWORD
, DWORD
);
68 static UINT (WINAPI
*pMsiGetPatchInfoExA
)
69 (LPCSTR
, LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, LPCSTR
, LPSTR
, DWORD
*);
70 static UINT (WINAPI
*pMsiEnumProductsExA
)
71 (LPCSTR
, LPCSTR
, DWORD
, DWORD
, CHAR
[39], MSIINSTALLCONTEXT
*, LPSTR
, LPDWORD
);
72 static UINT (WINAPI
*pMsiEnumComponentsExA
)
73 (LPCSTR
, DWORD
, DWORD
, CHAR
[39], MSIINSTALLCONTEXT
*, LPSTR
, LPDWORD
);
74 static UINT (WINAPI
*pMsiSetExternalUIRecord
)
75 (INSTALLUI_HANDLER_RECORD
, DWORD
, LPVOID
, PINSTALLUI_HANDLER_RECORD
);
76 static UINT (WINAPI
*pMsiSourceListGetInfoA
)
77 (LPCSTR
, LPCSTR
, MSIINSTALLCONTEXT
, DWORD
, LPCSTR
, LPSTR
, LPDWORD
);
79 static void init_functionpointers(void)
81 HMODULE hmsi
= GetModuleHandleA("msi.dll");
82 HMODULE hadvapi32
= GetModuleHandleA("advapi32.dll");
83 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
85 #define GET_PROC(dll, func) \
86 p ## func = (void *)GetProcAddress(dll, #func); \
88 trace("GetProcAddress(%s) failed\n", #func);
90 GET_PROC(hmsi
, MsiGetComponentPathA
)
91 GET_PROC(hmsi
, MsiGetFileHashA
)
92 GET_PROC(hmsi
, MsiGetProductInfoExA
)
93 GET_PROC(hmsi
, MsiOpenPackageExA
)
94 GET_PROC(hmsi
, MsiOpenPackageExW
)
95 GET_PROC(hmsi
, MsiEnumPatchesExA
)
96 GET_PROC(hmsi
, MsiQueryComponentStateA
)
97 GET_PROC(hmsi
, MsiSetExternalUIRecord
)
98 GET_PROC(hmsi
, MsiUseFeatureExA
)
99 GET_PROC(hmsi
, MsiGetPatchInfoExA
)
100 GET_PROC(hmsi
, MsiEnumProductsExA
)
101 GET_PROC(hmsi
, MsiEnumComponentsExA
)
102 GET_PROC(hmsi
, MsiSourceListGetInfoA
)
104 GET_PROC(hadvapi32
, CheckTokenMembership
);
105 GET_PROC(hadvapi32
, ConvertSidToStringSidA
)
106 GET_PROC(hadvapi32
, OpenProcessToken
);
107 GET_PROC(hadvapi32
, RegDeleteKeyExA
)
108 GET_PROC(hkernel32
, IsWow64Process
)
113 static BOOL
get_system_dirs(void)
118 if (RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey
))
122 if (RegQueryValueExA(hkey
, "ProgramFilesDir (x86)", 0, &type
, (LPBYTE
)PROG_FILES_DIR
, &size
) &&
123 RegQueryValueExA(hkey
, "ProgramFilesDir", 0, &type
, (LPBYTE
)PROG_FILES_DIR
, &size
))
129 if (RegQueryValueExA(hkey
, "CommonFilesDir (x86)", 0, &type
, (LPBYTE
)COMMON_FILES_DIR
, &size
) &&
130 RegQueryValueExA(hkey
, "CommonFilesDir", 0, &type
, (LPBYTE
)COMMON_FILES_DIR
, &size
))
136 if (RegQueryValueExA(hkey
, "ProgramFilesDir", 0, &type
, (LPBYTE
)PROG_FILES_DIR_NATIVE
, &size
))
142 if (!GetWindowsDirectoryA(WINDOWS_DIR
, MAX_PATH
)) return FALSE
;
146 static BOOL
file_exists(const char *file
)
148 return GetFileAttributesA(file
) != INVALID_FILE_ATTRIBUTES
;
151 static BOOL
pf_exists(const char *file
)
155 lstrcpyA(path
, PROG_FILES_DIR
);
156 lstrcatA(path
, "\\");
157 lstrcatA(path
, file
);
158 return file_exists(path
);
161 static BOOL
delete_pf(const char *rel_path
, BOOL is_file
)
165 lstrcpyA(path
, PROG_FILES_DIR
);
166 lstrcatA(path
, "\\");
167 lstrcatA(path
, rel_path
);
170 return DeleteFileA(path
);
172 return RemoveDirectoryA(path
);
175 static BOOL
is_process_limited(void)
177 SID_IDENTIFIER_AUTHORITY NtAuthority
= {SECURITY_NT_AUTHORITY
};
182 if (!pCheckTokenMembership
|| !pOpenProcessToken
) return FALSE
;
184 if (!AllocateAndInitializeSid(&NtAuthority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
185 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0, &Group
) ||
186 !pCheckTokenMembership(NULL
, Group
, &IsInGroup
))
188 trace("Could not check if the current user is an administrator\n");
196 /* Only administrators have enough privileges for these tests */
200 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
))
203 TOKEN_ELEVATION_TYPE type
= TokenElevationTypeDefault
;
206 ret
= GetTokenInformation(token
, TokenElevationType
, &type
, sizeof(type
), &size
);
208 return (ret
&& type
== TokenElevationTypeLimited
);
213 /* cabinet definitions */
215 /* make the max size large so there is only one cab file */
216 #define MEDIA_SIZE 0x7FFFFFFF
217 #define FOLDER_THRESHOLD 900000
219 /* the FCI callbacks */
221 static void * CDECL
mem_alloc(ULONG cb
)
223 return HeapAlloc(GetProcessHeap(), 0, cb
);
226 static void CDECL
mem_free(void *memory
)
228 HeapFree(GetProcessHeap(), 0, memory
);
231 static BOOL CDECL
get_next_cabinet(PCCAB pccab
, ULONG cbPrevCab
, void *pv
)
233 sprintf(pccab
->szCab
, pv
, pccab
->iCab
);
237 static LONG CDECL
progress(UINT typeStatus
, ULONG cb1
, ULONG cb2
, void *pv
)
242 static int CDECL
file_placed(PCCAB pccab
, char *pszFile
, LONG cbFile
,
243 BOOL fContinuation
, void *pv
)
248 static INT_PTR CDECL
fci_open(char *pszFile
, int oflag
, int pmode
, int *err
, void *pv
)
252 DWORD dwShareMode
= 0;
253 DWORD dwCreateDisposition
= OPEN_EXISTING
;
255 dwAccess
= GENERIC_READ
| GENERIC_WRITE
;
256 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
257 dwShareMode
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
259 if (GetFileAttributesA(pszFile
) != INVALID_FILE_ATTRIBUTES
)
260 dwCreateDisposition
= OPEN_EXISTING
;
262 dwCreateDisposition
= CREATE_NEW
;
264 handle
= CreateFileA(pszFile
, dwAccess
, dwShareMode
, NULL
,
265 dwCreateDisposition
, 0, NULL
);
267 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to CreateFile %s\n", pszFile
);
269 return (INT_PTR
)handle
;
272 static UINT CDECL
fci_read(INT_PTR hf
, void *memory
, UINT cb
, int *err
, void *pv
)
274 HANDLE handle
= (HANDLE
)hf
;
278 res
= ReadFile(handle
, memory
, cb
, &dwRead
, NULL
);
279 ok(res
, "Failed to ReadFile\n");
284 static UINT CDECL
fci_write(INT_PTR hf
, void *memory
, UINT cb
, int *err
, void *pv
)
286 HANDLE handle
= (HANDLE
)hf
;
290 res
= WriteFile(handle
, memory
, cb
, &dwWritten
, NULL
);
291 ok(res
, "Failed to WriteFile\n");
296 static int CDECL
fci_close(INT_PTR hf
, int *err
, void *pv
)
298 HANDLE handle
= (HANDLE
)hf
;
299 ok(CloseHandle(handle
), "Failed to CloseHandle\n");
304 static LONG CDECL
fci_seek(INT_PTR hf
, LONG dist
, int seektype
, int *err
, void *pv
)
306 HANDLE handle
= (HANDLE
)hf
;
309 ret
= SetFilePointer(handle
, dist
, NULL
, seektype
);
310 ok(ret
!= INVALID_SET_FILE_POINTER
, "Failed to SetFilePointer\n");
315 static int CDECL
fci_delete(char *pszFile
, int *err
, void *pv
)
317 BOOL ret
= DeleteFileA(pszFile
);
318 ok(ret
, "Failed to DeleteFile %s\n", pszFile
);
323 static BOOL CDECL
get_temp_file(char *pszTempName
, int cbTempName
, void *pv
)
327 tempname
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
328 GetTempFileNameA(".", "xx", 0, tempname
);
330 if (tempname
&& (strlen(tempname
) < (unsigned)cbTempName
))
332 lstrcpyA(pszTempName
, tempname
);
333 HeapFree(GetProcessHeap(), 0, tempname
);
337 HeapFree(GetProcessHeap(), 0, tempname
);
342 static INT_PTR CDECL
get_open_info(char *pszName
, USHORT
*pdate
, USHORT
*ptime
,
343 USHORT
*pattribs
, int *err
, void *pv
)
345 BY_HANDLE_FILE_INFORMATION finfo
;
351 handle
= CreateFileA(pszName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
352 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
| FILE_FLAG_SEQUENTIAL_SCAN
, NULL
);
353 ok(handle
!= INVALID_HANDLE_VALUE
, "Failed to CreateFile %s\n", pszName
);
355 res
= GetFileInformationByHandle(handle
, &finfo
);
356 ok(res
, "Expected GetFileInformationByHandle to succeed\n");
358 FileTimeToLocalFileTime(&finfo
.ftLastWriteTime
, &filetime
);
359 FileTimeToDosDateTime(&filetime
, pdate
, ptime
);
361 attrs
= GetFileAttributesA(pszName
);
362 ok(attrs
!= INVALID_FILE_ATTRIBUTES
, "Failed to GetFileAttributes\n");
364 return (INT_PTR
)handle
;
367 static BOOL
add_file(HFCI hfci
, const char *file
, TCOMP compress
)
370 char filename
[MAX_PATH
];
372 lstrcpyA(path
, CURR_DIR
);
373 lstrcatA(path
, "\\");
374 lstrcatA(path
, file
);
376 lstrcpyA(filename
, file
);
378 return FCIAddFile(hfci
, path
, filename
, FALSE
, get_next_cabinet
,
379 progress
, get_open_info
, compress
);
382 static void set_cab_parameters(PCCAB pCabParams
, const CHAR
*name
, DWORD max_size
)
384 ZeroMemory(pCabParams
, sizeof(CCAB
));
386 pCabParams
->cb
= max_size
;
387 pCabParams
->cbFolderThresh
= FOLDER_THRESHOLD
;
388 pCabParams
->setID
= 0xbeef;
389 pCabParams
->iCab
= 1;
390 lstrcpyA(pCabParams
->szCabPath
, CURR_DIR
);
391 lstrcatA(pCabParams
->szCabPath
, "\\");
392 lstrcpyA(pCabParams
->szCab
, name
);
395 static void create_cab_file(const CHAR
*name
, DWORD max_size
, const CHAR
*files
)
403 set_cab_parameters(&cabParams
, name
, max_size
);
405 hfci
= FCICreate(&erf
, file_placed
, mem_alloc
, mem_free
, fci_open
,
406 fci_read
, fci_write
, fci_close
, fci_seek
, fci_delete
,
407 get_temp_file
, &cabParams
, NULL
);
409 ok(hfci
!= NULL
, "Failed to create an FCI context\n");
414 res
= add_file(hfci
, ptr
, tcompTYPE_MSZIP
);
415 ok(res
, "Failed to add file: %s\n", ptr
);
416 ptr
+= lstrlenA(ptr
) + 1;
419 res
= FCIFlushCabinet(hfci
, FALSE
, get_next_cabinet
, progress
);
420 ok(res
, "Failed to flush the cabinet\n");
422 res
= FCIDestroy(hfci
);
423 ok(res
, "Failed to destroy the cabinet\n");
426 static BOOL
add_cabinet_storage(LPCSTR db
, LPCSTR cabinet
)
428 WCHAR dbW
[MAX_PATH
], cabinetW
[MAX_PATH
];
434 MultiByteToWideChar(CP_ACP
, 0, db
, -1, dbW
, MAX_PATH
);
435 hr
= StgOpenStorage(dbW
, NULL
, STGM_DIRECT
|STGM_READWRITE
|STGM_SHARE_EXCLUSIVE
, NULL
, 0, &stg
);
439 MultiByteToWideChar(CP_ACP
, 0, cabinet
, -1, cabinetW
, MAX_PATH
);
440 hr
= IStorage_CreateStream(stg
, cabinetW
, STGM_WRITE
|STGM_SHARE_EXCLUSIVE
, 0, 0, &stm
);
443 IStorage_Release(stg
);
447 handle
= CreateFileW(cabinetW
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
448 if (handle
!= INVALID_HANDLE_VALUE
)
452 if (ReadFile(handle
, buffer
, sizeof(buffer
), &count
, NULL
))
453 IStream_Write(stm
, buffer
, count
, &count
);
457 IStream_Release(stm
);
458 IStorage_Release(stg
);
463 static void delete_cab_files(void)
465 SHFILEOPSTRUCTA shfl
;
466 CHAR path
[MAX_PATH
+10];
468 lstrcpyA(path
, CURR_DIR
);
469 lstrcatA(path
, "\\*.cab");
470 path
[strlen(path
) + 1] = '\0';
473 shfl
.wFunc
= FO_DELETE
;
476 shfl
.fFlags
= FOF_FILESONLY
| FOF_NOCONFIRMATION
| FOF_NORECURSION
| FOF_SILENT
;
478 SHFileOperationA(&shfl
);
481 /* msi database data */
483 static const char directory_dat
[] =
484 "Directory\tDirectory_Parent\tDefaultDir\n"
486 "Directory\tDirectory\n"
487 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
488 "ProgramFilesFolder\tTARGETDIR\t.\n"
489 "TARGETDIR\t\tSourceDir";
491 static const char component_dat
[] =
492 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
493 "s72\tS38\ts72\ti2\tS255\tS72\n"
494 "Component\tComponent\n"
495 "One\t{8F5BAEEF-DD92-40AC-9397-BE3CF9F97C81}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n";
497 static const char feature_dat
[] =
498 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
499 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
501 "One\t\tOne\tOne\t1\t3\tMSITESTDIR\t0\n"
502 "Two\t\t\t\t2\t1\tTARGETDIR\t0\n";
504 static const char feature_comp_dat
[] =
505 "Feature_\tComponent_\n"
507 "FeatureComponents\tFeature_\tComponent_\n"
510 static const char file_dat
[] =
511 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
512 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
514 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n";
516 static const char install_exec_seq_dat
[] =
517 "Action\tCondition\tSequence\n"
519 "InstallExecuteSequence\tAction\n"
520 "ValidateProductID\t\t700\n"
521 "CostInitialize\t\t800\n"
523 "CostFinalize\t\t1000\n"
524 "InstallValidate\t\t1400\n"
525 "InstallInitialize\t\t1500\n"
526 "ProcessComponents\t\t1600\n"
527 "UnpublishFeatures\t\t1800\n"
528 "RemoveFiles\t\t3500\n"
529 "InstallFiles\t\t4000\n"
530 "RegisterProduct\t\t6100\n"
531 "PublishFeatures\t\t6300\n"
532 "PublishProduct\t\t6400\n"
533 "InstallFinalize\t\t6600";
535 static const char media_dat
[] =
536 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
537 "i2\ti4\tL64\tS255\tS32\tS72\n"
539 "1\t1\t\t\tDISK1\t\n";
541 static const char property_dat
[] =
544 "Property\tProperty\n"
546 "Manufacturer\tWine\n"
547 "ProductCode\t{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}\n"
548 "ProductName\tMSITEST\n"
549 "ProductVersion\t1.1.1\n"
550 "UpgradeCode\t{9574448F-9B86-4E07-B6F6-8D199DA12127}\n"
551 "MSIFASTINSTALL\t1\n";
553 static const char mcp_component_dat
[] =
554 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
555 "s72\tS38\ts72\ti2\tS255\tS72\n"
556 "Component\tComponent\n"
557 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
558 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
559 "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";
561 static const char mcp_feature_dat
[] =
562 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
563 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
565 "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
566 "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
567 "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";
569 static const char mcp_feature_comp_dat
[] =
570 "Feature_\tComponent_\n"
572 "FeatureComponents\tFeature_\tComponent_\n"
573 "hydroxyl\thydrogen\n"
577 static const char mcp_file_dat
[] =
578 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
579 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
581 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
582 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
583 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
585 static const char lus_component_dat
[] =
586 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
587 "s72\tS38\ts72\ti2\tS255\tS72\n"
588 "Component\tComponent\n"
589 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
591 static const char lus_feature_dat
[] =
592 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
593 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
595 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
596 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
598 static const char lus_file_dat
[] =
599 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
600 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
602 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
604 static const char lus_feature_comp_dat
[] =
605 "Feature_\tComponent_\n"
607 "FeatureComponents\tFeature_\tComponent_\n"
609 "montecristo\tmaximus";
611 static const char lus_install_exec_seq_dat
[] =
612 "Action\tCondition\tSequence\n"
614 "InstallExecuteSequence\tAction\n"
615 "ValidateProductID\t\t700\n"
616 "CostInitialize\t\t800\n"
618 "CostFinalize\t\t1000\n"
619 "InstallValidate\t\t1400\n"
620 "InstallInitialize\t\t1500\n"
621 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
622 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
623 "RemoveFiles\t\t3500\n"
624 "InstallFiles\t\t4000\n"
625 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
626 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
627 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
628 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
629 "InstallFinalize\t\t6600";
631 static const char lus0_media_dat
[] =
632 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
633 "i2\ti4\tL64\tS255\tS32\tS72\n"
635 "1\t1\t\t\tDISK1\t\n";
637 static const char lus1_media_dat
[] =
638 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
639 "i2\ti4\tL64\tS255\tS32\tS72\n"
641 "1\t1\t\ttest1.cab\tDISK1\t\n";
643 static const char lus2_media_dat
[] =
644 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
645 "i2\ti4\tL64\tS255\tS32\tS72\n"
647 "1\t1\t\t#test1.cab\tDISK1\t\n";
649 static const char spf_custom_action_dat
[] =
650 "Action\tType\tSource\tTarget\tISComments\n"
651 "s72\ti2\tS64\tS0\tS255\n"
652 "CustomAction\tAction\n"
653 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
655 static const char spf_install_exec_seq_dat
[] =
656 "Action\tCondition\tSequence\n"
658 "InstallExecuteSequence\tAction\n"
659 "CostFinalize\t\t1000\n"
660 "CostInitialize\t\t800\n"
662 "SetFolderProp\t\t950\n"
663 "InstallFiles\t\t4000\n"
664 "InstallServices\t\t5000\n"
665 "InstallFinalize\t\t6600\n"
666 "InstallInitialize\t\t1500\n"
667 "InstallValidate\t\t1400\n"
668 "LaunchConditions\t\t100";
670 static const char spf_install_ui_seq_dat
[] =
671 "Action\tCondition\tSequence\n"
673 "InstallUISequence\tAction\n"
674 "CostInitialize\t\t800\n"
676 "CostFinalize\t\t1000\n"
677 "ExecuteAction\t\t1100\n";
679 static const char sd_file_dat
[] =
680 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
681 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
683 "sourcedir.txt\tsourcedir\tsourcedir.txt\t1000\t\t\t8192\t1\n";
685 static const char sd_feature_dat
[] =
686 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
687 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
689 "sourcedir\t\t\tsourcedir feature\t1\t2\tMSITESTDIR\t0\n";
691 static const char sd_feature_comp_dat
[] =
692 "Feature_\tComponent_\n"
694 "FeatureComponents\tFeature_\tComponent_\n"
695 "sourcedir\tsourcedir\n";
697 static const char sd_component_dat
[] =
698 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
699 "s72\tS38\ts72\ti2\tS255\tS72\n"
700 "Component\tComponent\n"
701 "sourcedir\t{DD422F92-3ED8-49B5-A0B7-F266F98357DF}\tMSITESTDIR\t0\t\tsourcedir.txt\n";
703 static const char sd_install_ui_seq_dat
[] =
704 "Action\tCondition\tSequence\n"
706 "InstallUISequence\tAction\n"
707 "TestSourceDirProp1\tnot SourceDir and not SOURCEDIR and not Installed\t99\n"
709 "TestSourceDirProp2\tnot SourceDir and not SOURCEDIR and not Installed\t101\n"
710 "LaunchConditions\tnot Installed \t110\n"
711 "TestSourceDirProp3\tnot SourceDir and not SOURCEDIR and not Installed\t111\n"
712 "FindRelatedProducts\t\t120\n"
713 "TestSourceDirProp4\tnot SourceDir and not SOURCEDIR and not Installed\t121\n"
715 "TestSourceDirProp5\tnot SourceDir and not SOURCEDIR and not Installed\t131\n"
716 "RMCCPSearch\t\t140\n"
717 "TestSourceDirProp6\tnot SourceDir and not SOURCEDIR and not Installed\t141\n"
718 "ValidateProductID\t\t150\n"
719 "TestSourceDirProp7\tnot SourceDir and not SOURCEDIR and not Installed\t151\n"
720 "CostInitialize\t\t800\n"
721 "TestSourceDirProp8\tnot SourceDir and not SOURCEDIR and not Installed\t801\n"
723 "TestSourceDirProp9\tnot SourceDir and not SOURCEDIR and not Installed\t901\n"
724 "IsolateComponents\t\t1000\n"
725 "TestSourceDirProp10\tnot SourceDir and not SOURCEDIR and not Installed\t1001\n"
726 "CostFinalize\t\t1100\n"
727 "TestSourceDirProp11\tnot SourceDir and not SOURCEDIR and not Installed\t1101\n"
728 "MigrateFeatureStates\t\t1200\n"
729 "TestSourceDirProp12\tnot SourceDir and not SOURCEDIR and not Installed\t1201\n"
730 "ExecuteAction\t\t1300\n"
731 "TestSourceDirProp13\tnot SourceDir and not SOURCEDIR and not Installed\t1301\n";
733 static const char sd_install_exec_seq_dat
[] =
734 "Action\tCondition\tSequence\n"
736 "InstallExecuteSequence\tAction\n"
737 "TestSourceDirProp14\tSourceDir and SOURCEDIR and not Installed\t99\n"
738 "LaunchConditions\t\t100\n"
739 "TestSourceDirProp15\tSourceDir and SOURCEDIR and not Installed\t101\n"
740 "ValidateProductID\t\t700\n"
741 "TestSourceDirProp16\tSourceDir and SOURCEDIR and not Installed\t701\n"
742 "CostInitialize\t\t800\n"
743 "TestSourceDirProp17\tSourceDir and SOURCEDIR and not Installed\t801\n"
744 "ResolveSource\tResolveSource and not Installed\t850\n"
745 "TestSourceDirProp18\tResolveSource and not SourceDir and not SOURCEDIR and not Installed\t851\n"
746 "TestSourceDirProp19\tnot ResolveSource and SourceDir and SOURCEDIR and not Installed\t852\n"
748 "TestSourceDirProp20\tSourceDir and SOURCEDIR and not Installed\t901\n"
749 "IsolateComponents\t\t1000\n"
750 "TestSourceDirProp21\tSourceDir and SOURCEDIR and not Installed\t1001\n"
751 "CostFinalize\t\t1100\n"
752 "TestSourceDirProp22\tSourceDir and SOURCEDIR and not Installed\t1101\n"
753 "MigrateFeatureStates\t\t1200\n"
754 "TestSourceDirProp23\tSourceDir and SOURCEDIR and not Installed\t1201\n"
755 "InstallValidate\t\t1400\n"
756 "TestSourceDirProp24\tSourceDir and SOURCEDIR and not Installed\t1401\n"
757 "InstallInitialize\t\t1500\n"
758 "TestSourceDirProp25\tSourceDir and SOURCEDIR and not Installed\t1501\n"
759 "ProcessComponents\t\t1600\n"
760 "TestSourceDirProp26\tnot SourceDir and not SOURCEDIR and not Installed\t1601\n"
761 "UnpublishFeatures\t\t1800\n"
762 "TestSourceDirProp27\tnot SourceDir and not SOURCEDIR and not Installed\t1801\n"
763 "RemoveFiles\t\t3500\n"
764 "TestSourceDirProp28\tnot SourceDir and not SOURCEDIR and not Installed\t3501\n"
765 "InstallFiles\t\t4000\n"
766 "TestSourceDirProp29\tnot SourceDir and not SOURCEDIR and not Installed\t4001\n"
767 "RegisterUser\t\t6000\n"
768 "TestSourceDirProp30\tnot SourceDir and not SOURCEDIR and not Installed\t6001\n"
769 "RegisterProduct\t\t6100\n"
770 "TestSourceDirProp31\tnot SourceDir and not SOURCEDIR and not Installed\t6101\n"
771 "PublishFeatures\t\t6300\n"
772 "TestSourceDirProp32\tnot SourceDir and not SOURCEDIR and not Installed\t6301\n"
773 "PublishProduct\t\t6400\n"
774 "TestSourceDirProp33\tnot SourceDir and not SOURCEDIR and not Installed\t6401\n"
775 "InstallExecute\t\t6500\n"
776 "TestSourceDirProp34\tnot SourceDir and not SOURCEDIR and not Installed\t6501\n"
777 "InstallFinalize\t\t6600\n"
778 "TestSourceDirProp35\tnot SourceDir and not SOURCEDIR and not Installed\t6601\n";
780 static const char sd_custom_action_dat
[] =
781 "Action\tType\tSource\tTarget\tISComments\n"
782 "s72\ti2\tS64\tS0\tS255\n"
783 "CustomAction\tAction\n"
784 "TestSourceDirProp1\t19\t\tTest 1 failed\t\n"
785 "TestSourceDirProp2\t19\t\tTest 2 failed\t\n"
786 "TestSourceDirProp3\t19\t\tTest 3 failed\t\n"
787 "TestSourceDirProp4\t19\t\tTest 4 failed\t\n"
788 "TestSourceDirProp5\t19\t\tTest 5 failed\t\n"
789 "TestSourceDirProp6\t19\t\tTest 6 failed\t\n"
790 "TestSourceDirProp7\t19\t\tTest 7 failed\t\n"
791 "TestSourceDirProp8\t19\t\tTest 8 failed\t\n"
792 "TestSourceDirProp9\t19\t\tTest 9 failed\t\n"
793 "TestSourceDirProp10\t19\t\tTest 10 failed\t\n"
794 "TestSourceDirProp11\t19\t\tTest 11 failed\t\n"
795 "TestSourceDirProp12\t19\t\tTest 12 failed\t\n"
796 "TestSourceDirProp13\t19\t\tTest 13 failed\t\n"
797 "TestSourceDirProp14\t19\t\tTest 14 failed\t\n"
798 "TestSourceDirProp15\t19\t\tTest 15 failed\t\n"
799 "TestSourceDirProp16\t19\t\tTest 16 failed\t\n"
800 "TestSourceDirProp17\t19\t\tTest 17 failed\t\n"
801 "TestSourceDirProp18\t19\t\tTest 18 failed\t\n"
802 "TestSourceDirProp19\t19\t\tTest 19 failed\t\n"
803 "TestSourceDirProp20\t19\t\tTest 20 failed\t\n"
804 "TestSourceDirProp21\t19\t\tTest 21 failed\t\n"
805 "TestSourceDirProp22\t19\t\tTest 22 failed\t\n"
806 "TestSourceDirProp23\t19\t\tTest 23 failed\t\n"
807 "TestSourceDirProp24\t19\t\tTest 24 failed\t\n"
808 "TestSourceDirProp25\t19\t\tTest 25 failed\t\n"
809 "TestSourceDirProp26\t19\t\tTest 26 failed\t\n"
810 "TestSourceDirProp27\t19\t\tTest 27 failed\t\n"
811 "TestSourceDirProp28\t19\t\tTest 28 failed\t\n"
812 "TestSourceDirProp29\t19\t\tTest 29 failed\t\n"
813 "TestSourceDirProp30\t19\t\tTest 30 failed\t\n"
814 "TestSourceDirProp31\t19\t\tTest 31 failed\t\n"
815 "TestSourceDirProp32\t19\t\tTest 32 failed\t\n"
816 "TestSourceDirProp33\t19\t\tTest 33 failed\t\n"
817 "TestSourceDirProp34\t19\t\tTest 34 failed\t\n"
818 "TestSourceDirProp35\t19\t\tTest 35 failed\t\n";
820 static const char ci_install_exec_seq_dat
[] =
821 "Action\tCondition\tSequence\n"
823 "InstallExecuteSequence\tAction\n"
824 "CostFinalize\t\t1000\n"
825 "CostInitialize\t\t800\n"
827 "InstallFiles\t\t4000\n"
828 "InstallServices\t\t5000\n"
829 "InstallFinalize\t\t6600\n"
830 "InstallInitialize\t\t1500\n"
831 "RunInstall\t\t1600\n"
832 "InstallValidate\t\t1400\n"
833 "LaunchConditions\t\t100";
835 static const char ci_custom_action_dat
[] =
836 "Action\tType\tSource\tTarget\tISComments\n"
837 "s72\ti2\tS64\tS0\tS255\n"
838 "CustomAction\tAction\n"
839 "RunInstall\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
841 static const char ci_component_dat
[] =
842 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
843 "s72\tS38\ts72\ti2\tS255\tS72\n"
844 "Component\tComponent\n"
845 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
847 static const char ci2_component_dat
[] =
848 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
849 "s72\tS38\ts72\ti2\tS255\tS72\n"
850 "Component\tComponent\n"
851 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
853 static const char ci2_feature_comp_dat
[] =
854 "Feature_\tComponent_\n"
856 "FeatureComponents\tFeature_\tComponent_\n"
859 static const char ci2_file_dat
[] =
860 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
861 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
863 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
865 static const char cl_custom_action_dat
[] =
866 "Action\tType\tSource\tTarget\tISComments\n"
867 "s72\ti2\tS64\tS0\tS255\n"
868 "CustomAction\tAction\n"
869 "TestCommandlineProp\t19\t\tTest1\t\n";
871 static const char cl_install_exec_seq_dat
[] =
872 "Action\tCondition\tSequence\n"
874 "InstallExecuteSequence\tAction\n"
875 "LaunchConditions\t\t100\n"
876 "ValidateProductID\t\t700\n"
877 "CostInitialize\t\t800\n"
879 "CostFinalize\t\t1000\n"
880 "TestCommandlineProp\tP=\"one\"\t1100\n"
881 "InstallInitialize\t\t1500\n"
882 "ProcessComponents\t\t1600\n"
883 "InstallValidate\t\t1400\n"
884 "InstallFinalize\t\t5000\n";
886 typedef struct _msi_table
888 const CHAR
*filename
;
893 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
895 static const msi_table tables
[] =
897 ADD_TABLE(directory
),
898 ADD_TABLE(component
),
900 ADD_TABLE(feature_comp
),
902 ADD_TABLE(install_exec_seq
),
907 static const msi_table mcp_tables
[] =
909 ADD_TABLE(directory
),
910 ADD_TABLE(mcp_component
),
911 ADD_TABLE(mcp_feature
),
912 ADD_TABLE(mcp_feature_comp
),
914 ADD_TABLE(install_exec_seq
),
919 static const msi_table lus0_tables
[] =
921 ADD_TABLE(lus_component
),
922 ADD_TABLE(directory
),
923 ADD_TABLE(lus_feature
),
924 ADD_TABLE(lus_feature_comp
),
926 ADD_TABLE(lus_install_exec_seq
),
927 ADD_TABLE(lus0_media
),
931 static const msi_table lus1_tables
[] =
933 ADD_TABLE(lus_component
),
934 ADD_TABLE(directory
),
935 ADD_TABLE(lus_feature
),
936 ADD_TABLE(lus_feature_comp
),
938 ADD_TABLE(lus_install_exec_seq
),
939 ADD_TABLE(lus1_media
),
943 static const msi_table lus2_tables
[] =
945 ADD_TABLE(lus_component
),
946 ADD_TABLE(directory
),
947 ADD_TABLE(lus_feature
),
948 ADD_TABLE(lus_feature_comp
),
950 ADD_TABLE(lus_install_exec_seq
),
951 ADD_TABLE(lus2_media
),
955 static const msi_table spf_tables
[] =
957 ADD_TABLE(lus_component
),
958 ADD_TABLE(directory
),
959 ADD_TABLE(lus_feature
),
960 ADD_TABLE(lus_feature_comp
),
962 ADD_TABLE(lus0_media
),
964 ADD_TABLE(spf_custom_action
),
965 ADD_TABLE(spf_install_exec_seq
),
966 ADD_TABLE(spf_install_ui_seq
)
969 static const msi_table sd_tables
[] =
971 ADD_TABLE(directory
),
972 ADD_TABLE(sd_component
),
973 ADD_TABLE(sd_feature
),
974 ADD_TABLE(sd_feature_comp
),
976 ADD_TABLE(sd_install_exec_seq
),
977 ADD_TABLE(sd_install_ui_seq
),
978 ADD_TABLE(sd_custom_action
),
983 static const msi_table ci_tables
[] =
985 ADD_TABLE(ci_component
),
986 ADD_TABLE(directory
),
987 ADD_TABLE(lus_feature
),
988 ADD_TABLE(lus_feature_comp
),
990 ADD_TABLE(ci_install_exec_seq
),
991 ADD_TABLE(lus0_media
),
993 ADD_TABLE(ci_custom_action
),
996 static const msi_table ci2_tables
[] =
998 ADD_TABLE(ci2_component
),
999 ADD_TABLE(directory
),
1000 ADD_TABLE(lus_feature
),
1001 ADD_TABLE(ci2_feature_comp
),
1002 ADD_TABLE(ci2_file
),
1003 ADD_TABLE(install_exec_seq
),
1004 ADD_TABLE(lus0_media
),
1005 ADD_TABLE(property
),
1008 static const msi_table cl_tables
[] =
1010 ADD_TABLE(component
),
1011 ADD_TABLE(directory
),
1013 ADD_TABLE(feature_comp
),
1015 ADD_TABLE(cl_custom_action
),
1016 ADD_TABLE(cl_install_exec_seq
),
1021 static void write_file(const CHAR
*filename
, const char *data
, int data_size
)
1025 HANDLE hf
= CreateFileA(filename
, GENERIC_WRITE
, 0, NULL
,
1026 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1027 WriteFile(hf
, data
, data_size
, &size
, NULL
);
1031 static void write_msi_summary_info(MSIHANDLE db
, INT version
, INT wordcount
, const char *template)
1036 r
= MsiGetSummaryInformationA(db
, NULL
, 5, &summary
);
1037 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1039 r
= MsiSummaryInfoSetPropertyA(summary
, PID_TEMPLATE
, VT_LPSTR
, 0, NULL
, template);
1040 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1042 r
= MsiSummaryInfoSetPropertyA(summary
, PID_REVNUMBER
, VT_LPSTR
, 0, NULL
,
1043 "{004757CA-5092-49C2-AD20-28E1CE0DF5F2}");
1044 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1046 r
= MsiSummaryInfoSetPropertyA(summary
, PID_PAGECOUNT
, VT_I4
, version
, NULL
, NULL
);
1047 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1049 r
= MsiSummaryInfoSetPropertyA(summary
, PID_WORDCOUNT
, VT_I4
, wordcount
, NULL
, NULL
);
1050 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1052 r
= MsiSummaryInfoSetPropertyA(summary
, PID_TITLE
, VT_LPSTR
, 0, NULL
, "MSITEST");
1053 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1055 /* write the summary changes back to the stream */
1056 r
= MsiSummaryInfoPersist(summary
);
1057 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1059 MsiCloseHandle(summary
);
1062 #define create_database(name, tables, num_tables) \
1063 create_database_wordcount(name, tables, num_tables, 100, 0, ";1033");
1065 #define create_database_template(name, tables, num_tables, version, template) \
1066 create_database_wordcount(name, tables, num_tables, version, 0, template);
1068 static void create_database_wordcount(const CHAR
*name
, const msi_table
*tables
,
1069 int num_tables
, INT version
, INT wordcount
,
1070 const char *template)
1077 len
= MultiByteToWideChar( CP_ACP
, 0, name
, -1, NULL
, 0 );
1078 if (!(nameW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) ))) return;
1079 MultiByteToWideChar( CP_ACP
, 0, name
, -1, nameW
, len
);
1081 r
= MsiOpenDatabaseW(nameW
, MSIDBOPEN_CREATE
, &db
);
1082 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1084 /* import the tables into the database */
1085 for (j
= 0; j
< num_tables
; j
++)
1087 const msi_table
*table
= &tables
[j
];
1089 write_file(table
->filename
, table
->data
, (table
->size
- 1) * sizeof(char));
1091 r
= MsiDatabaseImportA(db
, CURR_DIR
, table
->filename
);
1092 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1094 DeleteFileA(table
->filename
);
1097 write_msi_summary_info(db
, version
, wordcount
, template);
1099 r
= MsiDatabaseCommit(db
);
1100 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
1103 HeapFree( GetProcessHeap(), 0, nameW
);
1106 static UINT
run_query(MSIHANDLE hdb
, const char *query
)
1108 MSIHANDLE hview
= 0;
1111 r
= MsiDatabaseOpenViewA(hdb
, query
, &hview
);
1112 if (r
!= ERROR_SUCCESS
)
1115 r
= MsiViewExecute(hview
, 0);
1116 if (r
== ERROR_SUCCESS
)
1117 r
= MsiViewClose(hview
);
1118 MsiCloseHandle(hview
);
1122 static UINT
set_summary_info(MSIHANDLE hdb
, LPSTR prodcode
)
1127 /* build summary info */
1128 res
= MsiGetSummaryInformationA(hdb
, NULL
, 7, &suminfo
);
1129 ok(res
== ERROR_SUCCESS
, "Failed to open summaryinfo\n");
1131 res
= MsiSummaryInfoSetPropertyA(suminfo
, 2, VT_LPSTR
, 0, NULL
,
1132 "Installation Database");
1133 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1135 res
= MsiSummaryInfoSetPropertyA(suminfo
, 3, VT_LPSTR
, 0, NULL
,
1136 "Installation Database");
1137 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1139 res
= MsiSummaryInfoSetPropertyA(suminfo
, 4, VT_LPSTR
, 0, NULL
,
1141 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1143 res
= MsiSummaryInfoSetPropertyA(suminfo
, 7, VT_LPSTR
, 0, NULL
,
1145 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1147 res
= MsiSummaryInfoSetPropertyA(suminfo
, PID_REVNUMBER
, VT_LPSTR
, 0, NULL
,
1148 "{A2078D65-94D6-4205-8DEE-F68D6FD622AA}");
1149 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1151 res
= MsiSummaryInfoSetPropertyA(suminfo
, 14, VT_I4
, 100, NULL
, NULL
);
1152 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1154 res
= MsiSummaryInfoSetPropertyA(suminfo
, 15, VT_I4
, 0, NULL
, NULL
);
1155 ok(res
== ERROR_SUCCESS
, "Failed to set summary info\n");
1157 res
= MsiSummaryInfoPersist(suminfo
);
1158 ok(res
== ERROR_SUCCESS
, "Failed to make summary info persist\n");
1160 res
= MsiCloseHandle(suminfo
);
1161 ok(res
== ERROR_SUCCESS
, "Failed to close suminfo\n");
1166 static MSIHANDLE
create_package_db(LPSTR prodcode
)
1169 CHAR query
[MAX_PATH
];
1172 DeleteFileA(msifile
);
1174 /* create an empty database */
1175 res
= MsiOpenDatabaseW(msifileW
, MSIDBOPEN_CREATE
, &hdb
);
1176 ok( res
== ERROR_SUCCESS
, "Failed to create database\n" );
1177 if (res
!= ERROR_SUCCESS
)
1180 res
= MsiDatabaseCommit(hdb
);
1181 ok(res
== ERROR_SUCCESS
, "Failed to commit database\n");
1183 set_summary_info(hdb
, prodcode
);
1185 res
= run_query(hdb
,
1186 "CREATE TABLE `Directory` ( "
1187 "`Directory` CHAR(255) NOT NULL, "
1188 "`Directory_Parent` CHAR(255), "
1189 "`DefaultDir` CHAR(255) NOT NULL "
1190 "PRIMARY KEY `Directory`)");
1191 ok(res
== ERROR_SUCCESS
, "Failed to create directory table\n");
1193 res
= run_query(hdb
,
1194 "CREATE TABLE `Property` ( "
1195 "`Property` CHAR(72) NOT NULL, "
1196 "`Value` CHAR(255) "
1197 "PRIMARY KEY `Property`)");
1198 ok(res
== ERROR_SUCCESS
, "Failed to create directory table\n");
1200 sprintf(query
, "INSERT INTO `Property` "
1201 "(`Property`, `Value`) "
1202 "VALUES( 'ProductCode', '%s' )", prodcode
);
1203 res
= run_query(hdb
, query
);
1204 ok(res
== ERROR_SUCCESS
, "Failed\n");
1206 res
= MsiDatabaseCommit(hdb
);
1207 ok(res
== ERROR_SUCCESS
, "Failed to commit database\n");
1212 static void test_usefeature(void)
1216 if (!pMsiUseFeatureExA
)
1218 win_skip("MsiUseFeatureExA not implemented\n");
1222 r
= MsiQueryFeatureStateA(NULL
, NULL
);
1223 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1225 r
= MsiQueryFeatureStateA("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL
);
1226 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1228 r
= pMsiUseFeatureExA(NULL
,NULL
,0,0);
1229 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1231 r
= pMsiUseFeatureExA(NULL
, "WORDVIEWFiles", -2, 1 );
1232 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1234 r
= pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
1236 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1238 r
= pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
1239 "WORDVIEWFiles", -2, 0 );
1240 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1242 r
= pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
1243 "WORDVIEWFiles", -2, 0 );
1244 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1246 r
= pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
1247 "WORDVIEWFiles", -2, 1 );
1248 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return val\n");
1251 static LONG
delete_key( HKEY key
, LPCSTR subkey
, REGSAM access
)
1253 if (pRegDeleteKeyExA
)
1254 return pRegDeleteKeyExA( key
, subkey
, access
, 0 );
1255 return RegDeleteKeyA( key
, subkey
);
1258 static void test_null(void)
1263 DWORD dwType
, cbData
;
1264 LPBYTE lpData
= NULL
;
1266 REGSAM access
= KEY_ALL_ACCESS
;
1269 access
|= KEY_WOW64_64KEY
;
1271 r
= pMsiOpenPackageExW(NULL
, 0, &hpkg
);
1272 ok( r
== ERROR_INVALID_PARAMETER
,"wrong error\n");
1274 state
= MsiQueryProductStateW(NULL
);
1275 ok( state
== INSTALLSTATE_INVALIDARG
, "wrong return\n");
1277 r
= MsiEnumFeaturesW(NULL
,0,NULL
,NULL
);
1278 ok( r
== ERROR_INVALID_PARAMETER
,"wrong error\n");
1280 r
= MsiConfigureFeatureW(NULL
, NULL
, 0);
1281 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error\n");
1283 r
= MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL
, 0);
1284 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error\n");
1286 r
= MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000001}", "foo", 0);
1287 ok( r
== ERROR_INVALID_PARAMETER
, "wrong error %d\n", r
);
1289 r
= MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000002}", "foo", INSTALLSTATE_DEFAULT
);
1290 ok( r
== ERROR_UNKNOWN_PRODUCT
, "wrong error %d\n", r
);
1292 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
1293 * necessary registry values */
1295 /* empty product string */
1296 r
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, access
, &hkey
);
1297 if (r
== ERROR_ACCESS_DENIED
)
1299 skip("Not enough rights to perform tests\n");
1302 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1304 r
= RegQueryValueExA(hkey
, NULL
, 0, &dwType
, lpData
, &cbData
);
1305 ok ( r
== ERROR_SUCCESS
|| r
== ERROR_FILE_NOT_FOUND
, "wrong error %d\n", r
);
1306 if ( r
== ERROR_SUCCESS
)
1308 lpData
= HeapAlloc(GetProcessHeap(), 0, cbData
);
1310 skip("Out of memory\n");
1313 r
= RegQueryValueExA(hkey
, NULL
, 0, &dwType
, lpData
, &cbData
);
1314 ok ( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1318 r
= RegSetValueA(hkey
, NULL
, REG_SZ
, "test", strlen("test"));
1319 if (r
== ERROR_ACCESS_DENIED
)
1321 skip("Not enough rights to perform tests\n");
1322 HeapFree(GetProcessHeap(), 0, lpData
);
1326 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1328 r
= MsiGetProductInfoA("", "", NULL
, NULL
);
1329 ok ( r
== ERROR_INVALID_PARAMETER
, "wrong error %d\n", r
);
1333 r
= RegSetValueExA(hkey
, NULL
, 0, dwType
, lpData
, cbData
);
1334 ok ( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1336 HeapFree(GetProcessHeap(), 0, lpData
);
1340 r
= RegDeleteValueA(hkey
, NULL
);
1341 ok ( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1344 r
= RegCloseKey(hkey
);
1345 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1347 /* empty attribute */
1348 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1349 0, NULL
, 0, access
, NULL
, &hkey
, NULL
);
1350 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1352 r
= RegSetValueA(hkey
, NULL
, REG_SZ
, "test", strlen("test"));
1353 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1355 r
= MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL
, NULL
);
1356 ok ( r
== ERROR_UNKNOWN_PROPERTY
, "wrong error %d\n", r
);
1358 r
= RegCloseKey(hkey
);
1359 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1361 r
= delete_key(HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1362 access
& KEY_WOW64_64KEY
);
1363 ok( r
== ERROR_SUCCESS
, "wrong error %d\n", r
);
1366 static void test_getcomponentpath(void)
1372 if(!pMsiGetComponentPathA
)
1375 r
= pMsiGetComponentPathA( NULL
, NULL
, NULL
, NULL
);
1376 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1378 r
= pMsiGetComponentPathA( "bogus", "bogus", NULL
, NULL
);
1379 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1381 r
= pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL
, NULL
);
1382 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1386 r
= pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer
, &sz
);
1387 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1389 r
= pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
1390 "{00000000-0000-0000-0000-000000000000}", buffer
, &sz
);
1391 ok( r
== INSTALLSTATE_UNKNOWN
, "wrong return value\n");
1393 r
= pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1394 "{00000000-0000-0000-0000-00000000}", buffer
, &sz
);
1395 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1397 r
= pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1398 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer
, &sz
);
1399 ok( r
== INSTALLSTATE_INVALIDARG
, "wrong return value\n");
1401 r
= pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
1402 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer
, &sz
);
1403 ok( r
== INSTALLSTATE_UNKNOWN
, "wrong return value\n");
1406 static void create_file(LPCSTR name
, LPCSTR data
, DWORD size
)
1411 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1412 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
1413 WriteFile(file
, data
, strlen(data
), &written
, NULL
);
1417 SetFilePointer(file
, size
, NULL
, FILE_BEGIN
);
1424 static void create_test_files(void)
1426 CreateDirectoryA("msitest", NULL
);
1427 create_file("msitest\\one.txt", "msitest\\one.txt", 100);
1428 CreateDirectoryA("msitest\\first", NULL
);
1429 create_file("msitest\\first\\two.txt", "msitest\\first\\two.txt", 100);
1430 CreateDirectoryA("msitest\\second", NULL
);
1431 create_file("msitest\\second\\three.txt", "msitest\\second\\three.txt", 100);
1433 create_file("four.txt", "four.txt", 100);
1434 create_file("five.txt", "five.txt", 100);
1435 create_cab_file("msitest.cab", MEDIA_SIZE
, "four.txt\0five.txt\0");
1437 create_file("msitest\\filename", "msitest\\filename", 100);
1438 create_file("msitest\\service.exe", "msitest\\service.exe", 100);
1440 DeleteFileA("four.txt");
1441 DeleteFileA("five.txt");
1444 static void delete_test_files(void)
1446 DeleteFileA("msitest.msi");
1447 DeleteFileA("msitest.cab");
1448 DeleteFileA("msitest\\second\\three.txt");
1449 DeleteFileA("msitest\\first\\two.txt");
1450 DeleteFileA("msitest\\one.txt");
1451 DeleteFileA("msitest\\service.exe");
1452 DeleteFileA("msitest\\filename");
1453 RemoveDirectoryA("msitest\\second");
1454 RemoveDirectoryA("msitest\\first");
1455 RemoveDirectoryA("msitest");
1458 #define HASHSIZE sizeof(MSIFILEHASHINFO)
1464 MSIFILEHASHINFO hash
;
1475 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
1479 { "C:\\Program Files\\msitest\\caesar\n", 0,
1481 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
1485 { "C:\\Program Files\\msitest\\caesar\n", 500,
1487 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
1492 static void test_MsiGetFileHash(void)
1494 const char name
[] = "msitest.bin";
1496 MSIFILEHASHINFO hash
;
1499 if (!pMsiGetFileHashA
)
1501 win_skip("MsiGetFileHash not implemented\n");
1505 hash
.dwFileHashInfoSize
= sizeof(MSIFILEHASHINFO
);
1507 /* szFilePath is NULL */
1508 r
= pMsiGetFileHashA(NULL
, 0, &hash
);
1509 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1511 /* szFilePath is empty */
1512 r
= pMsiGetFileHashA("", 0, &hash
);
1513 ok(r
== ERROR_PATH_NOT_FOUND
|| r
== ERROR_BAD_PATHNAME
,
1514 "Expected ERROR_PATH_NOT_FOUND or ERROR_BAD_PATHNAME, got %d\n", r
);
1516 /* szFilePath is nonexistent */
1517 r
= pMsiGetFileHashA(name
, 0, &hash
);
1518 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
1520 /* dwOptions is non-zero */
1521 r
= pMsiGetFileHashA(name
, 1, &hash
);
1522 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1524 /* pHash.dwFileHashInfoSize is not correct */
1525 hash
.dwFileHashInfoSize
= 0;
1526 r
= pMsiGetFileHashA(name
, 0, &hash
);
1527 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1530 r
= pMsiGetFileHashA(name
, 0, NULL
);
1531 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
1533 for (i
= 0; i
< sizeof(hash_data
) / sizeof(hash_data
[0]); i
++)
1537 create_file(name
, hash_data
[i
].data
, hash_data
[i
].size
);
1539 memset(&hash
, 0, sizeof(MSIFILEHASHINFO
));
1540 hash
.dwFileHashInfoSize
= sizeof(MSIFILEHASHINFO
);
1542 r
= pMsiGetFileHashA(name
, 0, &hash
);
1543 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
1545 ret
= memcmp(&hash
, &hash_data
[i
].hash
, HASHSIZE
);
1546 ok(!ret
, "Hash incorrect\n");
1552 /* copied from dlls/msi/registry.c */
1553 static BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
1558 if (FAILED(CLSIDFromString((LPCOLESTR
)in
, &guid
)))
1565 out
[11-i
] = in
[n
++];
1568 out
[15-i
] = in
[n
++];
1572 out
[17+i
*2] = in
[n
++];
1573 out
[16+i
*2] = in
[n
++];
1578 out
[17+i
*2] = in
[n
++];
1579 out
[16+i
*2] = in
[n
++];
1585 static void create_test_guid(LPSTR prodcode
, LPSTR squashed
)
1587 WCHAR guidW
[MAX_PATH
];
1588 WCHAR squashedW
[MAX_PATH
];
1593 hr
= CoCreateGuid(&guid
);
1594 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
1596 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
1597 ok(size
== 39, "Expected 39, got %d\n", hr
);
1599 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, prodcode
, MAX_PATH
, NULL
, NULL
);
1602 squash_guid(guidW
, squashedW
);
1603 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
1607 static char *get_user_sid(void)
1612 char *usersid
= NULL
;
1614 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &token
);
1615 GetTokenInformation(token
, TokenUser
, NULL
, size
, &size
);
1617 user
= HeapAlloc(GetProcessHeap(), 0, size
);
1618 GetTokenInformation(token
, TokenUser
, user
, size
, &size
);
1619 pConvertSidToStringSidA(user
->User
.Sid
, &usersid
);
1620 HeapFree(GetProcessHeap(), 0, user
);
1626 static void test_MsiQueryProductState(void)
1628 CHAR prodcode
[MAX_PATH
];
1629 CHAR prod_squashed
[MAX_PATH
];
1630 CHAR keypath
[MAX_PATH
*2];
1634 HKEY userkey
, localkey
, props
;
1637 REGSAM access
= KEY_ALL_ACCESS
;
1639 create_test_guid(prodcode
, prod_squashed
);
1640 usersid
= get_user_sid();
1643 access
|= KEY_WOW64_64KEY
;
1646 SetLastError(0xdeadbeef);
1647 state
= MsiQueryProductStateA(NULL
);
1648 error
= GetLastError();
1649 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1650 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1652 /* empty prodcode */
1653 SetLastError(0xdeadbeef);
1654 state
= MsiQueryProductStateA("");
1655 error
= GetLastError();
1656 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1657 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1659 /* garbage prodcode */
1660 SetLastError(0xdeadbeef);
1661 state
= MsiQueryProductStateA("garbage");
1662 error
= GetLastError();
1663 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1664 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1666 /* guid without brackets */
1667 SetLastError(0xdeadbeef);
1668 state
= MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
1669 error
= GetLastError();
1670 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
1671 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1673 /* guid with brackets */
1674 SetLastError(0xdeadbeef);
1675 state
= MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
1676 error
= GetLastError();
1677 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1678 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1679 "expected ERROR_SUCCESS, got %u\n", error
);
1681 /* same length as guid, but random */
1682 SetLastError(0xdeadbeef);
1683 state
= MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
1684 error
= GetLastError();
1685 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1686 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
1688 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1690 SetLastError(0xdeadbeef);
1691 state
= MsiQueryProductStateA(prodcode
);
1692 error
= GetLastError();
1693 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
1694 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1695 "expected ERROR_SUCCESS, got %u\n", error
);
1697 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
1698 lstrcatA(keypath
, prod_squashed
);
1700 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
1701 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1703 /* user product key 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 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
1712 lstrcatA(keypath
, prodcode
);
1714 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1715 if (res
== ERROR_ACCESS_DENIED
)
1717 skip("Not enough rights to perform tests\n");
1718 RegDeleteKeyA(userkey
, "");
1719 RegCloseKey(userkey
);
1723 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1725 /* local uninstall key exists */
1726 SetLastError(0xdeadbeef);
1727 state
= MsiQueryProductStateA(prodcode
);
1728 error
= GetLastError();
1729 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1730 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1731 "expected ERROR_SUCCESS, got %u\n", error
);
1734 res
= RegSetValueExA(localkey
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1735 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1737 /* WindowsInstaller value exists */
1738 SetLastError(0xdeadbeef);
1739 state
= MsiQueryProductStateA(prodcode
);
1740 error
= GetLastError();
1741 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1742 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1743 "expected ERROR_SUCCESS, got %u\n", error
);
1745 RegDeleteValueA(localkey
, "WindowsInstaller");
1746 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1748 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1749 lstrcatA(keypath
, usersid
);
1750 lstrcatA(keypath
, "\\Products\\");
1751 lstrcatA(keypath
, prod_squashed
);
1753 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1754 if (res
== ERROR_ACCESS_DENIED
)
1756 skip("Not enough rights to perform tests\n");
1757 RegDeleteKeyA(userkey
, "");
1758 RegCloseKey(userkey
);
1762 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1764 /* local product key exists */
1765 SetLastError(0xdeadbeef);
1766 state
= MsiQueryProductStateA(prodcode
);
1767 error
= GetLastError();
1768 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1769 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1770 "expected ERROR_SUCCESS, got %u\n", error
);
1772 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
1773 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1775 /* install properties key exists */
1776 SetLastError(0xdeadbeef);
1777 state
= MsiQueryProductStateA(prodcode
);
1778 error
= GetLastError();
1779 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1780 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1781 "expected ERROR_SUCCESS, got %u\n", error
);
1784 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1785 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1787 /* WindowsInstaller value exists */
1788 SetLastError(0xdeadbeef);
1789 state
= MsiQueryProductStateA(prodcode
);
1790 error
= GetLastError();
1791 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1792 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1793 "expected ERROR_SUCCESS, got %u\n", error
);
1796 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1797 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1799 /* WindowsInstaller value is not 1 */
1800 SetLastError(0xdeadbeef);
1801 state
= MsiQueryProductStateA(prodcode
);
1802 error
= GetLastError();
1803 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1804 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1805 "expected ERROR_SUCCESS, got %u\n", error
);
1807 RegDeleteKeyA(userkey
, "");
1809 /* user product key does not exist */
1810 SetLastError(0xdeadbeef);
1811 state
= MsiQueryProductStateA(prodcode
);
1812 error
= GetLastError();
1813 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
1814 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
1815 "expected ERROR_SUCCESS, got %u\n", error
);
1817 RegDeleteValueA(props
, "WindowsInstaller");
1818 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
1820 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1821 RegCloseKey(localkey
);
1822 RegDeleteKeyA(userkey
, "");
1823 RegCloseKey(userkey
);
1825 /* MSIINSTALLCONTEXT_USERMANAGED */
1827 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1828 lstrcatA(keypath
, usersid
);
1829 lstrcatA(keypath
, "\\Installer\\Products\\");
1830 lstrcatA(keypath
, prod_squashed
);
1832 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
1833 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1835 state
= MsiQueryProductStateA(prodcode
);
1836 ok(state
== INSTALLSTATE_ADVERTISED
,
1837 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1839 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1840 lstrcatA(keypath
, usersid
);
1841 lstrcatA(keypath
, "\\Products\\");
1842 lstrcatA(keypath
, prod_squashed
);
1844 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1845 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1847 state
= MsiQueryProductStateA(prodcode
);
1848 ok(state
== INSTALLSTATE_ADVERTISED
,
1849 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1851 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
1852 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1854 state
= MsiQueryProductStateA(prodcode
);
1855 ok(state
== INSTALLSTATE_ADVERTISED
,
1856 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1859 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1860 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1862 /* WindowsInstaller value exists */
1863 state
= MsiQueryProductStateA(prodcode
);
1864 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1866 RegDeleteValueA(props
, "WindowsInstaller");
1867 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
1869 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1870 RegCloseKey(localkey
);
1871 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
1872 RegCloseKey(prodkey
);
1874 /* MSIINSTALLCONTEXT_MACHINE */
1876 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
1877 lstrcatA(keypath
, prod_squashed
);
1879 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
1880 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1882 state
= MsiQueryProductStateA(prodcode
);
1883 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1885 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1886 lstrcatA(keypath
, "S-1-5-18\\Products\\");
1887 lstrcatA(keypath
, prod_squashed
);
1889 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
1890 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1892 state
= MsiQueryProductStateA(prodcode
);
1893 ok(state
== INSTALLSTATE_ADVERTISED
,
1894 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1896 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
1897 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1899 state
= MsiQueryProductStateA(prodcode
);
1900 ok(state
== INSTALLSTATE_ADVERTISED
,
1901 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
1904 res
= RegSetValueExA(props
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
1905 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
1907 /* WindowsInstaller value exists */
1908 state
= MsiQueryProductStateA(prodcode
);
1909 ok(state
== INSTALLSTATE_DEFAULT
, "Expected INSTALLSTATE_DEFAULT, got %d\n", state
);
1911 RegDeleteValueA(props
, "WindowsInstaller");
1912 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
1914 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
1915 RegCloseKey(localkey
);
1916 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
1917 RegCloseKey(prodkey
);
1922 static const char table_enc85
[] =
1923 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
1924 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
1928 * Encodes a base85 guid given a GUID pointer
1929 * Caller should provide a 21 character buffer for the encoded string.
1931 static void encode_base85_guid( GUID
*guid
, LPWSTR str
)
1933 unsigned int x
, *p
, i
;
1935 p
= (unsigned int*) guid
;
1936 for( i
=0; i
<4; i
++ )
1939 *str
++ = table_enc85
[x
%85];
1941 *str
++ = table_enc85
[x
%85];
1943 *str
++ = table_enc85
[x
%85];
1945 *str
++ = table_enc85
[x
%85];
1947 *str
++ = table_enc85
[x
%85];
1952 static void compose_base85_guid(LPSTR component
, LPSTR comp_base85
, LPSTR squashed
)
1954 WCHAR guidW
[MAX_PATH
];
1955 WCHAR base85W
[MAX_PATH
];
1956 WCHAR squashedW
[MAX_PATH
];
1961 hr
= CoCreateGuid(&guid
);
1962 ok(hr
== S_OK
, "Expected S_OK, got %d\n", hr
);
1964 size
= StringFromGUID2(&guid
, guidW
, MAX_PATH
);
1965 ok(size
== 39, "Expected 39, got %d\n", hr
);
1967 WideCharToMultiByte(CP_ACP
, 0, guidW
, size
, component
, MAX_PATH
, NULL
, NULL
);
1968 encode_base85_guid(&guid
, base85W
);
1969 WideCharToMultiByte(CP_ACP
, 0, base85W
, -1, comp_base85
, MAX_PATH
, NULL
, NULL
);
1970 squash_guid(guidW
, squashedW
);
1971 WideCharToMultiByte(CP_ACP
, 0, squashedW
, -1, squashed
, MAX_PATH
, NULL
, NULL
);
1974 static void test_MsiQueryFeatureState(void)
1976 HKEY userkey
, localkey
, compkey
, compkey2
;
1977 CHAR prodcode
[MAX_PATH
];
1978 CHAR prod_squashed
[MAX_PATH
];
1979 CHAR component
[MAX_PATH
];
1980 CHAR comp_base85
[MAX_PATH
];
1981 CHAR comp_squashed
[MAX_PATH
], comp_squashed2
[MAX_PATH
];
1982 CHAR keypath
[MAX_PATH
*2];
1986 REGSAM access
= KEY_ALL_ACCESS
;
1989 create_test_guid(prodcode
, prod_squashed
);
1990 compose_base85_guid(component
, comp_base85
, comp_squashed
);
1991 compose_base85_guid(component
, comp_base85
+ 20, comp_squashed2
);
1992 usersid
= get_user_sid();
1995 access
|= KEY_WOW64_64KEY
;
1998 SetLastError(0xdeadbeef);
1999 state
= MsiQueryFeatureStateA(NULL
, "feature");
2000 error
= GetLastError();
2001 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2002 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2004 /* empty prodcode */
2005 SetLastError(0xdeadbeef);
2006 state
= MsiQueryFeatureStateA("", "feature");
2007 error
= GetLastError();
2008 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2009 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2011 /* garbage prodcode */
2012 SetLastError(0xdeadbeef);
2013 state
= MsiQueryFeatureStateA("garbage", "feature");
2014 error
= GetLastError();
2015 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2016 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2018 /* guid without brackets */
2019 SetLastError(0xdeadbeef);
2020 state
= MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
2021 error
= GetLastError();
2022 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2023 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2025 /* guid with brackets */
2026 SetLastError(0xdeadbeef);
2027 state
= MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
2028 error
= GetLastError();
2029 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2030 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_ALREADY_EXISTS
) /* win2k */,
2031 "expected ERROR_SUCCESS, got %u\n", error
);
2033 /* same length as guid, but random */
2034 SetLastError(0xdeadbeef);
2035 state
= MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
2036 error
= GetLastError();
2037 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2038 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2040 /* NULL szFeature */
2041 SetLastError(0xdeadbeef);
2042 state
= MsiQueryFeatureStateA(prodcode
, NULL
);
2043 error
= GetLastError();
2044 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2045 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2047 /* empty szFeature */
2048 SetLastError(0xdeadbeef);
2049 state
= MsiQueryFeatureStateA(prodcode
, "");
2050 error
= GetLastError();
2051 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2052 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2053 "expected ERROR_SUCCESS, got %u\n", error
);
2055 /* feature key does not exist yet */
2056 SetLastError(0xdeadbeef);
2057 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2058 error
= GetLastError();
2059 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2060 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2061 "expected ERROR_SUCCESS, got %u\n", error
);
2063 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2065 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Features\\");
2066 lstrcatA(keypath
, prod_squashed
);
2068 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &userkey
);
2069 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2071 /* feature key exists */
2072 SetLastError(0xdeadbeef);
2073 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2074 error
= GetLastError();
2075 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2076 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2077 "expected ERROR_SUCCESS, got %u\n", error
);
2079 res
= RegSetValueExA(userkey
, "feature", 0, REG_SZ
, (const BYTE
*)"", 2);
2080 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2082 /* feature value exists */
2083 SetLastError(0xdeadbeef);
2084 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2085 error
= GetLastError();
2086 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2087 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2088 "expected ERROR_SUCCESS, got %u\n", error
);
2090 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2091 lstrcatA(keypath
, usersid
);
2092 lstrcatA(keypath
, "\\Products\\");
2093 lstrcatA(keypath
, prod_squashed
);
2094 lstrcatA(keypath
, "\\Features");
2096 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
2097 if (res
== ERROR_ACCESS_DENIED
)
2099 skip("Not enough rights to perform tests\n");
2100 RegDeleteKeyA(userkey
, "");
2101 RegCloseKey(userkey
);
2105 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2107 /* userdata features key exists */
2108 SetLastError(0xdeadbeef);
2109 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2110 error
= GetLastError();
2111 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2112 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2113 "expected ERROR_SUCCESS, got %u\n", error
);
2115 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaa", 20);
2116 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2118 SetLastError(0xdeadbeef);
2119 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2120 error
= GetLastError();
2121 ok(state
== INSTALLSTATE_BADCONFIG
, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state
);
2122 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2123 "expected ERROR_SUCCESS, got %u\n", error
);
2125 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaa", 21);
2126 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2128 SetLastError(0xdeadbeef);
2129 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2130 error
= GetLastError();
2131 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2132 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2133 "expected ERROR_SUCCESS, got %u\n", error
);
2135 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaaa", 22);
2136 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2138 SetLastError(0xdeadbeef);
2139 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2140 error
= GetLastError();
2141 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2142 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2143 "expected ERROR_SUCCESS, got %u\n", error
);
2145 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)comp_base85
, 41);
2146 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2148 SetLastError(0xdeadbeef);
2149 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2150 error
= GetLastError();
2151 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2152 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2153 "expected ERROR_SUCCESS, got %u\n", error
);
2155 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2156 lstrcatA(keypath
, usersid
);
2157 lstrcatA(keypath
, "\\Components\\");
2158 lstrcatA(keypath
, comp_squashed
);
2160 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2161 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2163 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2164 lstrcatA(keypath
, usersid
);
2165 lstrcatA(keypath
, "\\Components\\");
2166 lstrcatA(keypath
, comp_squashed2
);
2168 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey2
, NULL
);
2169 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2171 SetLastError(0xdeadbeef);
2172 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2173 error
= GetLastError();
2174 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, 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
*)"", 1);
2179 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2181 SetLastError(0xdeadbeef);
2182 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2183 error
= GetLastError();
2184 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2185 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2186 "expected ERROR_SUCCESS, got %u\n", error
);
2188 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"apple", 6);
2189 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2191 SetLastError(0xdeadbeef);
2192 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2193 error
= GetLastError();
2194 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2195 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2196 "expected ERROR_SUCCESS, got %u\n", error
);
2198 res
= RegSetValueExA(compkey2
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"orange", 7);
2199 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2201 /* INSTALLSTATE_LOCAL */
2202 SetLastError(0xdeadbeef);
2203 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2204 error
= GetLastError();
2205 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2206 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2207 "expected ERROR_SUCCESS, got %u\n", error
);
2209 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01\\", 4);
2210 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2212 /* INSTALLSTATE_SOURCE */
2213 SetLastError(0xdeadbeef);
2214 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2215 error
= GetLastError();
2216 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2217 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2218 "expected ERROR_SUCCESS, got %u\n", error
);
2220 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01", 3);
2221 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2223 /* bad INSTALLSTATE_SOURCE */
2224 SetLastError(0xdeadbeef);
2225 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2226 error
= GetLastError();
2227 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2228 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2229 "expected ERROR_SUCCESS, got %u\n", error
);
2231 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01a", 4);
2232 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2234 /* INSTALLSTATE_SOURCE */
2235 SetLastError(0xdeadbeef);
2236 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2237 error
= GetLastError();
2238 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2239 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2240 "expected ERROR_SUCCESS, got %u\n", error
);
2242 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01", 3);
2243 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2245 /* bad INSTALLSTATE_SOURCE */
2246 SetLastError(0xdeadbeef);
2247 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2248 error
= GetLastError();
2249 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2250 ok(error
== ERROR_SUCCESS
|| broken(error
== ERROR_NO_TOKEN
) /* win2k */,
2251 "expected ERROR_SUCCESS, got %u\n", error
);
2253 RegDeleteValueA(compkey
, prod_squashed
);
2254 RegDeleteValueA(compkey2
, prod_squashed
);
2255 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2256 delete_key(compkey2
, "", access
& KEY_WOW64_64KEY
);
2257 RegDeleteValueA(localkey
, "feature");
2258 RegDeleteValueA(userkey
, "feature");
2259 RegDeleteKeyA(userkey
, "");
2260 RegCloseKey(compkey
);
2261 RegCloseKey(compkey2
);
2262 RegCloseKey(localkey
);
2263 RegCloseKey(userkey
);
2265 /* MSIINSTALLCONTEXT_USERMANAGED */
2267 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2268 lstrcatA(keypath
, usersid
);
2269 lstrcatA(keypath
, "\\Installer\\Features\\");
2270 lstrcatA(keypath
, prod_squashed
);
2272 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
2273 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2275 /* feature key exists */
2276 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2277 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2279 res
= RegSetValueExA(userkey
, "feature", 0, REG_SZ
, (const BYTE
*)"", 1);
2280 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2282 /* feature value exists */
2283 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2284 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2286 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2287 lstrcatA(keypath
, usersid
);
2288 lstrcatA(keypath
, "\\Products\\");
2289 lstrcatA(keypath
, prod_squashed
);
2290 lstrcatA(keypath
, "\\Features");
2292 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
2293 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2295 /* userdata features key exists */
2296 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2297 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2299 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaa", 20);
2300 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2302 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2303 ok(state
== INSTALLSTATE_BADCONFIG
, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state
);
2305 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaa", 21);
2306 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2308 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2309 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2311 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaaa", 22);
2312 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2314 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2315 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2317 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)comp_base85
, 41);
2318 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2320 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2321 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2323 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2324 lstrcatA(keypath
, usersid
);
2325 lstrcatA(keypath
, "\\Components\\");
2326 lstrcatA(keypath
, comp_squashed
);
2328 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2329 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2331 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2332 lstrcatA(keypath
, usersid
);
2333 lstrcatA(keypath
, "\\Components\\");
2334 lstrcatA(keypath
, comp_squashed2
);
2336 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey2
, NULL
);
2337 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2339 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2340 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2342 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 1);
2343 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2345 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2346 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2348 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"apple", 6);
2349 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2351 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2352 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2354 res
= RegSetValueExA(compkey2
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"orange", 7);
2355 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2357 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2358 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2360 RegDeleteValueA(compkey
, prod_squashed
);
2361 RegDeleteValueA(compkey2
, prod_squashed
);
2362 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2363 delete_key(compkey2
, "", access
& KEY_WOW64_64KEY
);
2364 RegDeleteValueA(localkey
, "feature");
2365 RegDeleteValueA(userkey
, "feature");
2366 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
2367 RegCloseKey(compkey
);
2368 RegCloseKey(compkey2
);
2369 RegCloseKey(localkey
);
2370 RegCloseKey(userkey
);
2372 /* MSIINSTALLCONTEXT_MACHINE */
2374 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Features\\");
2375 lstrcatA(keypath
, prod_squashed
);
2377 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
2378 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2380 /* feature key exists */
2381 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2382 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2384 res
= RegSetValueExA(userkey
, "feature", 0, REG_SZ
, (const BYTE
*)"", 1);
2385 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2387 /* feature value exists */
2388 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2389 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2391 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2392 lstrcatA(keypath
, "S-1-5-18\\Products\\");
2393 lstrcatA(keypath
, prod_squashed
);
2394 lstrcatA(keypath
, "\\Features");
2396 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
2397 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2399 /* userdata features key exists */
2400 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2401 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2403 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaa", 20);
2404 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2406 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2407 ok(state
== INSTALLSTATE_BADCONFIG
, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state
);
2409 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaa", 21);
2410 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2412 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2413 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2415 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)"aaaaaaaaaaaaaaaaaaaaa", 22);
2416 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2418 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2419 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2421 res
= RegSetValueExA(localkey
, "feature", 0, REG_SZ
, (const BYTE
*)comp_base85
, 41);
2422 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2424 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2425 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2427 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2428 lstrcatA(keypath
, "S-1-5-18\\Components\\");
2429 lstrcatA(keypath
, comp_squashed
);
2431 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2432 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2434 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2435 lstrcatA(keypath
, "S-1-5-18\\Components\\");
2436 lstrcatA(keypath
, comp_squashed2
);
2438 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey2
, NULL
);
2439 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2441 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2442 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2444 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 1);
2445 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2447 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2448 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2450 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"apple", 6);
2451 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2453 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2454 ok(state
== INSTALLSTATE_ADVERTISED
, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state
);
2456 res
= RegSetValueExA(compkey2
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"orange", 7);
2457 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2459 state
= MsiQueryFeatureStateA(prodcode
, "feature");
2460 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2462 RegDeleteValueA(compkey
, prod_squashed
);
2463 RegDeleteValueA(compkey2
, prod_squashed
);
2464 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2465 delete_key(compkey2
, "", access
& KEY_WOW64_64KEY
);
2466 RegDeleteValueA(localkey
, "feature");
2467 RegDeleteValueA(userkey
, "feature");
2468 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
2469 RegCloseKey(compkey
);
2470 RegCloseKey(compkey2
);
2471 RegCloseKey(localkey
);
2472 RegCloseKey(userkey
);
2476 static void test_MsiQueryComponentState(void)
2478 HKEY compkey
, prodkey
;
2479 CHAR prodcode
[MAX_PATH
];
2480 CHAR prod_squashed
[MAX_PATH
];
2481 CHAR component
[MAX_PATH
];
2482 CHAR comp_base85
[MAX_PATH
];
2483 CHAR comp_squashed
[MAX_PATH
];
2484 CHAR keypath
[MAX_PATH
];
2489 REGSAM access
= KEY_ALL_ACCESS
;
2492 static const INSTALLSTATE MAGIC_ERROR
= 0xdeadbeef;
2494 if (!pMsiQueryComponentStateA
)
2496 win_skip("MsiQueryComponentStateA not implemented\n");
2500 create_test_guid(prodcode
, prod_squashed
);
2501 compose_base85_guid(component
, comp_base85
, comp_squashed
);
2502 usersid
= get_user_sid();
2505 access
|= KEY_WOW64_64KEY
;
2507 /* NULL szProductCode */
2508 state
= MAGIC_ERROR
;
2509 SetLastError(0xdeadbeef);
2510 r
= pMsiQueryComponentStateA(NULL
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2511 error
= GetLastError();
2512 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2513 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2514 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2516 /* empty szProductCode */
2517 state
= MAGIC_ERROR
;
2518 SetLastError(0xdeadbeef);
2519 r
= pMsiQueryComponentStateA("", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2520 error
= GetLastError();
2521 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2522 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2523 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2525 /* random szProductCode */
2526 state
= MAGIC_ERROR
;
2527 SetLastError(0xdeadbeef);
2528 r
= pMsiQueryComponentStateA("random", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2529 error
= GetLastError();
2530 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2531 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2532 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2534 /* GUID-length szProductCode */
2535 state
= MAGIC_ERROR
;
2536 SetLastError(0xdeadbeef);
2537 r
= pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2538 error
= GetLastError();
2539 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2540 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2541 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2543 /* GUID-length with brackets */
2544 state
= MAGIC_ERROR
;
2545 SetLastError(0xdeadbeef);
2546 r
= pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2547 error
= GetLastError();
2548 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2549 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2550 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2553 state
= MAGIC_ERROR
;
2554 SetLastError(0xdeadbeef);
2555 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2556 error
= GetLastError();
2557 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2558 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2559 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2561 state
= MAGIC_ERROR
;
2562 SetLastError(0xdeadbeef);
2563 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2564 error
= GetLastError();
2565 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2566 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2567 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2569 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
2570 lstrcatA(keypath
, prod_squashed
);
2572 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2573 if (res
== ERROR_ACCESS_DENIED
)
2575 skip("Not enough rights to perform tests\n");
2579 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2581 state
= MAGIC_ERROR
;
2582 SetLastError(0xdeadbeef);
2583 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2584 error
= GetLastError();
2585 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2586 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2587 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2589 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2590 RegCloseKey(prodkey
);
2592 /* create local system product key */
2593 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
2594 lstrcatA(keypath
, prod_squashed
);
2595 lstrcatA(keypath
, "\\InstallProperties");
2597 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2598 if (res
== ERROR_ACCESS_DENIED
)
2600 skip("Not enough rights to perform tests\n");
2604 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2606 /* local system product key exists */
2607 state
= MAGIC_ERROR
;
2608 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2609 error
= GetLastError();
2610 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2611 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2612 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2614 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (const BYTE
*)"msitest.msi", 11);
2615 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2617 /* LocalPackage value exists */
2618 state
= MAGIC_ERROR
;
2619 SetLastError(0xdeadbeef);
2620 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2621 error
= GetLastError();
2622 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2623 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2624 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2626 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
2627 lstrcatA(keypath
, comp_squashed
);
2629 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2630 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2632 /* component key exists */
2633 state
= MAGIC_ERROR
;
2634 SetLastError(0xdeadbeef);
2635 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2636 error
= GetLastError();
2637 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2638 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2639 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2641 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 0);
2642 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2644 /* component\product exists */
2645 state
= MAGIC_ERROR
;
2646 SetLastError(0xdeadbeef);
2647 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2648 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2649 error
= GetLastError();
2650 ok(state
== INSTALLSTATE_NOTUSED
|| state
== INSTALLSTATE_LOCAL
,
2651 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state
);
2652 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2654 /* NULL component, product exists */
2655 state
= MAGIC_ERROR
;
2656 SetLastError(0xdeadbeef);
2657 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, NULL
, &state
);
2658 error
= GetLastError();
2659 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
2660 ok(state
== MAGIC_ERROR
, "Expected state not changed, 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
*)"hi", 2);
2664 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2666 /* INSTALLSTATE_LOCAL */
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 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01\\", 4);
2676 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2678 /* INSTALLSTATE_SOURCE */
2679 state
= MAGIC_ERROR
;
2680 SetLastError(0xdeadbeef);
2681 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2682 error
= GetLastError();
2683 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2684 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2685 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2687 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01", 3);
2688 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2690 /* bad INSTALLSTATE_SOURCE */
2691 state
= MAGIC_ERROR
;
2692 SetLastError(0xdeadbeef);
2693 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2694 error
= GetLastError();
2695 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2696 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2697 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2699 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01a", 4);
2700 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2702 /* INSTALLSTATE_SOURCE */
2703 state
= MAGIC_ERROR
;
2704 SetLastError(0xdeadbeef);
2705 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2706 error
= GetLastError();
2707 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2708 ok(state
== INSTALLSTATE_SOURCE
, "Expected INSTALLSTATE_SOURCE, got %d\n", state
);
2709 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2711 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"01:", 4);
2712 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2714 /* registry component */
2715 state
= MAGIC_ERROR
;
2716 SetLastError(0xdeadbeef);
2717 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
, component
, &state
);
2718 error
= GetLastError();
2719 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2720 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2721 ok(error
== 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error
);
2723 RegDeleteValueA(prodkey
, "LocalPackage");
2724 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2725 RegDeleteValueA(compkey
, prod_squashed
);
2726 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2727 RegCloseKey(prodkey
);
2728 RegCloseKey(compkey
);
2730 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2732 state
= MAGIC_ERROR
;
2733 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2734 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2735 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2737 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
2738 lstrcatA(keypath
, prod_squashed
);
2740 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
2741 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2743 state
= MAGIC_ERROR
;
2744 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2745 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2746 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2748 RegDeleteKeyA(prodkey
, "");
2749 RegCloseKey(prodkey
);
2751 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2752 lstrcatA(keypath
, usersid
);
2753 lstrcatA(keypath
, "\\Products\\");
2754 lstrcatA(keypath
, prod_squashed
);
2755 lstrcatA(keypath
, "\\InstallProperties");
2757 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2758 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2760 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (const BYTE
*)"msitest.msi", 11);
2761 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2763 RegCloseKey(prodkey
);
2765 state
= MAGIC_ERROR
;
2766 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2767 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2768 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2770 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2771 lstrcatA(keypath
, usersid
);
2772 lstrcatA(keypath
, "\\Components\\");
2773 lstrcatA(keypath
, comp_squashed
);
2775 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2776 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2778 /* component key exists */
2779 state
= MAGIC_ERROR
;
2780 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2781 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2782 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2784 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"", 0);
2785 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2787 /* component\product exists */
2788 state
= MAGIC_ERROR
;
2789 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2790 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2791 ok(state
== INSTALLSTATE_NOTUSED
|| state
== INSTALLSTATE_LOCAL
,
2792 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state
);
2794 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"hi", 2);
2795 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2797 state
= MAGIC_ERROR
;
2798 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
, component
, &state
);
2799 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2800 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2802 /* MSIINSTALLCONTEXT_USERMANAGED */
2804 state
= MAGIC_ERROR
;
2805 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2806 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2807 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2809 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
2810 lstrcatA(keypath
, prod_squashed
);
2812 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
2813 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2815 state
= MAGIC_ERROR
;
2816 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2817 ok(r
== ERROR_UNKNOWN_PRODUCT
, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
2818 ok(state
== MAGIC_ERROR
, "Expected 0xdeadbeef, got %d\n", state
);
2820 RegDeleteKeyA(prodkey
, "");
2821 RegCloseKey(prodkey
);
2823 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2824 lstrcatA(keypath
, usersid
);
2825 lstrcatA(keypath
, "\\Installer\\Products\\");
2826 lstrcatA(keypath
, prod_squashed
);
2828 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2829 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2831 state
= MAGIC_ERROR
;
2832 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2833 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
2834 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2836 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2837 RegCloseKey(prodkey
);
2839 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2840 lstrcatA(keypath
, usersid
);
2841 lstrcatA(keypath
, "\\Products\\");
2842 lstrcatA(keypath
, prod_squashed
);
2843 lstrcatA(keypath
, "\\InstallProperties");
2845 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
2846 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2848 res
= RegSetValueExA(prodkey
, "ManagedLocalPackage", 0, REG_SZ
, (const BYTE
*)"msitest.msi", 11);
2849 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2851 state
= MAGIC_ERROR
;
2852 r
= pMsiQueryComponentStateA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
, component
, &state
);
2853 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
2854 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
2856 RegDeleteValueA(prodkey
, "LocalPackage");
2857 RegDeleteValueA(prodkey
, "ManagedLocalPackage");
2858 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
2859 RegDeleteValueA(compkey
, prod_squashed
);
2860 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
2861 RegCloseKey(prodkey
);
2862 RegCloseKey(compkey
);
2866 static void test_MsiGetComponentPath(void)
2868 HKEY compkey
, prodkey
, installprop
;
2869 CHAR prodcode
[MAX_PATH
];
2870 CHAR prod_squashed
[MAX_PATH
];
2871 CHAR component
[MAX_PATH
];
2872 CHAR comp_base85
[MAX_PATH
];
2873 CHAR comp_squashed
[MAX_PATH
];
2874 CHAR keypath
[MAX_PATH
];
2875 CHAR path
[MAX_PATH
];
2879 REGSAM access
= KEY_ALL_ACCESS
;
2882 create_test_guid(prodcode
, prod_squashed
);
2883 compose_base85_guid(component
, comp_base85
, comp_squashed
);
2884 usersid
= get_user_sid();
2887 access
|= KEY_WOW64_64KEY
;
2889 /* NULL szProduct */
2891 state
= MsiGetComponentPathA(NULL
, component
, path
, &size
);
2892 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2893 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2895 /* NULL szComponent */
2897 state
= MsiGetComponentPathA(prodcode
, NULL
, path
, &size
);
2898 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2899 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2902 state
= MsiLocateComponentA(NULL
, path
, &size
);
2903 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2904 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2906 /* NULL lpPathBuf */
2908 state
= MsiGetComponentPathA(prodcode
, component
, NULL
, &size
);
2909 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2910 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2913 state
= MsiLocateComponentA(component
, NULL
, &size
);
2914 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2915 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2919 state
= MsiGetComponentPathA(prodcode
, component
, path
, NULL
);
2920 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2921 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2924 state
= MsiLocateComponentA(component
, path
, NULL
);
2925 ok(state
== INSTALLSTATE_INVALIDARG
, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state
);
2926 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2928 /* all params valid */
2930 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2931 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2932 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2935 state
= MsiLocateComponentA(component
, path
, &size
);
2936 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2937 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2939 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2940 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
2941 lstrcatA(keypath
, comp_squashed
);
2943 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
2944 if (res
== ERROR_ACCESS_DENIED
)
2946 skip("Not enough rights to perform tests\n");
2950 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2952 /* local system component key exists */
2954 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2955 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2956 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2959 state
= MsiLocateComponentA(component
, path
, &size
);
2960 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
2961 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
2963 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
2964 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2966 /* product value exists */
2969 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2970 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2971 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2972 ok(size
== 10, "Expected 10, got %d\n", size
);
2976 state
= MsiLocateComponentA(component
, path
, &size
);
2977 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2978 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2979 ok(size
== 10, "Expected 10, got %d\n", size
);
2981 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2982 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
2983 lstrcatA(keypath
, prod_squashed
);
2984 lstrcatA(keypath
, "\\InstallProperties");
2986 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &installprop
, NULL
);
2987 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2990 res
= RegSetValueExA(installprop
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
2991 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
2993 /* install properties key exists */
2996 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
2997 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
2998 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
2999 ok(size
== 10, "Expected 10, got %d\n", size
);
3003 state
= MsiLocateComponentA(component
, path
, &size
);
3004 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3005 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3006 ok(size
== 10, "Expected 10, got %d\n", size
);
3008 create_file("C:\\imapath", "C:\\imapath", 11);
3013 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3014 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3015 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3016 ok(size
== 10, "Expected 10, got %d\n", size
);
3020 state
= MsiLocateComponentA(component
, path
, &size
);
3021 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3022 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3023 ok(size
== 10, "Expected 10, got %d\n", size
);
3025 RegDeleteValueA(compkey
, prod_squashed
);
3026 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3027 RegDeleteValueA(installprop
, "WindowsInstaller");
3028 delete_key(installprop
, "", access
& KEY_WOW64_64KEY
);
3029 RegCloseKey(compkey
);
3030 RegCloseKey(installprop
);
3031 DeleteFileA("C:\\imapath");
3033 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3034 lstrcatA(keypath
, "Installer\\UserData\\");
3035 lstrcatA(keypath
, usersid
);
3036 lstrcatA(keypath
, "\\Components\\");
3037 lstrcatA(keypath
, comp_squashed
);
3039 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3040 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3042 /* user managed component key exists */
3044 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3045 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3046 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3049 state
= MsiLocateComponentA(component
, path
, &size
);
3050 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3051 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3053 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3054 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3056 /* product value exists */
3059 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3060 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3061 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3062 ok(size
== 10, "Expected 10, got %d\n", size
);
3066 state
= MsiLocateComponentA(component
, path
, &size
);
3067 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3068 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3069 ok(size
== 10, "Expected 10, got %d\n", size
);
3071 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3072 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
3073 lstrcatA(keypath
, prod_squashed
);
3074 lstrcatA(keypath
, "\\InstallProperties");
3076 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &installprop
, NULL
);
3077 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3080 res
= RegSetValueExA(installprop
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
3081 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3083 /* install properties key exists */
3086 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3087 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3088 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3089 ok(size
== 10, "Expected 10, got %d\n", size
);
3093 state
= MsiLocateComponentA(component
, path
, &size
);
3094 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3095 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3096 ok(size
== 10, "Expected 10, got %d\n", size
);
3098 create_file("C:\\imapath", "C:\\imapath", 11);
3103 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3104 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3105 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3106 ok(size
== 10, "Expected 10, got %d\n", size
);
3110 state
= MsiLocateComponentA(component
, path
, &size
);
3111 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3112 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3113 ok(size
== 10, "Expected 10, got %d\n", size
);
3115 RegDeleteValueA(compkey
, prod_squashed
);
3116 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3117 RegDeleteValueA(installprop
, "WindowsInstaller");
3118 delete_key(installprop
, "", access
& KEY_WOW64_64KEY
);
3119 RegCloseKey(compkey
);
3120 RegCloseKey(installprop
);
3121 DeleteFileA("C:\\imapath");
3123 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3124 lstrcatA(keypath
, "Installer\\Managed\\");
3125 lstrcatA(keypath
, usersid
);
3126 lstrcatA(keypath
, "\\Installer\\Products\\");
3127 lstrcatA(keypath
, prod_squashed
);
3129 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3130 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3132 /* user managed product key exists */
3134 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3135 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3136 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3139 state
= MsiLocateComponentA(component
, path
, &size
);
3140 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3141 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3143 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3144 lstrcatA(keypath
, "Installer\\UserData\\");
3145 lstrcatA(keypath
, usersid
);
3146 lstrcatA(keypath
, "\\Components\\");
3147 lstrcatA(keypath
, comp_squashed
);
3149 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3150 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3152 /* user managed component key exists */
3154 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3155 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3156 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3159 state
= MsiLocateComponentA(component
, path
, &size
);
3160 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3161 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3163 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3164 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3166 /* product value exists */
3169 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3170 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3171 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3172 ok(size
== 10, "Expected 10, got %d\n", size
);
3176 state
= MsiLocateComponentA(component
, path
, &size
);
3177 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3178 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3179 ok(size
== 10, "Expected 10, got %d\n", size
);
3181 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3182 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
3183 lstrcatA(keypath
, prod_squashed
);
3184 lstrcatA(keypath
, "\\InstallProperties");
3186 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &installprop
, NULL
);
3187 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3190 res
= RegSetValueExA(installprop
, "WindowsInstaller", 0, REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
3191 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3193 /* install properties key exists */
3196 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3197 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3198 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3199 ok(size
== 10, "Expected 10, got %d\n", size
);
3203 state
= MsiLocateComponentA(component
, path
, &size
);
3204 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3205 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3206 ok(size
== 10, "Expected 10, got %d\n", size
);
3208 create_file("C:\\imapath", "C:\\imapath", 11);
3213 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3214 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3215 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3216 ok(size
== 10, "Expected 10, got %d\n", size
);
3220 state
= MsiLocateComponentA(component
, path
, &size
);
3221 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3222 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3223 ok(size
== 10, "Expected 10, got %d\n", size
);
3225 RegDeleteValueA(compkey
, prod_squashed
);
3226 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3227 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3228 RegDeleteValueA(installprop
, "WindowsInstaller");
3229 delete_key(installprop
, "", access
& KEY_WOW64_64KEY
);
3230 RegCloseKey(prodkey
);
3231 RegCloseKey(compkey
);
3232 RegCloseKey(installprop
);
3233 DeleteFileA("C:\\imapath");
3235 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3236 lstrcatA(keypath
, prod_squashed
);
3238 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
3239 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3241 /* user unmanaged product key exists */
3243 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3244 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3245 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3248 state
= MsiLocateComponentA(component
, path
, &size
);
3249 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3250 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3252 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3253 lstrcatA(keypath
, "Installer\\UserData\\");
3254 lstrcatA(keypath
, usersid
);
3255 lstrcatA(keypath
, "\\Components\\");
3256 lstrcatA(keypath
, comp_squashed
);
3258 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3259 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3261 /* user unmanaged component key exists */
3263 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3264 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3265 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3268 state
= MsiLocateComponentA(component
, path
, &size
);
3269 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3270 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3272 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3273 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3275 /* product value exists */
3278 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3279 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3280 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3281 ok(size
== 10, "Expected 10, got %d\n", size
);
3285 state
= MsiLocateComponentA(component
, path
, &size
);
3286 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3287 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3288 ok(size
== 10, "Expected 10, got %d\n", size
);
3290 create_file("C:\\imapath", "C:\\imapath", 11);
3295 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3296 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3297 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3298 ok(size
== 10, "Expected 10, got %d\n", size
);
3302 state
= MsiLocateComponentA(component
, path
, &size
);
3303 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3304 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3305 ok(size
== 10, "Expected 10, got %d\n", size
);
3307 RegDeleteValueA(compkey
, prod_squashed
);
3308 RegDeleteKeyA(prodkey
, "");
3309 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3310 RegCloseKey(prodkey
);
3311 RegCloseKey(compkey
);
3312 DeleteFileA("C:\\imapath");
3314 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3315 lstrcatA(keypath
, prod_squashed
);
3317 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3318 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3320 /* local classes product key exists */
3322 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3323 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3324 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3327 state
= MsiLocateComponentA(component
, path
, &size
);
3328 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3329 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3331 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3332 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
3333 lstrcatA(keypath
, comp_squashed
);
3335 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3336 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3338 /* local user component key exists */
3340 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3341 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3342 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3345 state
= MsiLocateComponentA(component
, path
, &size
);
3346 ok(state
== INSTALLSTATE_UNKNOWN
, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state
);
3347 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
3349 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3350 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3352 /* product value exists */
3355 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3356 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3357 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3358 ok(size
== 10, "Expected 10, got %d\n", size
);
3362 state
= MsiLocateComponentA(component
, path
, &size
);
3363 ok(state
== INSTALLSTATE_ABSENT
, "Expected INSTALLSTATE_ABSENT, got %d\n", state
);
3364 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3365 ok(size
== 10, "Expected 10, got %d\n", size
);
3367 create_file("C:\\imapath", "C:\\imapath", 11);
3372 state
= MsiGetComponentPathA(prodcode
, component
, path
, &size
);
3373 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3374 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3375 ok(size
== 10, "Expected 10, got %d\n", size
);
3379 state
= MsiLocateComponentA(component
, path
, &size
);
3380 ok(state
== INSTALLSTATE_LOCAL
, "Expected INSTALLSTATE_LOCAL, got %d\n", state
);
3381 ok(!lstrcmpA(path
, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path
);
3382 ok(size
== 10, "Expected 10, got %d\n", size
);
3384 RegDeleteValueA(compkey
, prod_squashed
);
3385 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3386 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3387 RegCloseKey(prodkey
);
3388 RegCloseKey(compkey
);
3389 DeleteFileA("C:\\imapath");
3393 static void test_MsiGetProductCode(void)
3395 HKEY compkey
, prodkey
;
3396 CHAR prodcode
[MAX_PATH
];
3397 CHAR prod_squashed
[MAX_PATH
];
3398 CHAR prodcode2
[MAX_PATH
];
3399 CHAR prod2_squashed
[MAX_PATH
];
3400 CHAR component
[MAX_PATH
];
3401 CHAR comp_base85
[MAX_PATH
];
3402 CHAR comp_squashed
[MAX_PATH
];
3403 CHAR keypath
[MAX_PATH
];
3404 CHAR product
[MAX_PATH
];
3408 REGSAM access
= KEY_ALL_ACCESS
;
3410 create_test_guid(prodcode
, prod_squashed
);
3411 create_test_guid(prodcode2
, prod2_squashed
);
3412 compose_base85_guid(component
, comp_base85
, comp_squashed
);
3413 usersid
= get_user_sid();
3416 access
|= KEY_WOW64_64KEY
;
3418 /* szComponent is NULL */
3419 lstrcpyA(product
, "prod");
3420 r
= MsiGetProductCodeA(NULL
, product
);
3421 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3422 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3424 /* szComponent is empty */
3425 lstrcpyA(product
, "prod");
3426 r
= MsiGetProductCodeA("", product
);
3427 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3428 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3430 /* garbage szComponent */
3431 lstrcpyA(product
, "prod");
3432 r
= MsiGetProductCodeA("garbage", product
);
3433 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3434 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3436 /* guid without brackets */
3437 lstrcpyA(product
, "prod");
3438 r
= MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product
);
3439 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3440 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3442 /* guid with brackets */
3443 lstrcpyA(product
, "prod");
3444 r
= MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product
);
3445 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3446 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3448 /* same length as guid, but random */
3449 lstrcpyA(product
, "prod");
3450 r
= MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product
);
3451 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3452 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3454 /* all params correct, szComponent not published */
3455 lstrcpyA(product
, "prod");
3456 r
= MsiGetProductCodeA(component
, product
);
3457 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3458 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3460 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3461 lstrcatA(keypath
, "Installer\\UserData\\");
3462 lstrcatA(keypath
, usersid
);
3463 lstrcatA(keypath
, "\\Components\\");
3464 lstrcatA(keypath
, comp_squashed
);
3466 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3467 if (res
== ERROR_ACCESS_DENIED
)
3469 skip("Not enough rights to perform tests\n");
3473 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3475 /* user unmanaged component key exists */
3476 lstrcpyA(product
, "prod");
3477 r
= MsiGetProductCodeA(component
, product
);
3478 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3479 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3481 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3482 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3484 /* product value 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 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3491 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3493 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3494 lstrcatA(keypath
, "Installer\\Managed\\");
3495 lstrcatA(keypath
, usersid
);
3496 lstrcatA(keypath
, "\\Installer\\Products\\");
3497 lstrcatA(keypath
, prod_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 first 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
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3508 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3509 RegCloseKey(prodkey
);
3511 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3512 lstrcatA(keypath
, prod_squashed
);
3514 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
3515 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3517 /* user unmanaged product key exists */
3518 lstrcpyA(product
, "prod");
3519 r
= MsiGetProductCodeA(component
, product
);
3520 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3521 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3523 RegDeleteKeyA(prodkey
, "");
3524 RegCloseKey(prodkey
);
3526 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3527 lstrcatA(keypath
, prod_squashed
);
3529 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3530 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3532 /* local classes product key exists */
3533 lstrcpyA(product
, "prod");
3534 r
= MsiGetProductCodeA(component
, product
);
3535 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3536 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3538 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3539 RegCloseKey(prodkey
);
3541 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3542 lstrcatA(keypath
, "Installer\\Managed\\");
3543 lstrcatA(keypath
, usersid
);
3544 lstrcatA(keypath
, "\\Installer\\Products\\");
3545 lstrcatA(keypath
, prod2_squashed
);
3547 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3548 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3550 /* user managed product key of second product exists */
3551 lstrcpyA(product
, "prod");
3552 r
= MsiGetProductCodeA(component
, product
);
3553 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3554 ok(!lstrcmpA(product
, prodcode2
), "Expected %s, got %s\n", prodcode2
, product
);
3556 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3557 RegCloseKey(prodkey
);
3558 RegDeleteValueA(compkey
, prod_squashed
);
3559 RegDeleteValueA(compkey
, prod2_squashed
);
3560 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3561 RegCloseKey(compkey
);
3563 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3564 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
3565 lstrcatA(keypath
, comp_squashed
);
3567 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3568 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3570 /* local user component key exists */
3571 lstrcpyA(product
, "prod");
3572 r
= MsiGetProductCodeA(component
, product
);
3573 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3574 ok(!lstrcmpA(product
, "prod"), "Expected product to be unchanged, got %s\n", product
);
3576 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3577 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3579 /* product value 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 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3586 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3588 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3589 lstrcatA(keypath
, "Installer\\Managed\\");
3590 lstrcatA(keypath
, usersid
);
3591 lstrcatA(keypath
, "\\Installer\\Products\\");
3592 lstrcatA(keypath
, prod_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 first 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
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3603 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3604 RegCloseKey(prodkey
);
3606 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
3607 lstrcatA(keypath
, prod_squashed
);
3609 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
3610 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3612 /* user unmanaged product key exists */
3613 lstrcpyA(product
, "prod");
3614 r
= MsiGetProductCodeA(component
, product
);
3615 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3616 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3618 RegDeleteKeyA(prodkey
, "");
3619 RegCloseKey(prodkey
);
3621 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
3622 lstrcatA(keypath
, prod_squashed
);
3624 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3625 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3627 /* local classes product key exists */
3628 lstrcpyA(product
, "prod");
3629 r
= MsiGetProductCodeA(component
, product
);
3630 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3631 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3633 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3634 RegCloseKey(prodkey
);
3636 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3637 lstrcatA(keypath
, "Installer\\Managed\\");
3638 lstrcatA(keypath
, usersid
);
3639 lstrcatA(keypath
, "\\Installer\\Products\\");
3640 lstrcatA(keypath
, prod2_squashed
);
3642 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
3643 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3645 /* user managed product key of second product exists */
3646 lstrcpyA(product
, "prod");
3647 r
= MsiGetProductCodeA(component
, product
);
3648 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3649 ok(!lstrcmpA(product
, prodcode2
), "Expected %s, got %s\n", prodcode2
, product
);
3651 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
3652 RegCloseKey(prodkey
);
3653 RegDeleteValueA(compkey
, prod_squashed
);
3654 RegDeleteValueA(compkey
, prod2_squashed
);
3655 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3656 RegCloseKey(compkey
);
3660 static void test_MsiEnumClients(void)
3663 CHAR prodcode
[MAX_PATH
];
3664 CHAR prod_squashed
[MAX_PATH
];
3665 CHAR prodcode2
[MAX_PATH
];
3666 CHAR prod2_squashed
[MAX_PATH
];
3667 CHAR component
[MAX_PATH
];
3668 CHAR comp_base85
[MAX_PATH
];
3669 CHAR comp_squashed
[MAX_PATH
];
3670 CHAR product
[MAX_PATH
];
3671 CHAR keypath
[MAX_PATH
];
3675 REGSAM access
= KEY_ALL_ACCESS
;
3677 create_test_guid(prodcode
, prod_squashed
);
3678 create_test_guid(prodcode2
, prod2_squashed
);
3679 compose_base85_guid(component
, comp_base85
, comp_squashed
);
3680 usersid
= get_user_sid();
3683 access
|= KEY_WOW64_64KEY
;
3685 /* NULL szComponent */
3687 r
= MsiEnumClientsA(NULL
, 0, product
);
3688 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3689 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3691 /* empty szComponent */
3693 r
= MsiEnumClientsA("", 0, product
);
3694 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3695 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3697 /* NULL lpProductBuf */
3698 r
= MsiEnumClientsA(component
, 0, NULL
);
3699 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3701 /* all params correct, component missing */
3703 r
= MsiEnumClientsA(component
, 0, product
);
3704 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3705 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3707 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3708 lstrcatA(keypath
, "Installer\\UserData\\");
3709 lstrcatA(keypath
, usersid
);
3710 lstrcatA(keypath
, "\\Components\\");
3711 lstrcatA(keypath
, comp_squashed
);
3713 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3714 if (res
== ERROR_ACCESS_DENIED
)
3716 skip("Not enough rights to perform tests\n");
3720 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3722 /* user unmanaged component key exists */
3724 r
= MsiEnumClientsA(component
, 0, product
);
3725 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3726 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3728 /* index > 0, no products exist */
3730 r
= MsiEnumClientsA(component
, 1, product
);
3731 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3732 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3734 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3735 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3737 /* product value exists */
3738 r
= MsiEnumClientsA(component
, 0, product
);
3739 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3740 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3742 /* try index 0 again */
3744 r
= MsiEnumClientsA(component
, 0, product
);
3745 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3746 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3748 /* try index 1, second product value does not exist */
3750 r
= MsiEnumClientsA(component
, 1, product
);
3751 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
3752 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3754 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3755 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3757 /* try index 1, second product value does exist */
3759 r
= MsiEnumClientsA(component
, 1, product
);
3762 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3763 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3766 /* start the enumeration over */
3768 r
= MsiEnumClientsA(component
, 0, product
);
3769 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3770 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3771 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3773 /* correctly query second product */
3775 r
= MsiEnumClientsA(component
, 1, product
);
3776 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3777 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3778 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3780 RegDeleteValueA(compkey
, prod_squashed
);
3781 RegDeleteValueA(compkey
, prod2_squashed
);
3782 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3783 RegCloseKey(compkey
);
3785 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3786 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Components\\");
3787 lstrcatA(keypath
, comp_squashed
);
3789 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &compkey
, NULL
);
3790 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3792 /* user local component key exists */
3794 r
= MsiEnumClientsA(component
, 0, product
);
3795 ok(r
== ERROR_UNKNOWN_COMPONENT
, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r
);
3796 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3798 /* index > 0, no products exist */
3800 r
= MsiEnumClientsA(component
, 1, product
);
3801 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3802 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3804 res
= RegSetValueExA(compkey
, prod_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\imapath", 10);
3805 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3807 /* product value exists */
3809 r
= MsiEnumClientsA(component
, 0, product
);
3810 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3811 ok(!lstrcmpA(product
, prodcode
), "Expected %s, got %s\n", prodcode
, product
);
3813 /* try index 0 again */
3815 r
= MsiEnumClientsA(component
, 0, product
);
3816 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3818 /* try index 1, second product value does not exist */
3820 r
= MsiEnumClientsA(component
, 1, product
);
3821 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
3822 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3824 res
= RegSetValueExA(compkey
, prod2_squashed
, 0, REG_SZ
, (const BYTE
*)"C:\\another", 10);
3825 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
3827 /* try index 1, second product value does exist */
3829 r
= MsiEnumClientsA(component
, 1, product
);
3832 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3833 ok(!lstrcmpA(product
, ""), "Expected product to be unchanged, got %s\n", product
);
3836 /* start the enumeration over */
3838 r
= MsiEnumClientsA(component
, 0, product
);
3839 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3840 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3841 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3843 /* correctly query second product */
3845 r
= MsiEnumClientsA(component
, 1, product
);
3846 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
3847 ok(!lstrcmpA(product
, prodcode
) || !lstrcmpA(product
, prodcode2
),
3848 "Expected %s or %s, got %s\n", prodcode
, prodcode2
, product
);
3850 RegDeleteValueA(compkey
, prod_squashed
);
3851 RegDeleteValueA(compkey
, prod2_squashed
);
3852 delete_key(compkey
, "", access
& KEY_WOW64_64KEY
);
3853 RegCloseKey(compkey
);
3857 static void get_version_info(LPSTR path
, LPSTR
*vercheck
, LPDWORD verchecksz
,
3858 LPSTR
*langcheck
, LPDWORD langchecksz
)
3861 VS_FIXEDFILEINFO
*ffi
;
3862 DWORD size
= GetFileVersionInfoSizeA(path
, NULL
);
3865 version
= HeapAlloc(GetProcessHeap(), 0, size
);
3866 GetFileVersionInfoA(path
, 0, size
, version
);
3868 VerQueryValueA(version
, "\\", (LPVOID
*)&ffi
, &size
);
3869 *vercheck
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
3870 sprintf(*vercheck
, "%d.%d.%d.%d", HIWORD(ffi
->dwFileVersionMS
),
3871 LOWORD(ffi
->dwFileVersionMS
), HIWORD(ffi
->dwFileVersionLS
),
3872 LOWORD(ffi
->dwFileVersionLS
));
3873 *verchecksz
= lstrlenA(*vercheck
);
3875 VerQueryValueA(version
, "\\VarFileInfo\\Translation", (void **)&lang
, &size
);
3876 *langcheck
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
3877 sprintf(*langcheck
, "%d", *lang
);
3878 *langchecksz
= lstrlenA(*langcheck
);
3880 HeapFree(GetProcessHeap(), 0, version
);
3883 static void test_MsiGetFileVersion(void)
3886 DWORD versz
, langsz
;
3887 char version
[MAX_PATH
];
3888 char lang
[MAX_PATH
];
3889 char path
[MAX_PATH
];
3890 LPSTR vercheck
, langcheck
;
3891 DWORD verchecksz
, langchecksz
;
3893 /* NULL szFilePath */
3894 r
= MsiGetFileVersionA(NULL
, NULL
, NULL
, NULL
, NULL
);
3895 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3899 lstrcpyA(version
, "version");
3900 lstrcpyA(lang
, "lang");
3901 r
= MsiGetFileVersionA(NULL
, version
, &versz
, 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 /* empty szFilePath */
3912 r
= MsiGetFileVersionA("", NULL
, NULL
, NULL
, NULL
);
3913 ok(r
== ERROR_FILE_NOT_FOUND
, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3917 lstrcpyA(version
, "version");
3918 lstrcpyA(lang
, "lang");
3919 r
= MsiGetFileVersionA("", version
, &versz
, lang
, &langsz
);
3920 ok(r
== ERROR_FILE_NOT_FOUND
,
3921 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3922 ok(!lstrcmpA(version
, "version"),
3923 "Expected version to be unchanged, got %s\n", version
);
3924 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3925 ok(!lstrcmpA(lang
, "lang"),
3926 "Expected lang to be unchanged, got %s\n", lang
);
3927 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3929 /* nonexistent szFilePath */
3932 lstrcpyA(version
, "version");
3933 lstrcpyA(lang
, "lang");
3934 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, &langsz
);
3935 ok(r
== ERROR_FILE_NOT_FOUND
,
3936 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3937 ok(!lstrcmpA(version
, "version"),
3938 "Expected version to be unchanged, got %s\n", version
);
3939 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3940 ok(!lstrcmpA(lang
, "lang"),
3941 "Expected lang to be unchanged, got %s\n", lang
);
3942 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3944 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
3947 lstrcpyA(version
, "version");
3948 lstrcpyA(lang
, "lang");
3949 r
= MsiGetFileVersionA("nonexistent", version
, NULL
, lang
, &langsz
);
3950 ok(r
== ERROR_INVALID_PARAMETER
,
3951 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3952 ok(!lstrcmpA(version
, "version"),
3953 "Expected version to be unchanged, got %s\n", version
);
3954 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3955 ok(!lstrcmpA(lang
, "lang"),
3956 "Expected lang to be unchanged, got %s\n", lang
);
3957 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3959 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
3962 lstrcpyA(version
, "version");
3963 lstrcpyA(lang
, "lang");
3964 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, NULL
);
3965 ok(r
== ERROR_INVALID_PARAMETER
,
3966 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
3967 ok(!lstrcmpA(version
, "version"),
3968 "Expected version to be unchanged, got %s\n", version
);
3969 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
3970 ok(!lstrcmpA(lang
, "lang"),
3971 "Expected lang to be unchanged, got %s\n", lang
);
3972 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3974 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
3977 lstrcpyA(version
, "version");
3978 lstrcpyA(lang
, "lang");
3979 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, &langsz
);
3980 ok(r
== ERROR_FILE_NOT_FOUND
,
3981 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3982 ok(!lstrcmpA(version
, "version"),
3983 "Expected version to be unchanged, got %s\n", version
);
3984 ok(versz
== 0, "Expected 0, got %d\n", versz
);
3985 ok(!lstrcmpA(lang
, "lang"),
3986 "Expected lang to be unchanged, got %s\n", lang
);
3987 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
3989 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
3992 lstrcpyA(version
, "version");
3993 lstrcpyA(lang
, "lang");
3994 r
= MsiGetFileVersionA("nonexistent", version
, &versz
, lang
, &langsz
);
3995 ok(r
== ERROR_FILE_NOT_FOUND
,
3996 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
3997 ok(!lstrcmpA(version
, "version"),
3998 "Expected version to be unchanged, got %s\n", version
);
3999 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
4000 ok(!lstrcmpA(lang
, "lang"),
4001 "Expected lang to be unchanged, got %s\n", lang
);
4002 ok(langsz
== 0, "Expected 0, got %d\n", langsz
);
4004 /* nonexistent szFilePath, rest NULL */
4005 r
= MsiGetFileVersionA("nonexistent", NULL
, NULL
, NULL
, NULL
);
4006 ok(r
== ERROR_FILE_NOT_FOUND
,
4007 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
4009 create_file("ver.txt", "ver.txt", 20);
4011 /* file exists, no version information */
4012 r
= MsiGetFileVersionA("ver.txt", NULL
, NULL
, NULL
, NULL
);
4013 ok(r
== ERROR_FILE_INVALID
, "Expected ERROR_FILE_INVALID, got %d\n", r
);
4017 lstrcpyA(version
, "version");
4018 lstrcpyA(lang
, "lang");
4019 r
= MsiGetFileVersionA("ver.txt", version
, &versz
, lang
, &langsz
);
4020 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
4021 ok(!lstrcmpA(version
, "version"),
4022 "Expected version to be unchanged, got %s\n", version
);
4023 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
4024 ok(!lstrcmpA(lang
, "lang"),
4025 "Expected lang to be unchanged, got %s\n", lang
);
4026 ok(r
== ERROR_FILE_INVALID
,
4027 "Expected ERROR_FILE_INVALID, got %d\n", r
);
4029 DeleteFileA("ver.txt");
4031 /* relative path, has version information */
4034 lstrcpyA(version
, "version");
4035 lstrcpyA(lang
, "lang");
4036 r
= MsiGetFileVersionA("kernel32.dll", version
, &versz
, lang
, &langsz
);
4039 ok(r
== ERROR_FILE_NOT_FOUND
,
4040 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r
);
4041 ok(!lstrcmpA(version
, "version"),
4042 "Expected version to be unchanged, got %s\n", version
);
4043 ok(versz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, versz
);
4044 ok(!lstrcmpA(lang
, "lang"),
4045 "Expected lang to be unchanged, got %s\n", lang
);
4046 ok(langsz
== MAX_PATH
, "Expected %d, got %d\n", MAX_PATH
, langsz
);
4049 GetSystemDirectoryA(path
, MAX_PATH
);
4050 lstrcatA(path
, "\\kernel32.dll");
4052 get_version_info(path
, &vercheck
, &verchecksz
, &langcheck
, &langchecksz
);
4054 /* absolute path, has version information */
4057 lstrcpyA(version
, "version");
4058 lstrcpyA(lang
, "lang");
4059 r
= MsiGetFileVersionA(path
, version
, &versz
, lang
, &langsz
);
4060 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4061 if (langchecksz
&& !langsz
)
4063 win_skip("broken MsiGetFileVersionA detected\n");
4064 HeapFree(GetProcessHeap(), 0, vercheck
);
4065 HeapFree(GetProcessHeap(), 0, langcheck
);
4068 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4069 ok(strstr(lang
, langcheck
) != NULL
, "Expected \"%s\" in \"%s\"\n", langcheck
, lang
);
4070 ok(!lstrcmpA(version
, vercheck
),
4071 "Expected %s, got %s\n", vercheck
, version
);
4073 /* only check version */
4075 lstrcpyA(version
, "version");
4076 r
= MsiGetFileVersionA(path
, version
, &versz
, NULL
, NULL
);
4077 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4078 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4079 ok(!lstrcmpA(version
, vercheck
),
4080 "Expected %s, got %s\n", vercheck
, version
);
4082 /* only check language */
4084 lstrcpyA(lang
, "lang");
4085 r
= MsiGetFileVersionA(path
, NULL
, NULL
, lang
, &langsz
);
4086 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4087 ok(strstr(lang
, langcheck
) != NULL
, "Expected \"%s\" in \"%s\"\n", langcheck
, lang
);
4089 /* check neither version nor language */
4090 r
= MsiGetFileVersionA(path
, NULL
, NULL
, NULL
, NULL
);
4091 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4093 /* get pcchVersionBuf */
4095 r
= MsiGetFileVersionA(path
, NULL
, &versz
, NULL
, NULL
);
4096 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4097 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4099 /* get pcchLangBuf */
4101 r
= MsiGetFileVersionA(path
, NULL
, NULL
, NULL
, &langsz
);
4102 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4103 ok(langsz
>= langchecksz
, "Expected %d >= %d\n", langsz
, langchecksz
);
4105 /* pcchVersionBuf not big enough */
4107 lstrcpyA(version
, "version");
4108 r
= MsiGetFileVersionA(path
, version
, &versz
, NULL
, NULL
);
4109 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4110 ok(!strncmp(version
, vercheck
, 4),
4111 "Expected first 4 characters of \"%s\", got \"%s\"\n", vercheck
, version
);
4112 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4114 /* pcchLangBuf not big enough */
4116 lstrcpyA(lang
, "lang");
4117 r
= MsiGetFileVersionA(path
, NULL
, NULL
, lang
, &langsz
);
4118 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4119 ok(!strncmp(lang
, langcheck
, 2),
4120 "Expected first character of \"%s\", got \"%s\"\n", langcheck
, lang
);
4121 ok(langsz
>= langchecksz
, "Expected %d >= %d\n", langsz
, langchecksz
);
4123 /* pcchVersionBuf big enough, pcchLangBuf not big enough */
4126 lstrcpyA(version
, "version");
4127 r
= MsiGetFileVersionA(path
, version
, &versz
, NULL
, &langsz
);
4128 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4129 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4130 ok(!lstrcmpA(version
, vercheck
), "Expected \"%s\", got \"%s\"\n", vercheck
, version
);
4131 ok(langsz
>= langchecksz
&& langsz
< MAX_PATH
, "Expected %d >= %d\n", langsz
, langchecksz
);
4133 /* pcchVersionBuf not big enough, pcchLangBuf big enough */
4136 lstrcpyA(lang
, "lang");
4137 r
= MsiGetFileVersionA(path
, NULL
, &versz
, lang
, &langsz
);
4138 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4139 ok(versz
== verchecksz
, "Expected %d, got %d\n", verchecksz
, versz
);
4140 ok(langsz
>= langchecksz
&& langsz
< MAX_PATH
, "Expected %d >= %d\n", langsz
, langchecksz
);
4141 ok(lstrcmpA(lang
, "lang"), "lang buffer not modified\n");
4143 /* NULL pcchVersionBuf and pcchLangBuf */
4144 r
= MsiGetFileVersionA(path
, version
, NULL
, lang
, NULL
);
4145 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4147 /* All NULL except szFilePath */
4148 r
= MsiGetFileVersionA(path
, NULL
, NULL
, NULL
, NULL
);
4149 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4151 HeapFree(GetProcessHeap(), 0, vercheck
);
4152 HeapFree(GetProcessHeap(), 0, langcheck
);
4155 static void test_MsiGetProductInfo(void)
4159 HKEY propkey
, source
;
4160 HKEY prodkey
, localkey
;
4161 CHAR prodcode
[MAX_PATH
];
4162 CHAR prod_squashed
[MAX_PATH
];
4163 CHAR packcode
[MAX_PATH
];
4164 CHAR pack_squashed
[MAX_PATH
];
4166 CHAR keypath
[MAX_PATH
];
4169 REGSAM access
= KEY_ALL_ACCESS
;
4171 create_test_guid(prodcode
, prod_squashed
);
4172 create_test_guid(packcode
, pack_squashed
);
4173 usersid
= get_user_sid();
4176 access
|= KEY_WOW64_64KEY
;
4178 /* NULL szProduct */
4180 lstrcpyA(buf
, "apple");
4181 r
= MsiGetProductInfoA(NULL
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4182 ok(r
== ERROR_INVALID_PARAMETER
,
4183 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4184 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4185 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4187 /* empty szProduct */
4189 lstrcpyA(buf
, "apple");
4190 r
= MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4191 ok(r
== ERROR_INVALID_PARAMETER
,
4192 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4193 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4194 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4196 /* garbage szProduct */
4198 lstrcpyA(buf
, "apple");
4199 r
= MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4200 ok(r
== ERROR_INVALID_PARAMETER
,
4201 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4202 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4203 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4205 /* guid without brackets */
4207 lstrcpyA(buf
, "apple");
4208 r
= MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
4209 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4210 ok(r
== ERROR_INVALID_PARAMETER
,
4211 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4212 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4213 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4215 /* guid with brackets */
4217 lstrcpyA(buf
, "apple");
4218 r
= MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
4219 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4220 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4221 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4222 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4223 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4225 /* same length as guid, but random */
4227 lstrcpyA(buf
, "apple");
4228 r
= MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
4229 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4230 ok(r
== ERROR_INVALID_PARAMETER
,
4231 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4232 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4233 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4235 /* not installed, NULL szAttribute */
4237 lstrcpyA(buf
, "apple");
4238 r
= MsiGetProductInfoA(prodcode
, NULL
, buf
, &sz
);
4239 ok(r
== ERROR_INVALID_PARAMETER
,
4240 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4241 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4242 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4244 /* not installed, NULL lpValueBuf */
4246 lstrcpyA(buf
, "apple");
4247 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, NULL
, &sz
);
4248 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4249 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4250 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4251 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4253 /* not installed, NULL pcchValueBuf */
4255 lstrcpyA(buf
, "apple");
4256 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, NULL
);
4257 ok(r
== ERROR_INVALID_PARAMETER
,
4258 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
4259 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4260 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4262 /* created guid cannot possibly be an installed product code */
4264 lstrcpyA(buf
, "apple");
4265 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4266 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4267 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4268 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4269 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4271 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4272 lstrcatA(keypath
, usersid
);
4273 lstrcatA(keypath
, "\\Installer\\Products\\");
4274 lstrcatA(keypath
, prod_squashed
);
4276 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
4277 if (res
== ERROR_ACCESS_DENIED
)
4279 skip("Not enough rights to perform tests\n");
4283 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4285 /* managed product code exists */
4287 lstrcpyA(buf
, "apple");
4288 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4289 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4290 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4291 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4292 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4294 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
4295 RegCloseKey(prodkey
);
4297 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4298 lstrcatA(keypath
, usersid
);
4299 lstrcatA(keypath
, "\\Products\\");
4300 lstrcatA(keypath
, prod_squashed
);
4302 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4303 if (res
== ERROR_ACCESS_DENIED
)
4305 skip("Not enough rights to perform tests\n");
4309 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4311 /* local user product code exists */
4313 lstrcpyA(buf
, "apple");
4314 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4315 ok(r
== ERROR_UNKNOWN_PRODUCT
,
4316 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
4317 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4318 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4320 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4321 lstrcatA(keypath
, usersid
);
4322 lstrcatA(keypath
, "\\Installer\\Products\\");
4323 lstrcatA(keypath
, prod_squashed
);
4325 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
4326 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4328 /* both local and managed product code exist */
4330 lstrcpyA(buf
, "apple");
4331 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4332 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4333 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4334 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
4335 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4337 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4338 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4340 /* InstallProperties key exists */
4342 lstrcpyA(buf
, "apple");
4343 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4344 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4345 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4346 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4348 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
4349 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4351 /* HelpLink value exists */
4353 lstrcpyA(buf
, "apple");
4354 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4355 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4356 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
4357 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4359 /* pcchBuf is NULL */
4360 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, NULL
, NULL
);
4361 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4363 /* lpValueBuf is NULL */
4365 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, NULL
, &sz
);
4366 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4367 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4369 /* lpValueBuf is NULL, pcchValueBuf is too small */
4371 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, NULL
, &sz
);
4372 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4373 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4375 /* lpValueBuf is non-NULL, pcchValueBuf is too small */
4377 lstrcpyA(buf
, "apple");
4378 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4379 ok(!lstrcmpA(buf
, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf
);
4380 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4381 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4383 /* lpValueBuf is non-NULL, pcchValueBuf is exactly 4 */
4385 lstrcpyA(buf
, "apple");
4386 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4387 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
4388 ok(!lstrcmpA(buf
, "apple"),
4389 "Expected buf to remain unchanged, got \"%s\"\n", buf
);
4390 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4392 res
= RegSetValueExA(propkey
, "IMadeThis", 0, REG_SZ
, (LPBYTE
)"random", 7);
4393 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4395 /* random property not supported by MSI, value exists */
4397 lstrcpyA(buf
, "apple");
4398 r
= MsiGetProductInfoA(prodcode
, "IMadeThis", buf
, &sz
);
4399 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4400 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4401 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4402 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4404 RegDeleteValueA(propkey
, "IMadeThis");
4405 RegDeleteValueA(propkey
, "HelpLink");
4406 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
4407 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
4408 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
4409 RegCloseKey(propkey
);
4410 RegCloseKey(localkey
);
4411 RegCloseKey(prodkey
);
4413 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
4414 lstrcatA(keypath
, prod_squashed
);
4416 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
4417 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4419 /* user product key exists */
4421 lstrcpyA(buf
, "apple");
4422 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4423 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4424 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4425 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4426 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4428 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4429 lstrcatA(keypath
, usersid
);
4430 lstrcatA(keypath
, "\\Products\\");
4431 lstrcatA(keypath
, prod_squashed
);
4433 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4434 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4436 /* local user product key exists */
4438 lstrcpyA(buf
, "apple");
4439 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4440 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4441 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4442 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4443 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4445 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4446 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4448 /* InstallProperties key exists */
4450 lstrcpyA(buf
, "apple");
4451 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4452 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4453 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4454 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4456 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
4457 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4459 /* HelpLink value exists */
4461 lstrcpyA(buf
, "apple");
4462 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4463 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4464 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
4465 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4467 RegDeleteValueA(propkey
, "HelpLink");
4468 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
4469 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
4470 RegDeleteKeyA(prodkey
, "");
4471 RegCloseKey(propkey
);
4472 RegCloseKey(localkey
);
4473 RegCloseKey(prodkey
);
4475 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
4476 lstrcatA(keypath
, prod_squashed
);
4478 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
4479 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4481 /* classes product key exists */
4483 lstrcpyA(buf
, "apple");
4484 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4485 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4486 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4487 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4488 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4490 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4491 lstrcatA(keypath
, usersid
);
4492 lstrcatA(keypath
, "\\Products\\");
4493 lstrcatA(keypath
, prod_squashed
);
4495 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4496 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4498 /* local user product key exists */
4500 lstrcpyA(buf
, "apple");
4501 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4502 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4503 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4504 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4505 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4507 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4508 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4510 /* InstallProperties key exists */
4512 lstrcpyA(buf
, "apple");
4513 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4514 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4515 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4516 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4517 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4519 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
4520 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
4521 RegCloseKey(propkey
);
4522 RegCloseKey(localkey
);
4524 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4525 lstrcatA(keypath
, "S-1-5-18\\\\Products\\");
4526 lstrcatA(keypath
, prod_squashed
);
4528 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
4529 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4531 /* Local System product key exists */
4533 lstrcpyA(buf
, "apple");
4534 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4535 ok(r
== ERROR_UNKNOWN_PROPERTY
,
4536 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
4537 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
4538 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
4540 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
4541 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4543 /* InstallProperties key exists */
4545 lstrcpyA(buf
, "apple");
4546 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4547 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4548 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4549 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4551 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
4552 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4554 /* HelpLink value exists */
4556 lstrcpyA(buf
, "apple");
4557 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4558 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4559 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
4560 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4562 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_DWORD
,
4563 (const BYTE
*)&val
, sizeof(DWORD
));
4564 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4566 /* HelpLink type is REG_DWORD */
4568 lstrcpyA(buf
, "apple");
4569 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
4570 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4571 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4572 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4574 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
4575 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4577 /* DisplayName value exists */
4579 lstrcpyA(buf
, "apple");
4580 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
4581 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4582 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
4583 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4585 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_DWORD
,
4586 (const BYTE
*)&val
, sizeof(DWORD
));
4587 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4589 /* DisplayName type is REG_DWORD */
4591 lstrcpyA(buf
, "apple");
4592 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
4593 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4594 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4595 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4597 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"1.1.1", 6);
4598 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4600 /* DisplayVersion value exists */
4602 lstrcpyA(buf
, "apple");
4603 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
4604 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4605 ok(!lstrcmpA(buf
, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf
);
4606 ok(sz
== 5, "Expected 5, got %d\n", sz
);
4608 res
= RegSetValueExA(propkey
, "DisplayVersion", 0,
4609 REG_DWORD
, (const BYTE
*)&val
, sizeof(DWORD
));
4610 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4612 /* DisplayVersion type is REG_DWORD */
4614 lstrcpyA(buf
, "apple");
4615 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
4616 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4617 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4618 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4620 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"tele", 5);
4621 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4623 /* HelpTelephone value exists */
4625 lstrcpyA(buf
, "apple");
4626 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
4627 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4628 ok(!lstrcmpA(buf
, "tele"), "Expected \"tele\", got \"%s\"\n", buf
);
4629 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4631 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_DWORD
,
4632 (const BYTE
*)&val
, sizeof(DWORD
));
4633 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4635 /* HelpTelephone type is REG_DWORD */
4637 lstrcpyA(buf
, "apple");
4638 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
4639 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4640 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4641 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4643 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
4644 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4646 /* InstallLocation value exists */
4648 lstrcpyA(buf
, "apple");
4649 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
4650 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4651 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
4652 ok(sz
== 3, "Expected 3, got %d\n", sz
);
4654 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_DWORD
,
4655 (const BYTE
*)&val
, sizeof(DWORD
));
4656 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4658 /* InstallLocation type is REG_DWORD */
4660 lstrcpyA(buf
, "apple");
4661 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
4662 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4663 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4664 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4666 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
4667 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4669 /* InstallSource value exists */
4671 lstrcpyA(buf
, "apple");
4672 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
4673 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4674 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
4675 ok(sz
== 6, "Expected 6, got %d\n", sz
);
4677 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_DWORD
,
4678 (const BYTE
*)&val
, sizeof(DWORD
));
4679 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4681 /* InstallSource type is REG_DWORD */
4683 lstrcpyA(buf
, "apple");
4684 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
4685 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4686 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4687 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4689 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
4690 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4692 /* InstallDate value exists */
4694 lstrcpyA(buf
, "apple");
4695 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
4696 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4697 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
4698 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4700 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_DWORD
,
4701 (const BYTE
*)&val
, sizeof(DWORD
));
4702 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4704 /* InstallDate type is REG_DWORD */
4706 lstrcpyA(buf
, "apple");
4707 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
4708 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4709 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4710 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4712 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
4713 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4715 /* Publisher value exists */
4717 lstrcpyA(buf
, "apple");
4718 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
4719 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4720 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
4721 ok(sz
== 3, "Expected 3, got %d\n", sz
);
4723 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_DWORD
,
4724 (const BYTE
*)&val
, sizeof(DWORD
));
4725 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4727 /* Publisher type is REG_DWORD */
4729 lstrcpyA(buf
, "apple");
4730 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
4731 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4732 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4733 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4735 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"pack", 5);
4736 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4738 /* LocalPackage value exists */
4740 lstrcpyA(buf
, "apple");
4741 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
4742 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4743 ok(!lstrcmpA(buf
, "pack"), "Expected \"pack\", got \"%s\"\n", buf
);
4744 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4746 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_DWORD
,
4747 (const BYTE
*)&val
, sizeof(DWORD
));
4748 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4750 /* LocalPackage type is REG_DWORD */
4752 lstrcpyA(buf
, "apple");
4753 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
4754 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4755 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4756 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4758 res
= RegSetValueExA(propkey
, "UrlInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
4759 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4761 /* UrlInfoAbout value exists */
4763 lstrcpyA(buf
, "apple");
4764 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
4765 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4766 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
4767 ok(sz
== 5, "Expected 5, got %d\n", sz
);
4769 res
= RegSetValueExA(propkey
, "UrlInfoAbout", 0, REG_DWORD
,
4770 (const BYTE
*)&val
, sizeof(DWORD
));
4771 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4773 /* UrlInfoAbout type is REG_DWORD */
4775 lstrcpyA(buf
, "apple");
4776 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
4777 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4778 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4779 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4781 res
= RegSetValueExA(propkey
, "UrlUpdateInfo", 0, REG_SZ
, (LPBYTE
)"info", 5);
4782 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4784 /* UrlUpdateInfo value exists */
4786 lstrcpyA(buf
, "apple");
4787 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
4788 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4789 ok(!lstrcmpA(buf
, "info"), "Expected \"info\", got \"%s\"\n", buf
);
4790 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4792 res
= RegSetValueExA(propkey
, "UrlUpdateInfo", 0, REG_DWORD
,
4793 (const BYTE
*)&val
, sizeof(DWORD
));
4794 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4796 /* UrlUpdateInfo type is REG_DWORD */
4798 lstrcpyA(buf
, "apple");
4799 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
4800 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4801 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4802 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4804 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"1", 2);
4805 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4807 /* VersionMinor value exists */
4809 lstrcpyA(buf
, "apple");
4810 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
4811 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4812 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
4813 ok(sz
== 1, "Expected 1, got %d\n", sz
);
4815 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_DWORD
,
4816 (const BYTE
*)&val
, sizeof(DWORD
));
4817 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4819 /* VersionMinor type is REG_DWORD */
4821 lstrcpyA(buf
, "apple");
4822 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
4823 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4824 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4825 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4827 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"1", 2);
4828 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4830 /* VersionMajor value exists */
4832 lstrcpyA(buf
, "apple");
4833 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
4834 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4835 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
4836 ok(sz
== 1, "Expected 1, got %d\n", sz
);
4838 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_DWORD
,
4839 (const BYTE
*)&val
, sizeof(DWORD
));
4840 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4842 /* VersionMajor type is REG_DWORD */
4844 lstrcpyA(buf
, "apple");
4845 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
4846 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4847 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4848 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4850 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
4851 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4853 /* ProductID value exists */
4855 lstrcpyA(buf
, "apple");
4856 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
4857 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4858 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
4859 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4861 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_DWORD
,
4862 (const BYTE
*)&val
, sizeof(DWORD
));
4863 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4865 /* ProductID type is REG_DWORD */
4867 lstrcpyA(buf
, "apple");
4868 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
4869 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4870 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4871 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4873 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
4874 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4876 /* RegCompany value exists */
4878 lstrcpyA(buf
, "apple");
4879 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
4880 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4881 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
4882 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4884 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_DWORD
,
4885 (const BYTE
*)&val
, sizeof(DWORD
));
4886 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4888 /* RegCompany type is REG_DWORD */
4890 lstrcpyA(buf
, "apple");
4891 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
4892 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4893 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4894 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4896 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"own", 4);
4897 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4899 /* RegOwner value exists */
4901 lstrcpyA(buf
, "apple");
4902 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
4903 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4904 ok(!lstrcmpA(buf
, "own"), "Expected \"own\", got \"%s\"\n", buf
);
4905 ok(sz
== 3, "Expected 3, got %d\n", sz
);
4907 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_DWORD
,
4908 (const BYTE
*)&val
, sizeof(DWORD
));
4909 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4911 /* RegOwner type is REG_DWORD */
4913 lstrcpyA(buf
, "apple");
4914 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
4915 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4916 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4917 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4919 res
= RegSetValueExA(propkey
, "InstanceType", 0, REG_SZ
, (LPBYTE
)"type", 5);
4920 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4922 /* InstanceType value exists */
4924 lstrcpyA(buf
, "apple");
4925 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPEA
, buf
, &sz
);
4926 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4927 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4928 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4930 res
= RegSetValueExA(propkey
, "InstanceType", 0, REG_DWORD
,
4931 (const BYTE
*)&val
, sizeof(DWORD
));
4932 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4934 /* InstanceType type is REG_DWORD */
4936 lstrcpyA(buf
, "apple");
4937 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPEA
, buf
, &sz
);
4938 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4939 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4940 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4942 res
= RegSetValueExA(prodkey
, "InstanceType", 0, REG_SZ
, (LPBYTE
)"type", 5);
4943 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4945 /* InstanceType value exists */
4947 lstrcpyA(buf
, "apple");
4948 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPEA
, buf
, &sz
);
4949 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4950 ok(!lstrcmpA(buf
, "type"), "Expected \"type\", got \"%s\"\n", buf
);
4951 ok(sz
== 4, "Expected 4, got %d\n", sz
);
4953 res
= RegSetValueExA(prodkey
, "InstanceType", 0, REG_DWORD
,
4954 (const BYTE
*)&val
, sizeof(DWORD
));
4955 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4957 /* InstanceType type is REG_DWORD */
4959 lstrcpyA(buf
, "apple");
4960 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_INSTANCETYPEA
, buf
, &sz
);
4961 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4962 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
4963 ok(sz
== 2, "Expected 2, got %d\n", sz
);
4965 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"tforms", 7);
4966 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4968 /* Transforms value exists */
4970 lstrcpyA(buf
, "apple");
4971 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
4972 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4973 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4974 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4976 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_DWORD
,
4977 (const BYTE
*)&val
, sizeof(DWORD
));
4978 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4980 /* Transforms type is REG_DWORD */
4982 lstrcpyA(buf
, "apple");
4983 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
4984 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4985 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
4986 ok(sz
== 0, "Expected 0, got %d\n", sz
);
4988 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"tforms", 7);
4989 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
4991 /* Transforms value exists */
4993 lstrcpyA(buf
, "apple");
4994 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
4995 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
4996 ok(!lstrcmpA(buf
, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf
);
4997 ok(sz
== 6, "Expected 6, got %d\n", sz
);
4999 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_DWORD
,
5000 (const BYTE
*)&val
, sizeof(DWORD
));
5001 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5003 /* Transforms type is REG_DWORD */
5005 lstrcpyA(buf
, "apple");
5006 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
5007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5008 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5009 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5011 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
5012 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5014 /* Language value exists */
5016 lstrcpyA(buf
, "apple");
5017 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
5018 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5019 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5020 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5022 res
= RegSetValueExA(propkey
, "Language", 0, REG_DWORD
,
5023 (const BYTE
*)&val
, sizeof(DWORD
));
5024 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5026 /* Language type is REG_DWORD */
5028 lstrcpyA(buf
, "apple");
5029 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
5030 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5031 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5032 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5034 res
= RegSetValueExA(prodkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
5035 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5037 /* Language value exists */
5039 lstrcpyA(buf
, "apple");
5040 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
5041 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5042 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
5043 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5045 res
= RegSetValueExA(prodkey
, "Language", 0, REG_DWORD
,
5046 (const BYTE
*)&val
, sizeof(DWORD
));
5047 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5049 /* Language type is REG_DWORD */
5051 lstrcpyA(buf
, "apple");
5052 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
5053 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5054 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5055 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5057 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5058 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5060 /* ProductName value exists */
5062 lstrcpyA(buf
, "apple");
5063 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
5064 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5065 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5066 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5068 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_DWORD
,
5069 (const BYTE
*)&val
, sizeof(DWORD
));
5070 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5072 /* ProductName type is REG_DWORD */
5074 lstrcpyA(buf
, "apple");
5075 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
5076 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5077 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5078 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5080 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5081 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5083 /* ProductName value exists */
5085 lstrcpyA(buf
, "apple");
5086 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
5087 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5088 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
5089 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5091 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_DWORD
,
5092 (const BYTE
*)&val
, sizeof(DWORD
));
5093 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5095 /* ProductName type is REG_DWORD */
5097 lstrcpyA(buf
, "apple");
5098 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
5099 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5100 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5101 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5103 res
= RegSetValueExA(propkey
, "Assignment", 0, REG_SZ
, (LPBYTE
)"at", 3);
5104 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5106 /* Assignment value exists */
5108 lstrcpyA(buf
, "apple");
5109 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
5110 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5111 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5112 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5114 res
= RegSetValueExA(propkey
, "Assignment", 0, REG_DWORD
,
5115 (const BYTE
*)&val
, sizeof(DWORD
));
5116 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5118 /* Assignment type is REG_DWORD */
5120 lstrcpyA(buf
, "apple");
5121 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
5122 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5123 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5124 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5126 res
= RegSetValueExA(prodkey
, "Assignment", 0, REG_SZ
, (LPBYTE
)"at", 3);
5127 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5129 /* Assignment value exists */
5131 lstrcpyA(buf
, "apple");
5132 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
5133 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5134 ok(!lstrcmpA(buf
, "at"), "Expected \"at\", got \"%s\"\n", buf
);
5135 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5137 res
= RegSetValueExA(prodkey
, "Assignment", 0, REG_DWORD
,
5138 (const BYTE
*)&val
, sizeof(DWORD
));
5139 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5141 /* Assignment type is REG_DWORD */
5143 lstrcpyA(buf
, "apple");
5144 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
5145 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5146 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5147 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5149 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
5150 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5152 /* PackageCode value exists */
5154 lstrcpyA(buf
, "apple");
5155 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
5156 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5157 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5158 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5160 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_DWORD
,
5161 (const BYTE
*)&val
, sizeof(DWORD
));
5162 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5164 /* PackageCode type is REG_DWORD */
5166 lstrcpyA(buf
, "apple");
5167 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
5168 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5169 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5170 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5172 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
5173 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5175 /* PackageCode value exists */
5177 lstrcpyA(buf
, "apple");
5178 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
5179 ok(r
== ERROR_BAD_CONFIGURATION
,
5180 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
5181 ok(!lstrcmpA(buf
, "code"), "Expected \"code\", got \"%s\"\n", buf
);
5182 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5184 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_DWORD
,
5185 (const BYTE
*)&val
, sizeof(DWORD
));
5186 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5188 /* PackageCode type is REG_DWORD */
5190 lstrcpyA(buf
, "apple");
5191 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
5192 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5193 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5194 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5196 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)pack_squashed
, 33);
5197 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5199 /* PackageCode value exists */
5201 lstrcpyA(buf
, "apple");
5202 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
5203 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5204 ok(!lstrcmpA(buf
, packcode
), "Expected \"%s\", got \"%s\"\n", packcode
, buf
);
5205 ok(sz
== 38, "Expected 38, got %d\n", sz
);
5207 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
5208 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5210 /* Version value exists */
5212 lstrcpyA(buf
, "apple");
5213 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
5214 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5215 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5216 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5218 res
= RegSetValueExA(propkey
, "Version", 0, REG_DWORD
,
5219 (const BYTE
*)&val
, sizeof(DWORD
));
5220 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5222 /* Version type is REG_DWORD */
5224 lstrcpyA(buf
, "apple");
5225 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
5226 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5227 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5228 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5230 res
= RegSetValueExA(prodkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
5231 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5233 /* Version value exists */
5235 lstrcpyA(buf
, "apple");
5236 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
5237 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5238 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
5239 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5241 res
= RegSetValueExA(prodkey
, "Version", 0, REG_DWORD
,
5242 (const BYTE
*)&val
, sizeof(DWORD
));
5243 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5245 /* Version type is REG_DWORD */
5247 lstrcpyA(buf
, "apple");
5248 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
5249 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5250 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5251 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5253 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"ico", 4);
5254 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5256 /* ProductIcon value exists */
5258 lstrcpyA(buf
, "apple");
5259 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
5260 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5261 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5262 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5264 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_DWORD
,
5265 (const BYTE
*)&val
, sizeof(DWORD
));
5266 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5268 /* ProductIcon type is REG_DWORD */
5270 lstrcpyA(buf
, "apple");
5271 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
5272 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5273 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5274 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5276 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"ico", 4);
5277 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5279 /* ProductIcon value exists */
5281 lstrcpyA(buf
, "apple");
5282 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
5283 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5284 ok(!lstrcmpA(buf
, "ico"), "Expected \"ico\", got \"%s\"\n", buf
);
5285 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5287 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_DWORD
,
5288 (const BYTE
*)&val
, sizeof(DWORD
));
5289 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5291 /* ProductIcon type is REG_DWORD */
5293 lstrcpyA(buf
, "apple");
5294 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
5295 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5296 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5297 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5299 /* SourceList key does not exist */
5301 lstrcpyA(buf
, "apple");
5302 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
5303 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5304 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5305 ok(!lstrcmpA(buf
, "apple"),
5306 "Expected buf to be unchanged, got \"%s\"\n", buf
);
5307 ok(sz
== MAX_PATH
, "Expected sz to be unchanged, got %d\n", sz
);
5309 res
= RegCreateKeyExA(prodkey
, "SourceList", 0, NULL
, 0, access
, NULL
, &source
, NULL
);
5310 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5312 /* SourceList key exists, but PackageName val does not exist */
5314 lstrcpyA(buf
, "apple");
5315 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
5316 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5317 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5318 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5320 res
= RegSetValueExA(source
, "PackageName", 0, REG_SZ
, (LPBYTE
)"packname", 9);
5321 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5323 /* PackageName val exists */
5325 lstrcpyA(buf
, "apple");
5326 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
5327 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5328 ok(!lstrcmpA(buf
, "packname"), "Expected \"packname\", got \"%s\"\n", buf
);
5329 ok(sz
== 8, "Expected 8, got %d\n", sz
);
5331 res
= RegSetValueExA(source
, "PackageName", 0, REG_DWORD
,
5332 (const BYTE
*)&val
, sizeof(DWORD
));
5333 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5335 /* PackageName type is REG_DWORD */
5337 lstrcpyA(buf
, "apple");
5338 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
5339 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5340 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5341 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5343 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
5344 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5346 /* Authorized value exists */
5348 lstrcpyA(buf
, "apple");
5349 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
5350 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5352 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5353 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5354 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5357 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_DWORD
,
5358 (const BYTE
*)&val
, sizeof(DWORD
));
5359 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5361 /* AuthorizedLUAApp type is REG_DWORD */
5363 lstrcpyA(buf
, "apple");
5364 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
5365 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5367 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5368 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5369 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5372 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
5373 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5375 /* Authorized value exists */
5377 lstrcpyA(buf
, "apple");
5378 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
5379 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5381 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5382 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
5383 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5386 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_DWORD
,
5387 (const BYTE
*)&val
, sizeof(DWORD
));
5388 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5390 /* AuthorizedLUAApp type is REG_DWORD */
5392 lstrcpyA(buf
, "apple");
5393 r
= MsiGetProductInfoA(prodcode
, INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
5394 if (r
!= ERROR_UNKNOWN_PROPERTY
)
5396 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5397 ok(!lstrcmpA(buf
, "42"), "Expected \"42\", got \"%s\"\n", buf
);
5398 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5401 RegDeleteValueA(propkey
, "HelpLink");
5402 RegDeleteValueA(propkey
, "DisplayName");
5403 RegDeleteValueA(propkey
, "DisplayVersion");
5404 RegDeleteValueA(propkey
, "HelpTelephone");
5405 RegDeleteValueA(propkey
, "InstallLocation");
5406 RegDeleteValueA(propkey
, "InstallSource");
5407 RegDeleteValueA(propkey
, "InstallDate");
5408 RegDeleteValueA(propkey
, "Publisher");
5409 RegDeleteValueA(propkey
, "LocalPackage");
5410 RegDeleteValueA(propkey
, "UrlInfoAbout");
5411 RegDeleteValueA(propkey
, "UrlUpdateInfo");
5412 RegDeleteValueA(propkey
, "VersionMinor");
5413 RegDeleteValueA(propkey
, "VersionMajor");
5414 RegDeleteValueA(propkey
, "ProductID");
5415 RegDeleteValueA(propkey
, "RegCompany");
5416 RegDeleteValueA(propkey
, "RegOwner");
5417 RegDeleteValueA(propkey
, "InstanceType");
5418 RegDeleteValueA(propkey
, "Transforms");
5419 RegDeleteValueA(propkey
, "Language");
5420 RegDeleteValueA(propkey
, "ProductName");
5421 RegDeleteValueA(propkey
, "Assignment");
5422 RegDeleteValueA(propkey
, "PackageCode");
5423 RegDeleteValueA(propkey
, "Version");
5424 RegDeleteValueA(propkey
, "ProductIcon");
5425 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
5426 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
5427 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
5428 RegDeleteValueA(prodkey
, "InstanceType");
5429 RegDeleteValueA(prodkey
, "Transforms");
5430 RegDeleteValueA(prodkey
, "Language");
5431 RegDeleteValueA(prodkey
, "ProductName");
5432 RegDeleteValueA(prodkey
, "Assignment");
5433 RegDeleteValueA(prodkey
, "PackageCode");
5434 RegDeleteValueA(prodkey
, "Version");
5435 RegDeleteValueA(prodkey
, "ProductIcon");
5436 RegDeleteValueA(prodkey
, "AuthorizedLUAApp");
5437 RegDeleteValueA(source
, "PackageName");
5438 delete_key(source
, "", access
& KEY_WOW64_64KEY
);
5439 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
5440 RegCloseKey(propkey
);
5441 RegCloseKey(localkey
);
5442 RegCloseKey(source
);
5443 RegCloseKey(prodkey
);
5447 static void test_MsiGetProductInfoEx(void)
5451 HKEY propkey
, userkey
;
5452 HKEY prodkey
, localkey
;
5453 CHAR prodcode
[MAX_PATH
];
5454 CHAR prod_squashed
[MAX_PATH
];
5455 CHAR packcode
[MAX_PATH
];
5456 CHAR pack_squashed
[MAX_PATH
];
5458 CHAR keypath
[MAX_PATH
];
5461 REGSAM access
= KEY_ALL_ACCESS
;
5463 if (!pMsiGetProductInfoExA
)
5465 win_skip("MsiGetProductInfoExA is not available\n");
5469 create_test_guid(prodcode
, prod_squashed
);
5470 create_test_guid(packcode
, pack_squashed
);
5471 usersid
= get_user_sid();
5474 access
|= KEY_WOW64_64KEY
;
5476 /* NULL szProductCode */
5478 lstrcpyA(buf
, "apple");
5479 r
= pMsiGetProductInfoExA(NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
5480 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5481 ok(r
== ERROR_INVALID_PARAMETER
,
5482 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5483 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5484 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5486 /* empty szProductCode */
5488 lstrcpyA(buf
, "apple");
5489 r
= pMsiGetProductInfoExA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
5490 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5491 ok(r
== ERROR_INVALID_PARAMETER
,
5492 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5493 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5494 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5496 /* garbage szProductCode */
5498 lstrcpyA(buf
, "apple");
5499 r
= pMsiGetProductInfoExA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
5500 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5501 ok(r
== ERROR_INVALID_PARAMETER
,
5502 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5503 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5504 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5506 /* guid without brackets */
5508 lstrcpyA(buf
, "apple");
5509 r
= pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid
,
5510 MSIINSTALLCONTEXT_USERUNMANAGED
,
5511 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5512 ok(r
== ERROR_INVALID_PARAMETER
,
5513 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5514 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5515 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5517 /* guid with brackets */
5519 lstrcpyA(buf
, "apple");
5520 r
= pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid
,
5521 MSIINSTALLCONTEXT_USERUNMANAGED
,
5522 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5523 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5524 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5525 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5526 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5528 /* szValue is non-NULL while pcchValue is NULL */
5529 lstrcpyA(buf
, "apple");
5530 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5531 MSIINSTALLCONTEXT_USERUNMANAGED
,
5532 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, NULL
);
5533 ok(r
== ERROR_INVALID_PARAMETER
,
5534 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5535 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5537 /* dwContext is out of range */
5539 lstrcpyA(buf
, "apple");
5540 r
= pMsiGetProductInfoExA(prodcode
, usersid
, 42,
5541 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5542 ok(r
== ERROR_INVALID_PARAMETER
,
5543 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5544 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5545 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5547 /* szProperty is NULL */
5549 lstrcpyA(buf
, "apple");
5550 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5551 MSIINSTALLCONTEXT_USERUNMANAGED
,
5553 ok(r
== ERROR_INVALID_PARAMETER
,
5554 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5555 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5556 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5558 /* szProperty is empty */
5560 lstrcpyA(buf
, "apple");
5561 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5562 MSIINSTALLCONTEXT_USERUNMANAGED
,
5564 ok(r
== ERROR_INVALID_PARAMETER
,
5565 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5566 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5567 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5569 /* szProperty is not a valid property */
5571 lstrcpyA(buf
, "apple");
5572 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5573 MSIINSTALLCONTEXT_USERUNMANAGED
,
5574 "notvalid", buf
, &sz
);
5575 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5576 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5577 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5578 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5580 /* same length as guid, but random */
5582 lstrcpyA(buf
, "apple");
5583 r
= pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid
,
5584 MSIINSTALLCONTEXT_USERUNMANAGED
,
5585 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5586 ok(r
== ERROR_INVALID_PARAMETER
,
5587 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
5588 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5589 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5591 /* MSIINSTALLCONTEXT_USERUNMANAGED */
5593 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
5594 lstrcatA(keypath
, usersid
);
5595 lstrcatA(keypath
, "\\Products\\");
5596 lstrcatA(keypath
, prod_squashed
);
5598 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
5599 if (res
== ERROR_ACCESS_DENIED
)
5601 skip("Not enough rights to perform tests\n");
5605 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5607 /* local user product key exists */
5609 lstrcpyA(buf
, "apple");
5610 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5611 MSIINSTALLCONTEXT_USERUNMANAGED
,
5612 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5613 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5614 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5615 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5616 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5618 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
5619 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5621 /* InstallProperties key exists */
5623 lstrcpyA(buf
, "apple");
5624 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5625 MSIINSTALLCONTEXT_USERUNMANAGED
,
5626 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5627 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5628 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5629 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5630 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5632 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
5633 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5635 /* LocalPackage value exists */
5637 lstrcpyA(buf
, "apple");
5638 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5639 MSIINSTALLCONTEXT_USERUNMANAGED
,
5640 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
5641 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5642 ok(!lstrcmpA(buf
, "5"), "Expected \"5\", got \"%s\"\n", buf
);
5643 ok(sz
== 1, "Expected 1, got %d\n", sz
);
5645 RegDeleteValueA(propkey
, "LocalPackage");
5647 /* LocalPackage value must exist */
5649 lstrcpyA(buf
, "apple");
5650 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5651 MSIINSTALLCONTEXT_USERUNMANAGED
,
5652 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
5653 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5654 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5655 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5656 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5658 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
5659 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5661 /* LocalPackage exists, but HelpLink does not exist */
5663 lstrcpyA(buf
, "apple");
5664 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5665 MSIINSTALLCONTEXT_USERUNMANAGED
,
5666 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
5667 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5668 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
5669 ok(sz
== 0, "Expected 0, got %d\n", sz
);
5671 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
5672 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5674 /* HelpLink value exists */
5676 lstrcpyA(buf
, "apple");
5677 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5678 MSIINSTALLCONTEXT_USERUNMANAGED
,
5679 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
5680 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5681 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
5682 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5684 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
5685 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5687 /* HelpTelephone value exists */
5689 lstrcpyA(buf
, "apple");
5690 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5691 MSIINSTALLCONTEXT_USERUNMANAGED
,
5692 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
5693 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5694 ok(!lstrcmpA(buf
, "phone"), "Expected \"phone\", got \"%s\"\n", buf
);
5695 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5697 /* szValue and pcchValue are NULL */
5698 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5699 MSIINSTALLCONTEXT_USERUNMANAGED
,
5700 INSTALLPROPERTY_HELPTELEPHONEA
, NULL
, NULL
);
5701 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5703 /* pcchValue is exactly 5 */
5705 lstrcpyA(buf
, "apple");
5706 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5707 MSIINSTALLCONTEXT_USERUNMANAGED
,
5708 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
5709 ok(r
== ERROR_MORE_DATA
,
5710 "Expected ERROR_MORE_DATA, got %d\n", r
);
5711 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5713 /* szValue is NULL, pcchValue is exactly 5 */
5715 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5716 MSIINSTALLCONTEXT_USERUNMANAGED
,
5717 INSTALLPROPERTY_HELPTELEPHONEA
, NULL
, &sz
);
5718 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5719 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5721 /* szValue is NULL, pcchValue is MAX_PATH */
5723 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5724 MSIINSTALLCONTEXT_USERUNMANAGED
,
5725 INSTALLPROPERTY_HELPTELEPHONEA
, NULL
, &sz
);
5726 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5727 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5729 /* pcchValue is exactly 0 */
5731 lstrcpyA(buf
, "apple");
5732 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5733 MSIINSTALLCONTEXT_USERUNMANAGED
,
5734 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
5735 ok(r
== ERROR_MORE_DATA
,
5736 "Expected ERROR_MORE_DATA, got %d\n", r
);
5737 ok(!lstrcmpA(buf
, "apple"), "Expected \"apple\", got \"%s\"\n", buf
);
5738 ok(sz
== 10, "Expected 10, got %d\n", sz
);
5740 res
= RegSetValueExA(propkey
, "notvalid", 0, REG_SZ
, (LPBYTE
)"invalid", 8);
5741 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5743 /* szProperty is not a valid property */
5745 lstrcpyA(buf
, "apple");
5746 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5747 MSIINSTALLCONTEXT_USERUNMANAGED
,
5748 "notvalid", buf
, &sz
);
5749 ok(r
== ERROR_UNKNOWN_PROPERTY
,
5750 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
5751 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5752 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5754 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
5755 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5757 /* InstallDate value exists */
5759 lstrcpyA(buf
, "apple");
5760 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5761 MSIINSTALLCONTEXT_USERUNMANAGED
,
5762 INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
5763 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5764 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
5765 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5767 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5768 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5770 /* DisplayName value exists */
5772 lstrcpyA(buf
, "apple");
5773 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5774 MSIINSTALLCONTEXT_USERUNMANAGED
,
5775 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
5776 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5777 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
5778 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5780 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
5781 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5783 /* InstallLocation value exists */
5785 lstrcpyA(buf
, "apple");
5786 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5787 MSIINSTALLCONTEXT_USERUNMANAGED
,
5788 INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
5789 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5790 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
5791 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5793 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
5794 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5796 /* InstallSource value exists */
5798 lstrcpyA(buf
, "apple");
5799 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5800 MSIINSTALLCONTEXT_USERUNMANAGED
,
5801 INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
5802 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5803 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
5804 ok(sz
== 6, "Expected 6, got %d\n", sz
);
5806 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
5807 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5809 /* LocalPackage value exists */
5811 lstrcpyA(buf
, "apple");
5812 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5813 MSIINSTALLCONTEXT_USERUNMANAGED
,
5814 INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
5815 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5816 ok(!lstrcmpA(buf
, "local"), "Expected \"local\", got \"%s\"\n", buf
);
5817 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5819 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
5820 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5822 /* Publisher value exists */
5824 lstrcpyA(buf
, "apple");
5825 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5826 MSIINSTALLCONTEXT_USERUNMANAGED
,
5827 INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
5828 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5829 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
5830 ok(sz
== 3, "Expected 3, got %d\n", sz
);
5832 res
= RegSetValueExA(propkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
5833 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5835 /* URLInfoAbout value exists */
5837 lstrcpyA(buf
, "apple");
5838 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5839 MSIINSTALLCONTEXT_USERUNMANAGED
,
5840 INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
5841 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5842 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
5843 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5845 res
= RegSetValueExA(propkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
5846 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5848 /* URLUpdateInfo value exists */
5850 lstrcpyA(buf
, "apple");
5851 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5852 MSIINSTALLCONTEXT_USERUNMANAGED
,
5853 INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
5854 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5855 ok(!lstrcmpA(buf
, "update"), "Expected \"update\", got \"%s\"\n", buf
);
5856 ok(sz
== 6, "Expected 6, got %d\n", sz
);
5858 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
5859 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5861 /* VersionMinor value exists */
5863 lstrcpyA(buf
, "apple");
5864 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5865 MSIINSTALLCONTEXT_USERUNMANAGED
,
5866 INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
5867 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5868 ok(!lstrcmpA(buf
, "2"), "Expected \"2\", got \"%s\"\n", buf
);
5869 ok(sz
== 1, "Expected 1, got %d\n", sz
);
5871 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
5872 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5874 /* VersionMajor value exists */
5876 lstrcpyA(buf
, "apple");
5877 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5878 MSIINSTALLCONTEXT_USERUNMANAGED
,
5879 INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
5880 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5881 ok(!lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
5882 ok(sz
== 1, "Expected 1, got %d\n", sz
);
5884 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
5885 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5887 /* DisplayVersion value exists */
5889 lstrcpyA(buf
, "apple");
5890 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5891 MSIINSTALLCONTEXT_USERUNMANAGED
,
5892 INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
5893 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5894 ok(!lstrcmpA(buf
, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf
);
5895 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5897 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
5898 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5900 /* ProductID value exists */
5902 lstrcpyA(buf
, "apple");
5903 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5904 MSIINSTALLCONTEXT_USERUNMANAGED
,
5905 INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
5906 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5907 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
5908 ok(sz
== 2, "Expected 2, got %d\n", sz
);
5910 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
5911 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5913 /* RegCompany value exists */
5915 lstrcpyA(buf
, "apple");
5916 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5917 MSIINSTALLCONTEXT_USERUNMANAGED
,
5918 INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
5919 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5920 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
5921 ok(sz
== 4, "Expected 4, got %d\n", sz
);
5923 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
5924 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5926 /* RegOwner value exists */
5928 lstrcpyA(buf
, "apple");
5929 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5930 MSIINSTALLCONTEXT_USERUNMANAGED
,
5931 INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
5932 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
5933 ok(!lstrcmpA(buf
, "owner"), "Expected \"owner\", got \"%s\"\n", buf
);
5934 ok(sz
== 5, "Expected 5, got %d\n", sz
);
5936 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
5937 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5939 /* Transforms value exists */
5941 lstrcpyA(buf
, "apple");
5942 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5943 MSIINSTALLCONTEXT_USERUNMANAGED
,
5944 INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
5945 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5946 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5947 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5948 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5950 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
5951 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5953 /* Language value exists */
5955 lstrcpyA(buf
, "apple");
5956 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5957 MSIINSTALLCONTEXT_USERUNMANAGED
,
5958 INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
5959 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5960 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5961 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5962 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5964 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
5965 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5967 /* ProductName value exists */
5969 lstrcpyA(buf
, "apple");
5970 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5971 MSIINSTALLCONTEXT_USERUNMANAGED
,
5972 INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
5973 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5974 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5975 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5976 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5978 res
= RegSetValueExA(propkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
5979 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5983 /* AssignmentType value exists */
5985 lstrcpyA(buf
, "apple");
5986 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
5987 MSIINSTALLCONTEXT_USERUNMANAGED
,
5988 INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
5989 ok(r
== ERROR_UNKNOWN_PRODUCT
,
5990 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
5991 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
5992 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
5994 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
5995 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
5997 /* PackageCode value exists */
5999 lstrcpyA(buf
, "apple");
6000 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6001 MSIINSTALLCONTEXT_USERUNMANAGED
,
6002 INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
6003 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6004 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6005 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6006 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6008 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
6009 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6011 /* Version value exists */
6013 lstrcpyA(buf
, "apple");
6014 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6015 MSIINSTALLCONTEXT_USERUNMANAGED
,
6016 INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
6017 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6018 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6019 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6020 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6022 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
6023 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6025 /* ProductIcon value exists */
6027 lstrcpyA(buf
, "apple");
6028 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6029 MSIINSTALLCONTEXT_USERUNMANAGED
,
6030 INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
6031 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6032 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6033 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6034 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6036 res
= RegSetValueExA(propkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6037 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6039 /* PackageName value exists */
6041 lstrcpyA(buf
, "apple");
6042 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6043 MSIINSTALLCONTEXT_USERUNMANAGED
,
6044 INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
6045 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6046 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6047 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6048 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6050 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
6051 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6053 /* AuthorizedLUAApp value exists */
6055 lstrcpyA(buf
, "apple");
6056 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6057 MSIINSTALLCONTEXT_USERUNMANAGED
,
6058 INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
6059 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6060 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6061 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6062 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6064 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
6065 RegDeleteValueA(propkey
, "PackageName");
6066 RegDeleteValueA(propkey
, "ProductIcon");
6067 RegDeleteValueA(propkey
, "Version");
6068 RegDeleteValueA(propkey
, "PackageCode");
6069 RegDeleteValueA(propkey
, "AssignmentType");
6070 RegDeleteValueA(propkey
, "ProductName");
6071 RegDeleteValueA(propkey
, "Language");
6072 RegDeleteValueA(propkey
, "Transforms");
6073 RegDeleteValueA(propkey
, "RegOwner");
6074 RegDeleteValueA(propkey
, "RegCompany");
6075 RegDeleteValueA(propkey
, "ProductID");
6076 RegDeleteValueA(propkey
, "DisplayVersion");
6077 RegDeleteValueA(propkey
, "VersionMajor");
6078 RegDeleteValueA(propkey
, "VersionMinor");
6079 RegDeleteValueA(propkey
, "URLUpdateInfo");
6080 RegDeleteValueA(propkey
, "URLInfoAbout");
6081 RegDeleteValueA(propkey
, "Publisher");
6082 RegDeleteValueA(propkey
, "LocalPackage");
6083 RegDeleteValueA(propkey
, "InstallSource");
6084 RegDeleteValueA(propkey
, "InstallLocation");
6085 RegDeleteValueA(propkey
, "DisplayName");
6086 RegDeleteValueA(propkey
, "InstallDate");
6087 RegDeleteValueA(propkey
, "HelpTelephone");
6088 RegDeleteValueA(propkey
, "HelpLink");
6089 RegDeleteValueA(propkey
, "LocalPackage");
6090 RegDeleteKeyA(propkey
, "");
6091 RegCloseKey(propkey
);
6092 RegDeleteKeyA(localkey
, "");
6093 RegCloseKey(localkey
);
6095 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6096 lstrcatA(keypath
, usersid
);
6097 lstrcatA(keypath
, "\\Installer\\Products\\");
6098 lstrcatA(keypath
, prod_squashed
);
6100 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
6101 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6103 /* user product key exists */
6105 lstrcpyA(buf
, "apple");
6106 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6107 MSIINSTALLCONTEXT_USERUNMANAGED
,
6108 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6109 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6110 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6111 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6112 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6114 RegDeleteKeyA(userkey
, "");
6115 RegCloseKey(userkey
);
6117 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
6118 lstrcatA(keypath
, prod_squashed
);
6120 res
= RegCreateKeyExA(HKEY_CURRENT_USER
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
6121 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6124 lstrcpyA(buf
, "apple");
6125 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6126 MSIINSTALLCONTEXT_USERUNMANAGED
,
6127 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6128 ok(r
== ERROR_SUCCESS
|| broken(r
== ERROR_UNKNOWN_PRODUCT
), "Expected ERROR_SUCCESS, got %d\n", r
);
6129 if (r
== ERROR_UNKNOWN_PRODUCT
)
6131 win_skip("skipping remaining tests for MsiGetProductInfoEx\n");
6132 delete_key(prodkey
, "", access
);
6133 RegCloseKey(prodkey
);
6136 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
6137 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6139 res
= RegSetValueExA(prodkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6140 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6142 /* HelpLink value exists */
6144 lstrcpyA(buf
, "apple");
6145 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6146 MSIINSTALLCONTEXT_USERUNMANAGED
,
6147 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
6148 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6149 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6150 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6151 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6153 res
= RegSetValueExA(prodkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
6154 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6156 /* HelpTelephone value exists */
6158 lstrcpyA(buf
, "apple");
6159 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6160 MSIINSTALLCONTEXT_USERUNMANAGED
,
6161 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
6162 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6163 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6164 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6165 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6167 res
= RegSetValueExA(prodkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
6168 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6170 /* InstallDate value exists */
6172 lstrcpyA(buf
, "apple");
6173 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6174 MSIINSTALLCONTEXT_USERUNMANAGED
,
6175 INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
6176 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6177 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6178 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6179 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6181 res
= RegSetValueExA(prodkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6182 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6184 /* DisplayName value exists */
6186 lstrcpyA(buf
, "apple");
6187 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6188 MSIINSTALLCONTEXT_USERUNMANAGED
,
6189 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
6190 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6191 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6192 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6193 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6195 res
= RegSetValueExA(prodkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
6196 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6198 /* InstallLocation value exists */
6200 lstrcpyA(buf
, "apple");
6201 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6202 MSIINSTALLCONTEXT_USERUNMANAGED
,
6203 INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
6204 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6205 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6206 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6207 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6209 res
= RegSetValueExA(prodkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
6210 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6212 /* InstallSource value exists */
6214 lstrcpyA(buf
, "apple");
6215 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6216 MSIINSTALLCONTEXT_USERUNMANAGED
,
6217 INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
6218 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6219 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6220 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6221 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6223 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
6224 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6226 /* LocalPackage value exists */
6228 lstrcpyA(buf
, "apple");
6229 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6230 MSIINSTALLCONTEXT_USERUNMANAGED
,
6231 INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
6232 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6233 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6234 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6235 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6237 res
= RegSetValueExA(prodkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
6238 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6240 /* Publisher value exists */
6242 lstrcpyA(buf
, "apple");
6243 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6244 MSIINSTALLCONTEXT_USERUNMANAGED
,
6245 INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
6246 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6247 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6248 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6249 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6251 res
= RegSetValueExA(prodkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
6252 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6254 /* URLInfoAbout value exists */
6256 lstrcpyA(buf
, "apple");
6257 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6258 MSIINSTALLCONTEXT_USERUNMANAGED
,
6259 INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
6260 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6261 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6262 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6263 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6265 res
= RegSetValueExA(prodkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
6266 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6268 /* URLUpdateInfo value exists */
6270 lstrcpyA(buf
, "apple");
6271 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6272 MSIINSTALLCONTEXT_USERUNMANAGED
,
6273 INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
6274 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6275 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6276 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6277 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6279 res
= RegSetValueExA(prodkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
6280 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6282 /* VersionMinor value exists */
6284 lstrcpyA(buf
, "apple");
6285 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6286 MSIINSTALLCONTEXT_USERUNMANAGED
,
6287 INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
6288 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6289 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6290 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6291 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6293 res
= RegSetValueExA(prodkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
6294 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6296 /* VersionMajor value exists */
6298 lstrcpyA(buf
, "apple");
6299 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6300 MSIINSTALLCONTEXT_USERUNMANAGED
,
6301 INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
6302 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6303 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6304 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6305 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6307 res
= RegSetValueExA(prodkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
6308 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6310 /* DisplayVersion value exists */
6312 lstrcpyA(buf
, "apple");
6313 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6314 MSIINSTALLCONTEXT_USERUNMANAGED
,
6315 INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
6316 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6317 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6318 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6319 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6321 res
= RegSetValueExA(prodkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
6322 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6324 /* ProductID value exists */
6326 lstrcpyA(buf
, "apple");
6327 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6328 MSIINSTALLCONTEXT_USERUNMANAGED
,
6329 INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
6330 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6331 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6332 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6333 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6335 res
= RegSetValueExA(prodkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
6336 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6338 /* RegCompany value exists */
6340 lstrcpyA(buf
, "apple");
6341 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6342 MSIINSTALLCONTEXT_USERUNMANAGED
,
6343 INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
6344 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6345 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6346 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6347 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6349 res
= RegSetValueExA(prodkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
6350 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6352 /* RegOwner value exists */
6354 lstrcpyA(buf
, "apple");
6355 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6356 MSIINSTALLCONTEXT_USERUNMANAGED
,
6357 INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
6358 ok(r
== ERROR_UNKNOWN_PROPERTY
,
6359 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
6360 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6361 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6363 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
6364 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6366 /* Transforms value exists */
6368 lstrcpyA(buf
, "apple");
6369 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6370 MSIINSTALLCONTEXT_USERUNMANAGED
,
6371 INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
6372 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6373 ok(!lstrcmpA(buf
, "trans"), "Expected \"trans\", got \"%s\"\n", buf
);
6374 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6376 res
= RegSetValueExA(prodkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
6377 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6379 /* Language value exists */
6381 lstrcpyA(buf
, "apple");
6382 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6383 MSIINSTALLCONTEXT_USERUNMANAGED
,
6384 INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
6385 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6386 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
6387 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6389 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6390 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6392 /* ProductName value exists */
6394 lstrcpyA(buf
, "apple");
6395 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6396 MSIINSTALLCONTEXT_USERUNMANAGED
,
6397 INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
6398 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6399 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
6400 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6402 res
= RegSetValueExA(prodkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
6403 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6407 /* AssignmentType value exists */
6409 lstrcpyA(buf
, "apple");
6410 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6411 MSIINSTALLCONTEXT_USERUNMANAGED
,
6412 INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
6413 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6414 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
6415 ok(sz
== 0, "Expected 0, got %d\n", sz
);
6417 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
6418 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6422 /* PackageCode value exists */
6424 lstrcpyA(buf
, "apple");
6425 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6426 MSIINSTALLCONTEXT_USERUNMANAGED
,
6427 INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
6430 ok(r
== ERROR_BAD_CONFIGURATION
,
6431 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
6432 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6433 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6436 res
= RegSetValueExA(prodkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
6437 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6439 /* Version value exists */
6441 lstrcpyA(buf
, "apple");
6442 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6443 MSIINSTALLCONTEXT_USERUNMANAGED
,
6444 INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
6445 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6446 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
6447 ok(sz
== 3, "Expected 3, got %d\n", sz
);
6449 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
6450 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6452 /* ProductIcon value exists */
6454 lstrcpyA(buf
, "apple");
6455 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6456 MSIINSTALLCONTEXT_USERUNMANAGED
,
6457 INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
6458 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6459 ok(!lstrcmpA(buf
, "icon"), "Expected \"icon\", got \"%s\"\n", buf
);
6460 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6462 res
= RegSetValueExA(prodkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6463 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6465 /* PackageName value exists */
6467 lstrcpyA(buf
, "apple");
6468 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6469 MSIINSTALLCONTEXT_USERUNMANAGED
,
6470 INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
6473 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6474 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6475 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6476 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6479 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
6480 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6482 /* AuthorizedLUAApp value exists */
6484 lstrcpyA(buf
, "apple");
6485 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6486 MSIINSTALLCONTEXT_USERUNMANAGED
,
6487 INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
6488 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6489 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
6490 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6492 RegDeleteValueA(prodkey
, "AuthorizedLUAApp");
6493 RegDeleteValueA(prodkey
, "PackageName");
6494 RegDeleteValueA(prodkey
, "ProductIcon");
6495 RegDeleteValueA(prodkey
, "Version");
6496 RegDeleteValueA(prodkey
, "PackageCode");
6497 RegDeleteValueA(prodkey
, "AssignmentType");
6498 RegDeleteValueA(prodkey
, "ProductName");
6499 RegDeleteValueA(prodkey
, "Language");
6500 RegDeleteValueA(prodkey
, "Transforms");
6501 RegDeleteValueA(prodkey
, "RegOwner");
6502 RegDeleteValueA(prodkey
, "RegCompany");
6503 RegDeleteValueA(prodkey
, "ProductID");
6504 RegDeleteValueA(prodkey
, "DisplayVersion");
6505 RegDeleteValueA(prodkey
, "VersionMajor");
6506 RegDeleteValueA(prodkey
, "VersionMinor");
6507 RegDeleteValueA(prodkey
, "URLUpdateInfo");
6508 RegDeleteValueA(prodkey
, "URLInfoAbout");
6509 RegDeleteValueA(prodkey
, "Publisher");
6510 RegDeleteValueA(prodkey
, "LocalPackage");
6511 RegDeleteValueA(prodkey
, "InstallSource");
6512 RegDeleteValueA(prodkey
, "InstallLocation");
6513 RegDeleteValueA(prodkey
, "DisplayName");
6514 RegDeleteValueA(prodkey
, "InstallDate");
6515 RegDeleteValueA(prodkey
, "HelpTelephone");
6516 RegDeleteValueA(prodkey
, "HelpLink");
6517 RegDeleteValueA(prodkey
, "LocalPackage");
6518 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
6519 RegCloseKey(prodkey
);
6521 /* MSIINSTALLCONTEXT_USERMANAGED */
6523 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
6524 lstrcatA(keypath
, usersid
);
6525 lstrcatA(keypath
, "\\Products\\");
6526 lstrcatA(keypath
, prod_squashed
);
6528 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
6529 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6531 /* local user product key exists */
6533 lstrcpyA(buf
, "apple");
6534 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6535 MSIINSTALLCONTEXT_USERMANAGED
,
6536 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6537 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6538 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6539 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6540 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6542 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
6543 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6545 /* InstallProperties key exists */
6547 lstrcpyA(buf
, "apple");
6548 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6549 MSIINSTALLCONTEXT_USERMANAGED
,
6550 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6551 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6552 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6553 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6554 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6556 res
= RegSetValueExA(propkey
, "ManagedLocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
6557 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6559 /* ManagedLocalPackage value exists */
6561 lstrcpyA(buf
, "apple");
6562 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6563 MSIINSTALLCONTEXT_USERMANAGED
,
6564 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6565 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6566 ok(!lstrcmpA(buf
, "5"), "Expected \"5\", got \"%s\"\n", buf
);
6567 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6569 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6570 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6572 /* HelpLink value exists */
6574 lstrcpyA(buf
, "apple");
6575 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6576 MSIINSTALLCONTEXT_USERMANAGED
,
6577 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
6578 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6579 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
6580 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6582 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
6583 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6585 /* HelpTelephone value exists */
6587 lstrcpyA(buf
, "apple");
6588 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6589 MSIINSTALLCONTEXT_USERMANAGED
,
6590 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
6591 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6592 ok(!lstrcmpA(buf
, "phone"), "Expected \"phone\", got \"%s\"\n", buf
);
6593 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6595 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
6596 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6598 /* InstallDate value exists */
6600 lstrcpyA(buf
, "apple");
6601 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6602 MSIINSTALLCONTEXT_USERMANAGED
,
6603 INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
6604 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6605 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
6606 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6608 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6609 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6611 /* DisplayName value exists */
6613 lstrcpyA(buf
, "apple");
6614 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6615 MSIINSTALLCONTEXT_USERMANAGED
,
6616 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
6617 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6618 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
6619 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6621 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
6622 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6624 /* InstallLocation value exists */
6626 lstrcpyA(buf
, "apple");
6627 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6628 MSIINSTALLCONTEXT_USERMANAGED
,
6629 INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
6630 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6631 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
6632 ok(sz
== 3, "Expected 3, got %d\n", sz
);
6634 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
6635 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6637 /* InstallSource value exists */
6639 lstrcpyA(buf
, "apple");
6640 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6641 MSIINSTALLCONTEXT_USERMANAGED
,
6642 INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
6643 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6644 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
6645 ok(sz
== 6, "Expected 6, got %d\n", sz
);
6647 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
6648 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6650 /* LocalPackage value exists */
6652 lstrcpyA(buf
, "apple");
6653 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6654 MSIINSTALLCONTEXT_USERMANAGED
,
6655 INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
6656 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6657 ok(!lstrcmpA(buf
, "local"), "Expected \"local\", got \"%s\"\n", buf
);
6658 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6660 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
6661 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6663 /* Publisher value exists */
6665 lstrcpyA(buf
, "apple");
6666 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6667 MSIINSTALLCONTEXT_USERMANAGED
,
6668 INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
6669 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6670 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
6671 ok(sz
== 3, "Expected 3, got %d\n", sz
);
6673 res
= RegSetValueExA(propkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
6674 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6676 /* URLInfoAbout value exists */
6678 lstrcpyA(buf
, "apple");
6679 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6680 MSIINSTALLCONTEXT_USERMANAGED
,
6681 INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
6682 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6683 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
6684 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6686 res
= RegSetValueExA(propkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
6687 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6689 /* URLUpdateInfo value exists */
6691 lstrcpyA(buf
, "apple");
6692 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6693 MSIINSTALLCONTEXT_USERMANAGED
,
6694 INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
6695 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6696 ok(!lstrcmpA(buf
, "update"), "Expected \"update\", got \"%s\"\n", buf
);
6697 ok(sz
== 6, "Expected 6, got %d\n", sz
);
6699 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
6700 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6702 /* VersionMinor value exists */
6704 lstrcpyA(buf
, "apple");
6705 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6706 MSIINSTALLCONTEXT_USERMANAGED
,
6707 INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
6708 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6709 ok(!lstrcmpA(buf
, "2"), "Expected \"2\", got \"%s\"\n", buf
);
6710 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6712 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
6713 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6715 /* VersionMajor value exists */
6717 lstrcpyA(buf
, "apple");
6718 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6719 MSIINSTALLCONTEXT_USERMANAGED
,
6720 INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
6721 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6722 ok(!lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
6723 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6725 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
6726 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6728 /* DisplayVersion value exists */
6730 lstrcpyA(buf
, "apple");
6731 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6732 MSIINSTALLCONTEXT_USERMANAGED
,
6733 INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
6734 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6735 ok(!lstrcmpA(buf
, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf
);
6736 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6738 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
6739 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6741 /* ProductID value exists */
6743 lstrcpyA(buf
, "apple");
6744 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6745 MSIINSTALLCONTEXT_USERMANAGED
,
6746 INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
6747 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6748 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
6749 ok(sz
== 2, "Expected 2, got %d\n", sz
);
6751 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
6752 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6754 /* RegCompany value exists */
6756 lstrcpyA(buf
, "apple");
6757 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6758 MSIINSTALLCONTEXT_USERMANAGED
,
6759 INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
6760 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6761 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
6762 ok(sz
== 4, "Expected 4, got %d\n", sz
);
6764 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
6765 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6767 /* RegOwner value exists */
6769 lstrcpyA(buf
, "apple");
6770 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6771 MSIINSTALLCONTEXT_USERMANAGED
,
6772 INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
6773 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6774 ok(!lstrcmpA(buf
, "owner"), "Expected \"owner\", got \"%s\"\n", buf
);
6775 ok(sz
== 5, "Expected 5, got %d\n", sz
);
6777 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
6778 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6780 /* Transforms value exists */
6782 lstrcpyA(buf
, "apple");
6783 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6784 MSIINSTALLCONTEXT_USERMANAGED
,
6785 INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
6786 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6787 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6788 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6789 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6791 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
6792 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6794 /* Language value exists */
6796 lstrcpyA(buf
, "apple");
6797 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6798 MSIINSTALLCONTEXT_USERMANAGED
,
6799 INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
6800 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6801 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6802 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6803 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6805 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6806 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6808 /* ProductName value exists */
6810 lstrcpyA(buf
, "apple");
6811 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6812 MSIINSTALLCONTEXT_USERMANAGED
,
6813 INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
6814 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6815 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6816 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6817 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6819 res
= RegSetValueExA(propkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
6820 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6824 /* AssignmentType value exists */
6826 lstrcpyA(buf
, "apple");
6827 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6828 MSIINSTALLCONTEXT_USERMANAGED
,
6829 INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
6830 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6831 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6832 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6833 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6835 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
6836 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6838 /* PackageCode value exists */
6840 lstrcpyA(buf
, "apple");
6841 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6842 MSIINSTALLCONTEXT_USERMANAGED
,
6843 INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
6844 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6845 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6846 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6847 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6849 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
6850 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6852 /* Version value exists */
6854 lstrcpyA(buf
, "apple");
6855 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6856 MSIINSTALLCONTEXT_USERMANAGED
,
6857 INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
6858 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6859 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6860 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6861 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6863 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
6864 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6866 /* ProductIcon value exists */
6868 lstrcpyA(buf
, "apple");
6869 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6870 MSIINSTALLCONTEXT_USERMANAGED
,
6871 INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
6872 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6873 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6874 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6875 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6877 res
= RegSetValueExA(propkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
6878 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6880 /* PackageName value exists */
6882 lstrcpyA(buf
, "apple");
6883 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6884 MSIINSTALLCONTEXT_USERMANAGED
,
6885 INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
6886 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6887 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6888 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6889 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6891 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
6892 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6894 /* AuthorizedLUAApp value exists */
6896 lstrcpyA(buf
, "apple");
6897 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6898 MSIINSTALLCONTEXT_USERMANAGED
,
6899 INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
6900 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6901 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6902 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6903 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6905 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
6906 RegDeleteValueA(propkey
, "PackageName");
6907 RegDeleteValueA(propkey
, "ProductIcon");
6908 RegDeleteValueA(propkey
, "Version");
6909 RegDeleteValueA(propkey
, "PackageCode");
6910 RegDeleteValueA(propkey
, "AssignmentType");
6911 RegDeleteValueA(propkey
, "ProductName");
6912 RegDeleteValueA(propkey
, "Language");
6913 RegDeleteValueA(propkey
, "Transforms");
6914 RegDeleteValueA(propkey
, "RegOwner");
6915 RegDeleteValueA(propkey
, "RegCompany");
6916 RegDeleteValueA(propkey
, "ProductID");
6917 RegDeleteValueA(propkey
, "DisplayVersion");
6918 RegDeleteValueA(propkey
, "VersionMajor");
6919 RegDeleteValueA(propkey
, "VersionMinor");
6920 RegDeleteValueA(propkey
, "URLUpdateInfo");
6921 RegDeleteValueA(propkey
, "URLInfoAbout");
6922 RegDeleteValueA(propkey
, "Publisher");
6923 RegDeleteValueA(propkey
, "LocalPackage");
6924 RegDeleteValueA(propkey
, "InstallSource");
6925 RegDeleteValueA(propkey
, "InstallLocation");
6926 RegDeleteValueA(propkey
, "DisplayName");
6927 RegDeleteValueA(propkey
, "InstallDate");
6928 RegDeleteValueA(propkey
, "HelpTelephone");
6929 RegDeleteValueA(propkey
, "HelpLink");
6930 RegDeleteValueA(propkey
, "ManagedLocalPackage");
6931 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
6932 RegCloseKey(propkey
);
6933 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
6934 RegCloseKey(localkey
);
6936 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6937 lstrcatA(keypath
, usersid
);
6938 lstrcatA(keypath
, "\\Installer\\Products\\");
6939 lstrcatA(keypath
, prod_squashed
);
6941 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
6942 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6944 /* user product key exists */
6946 lstrcpyA(buf
, "apple");
6947 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6948 MSIINSTALLCONTEXT_USERMANAGED
,
6949 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6950 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
6951 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
6952 ok(sz
== 1, "Expected 1, got %d\n", sz
);
6954 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
6955 RegCloseKey(userkey
);
6957 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
6958 lstrcatA(keypath
, prod_squashed
);
6960 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
6961 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6963 /* current user product key exists */
6965 lstrcpyA(buf
, "apple");
6966 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6967 MSIINSTALLCONTEXT_USERMANAGED
,
6968 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
6969 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6970 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6971 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6972 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6974 res
= RegSetValueExA(prodkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6975 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6977 /* HelpLink value exists, user product key does not exist */
6979 lstrcpyA(buf
, "apple");
6980 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
6981 MSIINSTALLCONTEXT_USERMANAGED
,
6982 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
6983 ok(r
== ERROR_UNKNOWN_PRODUCT
,
6984 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
6985 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
6986 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
6988 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6989 lstrcatA(keypath
, usersid
);
6990 lstrcatA(keypath
, "\\Installer\\Products\\");
6991 lstrcatA(keypath
, prod_squashed
);
6993 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
6994 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6996 res
= RegSetValueExA(userkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
6997 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
6999 /* HelpLink value exists, user product key does exist */
7001 lstrcpyA(buf
, "apple");
7002 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7003 MSIINSTALLCONTEXT_USERMANAGED
,
7004 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
7005 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7006 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7007 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7008 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7010 res
= RegSetValueExA(userkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
7011 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7013 /* HelpTelephone value exists */
7015 lstrcpyA(buf
, "apple");
7016 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7017 MSIINSTALLCONTEXT_USERMANAGED
,
7018 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
7019 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7020 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7021 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7022 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7024 res
= RegSetValueExA(userkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
7025 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7027 /* InstallDate value exists */
7029 lstrcpyA(buf
, "apple");
7030 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7031 MSIINSTALLCONTEXT_USERMANAGED
,
7032 INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
7033 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7034 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7035 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7036 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7038 res
= RegSetValueExA(userkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7039 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7041 /* DisplayName value exists */
7043 lstrcpyA(buf
, "apple");
7044 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7045 MSIINSTALLCONTEXT_USERMANAGED
,
7046 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
7047 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7048 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7049 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7050 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7052 res
= RegSetValueExA(userkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
7053 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7055 /* InstallLocation value exists */
7057 lstrcpyA(buf
, "apple");
7058 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7059 MSIINSTALLCONTEXT_USERMANAGED
,
7060 INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
7061 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7062 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7063 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7064 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7066 res
= RegSetValueExA(userkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
7067 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7069 /* InstallSource value exists */
7071 lstrcpyA(buf
, "apple");
7072 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7073 MSIINSTALLCONTEXT_USERMANAGED
,
7074 INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
7075 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7076 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7077 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7078 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7080 res
= RegSetValueExA(userkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7081 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7083 /* LocalPackage value exists */
7085 lstrcpyA(buf
, "apple");
7086 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7087 MSIINSTALLCONTEXT_USERMANAGED
,
7088 INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
7089 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7090 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7091 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7092 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7094 res
= RegSetValueExA(userkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
7095 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7097 /* Publisher value exists */
7099 lstrcpyA(buf
, "apple");
7100 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7101 MSIINSTALLCONTEXT_USERMANAGED
,
7102 INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
7103 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7104 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7105 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7106 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7108 res
= RegSetValueExA(userkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
7109 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7111 /* URLInfoAbout value exists */
7113 lstrcpyA(buf
, "apple");
7114 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7115 MSIINSTALLCONTEXT_USERMANAGED
,
7116 INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
7117 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7118 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7119 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7120 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7122 res
= RegSetValueExA(userkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
7123 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7125 /* URLUpdateInfo value exists */
7127 lstrcpyA(buf
, "apple");
7128 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7129 MSIINSTALLCONTEXT_USERMANAGED
,
7130 INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
7131 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7132 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7133 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7134 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7136 res
= RegSetValueExA(userkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
7137 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7139 /* VersionMinor value exists */
7141 lstrcpyA(buf
, "apple");
7142 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7143 MSIINSTALLCONTEXT_USERMANAGED
,
7144 INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
7145 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7146 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7147 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7148 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7150 res
= RegSetValueExA(userkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
7151 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7153 /* VersionMajor value exists */
7155 lstrcpyA(buf
, "apple");
7156 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7157 MSIINSTALLCONTEXT_USERMANAGED
,
7158 INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
7159 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7160 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7161 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7162 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7164 res
= RegSetValueExA(userkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
7165 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7167 /* DisplayVersion value exists */
7169 lstrcpyA(buf
, "apple");
7170 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7171 MSIINSTALLCONTEXT_USERMANAGED
,
7172 INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
7173 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7174 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7175 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7176 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7178 res
= RegSetValueExA(userkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
7179 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7181 /* ProductID value exists */
7183 lstrcpyA(buf
, "apple");
7184 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7185 MSIINSTALLCONTEXT_USERMANAGED
,
7186 INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
7187 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7188 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7189 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7190 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7192 res
= RegSetValueExA(userkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
7193 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7195 /* RegCompany value exists */
7197 lstrcpyA(buf
, "apple");
7198 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7199 MSIINSTALLCONTEXT_USERMANAGED
,
7200 INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
7201 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7202 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7203 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7204 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7206 res
= RegSetValueExA(userkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
7207 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7209 /* RegOwner value exists */
7211 lstrcpyA(buf
, "apple");
7212 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7213 MSIINSTALLCONTEXT_USERMANAGED
,
7214 INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
7215 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7216 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7217 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7218 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7220 res
= RegSetValueExA(userkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
7221 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7223 /* Transforms value exists */
7225 lstrcpyA(buf
, "apple");
7226 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7227 MSIINSTALLCONTEXT_USERMANAGED
,
7228 INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
7229 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7230 ok(!lstrcmpA(buf
, "trans"), "Expected \"trans\", got \"%s\"\n", buf
);
7231 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7233 res
= RegSetValueExA(userkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
7234 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7236 /* Language value exists */
7238 lstrcpyA(buf
, "apple");
7239 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7240 MSIINSTALLCONTEXT_USERMANAGED
,
7241 INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
7242 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7243 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
7244 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7246 res
= RegSetValueExA(userkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7247 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7249 /* ProductName value exists */
7251 lstrcpyA(buf
, "apple");
7252 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7253 MSIINSTALLCONTEXT_USERMANAGED
,
7254 INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
7255 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7256 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
7257 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7259 res
= RegSetValueExA(userkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
7260 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7264 /* AssignmentType value exists */
7266 lstrcpyA(buf
, "apple");
7267 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7268 MSIINSTALLCONTEXT_USERMANAGED
,
7269 INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
7270 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7271 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
7272 ok(sz
== 0, "Expected 0, got %d\n", sz
);
7274 res
= RegSetValueExA(userkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
7275 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7279 /* PackageCode value exists */
7281 lstrcpyA(buf
, "apple");
7282 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7283 MSIINSTALLCONTEXT_USERMANAGED
,
7284 INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
7287 ok(r
== ERROR_BAD_CONFIGURATION
,
7288 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
7289 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7290 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7293 res
= RegSetValueExA(userkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
7294 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7296 /* Version value exists */
7298 lstrcpyA(buf
, "apple");
7299 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7300 MSIINSTALLCONTEXT_USERMANAGED
,
7301 INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
7302 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7303 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
7304 ok(sz
== 3, "Expected 3, got %d\n", sz
);
7306 res
= RegSetValueExA(userkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
7307 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7309 /* ProductIcon value exists */
7311 lstrcpyA(buf
, "apple");
7312 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7313 MSIINSTALLCONTEXT_USERMANAGED
,
7314 INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
7315 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7316 ok(!lstrcmpA(buf
, "icon"), "Expected \"icon\", got \"%s\"\n", buf
);
7317 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7319 res
= RegSetValueExA(userkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7320 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7322 /* PackageName value exists */
7324 lstrcpyA(buf
, "apple");
7325 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7326 MSIINSTALLCONTEXT_USERMANAGED
,
7327 INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
7330 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7331 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7332 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7333 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7336 res
= RegSetValueExA(userkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
7337 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7339 /* AuthorizedLUAApp value exists */
7341 lstrcpyA(buf
, "apple");
7342 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7343 MSIINSTALLCONTEXT_USERMANAGED
,
7344 INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
7345 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7346 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
7347 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7349 RegDeleteValueA(userkey
, "AuthorizedLUAApp");
7350 RegDeleteValueA(userkey
, "PackageName");
7351 RegDeleteValueA(userkey
, "ProductIcon");
7352 RegDeleteValueA(userkey
, "Version");
7353 RegDeleteValueA(userkey
, "PackageCode");
7354 RegDeleteValueA(userkey
, "AssignmentType");
7355 RegDeleteValueA(userkey
, "ProductName");
7356 RegDeleteValueA(userkey
, "Language");
7357 RegDeleteValueA(userkey
, "Transforms");
7358 RegDeleteValueA(userkey
, "RegOwner");
7359 RegDeleteValueA(userkey
, "RegCompany");
7360 RegDeleteValueA(userkey
, "ProductID");
7361 RegDeleteValueA(userkey
, "DisplayVersion");
7362 RegDeleteValueA(userkey
, "VersionMajor");
7363 RegDeleteValueA(userkey
, "VersionMinor");
7364 RegDeleteValueA(userkey
, "URLUpdateInfo");
7365 RegDeleteValueA(userkey
, "URLInfoAbout");
7366 RegDeleteValueA(userkey
, "Publisher");
7367 RegDeleteValueA(userkey
, "LocalPackage");
7368 RegDeleteValueA(userkey
, "InstallSource");
7369 RegDeleteValueA(userkey
, "InstallLocation");
7370 RegDeleteValueA(userkey
, "DisplayName");
7371 RegDeleteValueA(userkey
, "InstallDate");
7372 RegDeleteValueA(userkey
, "HelpTelephone");
7373 RegDeleteValueA(userkey
, "HelpLink");
7374 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
7375 RegCloseKey(userkey
);
7376 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
7377 RegCloseKey(prodkey
);
7379 /* MSIINSTALLCONTEXT_MACHINE */
7381 /* szUserSid is non-NULL */
7383 lstrcpyA(buf
, "apple");
7384 r
= pMsiGetProductInfoExA(prodcode
, usersid
,
7385 MSIINSTALLCONTEXT_MACHINE
,
7386 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
7387 ok(r
== ERROR_INVALID_PARAMETER
,
7388 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
7389 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7390 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7392 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
7393 lstrcatA(keypath
, prod_squashed
);
7395 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &localkey
, NULL
);
7396 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7398 /* local system product key exists */
7400 lstrcpyA(buf
, "apple");
7401 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7402 MSIINSTALLCONTEXT_MACHINE
,
7403 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
7404 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7405 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7406 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7407 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7409 res
= RegCreateKeyExA(localkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &propkey
, NULL
);
7410 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7412 /* InstallProperties key exists */
7414 lstrcpyA(buf
, "apple");
7415 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7416 MSIINSTALLCONTEXT_MACHINE
,
7417 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
7418 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7419 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7420 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7421 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7423 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7424 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7426 /* LocalPackage value exists */
7428 lstrcpyA(buf
, "apple");
7429 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7430 MSIINSTALLCONTEXT_MACHINE
,
7431 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
7432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7433 ok(!lstrcmpA(buf
, "5"), "Expected \"5\", got \"%s\"\n", buf
);
7434 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7436 res
= RegSetValueExA(propkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
7437 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7439 /* HelpLink value exists */
7441 lstrcpyA(buf
, "apple");
7442 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7443 MSIINSTALLCONTEXT_MACHINE
,
7444 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
7445 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7446 ok(!lstrcmpA(buf
, "link"), "Expected \"link\", got \"%s\"\n", buf
);
7447 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7449 res
= RegSetValueExA(propkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
7450 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7452 /* HelpTelephone value exists */
7454 lstrcpyA(buf
, "apple");
7455 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7456 MSIINSTALLCONTEXT_MACHINE
,
7457 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
7458 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7459 ok(!lstrcmpA(buf
, "phone"), "Expected \"phone\", got \"%s\"\n", buf
);
7460 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7462 res
= RegSetValueExA(propkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
7463 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7465 /* InstallDate value exists */
7467 lstrcpyA(buf
, "apple");
7468 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7469 MSIINSTALLCONTEXT_MACHINE
,
7470 INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
7471 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7472 ok(!lstrcmpA(buf
, "date"), "Expected \"date\", got \"%s\"\n", buf
);
7473 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7475 res
= RegSetValueExA(propkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7476 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7478 /* DisplayName value exists */
7480 lstrcpyA(buf
, "apple");
7481 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7482 MSIINSTALLCONTEXT_MACHINE
,
7483 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
7484 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7485 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
7486 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7488 res
= RegSetValueExA(propkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
7489 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7491 /* InstallLocation value exists */
7493 lstrcpyA(buf
, "apple");
7494 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7495 MSIINSTALLCONTEXT_MACHINE
,
7496 INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
7497 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7498 ok(!lstrcmpA(buf
, "loc"), "Expected \"loc\", got \"%s\"\n", buf
);
7499 ok(sz
== 3, "Expected 3, got %d\n", sz
);
7501 res
= RegSetValueExA(propkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
7502 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7504 /* InstallSource value exists */
7506 lstrcpyA(buf
, "apple");
7507 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7508 MSIINSTALLCONTEXT_MACHINE
,
7509 INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
7510 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7511 ok(!lstrcmpA(buf
, "source"), "Expected \"source\", got \"%s\"\n", buf
);
7512 ok(sz
== 6, "Expected 6, got %d\n", sz
);
7514 res
= RegSetValueExA(propkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7515 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7517 /* LocalPackage value exists */
7519 lstrcpyA(buf
, "apple");
7520 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7521 MSIINSTALLCONTEXT_MACHINE
,
7522 INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
7523 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7524 ok(!lstrcmpA(buf
, "local"), "Expected \"local\", got \"%s\"\n", buf
);
7525 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7527 res
= RegSetValueExA(propkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
7528 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7530 /* Publisher value exists */
7532 lstrcpyA(buf
, "apple");
7533 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7534 MSIINSTALLCONTEXT_MACHINE
,
7535 INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
7536 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7537 ok(!lstrcmpA(buf
, "pub"), "Expected \"pub\", got \"%s\"\n", buf
);
7538 ok(sz
== 3, "Expected 3, got %d\n", sz
);
7540 res
= RegSetValueExA(propkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
7541 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7543 /* URLInfoAbout value exists */
7545 lstrcpyA(buf
, "apple");
7546 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7547 MSIINSTALLCONTEXT_MACHINE
,
7548 INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
7549 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7550 ok(!lstrcmpA(buf
, "about"), "Expected \"about\", got \"%s\"\n", buf
);
7551 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7553 res
= RegSetValueExA(propkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
7554 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7556 /* URLUpdateInfo value exists */
7558 lstrcpyA(buf
, "apple");
7559 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7560 MSIINSTALLCONTEXT_MACHINE
,
7561 INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
7562 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7563 ok(!lstrcmpA(buf
, "update"), "Expected \"update\", got \"%s\"\n", buf
);
7564 ok(sz
== 6, "Expected 6, got %d\n", sz
);
7566 res
= RegSetValueExA(propkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
7567 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7569 /* VersionMinor value exists */
7571 lstrcpyA(buf
, "apple");
7572 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7573 MSIINSTALLCONTEXT_MACHINE
,
7574 INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
7575 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7576 ok(!lstrcmpA(buf
, "2"), "Expected \"2\", got \"%s\"\n", buf
);
7577 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7579 res
= RegSetValueExA(propkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
7580 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7582 /* VersionMajor value exists */
7584 lstrcpyA(buf
, "apple");
7585 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7586 MSIINSTALLCONTEXT_MACHINE
,
7587 INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
7588 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7589 ok(!lstrcmpA(buf
, "3"), "Expected \"3\", got \"%s\"\n", buf
);
7590 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7592 res
= RegSetValueExA(propkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
7593 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7595 /* DisplayVersion value exists */
7597 lstrcpyA(buf
, "apple");
7598 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7599 MSIINSTALLCONTEXT_MACHINE
,
7600 INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
7601 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7602 ok(!lstrcmpA(buf
, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf
);
7603 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7605 res
= RegSetValueExA(propkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
7606 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7608 /* ProductID value exists */
7610 lstrcpyA(buf
, "apple");
7611 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7612 MSIINSTALLCONTEXT_MACHINE
,
7613 INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
7614 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7615 ok(!lstrcmpA(buf
, "id"), "Expected \"id\", got \"%s\"\n", buf
);
7616 ok(sz
== 2, "Expected 2, got %d\n", sz
);
7618 res
= RegSetValueExA(propkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
7619 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7621 /* RegCompany value exists */
7623 lstrcpyA(buf
, "apple");
7624 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7625 MSIINSTALLCONTEXT_MACHINE
,
7626 INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
7627 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7628 ok(!lstrcmpA(buf
, "comp"), "Expected \"comp\", got \"%s\"\n", buf
);
7629 ok(sz
== 4, "Expected 4, got %d\n", sz
);
7631 res
= RegSetValueExA(propkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
7632 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7634 /* RegOwner value exists */
7636 lstrcpyA(buf
, "apple");
7637 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7638 MSIINSTALLCONTEXT_MACHINE
,
7639 INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
7640 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7641 ok(!lstrcmpA(buf
, "owner"), "Expected \"owner\", got \"%s\"\n", buf
);
7642 ok(sz
== 5, "Expected 5, got %d\n", sz
);
7644 res
= RegSetValueExA(propkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
7645 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7647 /* Transforms value exists */
7649 lstrcpyA(buf
, "apple");
7650 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7651 MSIINSTALLCONTEXT_MACHINE
,
7652 INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
7653 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7654 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7655 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7656 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7658 res
= RegSetValueExA(propkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
7659 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7661 /* Language value exists */
7663 lstrcpyA(buf
, "apple");
7664 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7665 MSIINSTALLCONTEXT_MACHINE
,
7666 INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
7667 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7668 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7669 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7670 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7672 res
= RegSetValueExA(propkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7673 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7675 /* ProductName value exists */
7677 lstrcpyA(buf
, "apple");
7678 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7679 MSIINSTALLCONTEXT_MACHINE
,
7680 INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
7681 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7682 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7683 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7684 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7686 res
= RegSetValueExA(propkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
7687 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7691 /* AssignmentType value exists */
7693 lstrcpyA(buf
, "apple");
7694 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7695 MSIINSTALLCONTEXT_MACHINE
,
7696 INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
7697 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7698 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7699 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7700 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7702 res
= RegSetValueExA(propkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
7703 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7705 /* PackageCode value exists */
7707 lstrcpyA(buf
, "apple");
7708 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7709 MSIINSTALLCONTEXT_MACHINE
,
7710 INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
7711 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7712 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7713 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7714 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7716 res
= RegSetValueExA(propkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
7717 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7719 /* Version value exists */
7721 lstrcpyA(buf
, "apple");
7722 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7723 MSIINSTALLCONTEXT_MACHINE
,
7724 INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
7725 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7726 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7727 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7728 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7730 res
= RegSetValueExA(propkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
7731 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7733 /* ProductIcon value exists */
7735 lstrcpyA(buf
, "apple");
7736 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7737 MSIINSTALLCONTEXT_MACHINE
,
7738 INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
7739 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7740 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7741 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7742 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7744 res
= RegSetValueExA(propkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7745 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7747 /* PackageName value exists */
7749 lstrcpyA(buf
, "apple");
7750 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7751 MSIINSTALLCONTEXT_MACHINE
,
7752 INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
7753 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7754 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7755 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7756 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7758 res
= RegSetValueExA(propkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
7759 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7761 /* AuthorizedLUAApp value exists */
7763 lstrcpyA(buf
, "apple");
7764 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7765 MSIINSTALLCONTEXT_MACHINE
,
7766 INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
7767 ok(r
== ERROR_UNKNOWN_PRODUCT
,
7768 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
7769 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7770 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7772 RegDeleteValueA(propkey
, "AuthorizedLUAApp");
7773 RegDeleteValueA(propkey
, "PackageName");
7774 RegDeleteValueA(propkey
, "ProductIcon");
7775 RegDeleteValueA(propkey
, "Version");
7776 RegDeleteValueA(propkey
, "PackageCode");
7777 RegDeleteValueA(propkey
, "AssignmentType");
7778 RegDeleteValueA(propkey
, "ProductName");
7779 RegDeleteValueA(propkey
, "Language");
7780 RegDeleteValueA(propkey
, "Transforms");
7781 RegDeleteValueA(propkey
, "RegOwner");
7782 RegDeleteValueA(propkey
, "RegCompany");
7783 RegDeleteValueA(propkey
, "ProductID");
7784 RegDeleteValueA(propkey
, "DisplayVersion");
7785 RegDeleteValueA(propkey
, "VersionMajor");
7786 RegDeleteValueA(propkey
, "VersionMinor");
7787 RegDeleteValueA(propkey
, "URLUpdateInfo");
7788 RegDeleteValueA(propkey
, "URLInfoAbout");
7789 RegDeleteValueA(propkey
, "Publisher");
7790 RegDeleteValueA(propkey
, "LocalPackage");
7791 RegDeleteValueA(propkey
, "InstallSource");
7792 RegDeleteValueA(propkey
, "InstallLocation");
7793 RegDeleteValueA(propkey
, "DisplayName");
7794 RegDeleteValueA(propkey
, "InstallDate");
7795 RegDeleteValueA(propkey
, "HelpTelephone");
7796 RegDeleteValueA(propkey
, "HelpLink");
7797 RegDeleteValueA(propkey
, "LocalPackage");
7798 delete_key(propkey
, "", access
& KEY_WOW64_64KEY
);
7799 RegCloseKey(propkey
);
7800 delete_key(localkey
, "", access
& KEY_WOW64_64KEY
);
7801 RegCloseKey(localkey
);
7803 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
7804 lstrcatA(keypath
, prod_squashed
);
7806 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
7807 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7809 /* local classes product key exists */
7811 lstrcpyA(buf
, "apple");
7812 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7813 MSIINSTALLCONTEXT_MACHINE
,
7814 INSTALLPROPERTY_PRODUCTSTATEA
, buf
, &sz
);
7815 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
7816 ok(!lstrcmpA(buf
, "1"), "Expected \"1\", got \"%s\"\n", buf
);
7817 ok(sz
== 1, "Expected 1, got %d\n", sz
);
7819 res
= RegSetValueExA(prodkey
, "HelpLink", 0, REG_SZ
, (LPBYTE
)"link", 5);
7820 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7822 /* HelpLink value exists */
7824 lstrcpyA(buf
, "apple");
7825 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7826 MSIINSTALLCONTEXT_MACHINE
,
7827 INSTALLPROPERTY_HELPLINKA
, buf
, &sz
);
7828 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7829 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7830 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7831 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7833 res
= RegSetValueExA(prodkey
, "HelpTelephone", 0, REG_SZ
, (LPBYTE
)"phone", 6);
7834 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7836 /* HelpTelephone value exists */
7838 lstrcpyA(buf
, "apple");
7839 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7840 MSIINSTALLCONTEXT_MACHINE
,
7841 INSTALLPROPERTY_HELPTELEPHONEA
, buf
, &sz
);
7842 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7843 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7844 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7845 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7847 res
= RegSetValueExA(prodkey
, "InstallDate", 0, REG_SZ
, (LPBYTE
)"date", 5);
7848 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7850 /* InstallDate value exists */
7852 lstrcpyA(buf
, "apple");
7853 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7854 MSIINSTALLCONTEXT_MACHINE
,
7855 INSTALLPROPERTY_INSTALLDATEA
, buf
, &sz
);
7856 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7857 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7858 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7859 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7861 res
= RegSetValueExA(prodkey
, "DisplayName", 0, REG_SZ
, (LPBYTE
)"name", 5);
7862 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7864 /* DisplayName value exists */
7866 lstrcpyA(buf
, "apple");
7867 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7868 MSIINSTALLCONTEXT_MACHINE
,
7869 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA
, buf
, &sz
);
7870 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7871 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7872 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7873 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7875 res
= RegSetValueExA(prodkey
, "InstallLocation", 0, REG_SZ
, (LPBYTE
)"loc", 4);
7876 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7878 /* InstallLocation value exists */
7880 lstrcpyA(buf
, "apple");
7881 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7882 MSIINSTALLCONTEXT_MACHINE
,
7883 INSTALLPROPERTY_INSTALLLOCATIONA
, buf
, &sz
);
7884 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7885 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7886 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7887 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7889 res
= RegSetValueExA(prodkey
, "InstallSource", 0, REG_SZ
, (LPBYTE
)"source", 7);
7890 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7892 /* InstallSource value exists */
7894 lstrcpyA(buf
, "apple");
7895 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7896 MSIINSTALLCONTEXT_MACHINE
,
7897 INSTALLPROPERTY_INSTALLSOURCEA
, buf
, &sz
);
7898 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7899 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7900 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7901 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7903 res
= RegSetValueExA(prodkey
, "LocalPackage", 0, REG_SZ
, (LPBYTE
)"local", 6);
7904 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7906 /* LocalPackage value exists */
7908 lstrcpyA(buf
, "apple");
7909 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7910 MSIINSTALLCONTEXT_MACHINE
,
7911 INSTALLPROPERTY_LOCALPACKAGEA
, buf
, &sz
);
7912 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7913 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7914 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7915 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7917 res
= RegSetValueExA(prodkey
, "Publisher", 0, REG_SZ
, (LPBYTE
)"pub", 4);
7918 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7920 /* Publisher value exists */
7922 lstrcpyA(buf
, "apple");
7923 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7924 MSIINSTALLCONTEXT_MACHINE
,
7925 INSTALLPROPERTY_PUBLISHERA
, buf
, &sz
);
7926 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7927 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7928 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7929 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7931 res
= RegSetValueExA(prodkey
, "URLInfoAbout", 0, REG_SZ
, (LPBYTE
)"about", 6);
7932 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7934 /* URLInfoAbout value exists */
7936 lstrcpyA(buf
, "apple");
7937 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7938 MSIINSTALLCONTEXT_MACHINE
,
7939 INSTALLPROPERTY_URLINFOABOUTA
, buf
, &sz
);
7940 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7941 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7942 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7943 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7945 res
= RegSetValueExA(prodkey
, "URLUpdateInfo", 0, REG_SZ
, (LPBYTE
)"update", 7);
7946 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7948 /* URLUpdateInfo value exists */
7950 lstrcpyA(buf
, "apple");
7951 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7952 MSIINSTALLCONTEXT_MACHINE
,
7953 INSTALLPROPERTY_URLUPDATEINFOA
, buf
, &sz
);
7954 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7955 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7956 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7957 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7959 res
= RegSetValueExA(prodkey
, "VersionMinor", 0, REG_SZ
, (LPBYTE
)"2", 2);
7960 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7962 /* VersionMinor value exists */
7964 lstrcpyA(buf
, "apple");
7965 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7966 MSIINSTALLCONTEXT_MACHINE
,
7967 INSTALLPROPERTY_VERSIONMINORA
, buf
, &sz
);
7968 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7969 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7970 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7971 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7973 res
= RegSetValueExA(prodkey
, "VersionMajor", 0, REG_SZ
, (LPBYTE
)"3", 2);
7974 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7976 /* VersionMajor value exists */
7978 lstrcpyA(buf
, "apple");
7979 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7980 MSIINSTALLCONTEXT_MACHINE
,
7981 INSTALLPROPERTY_VERSIONMAJORA
, buf
, &sz
);
7982 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7983 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7984 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7985 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
7987 res
= RegSetValueExA(prodkey
, "DisplayVersion", 0, REG_SZ
, (LPBYTE
)"3.2.1", 6);
7988 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
7990 /* DisplayVersion value exists */
7992 lstrcpyA(buf
, "apple");
7993 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
7994 MSIINSTALLCONTEXT_MACHINE
,
7995 INSTALLPROPERTY_VERSIONSTRINGA
, buf
, &sz
);
7996 ok(r
== ERROR_UNKNOWN_PROPERTY
,
7997 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
7998 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
7999 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8001 res
= RegSetValueExA(prodkey
, "ProductID", 0, REG_SZ
, (LPBYTE
)"id", 3);
8002 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8004 /* ProductID value exists */
8006 lstrcpyA(buf
, "apple");
8007 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8008 MSIINSTALLCONTEXT_MACHINE
,
8009 INSTALLPROPERTY_PRODUCTIDA
, buf
, &sz
);
8010 ok(r
== ERROR_UNKNOWN_PROPERTY
,
8011 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
8012 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
8013 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8015 res
= RegSetValueExA(prodkey
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"comp", 5);
8016 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8018 /* RegCompany value exists */
8020 lstrcpyA(buf
, "apple");
8021 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8022 MSIINSTALLCONTEXT_MACHINE
,
8023 INSTALLPROPERTY_REGCOMPANYA
, buf
, &sz
);
8024 ok(r
== ERROR_UNKNOWN_PROPERTY
,
8025 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
8026 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
8027 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8029 res
= RegSetValueExA(prodkey
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8030 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8032 /* RegOwner value exists */
8034 lstrcpyA(buf
, "apple");
8035 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8036 MSIINSTALLCONTEXT_MACHINE
,
8037 INSTALLPROPERTY_REGOWNERA
, buf
, &sz
);
8038 ok(r
== ERROR_UNKNOWN_PROPERTY
,
8039 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
8040 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
8041 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8043 res
= RegSetValueExA(prodkey
, "Transforms", 0, REG_SZ
, (LPBYTE
)"trans", 6);
8044 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8046 /* Transforms value exists */
8048 lstrcpyA(buf
, "apple");
8049 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8050 MSIINSTALLCONTEXT_MACHINE
,
8051 INSTALLPROPERTY_TRANSFORMSA
, buf
, &sz
);
8052 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8053 ok(!lstrcmpA(buf
, "trans"), "Expected \"trans\", got \"%s\"\n", buf
);
8054 ok(sz
== 5, "Expected 5, got %d\n", sz
);
8056 res
= RegSetValueExA(prodkey
, "Language", 0, REG_SZ
, (LPBYTE
)"lang", 5);
8057 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8059 /* Language value exists */
8061 lstrcpyA(buf
, "apple");
8062 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8063 MSIINSTALLCONTEXT_MACHINE
,
8064 INSTALLPROPERTY_LANGUAGEA
, buf
, &sz
);
8065 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8066 ok(!lstrcmpA(buf
, "lang"), "Expected \"lang\", got \"%s\"\n", buf
);
8067 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8069 res
= RegSetValueExA(prodkey
, "ProductName", 0, REG_SZ
, (LPBYTE
)"name", 5);
8070 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8072 /* ProductName value exists */
8074 lstrcpyA(buf
, "apple");
8075 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8076 MSIINSTALLCONTEXT_MACHINE
,
8077 INSTALLPROPERTY_PRODUCTNAMEA
, buf
, &sz
);
8078 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8079 ok(!lstrcmpA(buf
, "name"), "Expected \"name\", got \"%s\"\n", buf
);
8080 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8082 res
= RegSetValueExA(prodkey
, "AssignmentType", 0, REG_SZ
, (LPBYTE
)"type", 5);
8083 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8087 /* AssignmentType value exists */
8089 lstrcpyA(buf
, "apple");
8090 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8091 MSIINSTALLCONTEXT_MACHINE
,
8092 INSTALLPROPERTY_ASSIGNMENTTYPEA
, buf
, &sz
);
8093 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8094 ok(!lstrcmpA(buf
, ""), "Expected \"\", got \"%s\"\n", buf
);
8095 ok(sz
== 0, "Expected 0, got %d\n", sz
);
8097 res
= RegSetValueExA(prodkey
, "PackageCode", 0, REG_SZ
, (LPBYTE
)"code", 5);
8098 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8102 /* PackageCode value exists */
8104 lstrcpyA(buf
, "apple");
8105 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8106 MSIINSTALLCONTEXT_MACHINE
,
8107 INSTALLPROPERTY_PACKAGECODEA
, buf
, &sz
);
8110 ok(r
== ERROR_BAD_CONFIGURATION
,
8111 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
8112 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
8113 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8116 res
= RegSetValueExA(prodkey
, "Version", 0, REG_SZ
, (LPBYTE
)"ver", 4);
8117 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8119 /* Version value exists */
8121 lstrcpyA(buf
, "apple");
8122 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8123 MSIINSTALLCONTEXT_MACHINE
,
8124 INSTALLPROPERTY_VERSIONA
, buf
, &sz
);
8125 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8126 ok(!lstrcmpA(buf
, "ver"), "Expected \"ver\", got \"%s\"\n", buf
);
8127 ok(sz
== 3, "Expected 3, got %d\n", sz
);
8129 res
= RegSetValueExA(prodkey
, "ProductIcon", 0, REG_SZ
, (LPBYTE
)"icon", 5);
8130 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8132 /* ProductIcon value exists */
8134 lstrcpyA(buf
, "apple");
8135 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8136 MSIINSTALLCONTEXT_MACHINE
,
8137 INSTALLPROPERTY_PRODUCTICONA
, buf
, &sz
);
8138 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8139 ok(!lstrcmpA(buf
, "icon"), "Expected \"icon\", got \"%s\"\n", buf
);
8140 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8142 res
= RegSetValueExA(prodkey
, "PackageName", 0, REG_SZ
, (LPBYTE
)"name", 5);
8143 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8145 /* PackageName value exists */
8147 lstrcpyA(buf
, "apple");
8148 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8149 MSIINSTALLCONTEXT_MACHINE
,
8150 INSTALLPROPERTY_PACKAGENAMEA
, buf
, &sz
);
8153 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8154 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8155 ok(!lstrcmpA(buf
, "apple"), "Expected buf to be unchanged, got %s\n", buf
);
8156 ok(sz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", sz
);
8159 res
= RegSetValueExA(prodkey
, "AuthorizedLUAApp", 0, REG_SZ
, (LPBYTE
)"auth", 5);
8160 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8162 /* AuthorizedLUAApp value exists */
8164 lstrcpyA(buf
, "apple");
8165 r
= pMsiGetProductInfoExA(prodcode
, NULL
,
8166 MSIINSTALLCONTEXT_MACHINE
,
8167 INSTALLPROPERTY_AUTHORIZED_LUA_APPA
, buf
, &sz
);
8168 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8169 ok(!lstrcmpA(buf
, "auth"), "Expected \"auth\", got \"%s\"\n", buf
);
8170 ok(sz
== 4, "Expected 4, got %d\n", sz
);
8172 RegDeleteValueA(prodkey
, "AuthorizedLUAApp");
8173 RegDeleteValueA(prodkey
, "PackageName");
8174 RegDeleteValueA(prodkey
, "ProductIcon");
8175 RegDeleteValueA(prodkey
, "Version");
8176 RegDeleteValueA(prodkey
, "PackageCode");
8177 RegDeleteValueA(prodkey
, "AssignmentType");
8178 RegDeleteValueA(prodkey
, "ProductName");
8179 RegDeleteValueA(prodkey
, "Language");
8180 RegDeleteValueA(prodkey
, "Transforms");
8181 RegDeleteValueA(prodkey
, "RegOwner");
8182 RegDeleteValueA(prodkey
, "RegCompany");
8183 RegDeleteValueA(prodkey
, "ProductID");
8184 RegDeleteValueA(prodkey
, "DisplayVersion");
8185 RegDeleteValueA(prodkey
, "VersionMajor");
8186 RegDeleteValueA(prodkey
, "VersionMinor");
8187 RegDeleteValueA(prodkey
, "URLUpdateInfo");
8188 RegDeleteValueA(prodkey
, "URLInfoAbout");
8189 RegDeleteValueA(prodkey
, "Publisher");
8190 RegDeleteValueA(prodkey
, "LocalPackage");
8191 RegDeleteValueA(prodkey
, "InstallSource");
8192 RegDeleteValueA(prodkey
, "InstallLocation");
8193 RegDeleteValueA(prodkey
, "DisplayName");
8194 RegDeleteValueA(prodkey
, "InstallDate");
8195 RegDeleteValueA(prodkey
, "HelpTelephone");
8196 RegDeleteValueA(prodkey
, "HelpLink");
8197 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8198 RegCloseKey(prodkey
);
8202 #define INIT_USERINFO() \
8203 lstrcpyA(user, "apple"); \
8204 lstrcpyA(org, "orange"); \
8205 lstrcpyA(serial, "banana"); \
8206 usersz = orgsz = serialsz = MAX_PATH;
8208 static void test_MsiGetUserInfo(void)
8210 USERINFOSTATE state
;
8211 CHAR user
[MAX_PATH
];
8213 CHAR serial
[MAX_PATH
];
8214 DWORD usersz
, orgsz
, serialsz
;
8215 CHAR keypath
[MAX_PATH
* 2];
8216 CHAR prodcode
[MAX_PATH
];
8217 CHAR prod_squashed
[MAX_PATH
];
8218 HKEY prodkey
, userprod
, props
;
8221 REGSAM access
= KEY_ALL_ACCESS
;
8223 create_test_guid(prodcode
, prod_squashed
);
8224 usersid
= get_user_sid();
8227 access
|= KEY_WOW64_64KEY
;
8229 /* NULL szProduct */
8231 state
= MsiGetUserInfoA(NULL
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8232 ok(state
== USERINFOSTATE_INVALIDARG
,
8233 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8234 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8235 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8236 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8237 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8238 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8239 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8241 /* empty szProductCode */
8243 state
= MsiGetUserInfoA("", user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8244 ok(state
== USERINFOSTATE_INVALIDARG
,
8245 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8246 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8247 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8248 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8249 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8250 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8251 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8253 /* garbage szProductCode */
8255 state
= MsiGetUserInfoA("garbage", user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8256 ok(state
== USERINFOSTATE_INVALIDARG
,
8257 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8258 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8259 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8260 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8261 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8262 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8263 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8265 /* guid without brackets */
8267 state
= MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
8268 user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8269 ok(state
== USERINFOSTATE_INVALIDARG
,
8270 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8271 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8272 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8273 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8274 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8275 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8276 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8278 /* guid with brackets */
8280 state
= MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
8281 user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8282 ok(state
== USERINFOSTATE_UNKNOWN
,
8283 "Expected USERINFOSTATE_UNKNOWN, 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(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8289 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8291 /* NULL lpUserNameBuf */
8293 state
= MsiGetUserInfoA(prodcode
, NULL
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8294 ok(state
== USERINFOSTATE_UNKNOWN
,
8295 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8296 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8297 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8298 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8299 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8300 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8302 /* NULL pcchUserNameBuf */
8304 state
= MsiGetUserInfoA(prodcode
, user
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8305 ok(state
== USERINFOSTATE_INVALIDARG
,
8306 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8307 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8308 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8309 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8310 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8311 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8313 /* both lpUserNameBuf and pcchUserNameBuf NULL */
8315 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8316 ok(state
== USERINFOSTATE_UNKNOWN
,
8317 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8318 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8319 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8320 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8321 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8323 /* NULL lpOrgNameBuf */
8325 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, NULL
, &orgsz
, serial
, &serialsz
);
8326 ok(state
== USERINFOSTATE_UNKNOWN
,
8327 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8328 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8329 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8330 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8331 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8332 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8334 /* NULL pcchOrgNameBuf */
8336 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, NULL
, serial
, &serialsz
);
8337 ok(state
== USERINFOSTATE_INVALIDARG
,
8338 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8339 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8340 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8341 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8342 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8343 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8345 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
8347 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, NULL
, NULL
, serial
, &serialsz
);
8348 ok(state
== USERINFOSTATE_UNKNOWN
,
8349 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8350 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8351 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8352 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8353 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8355 /* NULL lpSerialBuf */
8357 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, NULL
, &serialsz
);
8358 ok(state
== USERINFOSTATE_UNKNOWN
,
8359 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8360 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8361 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8362 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8363 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8364 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8366 /* NULL pcchSerialBuf */
8368 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, NULL
);
8369 ok(state
== USERINFOSTATE_INVALIDARG
,
8370 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state
);
8371 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8372 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8373 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8374 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8375 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8377 /* both lpSerialBuf and pcchSerialBuf NULL */
8379 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, NULL
, NULL
);
8380 ok(state
== USERINFOSTATE_UNKNOWN
,
8381 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state
);
8382 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8383 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8384 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8385 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8387 /* MSIINSTALLCONTEXT_USERMANAGED */
8389 /* create local system product key */
8390 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
8391 lstrcatA(keypath
, usersid
);
8392 lstrcatA(keypath
, "\\Installer\\Products\\");
8393 lstrcatA(keypath
, prod_squashed
);
8395 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8396 if (res
== ERROR_ACCESS_DENIED
)
8398 skip("Not enough rights to perform tests\n");
8402 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8404 /* managed product key exists */
8406 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8407 ok(state
== USERINFOSTATE_ABSENT
,
8408 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8409 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8410 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8411 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8412 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8413 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8414 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8416 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8417 lstrcatA(keypath
, "Installer\\UserData\\");
8418 lstrcatA(keypath
, usersid
);
8419 lstrcatA(keypath
, "\\Products\\");
8420 lstrcatA(keypath
, prod_squashed
);
8422 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userprod
, NULL
);
8423 if (res
== ERROR_ACCESS_DENIED
)
8425 skip("Not enough rights to perform tests\n");
8429 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8431 res
= RegCreateKeyExA(userprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8432 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8434 /* InstallProperties key exists */
8436 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8437 ok(state
== USERINFOSTATE_ABSENT
,
8438 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8439 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8440 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8441 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8442 ok(usersz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", usersz
);
8443 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8444 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8446 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8448 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8449 ok(state
== USERINFOSTATE_ABSENT
,
8450 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8451 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8452 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8453 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8454 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8456 /* RegOwner, RegCompany don't exist, out params are NULL */
8458 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, NULL
, NULL
, serial
, &serialsz
);
8459 ok(state
== USERINFOSTATE_ABSENT
,
8460 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8461 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8462 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8464 res
= RegSetValueExA(props
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8465 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8467 /* RegOwner value exists */
8469 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8470 ok(state
== USERINFOSTATE_ABSENT
,
8471 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8472 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8473 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8474 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8475 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8476 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8477 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8479 res
= RegSetValueExA(props
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"company", 8);
8480 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8482 /* RegCompany value exists */
8484 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8485 ok(state
== USERINFOSTATE_ABSENT
,
8486 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8487 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8488 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8489 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8490 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8491 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8492 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8494 res
= RegSetValueExA(props
, "ProductID", 0, REG_SZ
, (LPBYTE
)"ID", 3);
8495 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8497 /* ProductID value exists */
8499 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8500 ok(state
== USERINFOSTATE_PRESENT
,
8501 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8502 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8503 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8504 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8505 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8506 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8507 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8509 /* pcchUserNameBuf is too small */
8512 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8513 ok(state
== USERINFOSTATE_MOREDATA
,
8514 "Expected USERINFOSTATE_MOREDATA, got %d\n", state
);
8515 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8516 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8517 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8518 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8519 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8520 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8522 /* pcchUserNameBuf has no room for NULL terminator */
8525 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8526 ok(state
== USERINFOSTATE_MOREDATA
,
8527 "Expected USERINFOSTATE_MOREDATA, got %d\n", state
);
8530 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8532 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8533 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8534 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8535 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8536 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8538 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
8541 state
= MsiGetUserInfoA(prodcode
, NULL
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8542 ok(state
== USERINFOSTATE_PRESENT
,
8543 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8544 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8545 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8546 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8547 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8548 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8549 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8551 RegDeleteValueA(props
, "ProductID");
8552 RegDeleteValueA(props
, "RegCompany");
8553 RegDeleteValueA(props
, "RegOwner");
8554 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8556 delete_key(userprod
, "", access
& KEY_WOW64_64KEY
);
8557 RegCloseKey(userprod
);
8558 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8559 RegCloseKey(prodkey
);
8561 /* MSIINSTALLCONTEXT_USERUNMANAGED */
8563 /* create local system product key */
8564 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
8565 lstrcatA(keypath
, prod_squashed
);
8567 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
8568 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8570 /* product key exists */
8572 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8573 ok(state
== USERINFOSTATE_ABSENT
,
8574 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8575 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8576 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8577 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8578 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8579 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8580 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8582 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8583 lstrcatA(keypath
, "Installer\\UserData\\");
8584 lstrcatA(keypath
, usersid
);
8585 lstrcatA(keypath
, "\\Products\\");
8586 lstrcatA(keypath
, prod_squashed
);
8588 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userprod
, NULL
);
8589 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8591 res
= RegCreateKeyExA(userprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8592 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8594 /* InstallProperties key exists */
8596 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8597 ok(state
== USERINFOSTATE_ABSENT
,
8598 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8599 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8600 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8601 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8602 ok(usersz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", usersz
);
8603 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8604 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8606 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8608 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8609 ok(state
== USERINFOSTATE_ABSENT
,
8610 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8611 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8612 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8613 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8614 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8616 /* RegOwner, RegCompany don't exist, out params are NULL */
8618 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, NULL
, NULL
, serial
, &serialsz
);
8619 ok(state
== USERINFOSTATE_ABSENT
,
8620 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8621 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8622 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8624 res
= RegSetValueExA(props
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8625 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8627 /* RegOwner value exists */
8629 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8630 ok(state
== USERINFOSTATE_ABSENT
,
8631 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8632 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8633 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8634 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8635 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8636 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8637 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8639 res
= RegSetValueExA(props
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"company", 8);
8640 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8642 /* RegCompany value exists */
8644 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8645 ok(state
== USERINFOSTATE_ABSENT
,
8646 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8647 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8648 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8649 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8650 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8651 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8652 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8654 res
= RegSetValueExA(props
, "ProductID", 0, REG_SZ
, (LPBYTE
)"ID", 3);
8655 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8657 /* ProductID value exists */
8659 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8660 ok(state
== USERINFOSTATE_PRESENT
,
8661 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8662 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8663 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8664 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8665 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8666 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8667 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8669 RegDeleteValueA(props
, "ProductID");
8670 RegDeleteValueA(props
, "RegCompany");
8671 RegDeleteValueA(props
, "RegOwner");
8672 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8674 delete_key(userprod
, "", access
& KEY_WOW64_64KEY
);
8675 RegCloseKey(userprod
);
8676 RegDeleteKeyA(prodkey
, "");
8677 RegCloseKey(prodkey
);
8679 /* MSIINSTALLCONTEXT_MACHINE */
8681 /* create local system product key */
8682 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
8683 lstrcatA(keypath
, prod_squashed
);
8685 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8686 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8688 /* product key exists */
8690 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8691 ok(state
== USERINFOSTATE_ABSENT
,
8692 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8693 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8694 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8695 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8696 ok(usersz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", usersz
);
8697 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8698 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8700 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8701 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18");
8702 lstrcatA(keypath
, "\\Products\\");
8703 lstrcatA(keypath
, prod_squashed
);
8705 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userprod
, NULL
);
8706 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8708 res
= RegCreateKeyExA(userprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8709 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8711 /* InstallProperties key exists */
8713 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8714 ok(state
== USERINFOSTATE_ABSENT
,
8715 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8716 ok(!lstrcmpA(user
, "apple"), "Expected user to be unchanged, got \"%s\"\n", user
);
8717 ok(!lstrcmpA(org
, "orange"), "Expected org to be unchanged, got \"%s\"\n", org
);
8718 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8719 ok(usersz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", usersz
);
8720 ok(orgsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", orgsz
);
8721 ok(serialsz
== MAX_PATH
, "Expected MAX_PATH, got %d\n", serialsz
);
8723 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8725 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, org
, &orgsz
, serial
, &serialsz
);
8726 ok(state
== USERINFOSTATE_ABSENT
,
8727 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8728 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8729 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8730 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8731 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8733 /* RegOwner, RegCompany don't exist, out params are NULL */
8735 state
= MsiGetUserInfoA(prodcode
, NULL
, NULL
, NULL
, NULL
, serial
, &serialsz
);
8736 ok(state
== USERINFOSTATE_ABSENT
,
8737 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8738 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8739 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8741 res
= RegSetValueExA(props
, "RegOwner", 0, REG_SZ
, (LPBYTE
)"owner", 6);
8742 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8744 /* RegOwner value exists */
8746 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8747 ok(state
== USERINFOSTATE_ABSENT
,
8748 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8749 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8750 ok(!lstrcmpA(org
, ""), "Expected empty string, got \"%s\"\n", org
);
8751 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8752 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8753 ok(orgsz
== 0, "Expected 0, got %d\n", orgsz
);
8754 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8756 res
= RegSetValueExA(props
, "RegCompany", 0, REG_SZ
, (LPBYTE
)"company", 8);
8757 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8759 /* RegCompany value exists */
8761 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8762 ok(state
== USERINFOSTATE_ABSENT
,
8763 "Expected USERINFOSTATE_ABSENT, got %d\n", state
);
8764 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8765 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8766 ok(!lstrcmpA(serial
, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial
);
8767 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8768 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8769 ok(serialsz
== MAX_PATH
- 1, "Expected MAX_PATH - 1, got %d\n", serialsz
);
8771 res
= RegSetValueExA(props
, "ProductID", 0, REG_SZ
, (LPBYTE
)"ID", 3);
8772 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8774 /* ProductID value exists */
8776 state
= MsiGetUserInfoA(prodcode
, user
, &usersz
, org
, &orgsz
, serial
, &serialsz
);
8777 ok(state
== USERINFOSTATE_PRESENT
,
8778 "Expected USERINFOSTATE_PRESENT, got %d\n", state
);
8779 ok(!lstrcmpA(user
, "owner"), "Expected \"owner\", got \"%s\"\n", user
);
8780 ok(!lstrcmpA(org
, "company"), "Expected \"company\", got \"%s\"\n", org
);
8781 ok(!lstrcmpA(serial
, "ID"), "Expected \"ID\", got \"%s\"\n", serial
);
8782 ok(usersz
== 5, "Expected 5, got %d\n", usersz
);
8783 ok(orgsz
== 7, "Expected 7, got %d\n", orgsz
);
8784 ok(serialsz
== 2, "Expected 2, got %d\n", serialsz
);
8786 RegDeleteValueA(props
, "ProductID");
8787 RegDeleteValueA(props
, "RegCompany");
8788 RegDeleteValueA(props
, "RegOwner");
8789 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8791 delete_key(userprod
, "", access
& KEY_WOW64_64KEY
);
8792 RegCloseKey(userprod
);
8793 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8794 RegCloseKey(prodkey
);
8798 static void test_MsiOpenProduct(void)
8800 MSIHANDLE hprod
, hdb
;
8802 CHAR path
[MAX_PATH
];
8803 CHAR keypath
[MAX_PATH
*2];
8804 CHAR prodcode
[MAX_PATH
];
8805 CHAR prod_squashed
[MAX_PATH
];
8806 HKEY prodkey
, userkey
, props
;
8811 REGSAM access
= KEY_ALL_ACCESS
;
8813 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
8815 GetCurrentDirectoryA(MAX_PATH
, path
);
8816 lstrcatA(path
, "\\");
8818 create_test_guid(prodcode
, prod_squashed
);
8819 usersid
= get_user_sid();
8822 access
|= KEY_WOW64_64KEY
;
8824 hdb
= create_package_db(prodcode
);
8825 MsiCloseHandle(hdb
);
8827 /* NULL szProduct */
8829 r
= MsiOpenProductA(NULL
, &hprod
);
8830 ok(r
== ERROR_INVALID_PARAMETER
,
8831 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8832 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8834 /* empty szProduct */
8836 r
= MsiOpenProductA("", &hprod
);
8837 ok(r
== ERROR_INVALID_PARAMETER
,
8838 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8839 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8841 /* garbage szProduct */
8843 r
= MsiOpenProductA("garbage", &hprod
);
8844 ok(r
== ERROR_INVALID_PARAMETER
,
8845 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8846 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8848 /* guid without brackets */
8850 r
= MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod
);
8851 ok(r
== ERROR_INVALID_PARAMETER
,
8852 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8853 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8855 /* guid with brackets */
8857 r
= MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod
);
8858 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8859 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8860 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8862 /* same length as guid, but random */
8864 r
= MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod
);
8865 ok(r
== ERROR_INVALID_PARAMETER
,
8866 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8867 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8869 /* hProduct is NULL */
8871 r
= MsiOpenProductA(prodcode
, NULL
);
8872 ok(r
== ERROR_INVALID_PARAMETER
,
8873 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
8874 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8876 /* MSIINSTALLCONTEXT_USERMANAGED */
8878 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8879 lstrcatA(keypath
, "Installer\\Managed\\");
8880 lstrcatA(keypath
, usersid
);
8881 lstrcatA(keypath
, "\\Installer\\Products\\");
8882 lstrcatA(keypath
, prod_squashed
);
8884 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
8885 if (res
== ERROR_ACCESS_DENIED
)
8887 skip("Not enough rights to perform tests\n");
8891 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8893 /* managed product key exists */
8895 r
= MsiOpenProductA(prodcode
, &hprod
);
8896 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8897 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8898 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8900 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8901 lstrcatA(keypath
, "Installer\\UserData\\");
8902 lstrcatA(keypath
, usersid
);
8903 lstrcatA(keypath
, "\\Products\\");
8904 lstrcatA(keypath
, prod_squashed
);
8906 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8907 if (res
== ERROR_ACCESS_DENIED
)
8909 skip("Not enough rights to perform tests\n");
8913 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8915 /* user product key exists */
8917 r
= MsiOpenProductA(prodcode
, &hprod
);
8918 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8919 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8920 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8922 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8923 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8925 /* InstallProperties key exists */
8927 r
= MsiOpenProductA(prodcode
, &hprod
);
8928 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8929 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8930 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8932 lstrcpyA(val
, path
);
8933 lstrcatA(val
, "\\winetest.msi");
8934 res
= RegSetValueExA(props
, "ManagedLocalPackage", 0, REG_SZ
,
8935 (const BYTE
*)val
, lstrlenA(val
) + 1);
8936 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8938 /* ManagedLocalPackage value exists */
8940 r
= MsiOpenProductA(prodcode
, &hprod
);
8941 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8942 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
8945 r
= MsiGetPropertyA(hprod
, "ProductCode", val
, &size
);
8946 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
8947 ok(!lstrcmpA(val
, prodcode
), "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
8948 ok(size
== lstrlenA(prodcode
), "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
8950 MsiCloseHandle(hprod
);
8952 RegDeleteValueA(props
, "ManagedLocalPackage");
8953 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
8955 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
8956 RegCloseKey(userkey
);
8957 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
8958 RegCloseKey(prodkey
);
8960 /* MSIINSTALLCONTEXT_USERUNMANAGED */
8962 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
8963 lstrcatA(keypath
, prod_squashed
);
8965 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
8966 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8968 /* unmanaged product key exists */
8970 r
= MsiOpenProductA(prodcode
, &hprod
);
8971 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8972 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8973 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8975 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8976 lstrcatA(keypath
, "Installer\\UserData\\");
8977 lstrcatA(keypath
, usersid
);
8978 lstrcatA(keypath
, "\\Products\\");
8979 lstrcatA(keypath
, prod_squashed
);
8981 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
8982 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8984 /* user product key exists */
8986 r
= MsiOpenProductA(prodcode
, &hprod
);
8987 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8988 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8989 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
8991 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
8992 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
8994 /* InstallProperties key exists */
8996 r
= MsiOpenProductA(prodcode
, &hprod
);
8997 ok(r
== ERROR_UNKNOWN_PRODUCT
,
8998 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
8999 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9001 lstrcpyA(val
, path
);
9002 lstrcatA(val
, "\\winetest.msi");
9003 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9004 (const BYTE
*)val
, lstrlenA(val
) + 1);
9005 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9007 /* LocalPackage value exists */
9009 r
= MsiOpenProductA(prodcode
, &hprod
);
9010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9011 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
9014 r
= MsiGetPropertyA(hprod
, "ProductCode", val
, &size
);
9015 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9016 ok(!lstrcmpA(val
, prodcode
), "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
9017 ok(size
== lstrlenA(prodcode
), "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
9019 MsiCloseHandle(hprod
);
9021 RegDeleteValueA(props
, "LocalPackage");
9022 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
9024 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
9025 RegCloseKey(userkey
);
9026 RegDeleteKeyA(prodkey
, "");
9027 RegCloseKey(prodkey
);
9029 /* MSIINSTALLCONTEXT_MACHINE */
9031 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
9032 lstrcatA(keypath
, prod_squashed
);
9034 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
9035 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9037 /* managed product key exists */
9039 r
= MsiOpenProductA(prodcode
, &hprod
);
9040 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9041 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9042 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9044 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9045 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
9046 lstrcatA(keypath
, prod_squashed
);
9048 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
9049 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9051 /* user product key exists */
9053 r
= MsiOpenProductA(prodcode
, &hprod
);
9054 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9055 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9056 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9058 res
= RegCreateKeyExA(userkey
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
9059 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9061 /* InstallProperties key exists */
9063 r
= MsiOpenProductA(prodcode
, &hprod
);
9064 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9065 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9066 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9068 lstrcpyA(val
, path
);
9069 lstrcatA(val
, "\\winetest.msi");
9070 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9071 (const BYTE
*)val
, lstrlenA(val
) + 1);
9072 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9074 /* LocalPackage value exists */
9076 r
= MsiOpenProductA(prodcode
, &hprod
);
9077 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9078 ok(hprod
!= 0 && hprod
!= 0xdeadbeef, "Expected a valid product handle\n");
9081 r
= MsiGetPropertyA(hprod
, "ProductCode", val
, &size
);
9082 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9083 ok(!lstrcmpA(val
, prodcode
), "Expected \"%s\", got \"%s\"\n", prodcode
, val
);
9084 ok(size
== lstrlenA(prodcode
), "Expected %d, got %d\n", lstrlenA(prodcode
), size
);
9086 MsiCloseHandle(hprod
);
9088 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9089 (const BYTE
*)"winetest.msi", 13);
9090 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9092 lstrcpyA(val
, path
);
9093 lstrcatA(val
, "\\winetest.msi");
9094 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
9095 (const BYTE
*)val
, lstrlenA(val
) + 1);
9096 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9098 DeleteFileA(msifile
);
9100 /* local package does not exist */
9102 r
= MsiOpenProductA(prodcode
, &hprod
);
9103 ok(r
== ERROR_UNKNOWN_PRODUCT
,
9104 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
9105 ok(hprod
== 0xdeadbeef, "Expected hprod to be unchanged\n");
9107 RegDeleteValueA(props
, "LocalPackage");
9108 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
9110 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
9111 RegCloseKey(userkey
);
9112 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
9113 RegCloseKey(prodkey
);
9115 DeleteFileA(msifile
);
9119 static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid
, LPCSTR expectedsid
)
9121 MSIINSTALLCONTEXT context
;
9122 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
9123 CHAR patch_squashed
[MAX_PATH
], patchcode
[MAX_PATH
];
9124 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
9125 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
9126 HKEY prodkey
, patches
, udprod
, udpatch
, hpatch
;
9130 REGSAM access
= KEY_ALL_ACCESS
;
9132 create_test_guid(prodcode
, prod_squashed
);
9133 create_test_guid(patch
, patch_squashed
);
9136 access
|= KEY_WOW64_64KEY
;
9138 /* MSIPATCHSTATE_APPLIED */
9140 lstrcpyA(patchcode
, "apple");
9141 lstrcpyA(targetprod
, "banana");
9142 context
= 0xdeadbeef;
9143 lstrcpyA(targetsid
, "kiwi");
9145 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9146 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9147 &context
, targetsid
, &size
);
9148 if (r
== ERROR_ACCESS_DENIED
)
9150 skip("Not enough rights to perform tests\n");
9153 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9154 ok(!lstrcmpA(patchcode
, "apple"),
9155 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9156 ok(!lstrcmpA(targetprod
, "banana"),
9157 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9158 ok(context
== 0xdeadbeef,
9159 "Expected context to be unchanged, got %d\n", context
);
9160 ok(!lstrcmpA(targetsid
, "kiwi"),
9161 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9162 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9164 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
9165 lstrcatA(keypath
, expectedsid
);
9166 lstrcatA(keypath
, "\\Installer\\Products\\");
9167 lstrcatA(keypath
, prod_squashed
);
9169 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
9170 if (res
== ERROR_ACCESS_DENIED
)
9172 skip("Not enough rights to perform tests\n");
9175 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9177 /* managed product key exists */
9178 lstrcpyA(patchcode
, "apple");
9179 lstrcpyA(targetprod
, "banana");
9180 context
= 0xdeadbeef;
9181 lstrcpyA(targetsid
, "kiwi");
9183 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9184 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9185 &context
, targetsid
, &size
);
9186 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9187 ok(!lstrcmpA(patchcode
, "apple"),
9188 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9189 ok(!lstrcmpA(targetprod
, "banana"),
9190 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9191 ok(context
== 0xdeadbeef,
9192 "Expected context to be unchanged, got %d\n", context
);
9193 ok(!lstrcmpA(targetsid
, "kiwi"),
9194 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9195 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9197 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
9198 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9200 /* patches key exists */
9201 lstrcpyA(patchcode
, "apple");
9202 lstrcpyA(targetprod
, "banana");
9203 context
= 0xdeadbeef;
9204 lstrcpyA(targetsid
, "kiwi");
9206 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9207 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9208 &context
, targetsid
, &size
);
9209 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9210 ok(!lstrcmpA(patchcode
, "apple"),
9211 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9212 ok(!lstrcmpA(targetprod
, "banana"),
9213 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9214 ok(context
== 0xdeadbeef,
9215 "Expected context to be unchanged, got %d\n", context
);
9216 ok(!lstrcmpA(targetsid
, "kiwi"),
9217 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9218 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9220 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
9221 (const BYTE
*)patch_squashed
,
9222 lstrlenA(patch_squashed
) + 1);
9223 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9225 /* Patches value exists, is not REG_MULTI_SZ */
9226 lstrcpyA(patchcode
, "apple");
9227 lstrcpyA(targetprod
, "banana");
9228 context
= 0xdeadbeef;
9229 lstrcpyA(targetsid
, "kiwi");
9231 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9232 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9233 &context
, targetsid
, &size
);
9234 ok(r
== ERROR_BAD_CONFIGURATION
,
9235 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9236 ok(!lstrcmpA(patchcode
, "apple"),
9237 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9238 ok(!lstrcmpA(targetprod
, "banana"),
9239 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9240 ok(context
== 0xdeadbeef,
9241 "Expected context to be unchanged, got %d\n", context
);
9242 ok(!lstrcmpA(targetsid
, "kiwi"),
9243 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9244 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9246 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9247 (const BYTE
*)"a\0b\0c\0\0", 7);
9248 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9250 /* Patches value exists, is not a squashed guid */
9251 lstrcpyA(patchcode
, "apple");
9252 lstrcpyA(targetprod
, "banana");
9253 context
= 0xdeadbeef;
9254 lstrcpyA(targetsid
, "kiwi");
9256 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9257 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9258 &context
, targetsid
, &size
);
9259 ok(r
== ERROR_BAD_CONFIGURATION
,
9260 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9261 ok(!lstrcmpA(patchcode
, "apple"),
9262 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9263 ok(!lstrcmpA(targetprod
, "banana"),
9264 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9265 ok(context
== 0xdeadbeef,
9266 "Expected context to be unchanged, got %d\n", context
);
9267 ok(!lstrcmpA(targetsid
, "kiwi"),
9268 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9269 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9271 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
9272 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9273 (const BYTE
*)patch_squashed
,
9274 lstrlenA(patch_squashed
) + 2);
9275 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9277 /* Patches value exists */
9278 lstrcpyA(patchcode
, "apple");
9279 lstrcpyA(targetprod
, "banana");
9280 context
= 0xdeadbeef;
9281 lstrcpyA(targetsid
, "kiwi");
9283 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9284 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9285 &context
, targetsid
, &size
);
9286 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9287 ok(!lstrcmpA(patchcode
, "apple"),
9288 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9289 ok(!lstrcmpA(targetprod
, "banana"),
9290 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9291 ok(context
== 0xdeadbeef,
9292 "Expected context to be unchanged, got %d\n", context
);
9293 ok(!lstrcmpA(targetsid
, "kiwi"),
9294 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9295 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9297 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
9298 (const BYTE
*)"whatever", 9);
9299 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9301 /* patch squashed value exists */
9302 lstrcpyA(patchcode
, "apple");
9303 lstrcpyA(targetprod
, "banana");
9304 context
= 0xdeadbeef;
9305 lstrcpyA(targetsid
, "kiwi");
9307 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9308 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9309 &context
, targetsid
, &size
);
9310 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9311 ok(!lstrcmpA(patchcode
, patch
),
9312 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9313 ok(!lstrcmpA(targetprod
, prodcode
),
9314 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9315 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9316 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9317 ok(!lstrcmpA(targetsid
, expectedsid
),
9318 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9319 ok(size
== lstrlenA(expectedsid
),
9320 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9322 /* increase the index */
9323 lstrcpyA(patchcode
, "apple");
9324 lstrcpyA(targetprod
, "banana");
9325 context
= 0xdeadbeef;
9326 lstrcpyA(targetsid
, "kiwi");
9328 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9329 MSIPATCHSTATE_APPLIED
, 1, patchcode
, targetprod
,
9330 &context
, targetsid
, &size
);
9331 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9332 ok(!lstrcmpA(patchcode
, "apple"),
9333 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9334 ok(!lstrcmpA(targetprod
, "banana"),
9335 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9336 ok(context
== 0xdeadbeef,
9337 "Expected context to be unchanged, got %d\n", context
);
9338 ok(!lstrcmpA(targetsid
, "kiwi"),
9339 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9340 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9342 /* increase again */
9343 lstrcpyA(patchcode
, "apple");
9344 lstrcpyA(targetprod
, "banana");
9345 context
= 0xdeadbeef;
9346 lstrcpyA(targetsid
, "kiwi");
9348 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9349 MSIPATCHSTATE_APPLIED
, 2, patchcode
, targetprod
,
9350 &context
, targetsid
, &size
);
9351 ok(r
== ERROR_INVALID_PARAMETER
,
9352 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
9353 ok(!lstrcmpA(patchcode
, "apple"),
9354 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9355 ok(!lstrcmpA(targetprod
, "banana"),
9356 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9357 ok(context
== 0xdeadbeef,
9358 "Expected context to be unchanged, got %d\n", context
);
9359 ok(!lstrcmpA(targetsid
, "kiwi"),
9360 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9361 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9363 /* szPatchCode is NULL */
9364 lstrcpyA(targetprod
, "banana");
9365 context
= 0xdeadbeef;
9366 lstrcpyA(targetsid
, "kiwi");
9368 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9369 MSIPATCHSTATE_APPLIED
, 0, NULL
, targetprod
,
9370 &context
, targetsid
, &size
);
9371 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9372 ok(!lstrcmpA(targetprod
, prodcode
),
9373 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9374 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9375 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9376 ok(!lstrcmpA(targetsid
, expectedsid
),
9377 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9378 ok(size
== lstrlenA(expectedsid
),
9379 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9381 /* szTargetProductCode is NULL */
9382 lstrcpyA(patchcode
, "apple");
9383 context
= 0xdeadbeef;
9384 lstrcpyA(targetsid
, "kiwi");
9386 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9387 MSIPATCHSTATE_APPLIED
, 0, patchcode
, NULL
,
9388 &context
, targetsid
, &size
);
9389 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9390 ok(!lstrcmpA(patchcode
, patch
),
9391 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9392 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9393 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9394 ok(!lstrcmpA(targetsid
, expectedsid
),
9395 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9396 ok(size
== lstrlenA(expectedsid
),
9397 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9399 /* pdwTargetProductContext is NULL */
9400 lstrcpyA(patchcode
, "apple");
9401 lstrcpyA(targetprod
, "banana");
9402 lstrcpyA(targetsid
, "kiwi");
9404 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9405 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9406 NULL
, targetsid
, &size
);
9407 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9408 ok(!lstrcmpA(patchcode
, patch
),
9409 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9410 ok(!lstrcmpA(targetprod
, prodcode
),
9411 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9412 ok(!lstrcmpA(targetsid
, expectedsid
),
9413 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9414 ok(size
== lstrlenA(expectedsid
),
9415 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9417 /* szTargetUserSid is NULL */
9418 lstrcpyA(patchcode
, "apple");
9419 lstrcpyA(targetprod
, "banana");
9420 context
= 0xdeadbeef;
9422 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9423 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9424 &context
, NULL
, &size
);
9425 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9426 ok(!lstrcmpA(patchcode
, patch
),
9427 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9428 ok(!lstrcmpA(targetprod
, prodcode
),
9429 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9430 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9431 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9432 ok(size
== lstrlenA(expectedsid
) * sizeof(WCHAR
),
9433 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid
), size
);
9435 /* pcchTargetUserSid is exactly the length of szTargetUserSid */
9436 lstrcpyA(patchcode
, "apple");
9437 lstrcpyA(targetprod
, "banana");
9438 context
= 0xdeadbeef;
9439 lstrcpyA(targetsid
, "kiwi");
9440 size
= lstrlenA(expectedsid
);
9441 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9442 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9443 &context
, targetsid
, &size
);
9444 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
9445 ok(!lstrcmpA(patchcode
, patch
),
9446 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9447 ok(!lstrcmpA(targetprod
, prodcode
),
9448 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9449 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9450 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9451 ok(!strncmp(targetsid
, expectedsid
, lstrlenA(expectedsid
) - 1),
9452 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9453 ok(size
== lstrlenA(expectedsid
) * sizeof(WCHAR
),
9454 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid
), size
);
9456 /* pcchTargetUserSid has enough room for NULL terminator */
9457 lstrcpyA(patchcode
, "apple");
9458 lstrcpyA(targetprod
, "banana");
9459 context
= 0xdeadbeef;
9460 lstrcpyA(targetsid
, "kiwi");
9461 size
= lstrlenA(expectedsid
) + 1;
9462 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9463 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9464 &context
, targetsid
, &size
);
9465 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9466 ok(!lstrcmpA(patchcode
, patch
),
9467 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9468 ok(!lstrcmpA(targetprod
, prodcode
),
9469 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9470 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9471 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9472 ok(!lstrcmpA(targetsid
, expectedsid
),
9473 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9474 ok(size
== lstrlenA(expectedsid
),
9475 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9477 /* both szTargetuserSid and pcchTargetUserSid are NULL */
9478 lstrcpyA(patchcode
, "apple");
9479 lstrcpyA(targetprod
, "banana");
9480 context
= 0xdeadbeef;
9481 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9482 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9483 &context
, NULL
, NULL
);
9484 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9485 ok(!lstrcmpA(patchcode
, patch
),
9486 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9487 ok(!lstrcmpA(targetprod
, prodcode
),
9488 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9489 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9490 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9492 /* MSIPATCHSTATE_SUPERSEDED */
9494 lstrcpyA(patchcode
, "apple");
9495 lstrcpyA(targetprod
, "banana");
9496 context
= 0xdeadbeef;
9497 lstrcpyA(targetsid
, "kiwi");
9499 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9500 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9501 &context
, targetsid
, &size
);
9502 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9503 ok(!lstrcmpA(patchcode
, "apple"),
9504 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9505 ok(!lstrcmpA(targetprod
, "banana"),
9506 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9507 ok(context
== 0xdeadbeef,
9508 "Expected context to be unchanged, got %d\n", context
);
9509 ok(!lstrcmpA(targetsid
, "kiwi"),
9510 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9511 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9513 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9514 lstrcatA(keypath
, expectedsid
);
9515 lstrcatA(keypath
, "\\Products\\");
9516 lstrcatA(keypath
, prod_squashed
);
9518 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
9519 if (res
== ERROR_ACCESS_DENIED
)
9521 skip("Not enough rights to perform tests\n");
9524 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9526 /* UserData product key exists */
9527 lstrcpyA(patchcode
, "apple");
9528 lstrcpyA(targetprod
, "banana");
9529 context
= 0xdeadbeef;
9530 lstrcpyA(targetsid
, "kiwi");
9532 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9533 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9534 &context
, targetsid
, &size
);
9535 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9536 ok(!lstrcmpA(patchcode
, "apple"),
9537 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9538 ok(!lstrcmpA(targetprod
, "banana"),
9539 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9540 ok(context
== 0xdeadbeef,
9541 "Expected context to be unchanged, got %d\n", context
);
9542 ok(!lstrcmpA(targetsid
, "kiwi"),
9543 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9544 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9546 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
9547 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9549 /* UserData patches key exists */
9550 lstrcpyA(patchcode
, "apple");
9551 lstrcpyA(targetprod
, "banana");
9552 context
= 0xdeadbeef;
9553 lstrcpyA(targetsid
, "kiwi");
9555 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9556 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9557 &context
, targetsid
, &size
);
9558 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9559 ok(!lstrcmpA(patchcode
, "apple"),
9560 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9561 ok(!lstrcmpA(targetprod
, "banana"),
9562 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9563 ok(context
== 0xdeadbeef,
9564 "Expected context to be unchanged, got %d\n", context
);
9565 ok(!lstrcmpA(targetsid
, "kiwi"),
9566 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9567 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9569 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
9570 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9572 /* specific UserData patch key exists */
9573 lstrcpyA(patchcode
, "apple");
9574 lstrcpyA(targetprod
, "banana");
9575 context
= 0xdeadbeef;
9576 lstrcpyA(targetsid
, "kiwi");
9578 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9579 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9580 &context
, targetsid
, &size
);
9581 ok(r
== ERROR_BAD_CONFIGURATION
,
9582 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9583 ok(!lstrcmpA(patchcode
, "apple"),
9584 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9585 ok(!lstrcmpA(targetprod
, "banana"),
9586 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9587 ok(context
== 0xdeadbeef,
9588 "Expected context to be unchanged, got %d\n", context
);
9589 ok(!lstrcmpA(targetsid
, "kiwi"),
9590 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9591 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9593 data
= MSIPATCHSTATE_SUPERSEDED
;
9594 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
9595 (const BYTE
*)&data
, sizeof(DWORD
));
9596 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9598 /* State value exists */
9599 lstrcpyA(patchcode
, "apple");
9600 lstrcpyA(targetprod
, "banana");
9601 context
= 0xdeadbeef;
9602 lstrcpyA(targetsid
, "kiwi");
9604 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9605 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9606 &context
, targetsid
, &size
);
9607 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9608 ok(!lstrcmpA(patchcode
, patch
),
9609 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9610 ok(!lstrcmpA(targetprod
, prodcode
),
9611 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9612 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9613 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9614 ok(!lstrcmpA(targetsid
, expectedsid
),
9615 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9616 ok(size
== lstrlenA(expectedsid
),
9617 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9619 /* MSIPATCHSTATE_OBSOLETED */
9621 lstrcpyA(patchcode
, "apple");
9622 lstrcpyA(targetprod
, "banana");
9623 context
= 0xdeadbeef;
9624 lstrcpyA(targetsid
, "kiwi");
9626 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9627 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
9628 &context
, targetsid
, &size
);
9629 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9630 ok(!lstrcmpA(patchcode
, "apple"),
9631 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9632 ok(!lstrcmpA(targetprod
, "banana"),
9633 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9634 ok(context
== 0xdeadbeef,
9635 "Expected context to be unchanged, got %d\n", context
);
9636 ok(!lstrcmpA(targetsid
, "kiwi"),
9637 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9638 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9640 data
= MSIPATCHSTATE_OBSOLETED
;
9641 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
9642 (const BYTE
*)&data
, sizeof(DWORD
));
9643 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9645 /* State value is obsoleted */
9646 lstrcpyA(patchcode
, "apple");
9647 lstrcpyA(targetprod
, "banana");
9648 context
= 0xdeadbeef;
9649 lstrcpyA(targetsid
, "kiwi");
9651 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9652 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
9653 &context
, targetsid
, &size
);
9654 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9655 ok(!lstrcmpA(patchcode
, patch
),
9656 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9657 ok(!lstrcmpA(targetprod
, prodcode
),
9658 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9659 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9660 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9661 ok(!lstrcmpA(targetsid
, expectedsid
),
9662 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9663 ok(size
== lstrlenA(expectedsid
),
9664 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9666 /* MSIPATCHSTATE_REGISTERED */
9669 /* MSIPATCHSTATE_ALL */
9672 lstrcpyA(patchcode
, "apple");
9673 lstrcpyA(targetprod
, "banana");
9674 context
= 0xdeadbeef;
9675 lstrcpyA(targetsid
, "kiwi");
9677 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9678 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
9679 &context
, targetsid
, &size
);
9680 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9681 ok(!lstrcmpA(patchcode
, patch
),
9682 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9683 ok(!lstrcmpA(targetprod
, prodcode
),
9684 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9685 ok(context
== MSIINSTALLCONTEXT_USERMANAGED
,
9686 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context
);
9687 ok(!lstrcmpA(targetsid
, expectedsid
),
9688 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9689 ok(size
== lstrlenA(expectedsid
),
9690 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9692 /* same patch in multiple places, only one is enumerated */
9693 lstrcpyA(patchcode
, "apple");
9694 lstrcpyA(targetprod
, "banana");
9695 context
= 0xdeadbeef;
9696 lstrcpyA(targetsid
, "kiwi");
9698 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERMANAGED
,
9699 MSIPATCHSTATE_ALL
, 1, 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 RegDeleteValueA(hpatch
, "State");
9713 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
9714 RegCloseKey(hpatch
);
9715 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
9716 RegCloseKey(udpatch
);
9717 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
9718 RegCloseKey(udprod
);
9719 RegDeleteValueA(patches
, "Patches");
9720 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
9721 RegCloseKey(patches
);
9722 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
9723 RegCloseKey(prodkey
);
9726 static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid
, LPCSTR expectedsid
)
9728 MSIINSTALLCONTEXT context
;
9729 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
9730 CHAR patch_squashed
[MAX_PATH
], patchcode
[MAX_PATH
];
9731 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
9732 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
9733 HKEY prodkey
, patches
, udprod
, udpatch
;
9734 HKEY userkey
, hpatch
;
9738 REGSAM access
= KEY_ALL_ACCESS
;
9740 create_test_guid(prodcode
, prod_squashed
);
9741 create_test_guid(patch
, patch_squashed
);
9744 access
|= KEY_WOW64_64KEY
;
9746 /* MSIPATCHSTATE_APPLIED */
9748 lstrcpyA(patchcode
, "apple");
9749 lstrcpyA(targetprod
, "banana");
9750 context
= 0xdeadbeef;
9751 lstrcpyA(targetsid
, "kiwi");
9753 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9754 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9755 &context
, targetsid
, &size
);
9756 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9757 ok(!lstrcmpA(patchcode
, "apple"),
9758 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9759 ok(!lstrcmpA(targetprod
, "banana"),
9760 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9761 ok(context
== 0xdeadbeef,
9762 "Expected context to be unchanged, got %d\n", context
);
9763 ok(!lstrcmpA(targetsid
, "kiwi"),
9764 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9765 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9767 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
9768 lstrcatA(keypath
, prod_squashed
);
9770 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
9771 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9773 /* current user product key exists */
9774 lstrcpyA(patchcode
, "apple");
9775 lstrcpyA(targetprod
, "banana");
9776 context
= 0xdeadbeef;
9777 lstrcpyA(targetsid
, "kiwi");
9779 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9780 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9781 &context
, targetsid
, &size
);
9782 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9783 ok(!lstrcmpA(patchcode
, "apple"),
9784 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9785 ok(!lstrcmpA(targetprod
, "banana"),
9786 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9787 ok(context
== 0xdeadbeef,
9788 "Expected context to be unchanged, got %d\n", context
);
9789 ok(!lstrcmpA(targetsid
, "kiwi"),
9790 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9791 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9793 res
= RegCreateKeyA(prodkey
, "Patches", &patches
);
9794 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9796 /* Patches key exists */
9797 lstrcpyA(patchcode
, "apple");
9798 lstrcpyA(targetprod
, "banana");
9799 context
= 0xdeadbeef;
9800 lstrcpyA(targetsid
, "kiwi");
9802 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9803 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9804 &context
, targetsid
, &size
);
9805 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9806 ok(!lstrcmpA(patchcode
, "apple"),
9807 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9808 ok(!lstrcmpA(targetprod
, "banana"),
9809 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9810 ok(context
== 0xdeadbeef,
9811 "Expected context to be unchanged, got %d\n", context
);
9812 ok(!lstrcmpA(targetsid
, "kiwi"),
9813 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9814 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9816 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
9817 (const BYTE
*)patch_squashed
,
9818 lstrlenA(patch_squashed
) + 1);
9819 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9821 /* Patches value exists, is not REG_MULTI_SZ */
9822 lstrcpyA(patchcode
, "apple");
9823 lstrcpyA(targetprod
, "banana");
9824 context
= 0xdeadbeef;
9825 lstrcpyA(targetsid
, "kiwi");
9827 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9828 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9829 &context
, targetsid
, &size
);
9830 ok(r
== ERROR_BAD_CONFIGURATION
,
9831 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9832 ok(!lstrcmpA(patchcode
, "apple"),
9833 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9834 ok(!lstrcmpA(targetprod
, "banana"),
9835 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9836 ok(context
== 0xdeadbeef,
9837 "Expected context to be unchanged, got %d\n", context
);
9838 ok(!lstrcmpA(targetsid
, "kiwi"),
9839 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9840 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9842 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9843 (const BYTE
*)"a\0b\0c\0\0", 7);
9844 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9846 /* Patches value exists, is not a squashed guid */
9847 lstrcpyA(patchcode
, "apple");
9848 lstrcpyA(targetprod
, "banana");
9849 context
= 0xdeadbeef;
9850 lstrcpyA(targetsid
, "kiwi");
9852 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9853 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9854 &context
, targetsid
, &size
);
9855 ok(r
== ERROR_BAD_CONFIGURATION
,
9856 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
9857 ok(!lstrcmpA(patchcode
, "apple"),
9858 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9859 ok(!lstrcmpA(targetprod
, "banana"),
9860 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9861 ok(context
== 0xdeadbeef,
9862 "Expected context to be unchanged, got %d\n", context
);
9863 ok(!lstrcmpA(targetsid
, "kiwi"),
9864 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9865 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9867 patch_squashed
[lstrlenA(patch_squashed
) + 1] = 0;
9868 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
9869 (const BYTE
*)patch_squashed
,
9870 lstrlenA(patch_squashed
) + 2);
9871 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9873 /* Patches value exists */
9874 lstrcpyA(patchcode
, "apple");
9875 lstrcpyA(targetprod
, "banana");
9876 context
= 0xdeadbeef;
9877 lstrcpyA(targetsid
, "kiwi");
9879 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9880 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9881 &context
, targetsid
, &size
);
9882 ok(r
== ERROR_NO_MORE_ITEMS
||
9883 broken(r
== ERROR_BAD_CONFIGURATION
), /* Windows Installer 3.0 */
9884 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9885 ok(!lstrcmpA(patchcode
, "apple"),
9886 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9887 ok(!lstrcmpA(targetprod
, "banana"),
9888 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9889 ok(context
== 0xdeadbeef,
9890 "Expected context to be unchanged, got %d\n", context
);
9891 ok(!lstrcmpA(targetsid
, "kiwi"),
9892 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9893 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9895 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
9896 (const BYTE
*)"whatever", 9);
9897 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9899 /* patch code value exists */
9900 lstrcpyA(patchcode
, "apple");
9901 lstrcpyA(targetprod
, "banana");
9902 context
= 0xdeadbeef;
9903 lstrcpyA(targetsid
, "kiwi");
9905 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9906 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
9907 &context
, targetsid
, &size
);
9908 ok(r
== ERROR_NO_MORE_ITEMS
||
9909 broken(r
== ERROR_BAD_CONFIGURATION
), /* Windows Installer 3.0 */
9910 "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
, "\\Patches\\");
9924 lstrcatA(keypath
, patch_squashed
);
9926 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, 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 patch 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_APPLIED
, 0, patchcode
, targetprod
,
9942 &context
, targetsid
, &size
);
9943 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
9944 ok(!lstrcmpA(patchcode
, patch
),
9945 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
9946 ok(!lstrcmpA(targetprod
, prodcode
),
9947 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
9948 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
9949 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
9950 ok(!lstrcmpA(targetsid
, expectedsid
),
9951 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
9952 ok(size
== lstrlenA(expectedsid
),
9953 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
9955 /* MSIPATCHSTATE_SUPERSEDED */
9957 lstrcpyA(patchcode
, "apple");
9958 lstrcpyA(targetprod
, "banana");
9959 context
= 0xdeadbeef;
9960 lstrcpyA(targetsid
, "kiwi");
9962 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9963 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9964 &context
, targetsid
, &size
);
9965 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9966 ok(!lstrcmpA(patchcode
, "apple"),
9967 "Expected patchcode to be unchanged, got %s\n", patchcode
);
9968 ok(!lstrcmpA(targetprod
, "banana"),
9969 "Expected targetprod to be unchanged, got %s\n", targetprod
);
9970 ok(context
== 0xdeadbeef,
9971 "Expected context to be unchanged, got %d\n", context
);
9972 ok(!lstrcmpA(targetsid
, "kiwi"),
9973 "Expected targetsid to be unchanged, got %s\n", targetsid
);
9974 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
9976 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9977 lstrcatA(keypath
, expectedsid
);
9978 lstrcatA(keypath
, "\\Products\\");
9979 lstrcatA(keypath
, prod_squashed
);
9981 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
9982 if (res
== ERROR_ACCESS_DENIED
)
9984 skip("Not enough rights to perform tests\n");
9987 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
9989 /* UserData product key exists */
9990 lstrcpyA(patchcode
, "apple");
9991 lstrcpyA(targetprod
, "banana");
9992 context
= 0xdeadbeef;
9993 lstrcpyA(targetsid
, "kiwi");
9995 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
9996 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
9997 &context
, targetsid
, &size
);
9998 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
9999 ok(!lstrcmpA(patchcode
, "apple"),
10000 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10001 ok(!lstrcmpA(targetprod
, "banana"),
10002 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10003 ok(context
== 0xdeadbeef,
10004 "Expected context to be unchanged, got %d\n", context
);
10005 ok(!lstrcmpA(targetsid
, "kiwi"),
10006 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10007 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10009 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
10010 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10012 /* UserData patches key exists */
10013 lstrcpyA(patchcode
, "apple");
10014 lstrcpyA(targetprod
, "banana");
10015 context
= 0xdeadbeef;
10016 lstrcpyA(targetsid
, "kiwi");
10018 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10019 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10020 &context
, targetsid
, &size
);
10021 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10022 ok(!lstrcmpA(patchcode
, "apple"),
10023 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10024 ok(!lstrcmpA(targetprod
, "banana"),
10025 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10026 ok(context
== 0xdeadbeef,
10027 "Expected context to be unchanged, got %d\n", context
);
10028 ok(!lstrcmpA(targetsid
, "kiwi"),
10029 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10030 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10032 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
10033 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10035 /* specific UserData patch key exists */
10036 lstrcpyA(patchcode
, "apple");
10037 lstrcpyA(targetprod
, "banana");
10038 context
= 0xdeadbeef;
10039 lstrcpyA(targetsid
, "kiwi");
10041 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10042 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10043 &context
, targetsid
, &size
);
10044 ok(r
== ERROR_BAD_CONFIGURATION
,
10045 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
10046 ok(!lstrcmpA(patchcode
, "apple"),
10047 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10048 ok(!lstrcmpA(targetprod
, "banana"),
10049 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10050 ok(context
== 0xdeadbeef,
10051 "Expected context to be unchanged, got %d\n", context
);
10052 ok(!lstrcmpA(targetsid
, "kiwi"),
10053 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10054 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10056 data
= MSIPATCHSTATE_SUPERSEDED
;
10057 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10058 (const BYTE
*)&data
, sizeof(DWORD
));
10059 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10061 /* State value exists */
10062 lstrcpyA(patchcode
, "apple");
10063 lstrcpyA(targetprod
, "banana");
10064 context
= 0xdeadbeef;
10065 lstrcpyA(targetsid
, "kiwi");
10067 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10068 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10069 &context
, targetsid
, &size
);
10070 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10071 ok(!lstrcmpA(patchcode
, patch
),
10072 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10073 ok(!lstrcmpA(targetprod
, prodcode
),
10074 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10075 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
10076 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
10077 ok(!lstrcmpA(targetsid
, expectedsid
),
10078 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
10079 ok(size
== lstrlenA(expectedsid
),
10080 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
10082 /* MSIPATCHSTATE_OBSOLETED */
10084 lstrcpyA(patchcode
, "apple");
10085 lstrcpyA(targetprod
, "banana");
10086 context
= 0xdeadbeef;
10087 lstrcpyA(targetsid
, "kiwi");
10089 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10090 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10091 &context
, targetsid
, &size
);
10092 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10093 ok(!lstrcmpA(patchcode
, "apple"),
10094 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10095 ok(!lstrcmpA(targetprod
, "banana"),
10096 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10097 ok(context
== 0xdeadbeef,
10098 "Expected context to be unchanged, got %d\n", context
);
10099 ok(!lstrcmpA(targetsid
, "kiwi"),
10100 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10101 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10103 data
= MSIPATCHSTATE_OBSOLETED
;
10104 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10105 (const BYTE
*)&data
, sizeof(DWORD
));
10106 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10108 /* State value is obsoleted */
10109 lstrcpyA(patchcode
, "apple");
10110 lstrcpyA(targetprod
, "banana");
10111 context
= 0xdeadbeef;
10112 lstrcpyA(targetsid
, "kiwi");
10114 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10115 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10116 &context
, targetsid
, &size
);
10117 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10118 ok(!lstrcmpA(patchcode
, patch
),
10119 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10120 ok(!lstrcmpA(targetprod
, prodcode
),
10121 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10122 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
10123 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
10124 ok(!lstrcmpA(targetsid
, expectedsid
),
10125 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
10126 ok(size
== lstrlenA(expectedsid
),
10127 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
10129 /* MSIPATCHSTATE_REGISTERED */
10132 /* MSIPATCHSTATE_ALL */
10135 lstrcpyA(patchcode
, "apple");
10136 lstrcpyA(targetprod
, "banana");
10137 context
= 0xdeadbeef;
10138 lstrcpyA(targetsid
, "kiwi");
10140 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10141 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10142 &context
, targetsid
, &size
);
10143 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10144 ok(!lstrcmpA(patchcode
, patch
),
10145 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10146 ok(!lstrcmpA(targetprod
, prodcode
),
10147 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10148 ok(context
== MSIINSTALLCONTEXT_USERUNMANAGED
,
10149 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context
);
10150 ok(!lstrcmpA(targetsid
, expectedsid
),
10151 "Expected \"%s\", got \"%s\"\n", expectedsid
, targetsid
);
10152 ok(size
== lstrlenA(expectedsid
),
10153 "Expected %d, got %d\n", lstrlenA(expectedsid
), size
);
10155 /* same patch in multiple places, only one is enumerated */
10156 lstrcpyA(patchcode
, "apple");
10157 lstrcpyA(targetprod
, "banana");
10158 context
= 0xdeadbeef;
10159 lstrcpyA(targetsid
, "kiwi");
10161 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10162 MSIPATCHSTATE_ALL
, 1, patchcode
, targetprod
,
10163 &context
, targetsid
, &size
);
10164 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10165 ok(!lstrcmpA(patchcode
, "apple"),
10166 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10167 ok(!lstrcmpA(targetprod
, "banana"),
10168 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10169 ok(context
== 0xdeadbeef,
10170 "Expected context to be unchanged, got %d\n", context
);
10171 ok(!lstrcmpA(targetsid
, "kiwi"),
10172 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10173 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10175 RegDeleteValueA(hpatch
, "State");
10176 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
10177 RegCloseKey(hpatch
);
10178 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
10179 RegCloseKey(udpatch
);
10180 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
10181 RegCloseKey(udprod
);
10182 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
10183 RegCloseKey(userkey
);
10184 RegDeleteValueA(patches
, patch_squashed
);
10185 RegDeleteValueA(patches
, "Patches");
10188 RegDeleteKeyA(patches
, "");
10189 RegCloseKey(patches
);
10190 RegDeleteKeyA(prodkey
, "");
10191 RegCloseKey(prodkey
);
10194 static void test_MsiEnumPatchesEx_machine(void)
10196 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
10197 CHAR patch_squashed
[MAX_PATH
], patchcode
[MAX_PATH
];
10198 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
10199 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
10200 HKEY prodkey
, patches
, udprod
, udpatch
;
10202 MSIINSTALLCONTEXT context
;
10206 REGSAM access
= KEY_ALL_ACCESS
;
10208 create_test_guid(prodcode
, prod_squashed
);
10209 create_test_guid(patch
, patch_squashed
);
10212 access
|= KEY_WOW64_64KEY
;
10214 /* MSIPATCHSTATE_APPLIED */
10216 lstrcpyA(patchcode
, "apple");
10217 lstrcpyA(targetprod
, "banana");
10218 context
= 0xdeadbeef;
10219 lstrcpyA(targetsid
, "kiwi");
10221 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10222 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10223 &context
, targetsid
, &size
);
10224 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10225 ok(!lstrcmpA(patchcode
, "apple"),
10226 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10227 ok(!lstrcmpA(targetprod
, "banana"),
10228 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10229 ok(context
== 0xdeadbeef,
10230 "Expected context to be unchanged, got %d\n", context
);
10231 ok(!lstrcmpA(targetsid
, "kiwi"),
10232 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10233 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10235 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
10236 lstrcatA(keypath
, prod_squashed
);
10238 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
10239 if (res
== ERROR_ACCESS_DENIED
)
10241 skip("Not enough rights to perform tests\n");
10244 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10246 /* local product key exists */
10247 lstrcpyA(patchcode
, "apple");
10248 lstrcpyA(targetprod
, "banana");
10249 context
= 0xdeadbeef;
10250 lstrcpyA(targetsid
, "kiwi");
10252 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10253 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10254 &context
, targetsid
, &size
);
10255 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10256 ok(!lstrcmpA(patchcode
, "apple"),
10257 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10258 ok(!lstrcmpA(targetprod
, "banana"),
10259 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10260 ok(context
== 0xdeadbeef,
10261 "Expected context to be unchanged, got %d\n", context
);
10262 ok(!lstrcmpA(targetsid
, "kiwi"),
10263 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10264 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10266 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
10267 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10269 /* Patches key exists */
10270 lstrcpyA(patchcode
, "apple");
10271 lstrcpyA(targetprod
, "banana");
10272 context
= 0xdeadbeef;
10273 lstrcpyA(targetsid
, "kiwi");
10275 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10276 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10277 &context
, targetsid
, &size
);
10278 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10279 ok(!lstrcmpA(patchcode
, "apple"),
10280 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10281 ok(!lstrcmpA(targetprod
, "banana"),
10282 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10283 ok(context
== 0xdeadbeef,
10284 "Expected context to be unchanged, got %d\n", context
);
10285 ok(!lstrcmpA(targetsid
, "kiwi"),
10286 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10287 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10289 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
10290 (const BYTE
*)patch_squashed
,
10291 lstrlenA(patch_squashed
) + 1);
10292 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10294 /* Patches value exists, is not REG_MULTI_SZ */
10295 lstrcpyA(patchcode
, "apple");
10296 lstrcpyA(targetprod
, "banana");
10297 context
= 0xdeadbeef;
10298 lstrcpyA(targetsid
, "kiwi");
10300 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10301 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10302 &context
, targetsid
, &size
);
10303 ok(r
== ERROR_BAD_CONFIGURATION
,
10304 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
10305 ok(!lstrcmpA(patchcode
, "apple"),
10306 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10307 ok(!lstrcmpA(targetprod
, "banana"),
10308 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10309 ok(context
== 0xdeadbeef,
10310 "Expected context to be unchanged, got %d\n", context
);
10311 ok(!lstrcmpA(targetsid
, "kiwi"),
10312 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10313 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10315 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
10316 (const BYTE
*)"a\0b\0c\0\0", 7);
10317 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10319 /* Patches value exists, is not a squashed guid */
10320 lstrcpyA(patchcode
, "apple");
10321 lstrcpyA(targetprod
, "banana");
10322 context
= 0xdeadbeef;
10323 lstrcpyA(targetsid
, "kiwi");
10325 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10326 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10327 &context
, targetsid
, &size
);
10328 ok(r
== ERROR_BAD_CONFIGURATION
,
10329 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
10330 ok(!lstrcmpA(patchcode
, "apple"),
10331 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10332 ok(!lstrcmpA(targetprod
, "banana"),
10333 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10334 ok(context
== 0xdeadbeef,
10335 "Expected context to be unchanged, got %d\n", context
);
10336 ok(!lstrcmpA(targetsid
, "kiwi"),
10337 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10338 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10340 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
10341 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
10342 (const BYTE
*)patch_squashed
,
10343 lstrlenA(patch_squashed
) + 2);
10344 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10346 /* Patches value exists */
10347 lstrcpyA(patchcode
, "apple");
10348 lstrcpyA(targetprod
, "banana");
10349 context
= 0xdeadbeef;
10350 lstrcpyA(targetsid
, "kiwi");
10352 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10353 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10354 &context
, targetsid
, &size
);
10355 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10356 ok(!lstrcmpA(patchcode
, "apple"),
10357 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10358 ok(!lstrcmpA(targetprod
, "banana"),
10359 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10360 ok(context
== 0xdeadbeef,
10361 "Expected context to be unchanged, got %d\n", context
);
10362 ok(!lstrcmpA(targetsid
, "kiwi"),
10363 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10364 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10366 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
10367 (const BYTE
*)"whatever", 9);
10368 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10370 /* patch code value exists */
10371 lstrcpyA(patchcode
, "apple");
10372 lstrcpyA(targetprod
, "banana");
10373 context
= 0xdeadbeef;
10374 lstrcpyA(targetsid
, "kiwi");
10376 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10377 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10378 &context
, targetsid
, &size
);
10379 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10380 ok(!lstrcmpA(patchcode
, patch
),
10381 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10382 ok(!lstrcmpA(targetprod
, prodcode
),
10383 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10384 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10385 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10386 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10387 ok(size
== 0, "Expected 0, got %d\n", size
);
10389 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
10390 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
10391 lstrcatA(keypath
, prod_squashed
);
10393 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
10394 if (res
== ERROR_ACCESS_DENIED
)
10396 skip("Not enough rights to perform tests\n");
10399 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10401 /* local UserData product key exists */
10402 lstrcpyA(patchcode
, "apple");
10403 lstrcpyA(targetprod
, "banana");
10404 context
= 0xdeadbeef;
10405 lstrcpyA(targetsid
, "kiwi");
10407 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10408 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10409 &context
, targetsid
, &size
);
10410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10411 ok(!lstrcmpA(patchcode
, patch
),
10412 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10413 ok(!lstrcmpA(targetprod
, prodcode
),
10414 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10415 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10416 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10417 ok(!lstrcmpA(targetsid
, ""),
10418 "Expected \"\", got \"%s\"\n", targetsid
);
10419 ok(size
== 0, "Expected 0, got %d\n", size
);
10421 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
10422 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10424 /* local UserData Patches key exists */
10425 lstrcpyA(patchcode
, "apple");
10426 lstrcpyA(targetprod
, "banana");
10427 context
= 0xdeadbeef;
10428 lstrcpyA(targetsid
, "kiwi");
10430 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10431 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10432 &context
, targetsid
, &size
);
10433 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10434 ok(!lstrcmpA(patchcode
, patch
),
10435 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10436 ok(!lstrcmpA(targetprod
, prodcode
),
10437 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10438 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10439 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10440 ok(!lstrcmpA(targetsid
, ""),
10441 "Expected \"\", got \"%s\"\n", targetsid
);
10442 ok(size
== 0, "Expected 0, got %d\n", size
);
10444 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
10445 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10447 /* local UserData Product patch key exists */
10448 lstrcpyA(patchcode
, "apple");
10449 lstrcpyA(targetprod
, "banana");
10450 context
= 0xdeadbeef;
10451 lstrcpyA(targetsid
, "kiwi");
10453 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10454 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10455 &context
, targetsid
, &size
);
10456 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10457 ok(!lstrcmpA(patchcode
, "apple"),
10458 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10459 ok(!lstrcmpA(targetprod
, "banana"),
10460 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10461 ok(context
== 0xdeadbeef,
10462 "Expected context to be unchanged, got %d\n", context
);
10463 ok(!lstrcmpA(targetsid
, "kiwi"),
10464 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10465 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10467 data
= MSIPATCHSTATE_APPLIED
;
10468 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10469 (const BYTE
*)&data
, sizeof(DWORD
));
10470 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10472 /* State value exists */
10473 lstrcpyA(patchcode
, "apple");
10474 lstrcpyA(targetprod
, "banana");
10475 context
= 0xdeadbeef;
10476 lstrcpyA(targetsid
, "kiwi");
10478 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10479 MSIPATCHSTATE_APPLIED
, 0, patchcode
, targetprod
,
10480 &context
, targetsid
, &size
);
10481 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10482 ok(!lstrcmpA(patchcode
, patch
),
10483 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10484 ok(!lstrcmpA(targetprod
, prodcode
),
10485 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10486 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10487 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10488 ok(!lstrcmpA(targetsid
, ""),
10489 "Expected \"\", got \"%s\"\n", targetsid
);
10490 ok(size
== 0, "Expected 0, got %d\n", size
);
10492 /* MSIPATCHSTATE_SUPERSEDED */
10494 lstrcpyA(patchcode
, "apple");
10495 lstrcpyA(targetprod
, "banana");
10496 context
= 0xdeadbeef;
10497 lstrcpyA(targetsid
, "kiwi");
10499 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10500 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10501 &context
, targetsid
, &size
);
10502 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10503 ok(!lstrcmpA(patchcode
, "apple"),
10504 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10505 ok(!lstrcmpA(targetprod
, "banana"),
10506 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10507 ok(context
== 0xdeadbeef,
10508 "Expected context to be unchanged, got %d\n", context
);
10509 ok(!lstrcmpA(targetsid
, "kiwi"),
10510 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10511 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10513 data
= MSIPATCHSTATE_SUPERSEDED
;
10514 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10515 (const BYTE
*)&data
, sizeof(DWORD
));
10516 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10518 /* State value is MSIPATCHSTATE_SUPERSEDED */
10519 lstrcpyA(patchcode
, "apple");
10520 lstrcpyA(targetprod
, "banana");
10521 context
= 0xdeadbeef;
10522 lstrcpyA(targetsid
, "kiwi");
10524 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10525 MSIPATCHSTATE_SUPERSEDED
, 0, patchcode
, targetprod
,
10526 &context
, targetsid
, &size
);
10527 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10528 ok(!lstrcmpA(patchcode
, patch
),
10529 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10530 ok(!lstrcmpA(targetprod
, prodcode
),
10531 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10532 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10533 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10534 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10535 ok(size
== 0, "Expected 0, got %d\n", size
);
10537 /* MSIPATCHSTATE_OBSOLETED */
10539 lstrcpyA(patchcode
, "apple");
10540 lstrcpyA(targetprod
, "banana");
10541 context
= 0xdeadbeef;
10542 lstrcpyA(targetsid
, "kiwi");
10544 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10545 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10546 &context
, targetsid
, &size
);
10547 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10548 ok(!lstrcmpA(patchcode
, "apple"),
10549 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10550 ok(!lstrcmpA(targetprod
, "banana"),
10551 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10552 ok(context
== 0xdeadbeef,
10553 "Expected context to be unchanged, got %d\n", context
);
10554 ok(!lstrcmpA(targetsid
, "kiwi"),
10555 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10556 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10558 data
= MSIPATCHSTATE_OBSOLETED
;
10559 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
10560 (const BYTE
*)&data
, sizeof(DWORD
));
10561 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
10563 /* State value is obsoleted */
10564 lstrcpyA(patchcode
, "apple");
10565 lstrcpyA(targetprod
, "banana");
10566 context
= 0xdeadbeef;
10567 lstrcpyA(targetsid
, "kiwi");
10569 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10570 MSIPATCHSTATE_OBSOLETED
, 0, patchcode
, targetprod
,
10571 &context
, targetsid
, &size
);
10572 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10573 ok(!lstrcmpA(patchcode
, patch
),
10574 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10575 ok(!lstrcmpA(targetprod
, prodcode
),
10576 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10577 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10578 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10579 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10580 ok(size
== 0, "Expected 0, got %d\n", size
);
10582 /* MSIPATCHSTATE_REGISTERED */
10585 /* MSIPATCHSTATE_ALL */
10588 lstrcpyA(patchcode
, "apple");
10589 lstrcpyA(targetprod
, "banana");
10590 context
= 0xdeadbeef;
10591 lstrcpyA(targetsid
, "kiwi");
10593 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10594 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10595 &context
, targetsid
, &size
);
10596 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
10597 ok(!lstrcmpA(patchcode
, patch
),
10598 "Expected \"%s\", got \"%s\"\n", patch
, patchcode
);
10599 ok(!lstrcmpA(targetprod
, prodcode
),
10600 "Expected \"%s\", got \"%s\"\n", prodcode
, targetprod
);
10601 ok(context
== MSIINSTALLCONTEXT_MACHINE
,
10602 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context
);
10603 ok(!lstrcmpA(targetsid
, ""), "Expected \"\", got \"%s\"\n", targetsid
);
10604 ok(size
== 0, "Expected 0, got %d\n", size
);
10606 /* same patch in multiple places, only one is enumerated */
10607 lstrcpyA(patchcode
, "apple");
10608 lstrcpyA(targetprod
, "banana");
10609 context
= 0xdeadbeef;
10610 lstrcpyA(targetsid
, "kiwi");
10612 r
= pMsiEnumPatchesExA(prodcode
, NULL
, MSIINSTALLCONTEXT_MACHINE
,
10613 MSIPATCHSTATE_ALL
, 1, patchcode
, targetprod
,
10614 &context
, targetsid
, &size
);
10615 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10616 ok(!lstrcmpA(patchcode
, "apple"),
10617 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10618 ok(!lstrcmpA(targetprod
, "banana"),
10619 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10620 ok(context
== 0xdeadbeef,
10621 "Expected context to be unchanged, got %d\n", context
);
10622 ok(!lstrcmpA(targetsid
, "kiwi"),
10623 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10624 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10626 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
10627 RegCloseKey(hpatch
);
10628 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
10629 RegCloseKey(udpatch
);
10632 RegDeleteValueA(patches
, patch_squashed
);
10633 RegDeleteValueA(patches
, "Patches");
10634 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
10635 RegCloseKey(patches
);
10636 RegDeleteValueA(hpatch
, "State");
10637 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
10638 RegCloseKey(udprod
);
10639 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
10640 RegCloseKey(prodkey
);
10643 static void test_MsiEnumPatchesEx(void)
10645 CHAR targetsid
[MAX_PATH
], targetprod
[MAX_PATH
];
10646 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
10647 CHAR patchcode
[MAX_PATH
];
10648 MSIINSTALLCONTEXT context
;
10653 if (!pMsiEnumPatchesExA
)
10655 win_skip("MsiEnumPatchesExA not implemented\n");
10659 create_test_guid(prodcode
, prod_squashed
);
10660 usersid
= get_user_sid();
10662 /* empty szProductCode */
10663 lstrcpyA(patchcode
, "apple");
10664 lstrcpyA(targetprod
, "banana");
10665 context
= 0xdeadbeef;
10666 lstrcpyA(targetsid
, "kiwi");
10668 r
= pMsiEnumPatchesExA("", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10669 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
, &context
,
10671 ok(r
== ERROR_INVALID_PARAMETER
,
10672 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10673 ok(!lstrcmpA(patchcode
, "apple"),
10674 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10675 ok(!lstrcmpA(targetprod
, "banana"),
10676 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10677 ok(context
== 0xdeadbeef,
10678 "Expected context to be unchanged, got %d\n", context
);
10679 ok(!lstrcmpA(targetsid
, "kiwi"),
10680 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10681 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10683 /* garbage szProductCode */
10684 lstrcpyA(patchcode
, "apple");
10685 lstrcpyA(targetprod
, "banana");
10686 context
= 0xdeadbeef;
10687 lstrcpyA(targetsid
, "kiwi");
10689 r
= pMsiEnumPatchesExA("garbage", usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10690 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
, &context
,
10692 ok(r
== ERROR_INVALID_PARAMETER
,
10693 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10694 ok(!lstrcmpA(patchcode
, "apple"),
10695 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10696 ok(!lstrcmpA(targetprod
, "banana"),
10697 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10698 ok(context
== 0xdeadbeef,
10699 "Expected context to be unchanged, got %d\n", context
);
10700 ok(!lstrcmpA(targetsid
, "kiwi"),
10701 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10702 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10704 /* guid without brackets */
10705 lstrcpyA(patchcode
, "apple");
10706 lstrcpyA(targetprod
, "banana");
10707 context
= 0xdeadbeef;
10708 lstrcpyA(targetsid
, "kiwi");
10710 r
= pMsiEnumPatchesExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid
,
10711 MSIINSTALLCONTEXT_USERUNMANAGED
, MSIPATCHSTATE_ALL
,
10712 0, patchcode
, targetprod
, &context
,
10714 ok(r
== ERROR_INVALID_PARAMETER
,
10715 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10716 ok(!lstrcmpA(patchcode
, "apple"),
10717 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10718 ok(!lstrcmpA(targetprod
, "banana"),
10719 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10720 ok(context
== 0xdeadbeef,
10721 "Expected context to be unchanged, got %d\n", context
);
10722 ok(!lstrcmpA(targetsid
, "kiwi"),
10723 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10724 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10726 /* guid with brackets */
10727 lstrcpyA(patchcode
, "apple");
10728 lstrcpyA(targetprod
, "banana");
10729 context
= 0xdeadbeef;
10730 lstrcpyA(targetsid
, "kiwi");
10732 r
= pMsiEnumPatchesExA("{6700E8CF-95AB-4D9C-BC2C-15840DDA7A5D}", usersid
,
10733 MSIINSTALLCONTEXT_USERUNMANAGED
, MSIPATCHSTATE_ALL
,
10734 0, patchcode
, targetprod
, &context
,
10736 ok(r
== ERROR_NO_MORE_ITEMS
,
10737 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
10738 ok(!lstrcmpA(patchcode
, "apple"),
10739 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10740 ok(!lstrcmpA(targetprod
, "banana"),
10741 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10742 ok(context
== 0xdeadbeef,
10743 "Expected context to be unchanged, got %d\n", context
);
10744 ok(!lstrcmpA(targetsid
, "kiwi"),
10745 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10746 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10748 /* szUserSid is S-1-5-18 */
10749 lstrcpyA(patchcode
, "apple");
10750 lstrcpyA(targetprod
, "banana");
10751 context
= 0xdeadbeef;
10752 lstrcpyA(targetsid
, "kiwi");
10754 r
= pMsiEnumPatchesExA(prodcode
, "S-1-5-18",
10755 MSIINSTALLCONTEXT_USERUNMANAGED
, MSIPATCHSTATE_ALL
,
10756 0, patchcode
, targetprod
, &context
,
10758 ok(r
== ERROR_INVALID_PARAMETER
,
10759 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10760 ok(!lstrcmpA(patchcode
, "apple"),
10761 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10762 ok(!lstrcmpA(targetprod
, "banana"),
10763 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10764 ok(context
== 0xdeadbeef,
10765 "Expected context to be unchanged, got %d\n", context
);
10766 ok(!lstrcmpA(targetsid
, "kiwi"),
10767 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10768 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10770 /* dwContext is MSIINSTALLCONTEXT_MACHINE, but szUserSid is non-NULL */
10771 lstrcpyA(patchcode
, "apple");
10772 lstrcpyA(targetprod
, "banana");
10773 context
= 0xdeadbeef;
10774 lstrcpyA(targetsid
, "kiwi");
10776 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_MACHINE
,
10777 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10778 &context
, targetsid
, &size
);
10779 ok(r
== ERROR_INVALID_PARAMETER
,
10780 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10781 ok(!lstrcmpA(patchcode
, "apple"),
10782 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10783 ok(!lstrcmpA(targetprod
, "banana"),
10784 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10785 ok(context
== 0xdeadbeef,
10786 "Expected context to be unchanged, got %d\n", context
);
10787 ok(!lstrcmpA(targetsid
, "kiwi"),
10788 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10789 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10791 /* dwContext is out of bounds */
10792 lstrcpyA(patchcode
, "apple");
10793 lstrcpyA(targetprod
, "banana");
10794 context
= 0xdeadbeef;
10795 lstrcpyA(targetsid
, "kiwi");
10797 r
= pMsiEnumPatchesExA(prodcode
, usersid
, 0,
10798 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10799 &context
, targetsid
, &size
);
10800 ok(r
== ERROR_INVALID_PARAMETER
,
10801 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10802 ok(!lstrcmpA(patchcode
, "apple"),
10803 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10804 ok(!lstrcmpA(targetprod
, "banana"),
10805 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10806 ok(context
== 0xdeadbeef,
10807 "Expected context to be unchanged, got %d\n", context
);
10808 ok(!lstrcmpA(targetsid
, "kiwi"),
10809 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10810 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10812 /* dwContext is out of bounds */
10813 lstrcpyA(patchcode
, "apple");
10814 lstrcpyA(targetprod
, "banana");
10815 context
= 0xdeadbeef;
10816 lstrcpyA(targetsid
, "kiwi");
10818 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_ALL
+ 1,
10819 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10820 &context
, targetsid
, &size
);
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
);
10831 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10833 /* dwFilter is out of bounds */
10834 lstrcpyA(patchcode
, "apple");
10835 lstrcpyA(targetprod
, "banana");
10836 context
= 0xdeadbeef;
10837 lstrcpyA(targetsid
, "kiwi");
10839 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10840 MSIPATCHSTATE_INVALID
, 0, patchcode
, targetprod
,
10841 &context
, targetsid
, &size
);
10842 ok(r
== ERROR_INVALID_PARAMETER
,
10843 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10844 ok(!lstrcmpA(patchcode
, "apple"),
10845 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10846 ok(!lstrcmpA(targetprod
, "banana"),
10847 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10848 ok(context
== 0xdeadbeef,
10849 "Expected context to be unchanged, got %d\n", context
);
10850 ok(!lstrcmpA(targetsid
, "kiwi"),
10851 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10852 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10854 /* dwFilter is out of bounds */
10855 lstrcpyA(patchcode
, "apple");
10856 lstrcpyA(targetprod
, "banana");
10857 context
= 0xdeadbeef;
10858 lstrcpyA(targetsid
, "kiwi");
10860 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10861 MSIPATCHSTATE_ALL
+ 1, 0, patchcode
, targetprod
,
10862 &context
, targetsid
, &size
);
10863 ok(r
== ERROR_INVALID_PARAMETER
,
10864 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10865 ok(!lstrcmpA(patchcode
, "apple"),
10866 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10867 ok(!lstrcmpA(targetprod
, "banana"),
10868 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10869 ok(context
== 0xdeadbeef,
10870 "Expected context to be unchanged, got %d\n", context
);
10871 ok(!lstrcmpA(targetsid
, "kiwi"),
10872 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10873 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10875 /* pcchTargetUserSid is NULL while szTargetUserSid is non-NULL */
10876 lstrcpyA(patchcode
, "apple");
10877 lstrcpyA(targetprod
, "banana");
10878 context
= 0xdeadbeef;
10879 lstrcpyA(targetsid
, "kiwi");
10880 r
= pMsiEnumPatchesExA(prodcode
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
,
10881 MSIPATCHSTATE_ALL
, 0, patchcode
, targetprod
,
10882 &context
, targetsid
, NULL
);
10883 ok(r
== ERROR_INVALID_PARAMETER
,
10884 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10885 ok(!lstrcmpA(patchcode
, "apple"),
10886 "Expected patchcode to be unchanged, got %s\n", patchcode
);
10887 ok(!lstrcmpA(targetprod
, "banana"),
10888 "Expected targetprod to be unchanged, got %s\n", targetprod
);
10889 ok(context
== 0xdeadbeef,
10890 "Expected context to be unchanged, got %d\n", context
);
10891 ok(!lstrcmpA(targetsid
, "kiwi"),
10892 "Expected targetsid to be unchanged, got %s\n", targetsid
);
10894 test_MsiEnumPatchesEx_usermanaged(usersid
, usersid
);
10895 test_MsiEnumPatchesEx_usermanaged(NULL
, usersid
);
10896 test_MsiEnumPatchesEx_usermanaged("S-1-2-34", "S-1-2-34");
10897 test_MsiEnumPatchesEx_userunmanaged(usersid
, usersid
);
10898 test_MsiEnumPatchesEx_userunmanaged(NULL
, usersid
);
10899 /* FIXME: Successfully test userunmanaged with a different user */
10900 test_MsiEnumPatchesEx_machine();
10901 LocalFree(usersid
);
10904 static void test_MsiEnumPatches(void)
10906 CHAR keypath
[MAX_PATH
], patch
[MAX_PATH
];
10907 CHAR patchcode
[MAX_PATH
], patch_squashed
[MAX_PATH
];
10908 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
10909 CHAR transforms
[MAX_PATH
];
10910 WCHAR patchW
[MAX_PATH
], prodcodeW
[MAX_PATH
], transformsW
[MAX_PATH
];
10911 HKEY prodkey
, patches
, udprod
;
10912 HKEY userkey
, hpatch
, udpatch
;
10917 REGSAM access
= KEY_ALL_ACCESS
;
10919 create_test_guid(prodcode
, prod_squashed
);
10920 create_test_guid(patchcode
, patch_squashed
);
10921 usersid
= get_user_sid();
10924 access
|= KEY_WOW64_64KEY
;
10926 /* NULL szProduct */
10928 lstrcpyA(patch
, "apple");
10929 lstrcpyA(transforms
, "banana");
10930 r
= MsiEnumPatchesA(NULL
, 0, patch
, transforms
, &size
);
10931 ok(r
== ERROR_INVALID_PARAMETER
,
10932 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10933 ok(!lstrcmpA(patch
, "apple"),
10934 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10935 ok(!lstrcmpA(transforms
, "banana"),
10936 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10937 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10939 /* empty szProduct */
10941 lstrcpyA(patch
, "apple");
10942 lstrcpyA(transforms
, "banana");
10943 r
= MsiEnumPatchesA("", 0, patch
, transforms
, &size
);
10944 ok(r
== ERROR_INVALID_PARAMETER
,
10945 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10946 ok(!lstrcmpA(patch
, "apple"),
10947 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10948 ok(!lstrcmpA(transforms
, "banana"),
10949 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10950 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10952 /* garbage szProduct */
10954 lstrcpyA(patch
, "apple");
10955 lstrcpyA(transforms
, "banana");
10956 r
= MsiEnumPatchesA("garbage", 0, patch
, transforms
, &size
);
10957 ok(r
== ERROR_INVALID_PARAMETER
,
10958 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10959 ok(!lstrcmpA(patch
, "apple"),
10960 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10961 ok(!lstrcmpA(transforms
, "banana"),
10962 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10963 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10965 /* guid without brackets */
10967 lstrcpyA(patch
, "apple");
10968 lstrcpyA(transforms
, "banana");
10969 r
= MsiEnumPatchesA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", 0, patch
,
10970 transforms
, &size
);
10971 ok(r
== ERROR_INVALID_PARAMETER
,
10972 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
10973 ok(!lstrcmpA(patch
, "apple"),
10974 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10975 ok(!lstrcmpA(transforms
, "banana"),
10976 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10977 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10979 /* guid with brackets */
10981 lstrcpyA(patch
, "apple");
10982 lstrcpyA(transforms
, "banana");
10983 r
= MsiEnumPatchesA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", 0, patch
,
10984 transforms
, &size
);
10985 ok(r
== ERROR_UNKNOWN_PRODUCT
,
10986 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
10987 ok(!lstrcmpA(patch
, "apple"),
10988 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
10989 ok(!lstrcmpA(transforms
, "banana"),
10990 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
10991 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
10993 /* same length as guid, but random */
10995 lstrcpyA(patch
, "apple");
10996 lstrcpyA(transforms
, "banana");
10997 r
= MsiEnumPatchesA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", 0, patch
,
10998 transforms
, &size
);
10999 ok(r
== ERROR_INVALID_PARAMETER
,
11000 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11001 ok(!lstrcmpA(patch
, "apple"),
11002 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11003 ok(!lstrcmpA(transforms
, "banana"),
11004 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11005 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11007 /* MSIINSTALLCONTEXT_USERMANAGED */
11010 lstrcpyA(patch
, "apple");
11011 lstrcpyA(transforms
, "banana");
11012 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11013 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11014 "Expected ERROR_UNKNOWN_PRODUCT, 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 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
11022 lstrcatA(keypath
, usersid
);
11023 lstrcatA(keypath
, "\\Installer\\Products\\");
11024 lstrcatA(keypath
, prod_squashed
);
11026 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
11027 if (res
== ERROR_ACCESS_DENIED
)
11029 skip("Not enough rights to perform tests\n");
11030 LocalFree(usersid
);
11033 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11035 /* managed product key exists */
11037 lstrcpyA(patch
, "apple");
11038 lstrcpyA(transforms
, "banana");
11039 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11040 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11041 ok(!lstrcmpA(patch
, "apple"),
11042 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11043 ok(!lstrcmpA(transforms
, "banana"),
11044 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11045 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11047 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
11048 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11050 /* patches key exists */
11052 lstrcpyA(patch
, "apple");
11053 lstrcpyA(transforms
, "banana");
11054 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11055 ok(r
== ERROR_NO_MORE_ITEMS
||
11056 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11057 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11058 ok(!lstrcmpA(patch
, "apple"),
11059 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11060 ok(!lstrcmpA(transforms
, "banana"),
11061 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11062 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11064 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
11065 (const BYTE
*)patch_squashed
,
11066 lstrlenA(patch_squashed
) + 1);
11067 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11069 /* Patches value exists, is not REG_MULTI_SZ */
11071 lstrcpyA(patch
, "apple");
11072 lstrcpyA(transforms
, "banana");
11073 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11074 ok(r
== ERROR_BAD_CONFIGURATION
||
11075 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11076 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11077 ok(!lstrcmpA(patch
, "apple"),
11078 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11079 ok(!lstrcmpA(transforms
, "banana"),
11080 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11081 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11083 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11084 (const BYTE
*)"a\0b\0c\0\0", 7);
11085 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11087 /* Patches value exists, is not a squashed guid */
11089 lstrcpyA(patch
, "apple");
11090 lstrcpyA(transforms
, "banana");
11091 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11092 ok(r
== ERROR_BAD_CONFIGURATION
,
11093 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11094 ok(!lstrcmpA(patch
, "apple"),
11095 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11096 ok(!lstrcmpA(transforms
, "banana"),
11097 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11098 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11100 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
11101 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11102 (const BYTE
*)patch_squashed
,
11103 lstrlenA(patch_squashed
) + 2);
11104 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11106 /* Patches value exists */
11108 lstrcpyA(patch
, "apple");
11109 lstrcpyA(transforms
, "banana");
11110 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11111 ok(r
== ERROR_NO_MORE_ITEMS
||
11112 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11113 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11114 ok(!lstrcmpA(patch
, "apple") ||
11115 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11116 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11117 ok(!lstrcmpA(transforms
, "banana"),
11118 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11119 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11121 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
11122 (const BYTE
*)"whatever", 9);
11123 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11125 /* patch squashed value exists */
11127 lstrcpyA(patch
, "apple");
11128 lstrcpyA(transforms
, "banana");
11129 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11130 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11131 ok(!lstrcmpA(patch
, patchcode
),
11132 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11133 ok(!lstrcmpA(transforms
, "whatever"),
11134 "Expected \"whatever\", got \"%s\"\n", transforms
);
11135 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11137 /* lpPatchBuf is NULL */
11139 lstrcpyA(transforms
, "banana");
11140 r
= MsiEnumPatchesA(prodcode
, 0, NULL
, transforms
, &size
);
11141 ok(r
== ERROR_INVALID_PARAMETER
,
11142 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11143 ok(!lstrcmpA(transforms
, "banana"),
11144 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11145 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11147 /* lpTransformsBuf is NULL, pcchTransformsBuf is not */
11149 lstrcpyA(patch
, "apple");
11150 r
= MsiEnumPatchesA(prodcode
, 0, patch
, NULL
, &size
);
11151 ok(r
== ERROR_INVALID_PARAMETER
,
11152 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11153 ok(!lstrcmpA(patch
, "apple"),
11154 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11155 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11157 /* pcchTransformsBuf is NULL, lpTransformsBuf is not */
11158 lstrcpyA(patch
, "apple");
11159 lstrcpyA(transforms
, "banana");
11160 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, NULL
);
11161 ok(r
== ERROR_INVALID_PARAMETER
,
11162 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11163 ok(!lstrcmpA(patch
, "apple"),
11164 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11165 ok(!lstrcmpA(transforms
, "banana"),
11166 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11168 /* pcchTransformsBuf is too small */
11170 lstrcpyA(patch
, "apple");
11171 lstrcpyA(transforms
, "banana");
11172 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11173 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
11174 ok(!lstrcmpA(patch
, patchcode
),
11175 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11176 ok(!lstrcmpA(transforms
, "whate") ||
11177 broken(!lstrcmpA(transforms
, "banana")), /* Windows Installer < 3.0 */
11178 "Expected \"whate\", got \"%s\"\n", transforms
);
11179 ok(size
== 8 || size
== 16, "Expected 8 or 16, got %d\n", size
);
11181 /* increase the index */
11183 lstrcpyA(patch
, "apple");
11184 lstrcpyA(transforms
, "banana");
11185 r
= MsiEnumPatchesA(prodcode
, 1, patch
, transforms
, &size
);
11186 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11187 ok(!lstrcmpA(patch
, "apple"),
11188 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11189 ok(!lstrcmpA(transforms
, "banana"),
11190 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11191 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11193 /* increase again */
11195 lstrcpyA(patch
, "apple");
11196 lstrcpyA(transforms
, "banana");
11197 r
= MsiEnumPatchesA(prodcode
, 2, patch
, transforms
, &size
);
11198 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11199 ok(!lstrcmpA(patch
, "apple"),
11200 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11201 ok(!lstrcmpA(transforms
, "banana"),
11202 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11203 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11205 RegDeleteValueA(patches
, "Patches");
11206 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
11207 RegCloseKey(patches
);
11208 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
11209 RegCloseKey(prodkey
);
11211 /* MSIINSTALLCONTEXT_USERUNMANAGED */
11214 lstrcpyA(patch
, "apple");
11215 lstrcpyA(transforms
, "banana");
11216 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11217 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11218 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11219 ok(!lstrcmpA(patch
, "apple"),
11220 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11221 ok(!lstrcmpA(transforms
, "banana"),
11222 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11223 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11225 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
11226 lstrcatA(keypath
, prod_squashed
);
11228 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
11229 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11231 /* current user product key exists */
11233 lstrcpyA(patch
, "apple");
11234 lstrcpyA(transforms
, "banana");
11235 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11236 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11237 ok(!lstrcmpA(patch
, "apple"),
11238 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11239 ok(!lstrcmpA(transforms
, "banana"),
11240 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11241 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11243 res
= RegCreateKeyA(prodkey
, "Patches", &patches
);
11244 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11246 /* Patches key exists */
11248 lstrcpyA(patch
, "apple");
11249 lstrcpyA(transforms
, "banana");
11250 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11251 ok(r
== ERROR_NO_MORE_ITEMS
||
11252 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11253 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11254 ok(!lstrcmpA(patch
, "apple"),
11255 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11256 ok(!lstrcmpA(transforms
, "banana"),
11257 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11258 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11260 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
11261 (const BYTE
*)patch_squashed
,
11262 lstrlenA(patch_squashed
) + 1);
11263 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11265 /* Patches value exists, is not REG_MULTI_SZ */
11267 lstrcpyA(patch
, "apple");
11268 lstrcpyA(transforms
, "banana");
11269 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11270 ok(r
== ERROR_BAD_CONFIGURATION
||
11271 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11272 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11273 ok(!lstrcmpA(patch
, "apple"),
11274 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11275 ok(!lstrcmpA(transforms
, "banana"),
11276 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11277 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11279 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11280 (const BYTE
*)"a\0b\0c\0\0", 7);
11281 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11283 /* Patches value exists, is not a squashed guid */
11285 lstrcpyA(patch
, "apple");
11286 lstrcpyA(transforms
, "banana");
11287 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11288 ok(r
== ERROR_BAD_CONFIGURATION
,
11289 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11290 ok(!lstrcmpA(patch
, "apple"),
11291 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11292 ok(!lstrcmpA(transforms
, "banana"),
11293 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11294 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11296 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
11297 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11298 (const BYTE
*)patch_squashed
,
11299 lstrlenA(patch_squashed
) + 2);
11300 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11302 /* Patches value exists */
11304 lstrcpyA(patch
, "apple");
11305 lstrcpyA(transforms
, "banana");
11306 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11307 ok(r
== ERROR_NO_MORE_ITEMS
||
11308 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11309 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11310 ok(!lstrcmpA(patch
, "apple") ||
11311 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11312 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11313 ok(!lstrcmpA(transforms
, "banana"),
11314 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11315 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11317 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
11318 (const BYTE
*)"whatever", 9);
11319 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11321 /* patch code value exists */
11323 lstrcpyA(patch
, "apple");
11324 lstrcpyA(transforms
, "banana");
11325 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11326 ok(r
== ERROR_NO_MORE_ITEMS
||
11327 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11328 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11329 ok(!lstrcmpA(patch
, "apple") ||
11330 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11331 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11332 ok(!lstrcmpA(transforms
, "banana") ||
11333 broken(!lstrcmpA(transforms
, "whatever")), /* Windows Installer < 3.0 */
11334 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11335 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11337 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11338 lstrcatA(keypath
, usersid
);
11339 lstrcatA(keypath
, "\\Patches\\");
11340 lstrcatA(keypath
, patch_squashed
);
11342 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &userkey
, NULL
);
11343 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11345 /* userdata patch key exists */
11347 lstrcpyA(patch
, "apple");
11348 lstrcpyA(transforms
, "banana");
11349 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11350 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11351 ok(!lstrcmpA(patch
, patchcode
),
11352 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11353 ok(!lstrcmpA(transforms
, "whatever"),
11354 "Expected \"whatever\", got \"%s\"\n", transforms
);
11355 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11357 delete_key(userkey
, "", access
& KEY_WOW64_64KEY
);
11358 RegCloseKey(userkey
);
11359 RegDeleteValueA(patches
, patch_squashed
);
11360 RegDeleteValueA(patches
, "Patches");
11361 RegDeleteKeyA(patches
, "");
11362 RegCloseKey(patches
);
11363 RegDeleteKeyA(prodkey
, "");
11364 RegCloseKey(prodkey
);
11366 /* MSIINSTALLCONTEXT_MACHINE */
11369 lstrcpyA(patch
, "apple");
11370 lstrcpyA(transforms
, "banana");
11371 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11372 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11373 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11374 ok(!lstrcmpA(patch
, "apple"),
11375 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11376 ok(!lstrcmpA(transforms
, "banana"),
11377 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11378 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11380 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
11381 lstrcatA(keypath
, prod_squashed
);
11383 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
11384 if (res
== ERROR_ACCESS_DENIED
)
11386 skip("Not enough rights to perform tests\n");
11387 LocalFree(usersid
);
11390 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11392 /* local product key exists */
11394 lstrcpyA(patch
, "apple");
11395 lstrcpyA(transforms
, "banana");
11396 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11397 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11398 ok(!lstrcmpA(patch
, "apple"),
11399 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11400 ok(!lstrcmpA(transforms
, "banana"),
11401 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11402 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11404 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
11405 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11407 /* Patches key exists */
11409 lstrcpyA(patch
, "apple");
11410 lstrcpyA(transforms
, "banana");
11411 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11412 ok(r
== ERROR_NO_MORE_ITEMS
||
11413 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11414 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11415 ok(!lstrcmpA(patch
, "apple"),
11416 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11417 ok(!lstrcmpA(transforms
, "banana"),
11418 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11419 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11421 res
= RegSetValueExA(patches
, "Patches", 0, REG_SZ
,
11422 (const BYTE
*)patch_squashed
,
11423 lstrlenA(patch_squashed
) + 1);
11424 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11426 /* Patches value exists, is not REG_MULTI_SZ */
11428 lstrcpyA(patch
, "apple");
11429 lstrcpyA(transforms
, "banana");
11430 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11431 ok(r
== ERROR_BAD_CONFIGURATION
||
11432 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11433 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11434 ok(!lstrcmpA(patch
, "apple"),
11435 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11436 ok(!lstrcmpA(transforms
, "banana"),
11437 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11438 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11440 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11441 (const BYTE
*)"a\0b\0c\0\0", 7);
11442 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11444 /* Patches value exists, is not a squashed guid */
11446 lstrcpyA(patch
, "apple");
11447 lstrcpyA(transforms
, "banana");
11448 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11449 ok(r
== ERROR_BAD_CONFIGURATION
,
11450 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r
);
11451 ok(!lstrcmpA(patch
, "apple"),
11452 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11453 ok(!lstrcmpA(transforms
, "banana"),
11454 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11455 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11457 patch_squashed
[lstrlenA(patch_squashed
) + 1] = '\0';
11458 res
= RegSetValueExA(patches
, "Patches", 0, REG_MULTI_SZ
,
11459 (const BYTE
*)patch_squashed
,
11460 lstrlenA(patch_squashed
) + 2);
11461 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11463 /* Patches value exists */
11465 lstrcpyA(patch
, "apple");
11466 lstrcpyA(transforms
, "banana");
11467 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11468 ok(r
== ERROR_NO_MORE_ITEMS
||
11469 broken(r
== ERROR_FILE_NOT_FOUND
), /* Windows Installer < 3.0 */
11470 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11471 ok(!lstrcmpA(patch
, "apple") ||
11472 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11473 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11474 ok(!lstrcmpA(transforms
, "banana"),
11475 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11476 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11478 res
= RegSetValueExA(patches
, patch_squashed
, 0, REG_SZ
,
11479 (const BYTE
*)"whatever", 9);
11480 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11482 /* patch code value exists */
11484 lstrcpyA(patch
, "apple");
11485 lstrcpyA(transforms
, "banana");
11486 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11487 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11488 ok(!lstrcmpA(patch
, patchcode
),
11489 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11490 ok(!lstrcmpA(transforms
, "whatever"),
11491 "Expected \"whatever\", got \"%s\"\n", transforms
);
11492 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11494 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11495 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
11496 lstrcatA(keypath
, prod_squashed
);
11498 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
11499 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11501 /* local UserData product key exists */
11503 lstrcpyA(patch
, "apple");
11504 lstrcpyA(transforms
, "banana");
11505 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11506 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11507 ok(!lstrcmpA(patch
, patchcode
),
11508 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11509 ok(!lstrcmpA(transforms
, "whatever"),
11510 "Expected \"whatever\", got \"%s\"\n", transforms
);
11511 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11513 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
11514 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11516 /* local UserData Patches key exists */
11518 lstrcpyA(patch
, "apple");
11519 lstrcpyA(transforms
, "banana");
11520 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11521 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11522 ok(!lstrcmpA(patch
, patchcode
),
11523 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11524 ok(!lstrcmpA(transforms
, "whatever"),
11525 "Expected \"whatever\", got \"%s\"\n", transforms
);
11526 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11528 res
= RegCreateKeyExA(udpatch
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
11529 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11531 /* local UserData Product patch key exists */
11533 lstrcpyA(patch
, "apple");
11534 lstrcpyA(transforms
, "banana");
11535 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11536 ok(r
== ERROR_NO_MORE_ITEMS
||
11537 broken(r
== ERROR_SUCCESS
), /* Windows Installer < 3.0 */
11538 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r
);
11539 ok(!lstrcmpA(patch
, "apple") ||
11540 broken(!lstrcmpA(patch
, patchcode
)), /* Windows Installer < 3.0 */
11541 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch
);
11542 ok(!lstrcmpA(transforms
, "banana") ||
11543 broken(!lstrcmpA(transforms
, "whatever")), /* Windows Installer < 3.0 */
11544 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms
);
11545 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11547 data
= MSIPATCHSTATE_APPLIED
;
11548 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
11549 (const BYTE
*)&data
, sizeof(DWORD
));
11550 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11552 /* State value exists */
11554 lstrcpyA(patch
, "apple");
11555 lstrcpyA(transforms
, "banana");
11556 r
= MsiEnumPatchesA(prodcode
, 0, patch
, transforms
, &size
);
11557 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11558 ok(!lstrcmpA(patch
, patchcode
),
11559 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11560 ok(!lstrcmpA(transforms
, "whatever"),
11561 "Expected \"whatever\", got \"%s\"\n", transforms
);
11562 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11564 /* now duplicate some of the tests for the W version */
11566 /* pcchTransformsBuf is too small */
11568 MultiByteToWideChar( CP_ACP
, 0, prodcode
, -1, prodcodeW
, MAX_PATH
);
11569 MultiByteToWideChar( CP_ACP
, 0, "apple", -1, patchW
, MAX_PATH
);
11570 MultiByteToWideChar( CP_ACP
, 0, "banana", -1, transformsW
, MAX_PATH
);
11571 r
= MsiEnumPatchesW(prodcodeW
, 0, patchW
, transformsW
, &size
);
11572 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
11573 WideCharToMultiByte( CP_ACP
, 0, patchW
, -1, patch
, MAX_PATH
, NULL
, NULL
);
11574 WideCharToMultiByte( CP_ACP
, 0, transformsW
, -1, transforms
, MAX_PATH
, NULL
, NULL
);
11575 ok(!lstrcmpA(patch
, patchcode
),
11576 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11577 ok(!lstrcmpA(transforms
, "whate") ||
11578 broken(!lstrcmpA(transforms
, "banana")), /* Windows Installer < 3.0 */
11579 "Expected \"whate\", got \"%s\"\n", transforms
);
11580 ok(size
== 8, "Expected 8, got %d\n", size
);
11582 /* patch code value exists */
11584 MultiByteToWideChar( CP_ACP
, 0, "apple", -1, patchW
, MAX_PATH
);
11585 MultiByteToWideChar( CP_ACP
, 0, "banana", -1, transformsW
, MAX_PATH
);
11586 r
= MsiEnumPatchesW(prodcodeW
, 0, patchW
, transformsW
, &size
);
11587 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
11588 WideCharToMultiByte( CP_ACP
, 0, patchW
, -1, patch
, MAX_PATH
, NULL
, NULL
);
11589 WideCharToMultiByte( CP_ACP
, 0, transformsW
, -1, transforms
, MAX_PATH
, NULL
, NULL
);
11590 ok(!lstrcmpA(patch
, patchcode
),
11591 "Expected \"%s\", got \"%s\"\n", patchcode
, patch
);
11592 ok(!lstrcmpA(transforms
, "whatever"),
11593 "Expected \"whatever\", got \"%s\"\n", transforms
);
11594 ok(size
== 8 || size
== MAX_PATH
, "Expected 8 or MAX_PATH, got %d\n", size
);
11596 RegDeleteValueA(patches
, patch_squashed
);
11597 RegDeleteValueA(patches
, "Patches");
11598 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
11599 RegCloseKey(patches
);
11600 RegDeleteValueA(hpatch
, "State");
11601 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
11602 RegCloseKey(hpatch
);
11603 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
11604 RegCloseKey(udpatch
);
11605 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
11606 RegCloseKey(udprod
);
11607 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
11608 RegCloseKey(prodkey
);
11609 LocalFree(usersid
);
11612 static void test_MsiGetPatchInfoEx(void)
11614 CHAR keypath
[MAX_PATH
], val
[MAX_PATH
];
11615 CHAR patchcode
[MAX_PATH
], patch_squashed
[MAX_PATH
];
11616 CHAR prodcode
[MAX_PATH
], prod_squashed
[MAX_PATH
];
11617 HKEY prodkey
, patches
, udprod
, props
;
11618 HKEY hpatch
, udpatch
, prodpatches
;
11623 REGSAM access
= KEY_ALL_ACCESS
;
11625 if (!pMsiGetPatchInfoExA
)
11627 win_skip("MsiGetPatchInfoEx not implemented\n");
11631 create_test_guid(prodcode
, prod_squashed
);
11632 create_test_guid(patchcode
, patch_squashed
);
11633 usersid
= get_user_sid();
11636 access
|= KEY_WOW64_64KEY
;
11638 /* NULL szPatchCode */
11639 lstrcpyA(val
, "apple");
11641 r
= pMsiGetPatchInfoExA(NULL
, prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11642 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11643 ok(r
== ERROR_INVALID_PARAMETER
,
11644 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11645 ok(!lstrcmpA(val
, "apple"),
11646 "Expected val to be unchanged, got \"%s\"\n", val
);
11647 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11649 /* empty szPatchCode */
11651 lstrcpyA(val
, "apple");
11652 r
= pMsiGetPatchInfoExA("", prodcode
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11653 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11654 ok(r
== ERROR_INVALID_PARAMETER
,
11655 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11656 ok(!lstrcmpA(val
, "apple"),
11657 "Expected val to be unchanged, got \"%s\"\n", val
);
11658 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11660 /* garbage szPatchCode */
11662 lstrcpyA(val
, "apple");
11663 r
= pMsiGetPatchInfoExA("garbage", prodcode
, NULL
,
11664 MSIINSTALLCONTEXT_USERMANAGED
,
11665 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11666 ok(r
== ERROR_INVALID_PARAMETER
,
11667 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11668 ok(!lstrcmpA(val
, "apple"),
11669 "Expected val to be unchanged, got \"%s\"\n", val
);
11670 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11672 /* guid without brackets */
11674 lstrcpyA(val
, "apple");
11675 r
= pMsiGetPatchInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", prodcode
,
11676 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11677 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11678 ok(r
== ERROR_INVALID_PARAMETER
,
11679 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11680 ok(!lstrcmpA(val
, "apple"),
11681 "Expected val to be unchanged, got \"%s\"\n", val
);
11682 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11684 /* guid with brackets */
11686 lstrcpyA(val
, "apple");
11687 r
= pMsiGetPatchInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", prodcode
,
11688 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11689 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11690 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11691 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11692 ok(!lstrcmpA(val
, "apple"),
11693 "Expected val to be unchanged, got \"%s\"\n", val
);
11694 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11696 /* same length as guid, but random */
11698 lstrcpyA(val
, "apple");
11699 r
= pMsiGetPatchInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", prodcode
,
11700 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11701 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11702 ok(r
== ERROR_INVALID_PARAMETER
,
11703 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11704 ok(!lstrcmpA(val
, "apple"),
11705 "Expected val to be unchanged, got \"%s\"\n", val
);
11706 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11708 /* NULL szProductCode */
11709 lstrcpyA(val
, "apple");
11711 r
= pMsiGetPatchInfoExA(patchcode
, NULL
, NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11712 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11713 ok(r
== ERROR_INVALID_PARAMETER
,
11714 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11715 ok(!lstrcmpA(val
, "apple"),
11716 "Expected val to be unchanged, got \"%s\"\n", val
);
11717 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11719 /* empty szProductCode */
11721 lstrcpyA(val
, "apple");
11722 r
= pMsiGetPatchInfoExA(patchcode
, "", NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11723 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11724 ok(r
== ERROR_INVALID_PARAMETER
,
11725 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11726 ok(!lstrcmpA(val
, "apple"),
11727 "Expected val to be unchanged, got \"%s\"\n", val
);
11728 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11730 /* garbage szProductCode */
11732 lstrcpyA(val
, "apple");
11733 r
= pMsiGetPatchInfoExA(patchcode
, "garbage", NULL
,
11734 MSIINSTALLCONTEXT_USERMANAGED
,
11735 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11736 ok(r
== ERROR_INVALID_PARAMETER
,
11737 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11738 ok(!lstrcmpA(val
, "apple"),
11739 "Expected val to be unchanged, got \"%s\"\n", val
);
11740 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11742 /* guid without brackets */
11744 lstrcpyA(val
, "apple");
11745 r
= pMsiGetPatchInfoExA(patchcode
, "6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
11746 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11747 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11748 ok(r
== ERROR_INVALID_PARAMETER
,
11749 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11750 ok(!lstrcmpA(val
, "apple"),
11751 "Expected val to be unchanged, got \"%s\"\n", val
);
11752 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11754 /* guid with brackets */
11756 lstrcpyA(val
, "apple");
11757 r
= pMsiGetPatchInfoExA(patchcode
, "{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
11758 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11759 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11760 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11761 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11762 ok(!lstrcmpA(val
, "apple"),
11763 "Expected val to be unchanged, got \"%s\"\n", val
);
11764 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11766 /* same length as guid, but random */
11768 lstrcpyA(val
, "apple");
11769 r
= pMsiGetPatchInfoExA(patchcode
, "A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
11770 NULL
, MSIINSTALLCONTEXT_USERMANAGED
,
11771 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11772 ok(r
== ERROR_INVALID_PARAMETER
,
11773 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11774 ok(!lstrcmpA(val
, "apple"),
11775 "Expected val to be unchanged, got \"%s\"\n", val
);
11776 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11778 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERMANAGED */
11780 lstrcpyA(val
, "apple");
11781 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, "S-1-5-18",
11782 MSIINSTALLCONTEXT_USERMANAGED
,
11783 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11784 ok(r
== ERROR_INVALID_PARAMETER
,
11785 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11786 ok(!lstrcmpA(val
, "apple"),
11787 "Expected val to be unchanged, got \"%s\"\n", val
);
11788 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11790 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERUNMANAGED */
11792 lstrcpyA(val
, "apple");
11793 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, "S-1-5-18",
11794 MSIINSTALLCONTEXT_USERUNMANAGED
,
11795 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11796 ok(r
== ERROR_INVALID_PARAMETER
,
11797 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11798 ok(!lstrcmpA(val
, "apple"),
11799 "Expected val to be unchanged, got \"%s\"\n", val
);
11800 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11802 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_MACHINE */
11804 lstrcpyA(val
, "apple");
11805 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, "S-1-5-18",
11806 MSIINSTALLCONTEXT_MACHINE
,
11807 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11808 ok(r
== ERROR_INVALID_PARAMETER
,
11809 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11810 ok(!lstrcmpA(val
, "apple"),
11811 "Expected val to be unchanged, got \"%s\"\n", val
);
11812 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11814 /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
11816 lstrcpyA(val
, "apple");
11817 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11818 MSIINSTALLCONTEXT_MACHINE
,
11819 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11820 ok(r
== ERROR_INVALID_PARAMETER
,
11821 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11822 ok(!lstrcmpA(val
, "apple"),
11823 "Expected val to be unchanged, got \"%s\"\n", val
);
11824 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11826 /* dwContext is out of range */
11828 lstrcpyA(val
, "apple");
11829 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11830 MSIINSTALLCONTEXT_NONE
,
11831 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11832 ok(r
== ERROR_INVALID_PARAMETER
,
11833 "Expected ERROR_INVALID_PARAMETER, 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 /* dwContext is out of range */
11840 lstrcpyA(val
, "apple");
11841 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11842 MSIINSTALLCONTEXT_ALL
,
11843 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11844 ok(r
== ERROR_INVALID_PARAMETER
,
11845 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11846 ok(!lstrcmpA(val
, "apple"),
11847 "Expected val to be unchanged, got \"%s\"\n", val
);
11848 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11850 /* dwContext is invalid */
11852 lstrcpyA(val
, "apple");
11853 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
, 3,
11854 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11855 ok(r
== ERROR_INVALID_PARAMETER
,
11856 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
11857 ok(!lstrcmpA(val
, "apple"),
11858 "Expected val to be unchanged, got \"%s\"\n", val
);
11859 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11861 /* MSIINSTALLCONTEXT_USERMANAGED */
11864 lstrcpyA(val
, "apple");
11865 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11866 MSIINSTALLCONTEXT_USERMANAGED
,
11867 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11868 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11869 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11870 ok(!lstrcmpA(val
, "apple"),
11871 "Expected val to be unchanged, got \"%s\"\n", val
);
11872 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11874 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11875 lstrcatA(keypath
, usersid
);
11876 lstrcatA(keypath
, "\\Products\\");
11877 lstrcatA(keypath
, prod_squashed
);
11879 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
11880 if (res
== ERROR_ACCESS_DENIED
)
11882 skip("Not enough rights to perform tests\n");
11883 LocalFree(usersid
);
11886 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11888 /* local UserData product key exists */
11890 lstrcpyA(val
, "apple");
11891 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11892 MSIINSTALLCONTEXT_USERMANAGED
,
11893 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11894 ok(r
== ERROR_UNKNOWN_PRODUCT
,
11895 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
11896 ok(!lstrcmpA(val
, "apple"),
11897 "Expected val to be unchanged, got \"%s\"\n", val
);
11898 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11900 res
= RegCreateKeyExA(udprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
11901 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11903 /* InstallProperties key exists */
11905 lstrcpyA(val
, "apple");
11906 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11907 MSIINSTALLCONTEXT_USERMANAGED
,
11908 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11909 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11910 ok(!lstrcmpA(val
, "apple"),
11911 "Expected val to be unchanged, got \"%s\"\n", val
);
11912 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11914 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
11915 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11917 /* Patches key exists */
11919 lstrcpyA(val
, "apple");
11920 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11921 MSIINSTALLCONTEXT_USERMANAGED
,
11922 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11923 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCHA, 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 res
= RegCreateKeyExA(patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
11929 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11931 /* Patches key exists */
11933 lstrcpyA(val
, "apple");
11934 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11935 MSIINSTALLCONTEXT_USERMANAGED
,
11936 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11937 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11938 ok(!lstrcmpA(val
, "apple"),
11939 "Expected val to be unchanged, got \"%s\"\n", val
);
11940 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11942 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
11943 lstrcatA(keypath
, usersid
);
11944 lstrcatA(keypath
, "\\Installer\\Products\\");
11945 lstrcatA(keypath
, prod_squashed
);
11947 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
11948 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11950 /* managed product key exists */
11952 lstrcpyA(val
, "apple");
11953 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11954 MSIINSTALLCONTEXT_USERMANAGED
,
11955 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11956 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11957 ok(!lstrcmpA(val
, "apple"),
11958 "Expected val to be unchanged, got \"%s\"\n", val
);
11959 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11961 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &prodpatches
, NULL
);
11962 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11964 /* Patches key exists */
11966 lstrcpyA(val
, "apple");
11967 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11968 MSIINSTALLCONTEXT_USERMANAGED
,
11969 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11970 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11971 ok(!lstrcmpA(val
, "apple"),
11972 "Expected val to be unchanged, got \"%s\"\n", val
);
11973 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11975 res
= RegSetValueExA(prodpatches
, patch_squashed
, 0, REG_SZ
,
11976 (const BYTE
*)"transforms", 11);
11977 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11979 /* specific patch value exists */
11981 lstrcpyA(val
, "apple");
11982 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
11983 MSIINSTALLCONTEXT_USERMANAGED
,
11984 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
11985 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
11986 ok(!lstrcmpA(val
, "apple"),
11987 "Expected val to be unchanged, got \"%s\"\n", val
);
11988 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
11990 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11991 lstrcatA(keypath
, usersid
);
11992 lstrcatA(keypath
, "\\Patches\\");
11993 lstrcatA(keypath
, patch_squashed
);
11995 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
11996 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
11998 /* UserData Patches key exists */
12000 lstrcpyA(val
, "apple");
12001 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12002 MSIINSTALLCONTEXT_USERMANAGED
,
12003 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12004 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12005 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
12006 ok(size
== 0, "Expected 0, got %d\n", size
);
12008 res
= RegSetValueExA(udpatch
, "ManagedLocalPackage", 0, REG_SZ
,
12009 (const BYTE
*)"pack", 5);
12010 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12012 /* ManagedLocalPatch value exists */
12014 lstrcpyA(val
, "apple");
12015 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12016 MSIINSTALLCONTEXT_USERMANAGED
,
12017 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12018 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12019 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12020 ok(size
== 4, "Expected 4, got %d\n", size
);
12023 lstrcpyA(val
, "apple");
12024 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12025 MSIINSTALLCONTEXT_USERMANAGED
,
12026 INSTALLPROPERTY_TRANSFORMSA
, val
, &size
);
12027 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12028 ok(!lstrcmpA(val
, "transforms"), "Expected \"transforms\", got \"%s\"\n", val
);
12029 ok(size
== 10, "Expected 10, got %d\n", size
);
12031 res
= RegSetValueExA(hpatch
, "Installed", 0, REG_SZ
,
12032 (const BYTE
*)"mydate", 7);
12033 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12035 /* Installed value exists */
12037 lstrcpyA(val
, "apple");
12038 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12039 MSIINSTALLCONTEXT_USERMANAGED
,
12040 INSTALLPROPERTY_INSTALLDATEA
, val
, &size
);
12041 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12042 ok(!lstrcmpA(val
, "mydate"), "Expected \"mydate\", got \"%s\"\n", val
);
12043 ok(size
== 6, "Expected 6, got %d\n", size
);
12045 res
= RegSetValueExA(hpatch
, "Uninstallable", 0, REG_SZ
,
12046 (const BYTE
*)"yes", 4);
12047 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12049 /* Uninstallable value exists */
12051 lstrcpyA(val
, "apple");
12052 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12053 MSIINSTALLCONTEXT_USERMANAGED
,
12054 INSTALLPROPERTY_UNINSTALLABLEA
, val
, &size
);
12055 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12056 ok(!lstrcmpA(val
, "yes"), "Expected \"yes\", got \"%s\"\n", val
);
12057 ok(size
== 3, "Expected 3, got %d\n", size
);
12059 res
= RegSetValueExA(hpatch
, "State", 0, REG_SZ
,
12060 (const BYTE
*)"good", 5);
12061 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12063 /* State value exists */
12065 lstrcpyA(val
, "apple");
12066 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12067 MSIINSTALLCONTEXT_USERMANAGED
,
12068 INSTALLPROPERTY_PATCHSTATEA
, val
, &size
);
12069 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12070 ok(!lstrcmpA(val
, "good"), "Expected \"good\", got \"%s\"\n", val
);
12071 ok(size
== 4, "Expected 4, got %d\n", size
);
12074 res
= RegSetValueExA(hpatch
, "State", 0, REG_DWORD
,
12075 (const BYTE
*)&size
, sizeof(DWORD
));
12076 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12078 /* State value exists */
12080 lstrcpyA(val
, "apple");
12081 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12082 MSIINSTALLCONTEXT_USERMANAGED
,
12083 INSTALLPROPERTY_PATCHSTATEA
, val
, &size
);
12084 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12085 todo_wine
ok(!lstrcmpA(val
, "1"), "Expected \"1\", got \"%s\"\n", val
);
12086 ok(size
== 1, "Expected 1, got %d\n", size
);
12088 res
= RegSetValueExA(hpatch
, "DisplayName", 0, REG_SZ
,
12089 (const BYTE
*)"display", 8);
12090 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12092 /* DisplayName value exists */
12094 lstrcpyA(val
, "apple");
12095 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12096 MSIINSTALLCONTEXT_USERMANAGED
,
12097 INSTALLPROPERTY_DISPLAYNAMEA
, val
, &size
);
12098 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12099 ok(!lstrcmpA(val
, "display"), "Expected \"display\", got \"%s\"\n", val
);
12100 ok(size
== 7, "Expected 7, got %d\n", size
);
12102 res
= RegSetValueExA(hpatch
, "MoreInfoURL", 0, REG_SZ
,
12103 (const BYTE
*)"moreinfo", 9);
12104 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12106 /* MoreInfoURL value exists */
12108 lstrcpyA(val
, "apple");
12109 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12110 MSIINSTALLCONTEXT_USERMANAGED
,
12111 INSTALLPROPERTY_MOREINFOURLA
, val
, &size
);
12112 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12113 ok(!lstrcmpA(val
, "moreinfo"), "Expected \"moreinfo\", got \"%s\"\n", val
);
12114 ok(size
== 8, "Expected 8, got %d\n", size
);
12116 /* szProperty is invalid */
12118 lstrcpyA(val
, "apple");
12119 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12120 MSIINSTALLCONTEXT_USERMANAGED
,
12121 "IDontExist", val
, &size
);
12122 ok(r
== ERROR_UNKNOWN_PROPERTY
,
12123 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r
);
12124 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12125 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12127 /* lpValue is NULL, while pcchValue is non-NULL */
12129 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12130 MSIINSTALLCONTEXT_USERMANAGED
,
12131 INSTALLPROPERTY_MOREINFOURLA
, NULL
, &size
);
12132 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12133 ok(size
== 16, "Expected 16, got %d\n", size
);
12135 /* pcchValue is NULL, while lpValue is non-NULL */
12136 lstrcpyA(val
, "apple");
12137 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12138 MSIINSTALLCONTEXT_USERMANAGED
,
12139 INSTALLPROPERTY_MOREINFOURLA
, val
, NULL
);
12140 ok(r
== ERROR_INVALID_PARAMETER
,
12141 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
12142 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12144 /* both lpValue and pcchValue are NULL */
12145 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12146 MSIINSTALLCONTEXT_USERMANAGED
,
12147 INSTALLPROPERTY_MOREINFOURLA
, NULL
, NULL
);
12148 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12150 /* pcchValue doesn't have enough room for NULL terminator */
12152 lstrcpyA(val
, "apple");
12153 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12154 MSIINSTALLCONTEXT_USERMANAGED
,
12155 INSTALLPROPERTY_MOREINFOURLA
, val
, &size
);
12156 ok(r
== ERROR_MORE_DATA
, "Expected ERROR_MORE_DATA, got %d\n", r
);
12157 ok(!lstrcmpA(val
, "moreinf"),
12158 "Expected \"moreinf\", got \"%s\"\n", val
);
12159 ok(size
== 16, "Expected 16, got %d\n", size
);
12161 /* pcchValue has exactly enough room for NULL terminator */
12163 lstrcpyA(val
, "apple");
12164 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12165 MSIINSTALLCONTEXT_USERMANAGED
,
12166 INSTALLPROPERTY_MOREINFOURLA
, val
, &size
);
12167 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12168 ok(!lstrcmpA(val
, "moreinfo"),
12169 "Expected \"moreinfo\", got \"%s\"\n", val
);
12170 ok(size
== 8, "Expected 8, got %d\n", size
);
12172 /* pcchValue is too small, lpValue is NULL */
12174 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12175 MSIINSTALLCONTEXT_USERMANAGED
,
12176 INSTALLPROPERTY_MOREINFOURLA
, NULL
, &size
);
12177 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12178 ok(size
== 16, "Expected 16, got %d\n", size
);
12180 RegDeleteValueA(prodpatches
, patch_squashed
);
12181 delete_key(prodpatches
, "", access
& KEY_WOW64_64KEY
);
12182 RegCloseKey(prodpatches
);
12183 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
12184 RegCloseKey(prodkey
);
12186 /* UserData is sufficient for all properties
12187 * except INSTALLPROPERTY_TRANSFORMS
12190 lstrcpyA(val
, "apple");
12191 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12192 MSIINSTALLCONTEXT_USERMANAGED
,
12193 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12194 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12195 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12196 ok(size
== 4, "Expected 4, got %d\n", size
);
12198 /* UserData is sufficient for all properties
12199 * except INSTALLPROPERTY_TRANSFORMS
12202 lstrcpyA(val
, "apple");
12203 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12204 MSIINSTALLCONTEXT_USERMANAGED
,
12205 INSTALLPROPERTY_TRANSFORMSA
, val
, &size
);
12206 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12207 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12208 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12210 RegDeleteValueA(hpatch
, "MoreInfoURL");
12211 RegDeleteValueA(hpatch
, "Display");
12212 RegDeleteValueA(hpatch
, "State");
12213 RegDeleteValueA(hpatch
, "Uninstallable");
12214 RegDeleteValueA(hpatch
, "Installed");
12215 RegDeleteValueA(udpatch
, "ManagedLocalPackage");
12216 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
12217 RegCloseKey(udpatch
);
12218 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
12219 RegCloseKey(hpatch
);
12220 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
12221 RegCloseKey(patches
);
12222 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
12223 RegCloseKey(props
);
12224 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
12225 RegCloseKey(udprod
);
12227 /* MSIINSTALLCONTEXT_USERUNMANAGED */
12230 lstrcpyA(val
, "apple");
12231 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12232 MSIINSTALLCONTEXT_USERUNMANAGED
,
12233 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12234 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12235 "Expected ERROR_UNKNOWN_PRODUCT, 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\\Windows\\CurrentVersion\\Installer\\UserData\\");
12241 lstrcatA(keypath
, usersid
);
12242 lstrcatA(keypath
, "\\Products\\");
12243 lstrcatA(keypath
, prod_squashed
);
12245 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
12246 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12248 /* local UserData product key exists */
12250 lstrcpyA(val
, "apple");
12251 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12252 MSIINSTALLCONTEXT_USERUNMANAGED
,
12253 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12254 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12255 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12256 ok(!lstrcmpA(val
, "apple"),
12257 "Expected val to be unchanged, got \"%s\"\n", val
);
12258 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12260 res
= RegCreateKeyExA(udprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
12261 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12263 /* InstallProperties key exists */
12265 lstrcpyA(val
, "apple");
12266 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12267 MSIINSTALLCONTEXT_USERUNMANAGED
,
12268 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12269 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12270 ok(!lstrcmpA(val
, "apple"),
12271 "Expected val to be unchanged, got \"%s\"\n", val
);
12272 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12274 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
12275 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12277 /* Patches key exists */
12279 lstrcpyA(val
, "apple");
12280 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12281 MSIINSTALLCONTEXT_USERUNMANAGED
,
12282 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12283 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12284 ok(!lstrcmpA(val
, "apple"),
12285 "Expected val to be unchanged, got \"%s\"\n", val
);
12286 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12288 res
= RegCreateKeyExA(patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
12289 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12291 /* Patches key exists */
12293 lstrcpyA(val
, "apple");
12294 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12295 MSIINSTALLCONTEXT_USERUNMANAGED
,
12296 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12297 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12298 ok(!lstrcmpA(val
, "apple"),
12299 "Expected val to be unchanged, got \"%s\"\n", val
);
12300 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12302 lstrcpyA(keypath
, "Software\\Microsoft\\Installer\\Products\\");
12303 lstrcatA(keypath
, prod_squashed
);
12305 res
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath
, &prodkey
);
12306 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12308 /* current user product key exists */
12310 lstrcpyA(val
, "apple");
12311 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12312 MSIINSTALLCONTEXT_USERUNMANAGED
,
12313 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12314 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12315 ok(!lstrcmpA(val
, "apple"),
12316 "Expected val to be unchanged, got \"%s\"\n", val
);
12317 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12319 res
= RegCreateKeyA(prodkey
, "Patches", &prodpatches
);
12320 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12322 /* Patches key exists */
12324 lstrcpyA(val
, "apple");
12325 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12326 MSIINSTALLCONTEXT_USERUNMANAGED
,
12327 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12328 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12329 ok(!lstrcmpA(val
, "apple"),
12330 "Expected val to be unchanged, got \"%s\"\n", val
);
12331 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12333 res
= RegSetValueExA(prodpatches
, patch_squashed
, 0, REG_SZ
,
12334 (const BYTE
*)"transforms", 11);
12335 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12337 /* specific patch value exists */
12339 lstrcpyA(val
, "apple");
12340 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12341 MSIINSTALLCONTEXT_USERUNMANAGED
,
12342 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12343 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12344 ok(!lstrcmpA(val
, "apple"),
12345 "Expected val to be unchanged, got \"%s\"\n", val
);
12346 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12348 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12349 lstrcatA(keypath
, usersid
);
12350 lstrcatA(keypath
, "\\Patches\\");
12351 lstrcatA(keypath
, patch_squashed
);
12353 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
12354 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12356 /* UserData Patches key exists */
12358 lstrcpyA(val
, "apple");
12359 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12360 MSIINSTALLCONTEXT_USERUNMANAGED
,
12361 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12362 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12363 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
12364 ok(size
== 0, "Expected 0, got %d\n", size
);
12366 res
= RegSetValueExA(udpatch
, "LocalPackage", 0, REG_SZ
,
12367 (const BYTE
*)"pack", 5);
12368 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12370 /* LocalPatch value exists */
12372 lstrcpyA(val
, "apple");
12373 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12374 MSIINSTALLCONTEXT_USERUNMANAGED
,
12375 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12376 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12377 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12378 ok(size
== 4, "Expected 4, got %d\n", size
);
12381 lstrcpyA(val
, "apple");
12382 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12383 MSIINSTALLCONTEXT_USERUNMANAGED
,
12384 INSTALLPROPERTY_TRANSFORMSA
, val
, &size
);
12385 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12386 ok(!lstrcmpA(val
, "transforms"), "Expected \"transforms\", got \"%s\"\n", val
);
12387 ok(size
== 10, "Expected 10, got %d\n", size
);
12389 RegDeleteValueA(prodpatches
, patch_squashed
);
12390 delete_key(prodpatches
, "", access
& KEY_WOW64_64KEY
);
12391 RegCloseKey(prodpatches
);
12392 RegDeleteKeyA(prodkey
, "");
12393 RegCloseKey(prodkey
);
12395 /* UserData is sufficient for all properties
12396 * except INSTALLPROPERTY_TRANSFORMS
12399 lstrcpyA(val
, "apple");
12400 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12401 MSIINSTALLCONTEXT_USERUNMANAGED
,
12402 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12403 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12404 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12405 ok(size
== 4, "Expected 4, got %d\n", size
);
12407 /* UserData is sufficient for all properties
12408 * except INSTALLPROPERTY_TRANSFORMS
12411 lstrcpyA(val
, "apple");
12412 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, usersid
,
12413 MSIINSTALLCONTEXT_USERUNMANAGED
,
12414 INSTALLPROPERTY_TRANSFORMSA
, val
, &size
);
12415 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12416 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12417 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12419 RegDeleteValueA(udpatch
, "LocalPackage");
12420 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
12421 RegCloseKey(udpatch
);
12422 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
12423 RegCloseKey(hpatch
);
12424 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
12425 RegCloseKey(patches
);
12426 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
12427 RegCloseKey(props
);
12428 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
12429 RegCloseKey(udprod
);
12431 /* MSIINSTALLCONTEXT_MACHINE */
12434 lstrcpyA(val
, "apple");
12435 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12436 MSIINSTALLCONTEXT_MACHINE
,
12437 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12438 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12439 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12440 ok(!lstrcmpA(val
, "apple"),
12441 "Expected val to be unchanged, got \"%s\"\n", val
);
12442 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12444 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12445 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Products\\");
12446 lstrcatA(keypath
, prod_squashed
);
12448 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udprod
, NULL
);
12449 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12451 /* local UserData product key exists */
12453 lstrcpyA(val
, "apple");
12454 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12455 MSIINSTALLCONTEXT_MACHINE
,
12456 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12457 ok(r
== ERROR_UNKNOWN_PRODUCT
,
12458 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
12459 ok(!lstrcmpA(val
, "apple"),
12460 "Expected val to be unchanged, got \"%s\"\n", val
);
12461 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12463 res
= RegCreateKeyExA(udprod
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &props
, NULL
);
12464 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12466 /* InstallProperties key exists */
12468 lstrcpyA(val
, "apple");
12469 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12470 MSIINSTALLCONTEXT_MACHINE
,
12471 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12472 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12473 ok(!lstrcmpA(val
, "apple"),
12474 "Expected val to be unchanged, got \"%s\"\n", val
);
12475 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12477 res
= RegCreateKeyExA(udprod
, "Patches", 0, NULL
, 0, access
, NULL
, &patches
, NULL
);
12478 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12480 /* Patches key exists */
12482 lstrcpyA(val
, "apple");
12483 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12484 MSIINSTALLCONTEXT_MACHINE
,
12485 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12486 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12487 ok(!lstrcmpA(val
, "apple"),
12488 "Expected val to be unchanged, got \"%s\"\n", val
);
12489 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12491 res
= RegCreateKeyExA(patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hpatch
, NULL
);
12492 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12494 /* Patches key exists */
12496 lstrcpyA(val
, "apple");
12497 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12498 MSIINSTALLCONTEXT_MACHINE
,
12499 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12500 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12501 ok(!lstrcmpA(val
, "apple"),
12502 "Expected val to be unchanged, got \"%s\"\n", val
);
12503 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12505 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
12506 lstrcatA(keypath
, prod_squashed
);
12508 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &prodkey
, NULL
);
12509 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12511 /* local product key exists */
12513 lstrcpyA(val
, "apple");
12514 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12515 MSIINSTALLCONTEXT_MACHINE
,
12516 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12517 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12518 ok(!lstrcmpA(val
, "apple"),
12519 "Expected val to be unchanged, got \"%s\"\n", val
);
12520 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12522 res
= RegCreateKeyExA(prodkey
, "Patches", 0, NULL
, 0, access
, NULL
, &prodpatches
, NULL
);
12523 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12525 /* Patches key exists */
12527 lstrcpyA(val
, "apple");
12528 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12529 MSIINSTALLCONTEXT_MACHINE
,
12530 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12531 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12532 ok(!lstrcmpA(val
, "apple"),
12533 "Expected val to be unchanged, got \"%s\"\n", val
);
12534 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12536 res
= RegSetValueExA(prodpatches
, patch_squashed
, 0, REG_SZ
,
12537 (const BYTE
*)"transforms", 11);
12538 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12540 /* specific patch value exists */
12542 lstrcpyA(val
, "apple");
12543 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12544 MSIINSTALLCONTEXT_MACHINE
,
12545 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12546 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12547 ok(!lstrcmpA(val
, "apple"),
12548 "Expected val to be unchanged, got \"%s\"\n", val
);
12549 ok(size
== MAX_PATH
, "Expected size to be unchanged, got %d\n", size
);
12551 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12552 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Patches\\");
12553 lstrcatA(keypath
, patch_squashed
);
12555 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &udpatch
, NULL
);
12556 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12558 /* UserData Patches key exists */
12560 lstrcpyA(val
, "apple");
12561 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12562 MSIINSTALLCONTEXT_MACHINE
,
12563 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12564 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12565 ok(!lstrcmpA(val
, ""), "Expected \"\", got \"%s\"\n", val
);
12566 ok(size
== 0, "Expected 0, got %d\n", size
);
12568 res
= RegSetValueExA(udpatch
, "LocalPackage", 0, REG_SZ
,
12569 (const BYTE
*)"pack", 5);
12570 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12572 /* LocalPatch value exists */
12574 lstrcpyA(val
, "apple");
12575 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12576 MSIINSTALLCONTEXT_MACHINE
,
12577 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12578 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12579 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12580 ok(size
== 4, "Expected 4, got %d\n", size
);
12583 lstrcpyA(val
, "apple");
12584 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12585 MSIINSTALLCONTEXT_MACHINE
,
12586 INSTALLPROPERTY_TRANSFORMSA
, val
, &size
);
12587 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12588 ok(!lstrcmpA(val
, "transforms"), "Expected \"transforms\", got \"%s\"\n", val
);
12589 ok(size
== 10, "Expected 10, got %d\n", size
);
12591 RegDeleteValueA(prodpatches
, patch_squashed
);
12592 delete_key(prodpatches
, "", access
& KEY_WOW64_64KEY
);
12593 RegCloseKey(prodpatches
);
12594 delete_key(prodkey
, "", access
& KEY_WOW64_64KEY
);
12595 RegCloseKey(prodkey
);
12597 /* UserData is sufficient for all properties
12598 * except INSTALLPROPERTY_TRANSFORMS
12601 lstrcpyA(val
, "apple");
12602 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12603 MSIINSTALLCONTEXT_MACHINE
,
12604 INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12605 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12606 ok(!lstrcmpA(val
, "pack"), "Expected \"pack\", got \"%s\"\n", val
);
12607 ok(size
== 4, "Expected 4, got %d\n", size
);
12609 /* UserData is sufficient for all properties
12610 * except INSTALLPROPERTY_TRANSFORMS
12613 lstrcpyA(val
, "apple");
12614 r
= pMsiGetPatchInfoExA(patchcode
, prodcode
, NULL
,
12615 MSIINSTALLCONTEXT_MACHINE
,
12616 INSTALLPROPERTY_TRANSFORMSA
, val
, &size
);
12617 ok(r
== ERROR_UNKNOWN_PATCH
, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r
);
12618 ok(!lstrcmpA(val
, "apple"), "Expected \"apple\", got \"%s\"\n", val
);
12619 ok(size
== MAX_PATH
, "Expected MAX_PATH, got %d\n", size
);
12621 RegDeleteValueA(udpatch
, "LocalPackage");
12622 delete_key(udpatch
, "", access
& KEY_WOW64_64KEY
);
12623 RegCloseKey(udpatch
);
12624 delete_key(hpatch
, "", access
& KEY_WOW64_64KEY
);
12625 RegCloseKey(hpatch
);
12626 delete_key(patches
, "", access
& KEY_WOW64_64KEY
);
12627 RegCloseKey(patches
);
12628 delete_key(props
, "", access
& KEY_WOW64_64KEY
);
12629 RegCloseKey(props
);
12630 delete_key(udprod
, "", access
& KEY_WOW64_64KEY
);
12631 RegCloseKey(udprod
);
12632 LocalFree(usersid
);
12635 static void test_MsiGetPatchInfo(void)
12638 char prod_code
[MAX_PATH
], prod_squashed
[MAX_PATH
], val
[MAX_PATH
];
12639 char patch_code
[MAX_PATH
], patch_squashed
[MAX_PATH
], keypath
[MAX_PATH
];
12640 WCHAR valW
[MAX_PATH
], patch_codeW
[MAX_PATH
];
12641 HKEY hkey_product
, hkey_patch
, hkey_patches
, hkey_udprops
, hkey_udproduct
;
12642 HKEY hkey_udpatch
, hkey_udpatches
, hkey_udproductpatches
, hkey_udproductpatch
;
12645 REGSAM access
= KEY_ALL_ACCESS
;
12647 create_test_guid(patch_code
, patch_squashed
);
12648 create_test_guid(prod_code
, prod_squashed
);
12649 MultiByteToWideChar(CP_ACP
, 0, patch_code
, -1, patch_codeW
, MAX_PATH
);
12652 access
|= KEY_WOW64_64KEY
;
12654 r
= MsiGetPatchInfoA(NULL
, NULL
, NULL
, NULL
);
12655 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12657 r
= MsiGetPatchInfoA(patch_code
, NULL
, NULL
, NULL
);
12658 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12660 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, NULL
, NULL
);
12661 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
12664 r
= MsiGetPatchInfoA(patch_code
, NULL
, NULL
, &size
);
12665 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12667 r
= MsiGetPatchInfoA(patch_code
, "", NULL
, &size
);
12668 ok(r
== ERROR_UNKNOWN_PROPERTY
, "expected ERROR_UNKNOWN_PROPERTY, got %u\n", r
);
12670 lstrcpyA(keypath
, "Software\\Classes\\Installer\\Products\\");
12671 lstrcatA(keypath
, prod_squashed
);
12673 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &hkey_product
, NULL
);
12674 if (res
== ERROR_ACCESS_DENIED
)
12676 skip("Not enough rights to perform tests\n");
12679 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12681 /* product key exists */
12683 lstrcpyA(val
, "apple");
12684 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12685 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12686 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged, got \"%s\"\n", val
);
12687 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12689 res
= RegCreateKeyExA(hkey_product
, "Patches", 0, NULL
, 0, access
, NULL
, &hkey_patches
, NULL
);
12690 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12692 /* patches 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 res
= RegCreateKeyExA(hkey_patches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hkey_patch
, NULL
);
12701 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12703 /* patch key exists */
12705 lstrcpyA(val
, "apple");
12706 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12707 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12708 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12709 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12711 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12712 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Products\\");
12713 lstrcatA(keypath
, prod_squashed
);
12715 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &hkey_udproduct
, NULL
);
12716 if (res
== ERROR_ACCESS_DENIED
)
12718 skip("Not enough rights to perform tests\n");
12721 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS got %d\n", res
);
12723 /* UserData product key exists */
12725 lstrcpyA(val
, "apple");
12726 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12727 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12728 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12729 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12731 res
= RegCreateKeyExA(hkey_udproduct
, "InstallProperties", 0, NULL
, 0, access
, NULL
, &hkey_udprops
, NULL
);
12732 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12734 /* InstallProperties key exists */
12736 lstrcpyA(val
, "apple");
12737 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12738 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12739 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged, got \"%s\"\n", val
);
12740 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12742 res
= RegCreateKeyExA(hkey_udproduct
, "Patches", 0, NULL
, 0, access
, NULL
, &hkey_udpatches
, NULL
);
12743 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12745 /* UserData Patches key exists */
12747 lstrcpyA(val
, "apple");
12748 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12749 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12750 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12751 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12753 res
= RegCreateKeyExA(hkey_udproduct
, "Patches", 0, NULL
, 0, access
, NULL
, &hkey_udproductpatches
, NULL
);
12754 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12756 res
= RegCreateKeyExA(hkey_udproductpatches
, patch_squashed
, 0, NULL
, 0, access
, NULL
, &hkey_udproductpatch
, NULL
);
12757 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
12759 /* UserData product patch key exists */
12761 lstrcpyA(val
, "apple");
12762 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12763 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r
);
12764 ok(!lstrcmpA(val
, "apple"), "expected val to be unchanged got \"%s\"\n", val
);
12765 ok(size
== MAX_PATH
, "expected size to be unchanged got %u\n", size
);
12767 lstrcpyA(keypath
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12768 lstrcatA(keypath
, "\\UserData\\S-1-5-18\\Patches\\");
12769 lstrcatA(keypath
, patch_squashed
);
12771 res
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, NULL
, 0, access
, NULL
, &hkey_udpatch
, NULL
);
12772 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12774 res
= RegSetValueExA(hkey_udpatch
, "LocalPackage", 0, REG_SZ
, (const BYTE
*)"c:\\test.msp", 12);
12775 ok(res
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %d\n", res
);
12777 /* UserData Patch key exists */
12779 lstrcpyA(val
, "apple");
12780 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12781 ok(r
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", r
);
12782 ok(!lstrcmpA(val
, "apple"), "expected \"apple\", got \"%s\"\n", val
);
12783 ok(size
== 11, "expected 11 got %u\n", size
);
12786 lstrcpyA(val
, "apple");
12787 r
= MsiGetPatchInfoA(patch_code
, INSTALLPROPERTY_LOCALPACKAGEA
, val
, &size
);
12788 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %u\n", r
);
12789 ok(!lstrcmpA(val
, "c:\\test.msp"), "expected \"c:\\test.msp\", got \"%s\"\n", val
);
12790 ok(size
== 11, "expected 11 got %u\n", size
);
12794 r
= MsiGetPatchInfoW(patch_codeW
, INSTALLPROPERTY_LOCALPACKAGEW
, valW
, &size
);
12795 ok(r
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA got %u\n", r
);
12796 ok(!valW
[0], "expected 0 got %u\n", valW
[0]);
12797 ok(size
== 11, "expected 11 got %u\n", size
);
12801 r
= MsiGetPatchInfoW(patch_codeW
, INSTALLPROPERTY_LOCALPACKAGEW
, valW
, &size
);
12802 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS got %u\n", r
);
12803 ok(valW
[0], "expected > 0 got %u\n", valW
[0]);
12804 ok(size
== 11, "expected 11 got %u\n", size
);
12806 delete_key(hkey_udproductpatch
, "", access
& KEY_WOW64_64KEY
);
12807 RegCloseKey(hkey_udproductpatch
);
12808 delete_key(hkey_udproductpatches
, "", access
& KEY_WOW64_64KEY
);
12809 RegCloseKey(hkey_udproductpatches
);
12810 delete_key(hkey_udpatch
, "", access
& KEY_WOW64_64KEY
);
12811 RegCloseKey(hkey_udpatch
);
12812 delete_key(hkey_udpatches
, "", access
& KEY_WOW64_64KEY
);
12813 RegCloseKey(hkey_udpatches
);
12814 delete_key(hkey_udprops
, "", access
& KEY_WOW64_64KEY
);
12815 RegCloseKey(hkey_udprops
);
12816 delete_key(hkey_udproduct
, "", access
& KEY_WOW64_64KEY
);
12817 RegCloseKey(hkey_udproduct
);
12820 delete_key(hkey_patches
, "", access
& KEY_WOW64_64KEY
);
12821 RegCloseKey(hkey_patches
);
12822 delete_key(hkey_product
, "", access
& KEY_WOW64_64KEY
);
12823 RegCloseKey(hkey_product
);
12824 delete_key(hkey_patch
, "", access
& KEY_WOW64_64KEY
);
12825 RegCloseKey(hkey_patch
);
12828 static void test_MsiEnumProducts(void)
12831 BOOL found1
, found2
, found3
;
12833 char product1
[39], product2
[39], product3
[39], guid
[39];
12834 char product_squashed1
[33], product_squashed2
[33], product_squashed3
[33];
12835 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
], keypath3
[MAX_PATH
];
12837 HKEY key1
, key2
, key3
;
12838 REGSAM access
= KEY_ALL_ACCESS
;
12840 create_test_guid(product1
, product_squashed1
);
12841 create_test_guid(product2
, product_squashed2
);
12842 create_test_guid(product3
, product_squashed3
);
12843 usersid
= get_user_sid();
12846 access
|= KEY_WOW64_64KEY
;
12848 strcpy(keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
12849 strcat(keypath2
, usersid
);
12850 strcat(keypath2
, "\\Installer\\Products\\");
12851 strcat(keypath2
, product_squashed2
);
12853 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
12854 if (r
== ERROR_ACCESS_DENIED
)
12856 skip("Not enough rights to perform tests\n");
12857 LocalFree(usersid
);
12860 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12862 strcpy(keypath1
, "Software\\Classes\\Installer\\Products\\");
12863 strcat(keypath1
, product_squashed1
);
12865 r
= RegCreateKeyExA(HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
12866 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12868 strcpy(keypath3
, "Software\\Microsoft\\Installer\\Products\\");
12869 strcat(keypath3
, product_squashed3
);
12871 r
= RegCreateKeyA(HKEY_CURRENT_USER
, keypath3
, &key3
);
12872 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
12875 r
= MsiEnumProductsA(index
, guid
);
12876 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
12878 r
= MsiEnumProductsA(index
, NULL
);
12879 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12882 r
= MsiEnumProductsA(index
, guid
);
12883 ok(r
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %u\n", r
);
12886 r
= MsiEnumProductsA(index
, guid
);
12887 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
12889 found1
= found2
= found3
= FALSE
;
12890 while ((r
= MsiEnumProductsA(index
, guid
)) == ERROR_SUCCESS
)
12892 if (!strcmp(product1
, guid
)) found1
= TRUE
;
12893 if (!strcmp(product2
, guid
)) found2
= TRUE
;
12894 if (!strcmp(product3
, guid
)) found3
= TRUE
;
12897 ok(r
== ERROR_NO_MORE_ITEMS
, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r
);
12898 ok(found1
, "product1 not found\n");
12899 ok(found2
, "product2 not found\n");
12900 ok(found3
, "product3 not found\n");
12902 delete_key(key1
, "", access
& KEY_WOW64_64KEY
);
12903 delete_key(key2
, "", access
& KEY_WOW64_64KEY
);
12904 RegDeleteKeyA(key3
, "");
12908 LocalFree(usersid
);
12911 static void test_MsiGetFileSignatureInformation(void)
12914 const CERT_CONTEXT
*cert
;
12917 hr
= MsiGetFileSignatureInformationA( NULL
, 0, NULL
, NULL
, NULL
);
12918 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12920 hr
= MsiGetFileSignatureInformationA( NULL
, 0, NULL
, NULL
, &len
);
12921 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12923 hr
= MsiGetFileSignatureInformationA( NULL
, 0, &cert
, NULL
, &len
);
12924 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12926 hr
= MsiGetFileSignatureInformationA( "", 0, NULL
, NULL
, NULL
);
12927 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12929 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, NULL
);
12930 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12932 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, &len
);
12933 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12935 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, &cert
, NULL
, &len
);
12936 todo_wine
ok(hr
== CRYPT_E_FILE_ERROR
, "expected CRYPT_E_FILE_ERROR got 0x%08x\n", hr
);
12938 create_file( "signature.bin", "signature", sizeof("signature") );
12940 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, NULL
);
12941 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12943 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, NULL
, NULL
, &len
);
12944 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG got 0x%08x\n", hr
);
12946 cert
= (const CERT_CONTEXT
*)0xdeadbeef;
12947 hr
= MsiGetFileSignatureInformationA( "signature.bin", 0, &cert
, NULL
, &len
);
12948 todo_wine
ok(hr
== HRESULT_FROM_WIN32(ERROR_FUNCTION_FAILED
), "got 0x%08x\n", hr
);
12949 ok(cert
== NULL
, "got %p\n", cert
);
12951 DeleteFileA( "signature.bin" );
12954 static void test_MsiEnumProductsEx(void)
12958 MSIINSTALLCONTEXT context
;
12959 char product0
[39], product1
[39], product2
[39], product3
[39], guid
[39], sid
[128];
12960 char product_squashed1
[33], product_squashed2
[33], product_squashed3
[33];
12961 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
], keypath3
[MAX_PATH
];
12962 HKEY key1
= NULL
, key2
= NULL
, key3
= NULL
;
12963 REGSAM access
= KEY_ALL_ACCESS
;
12964 char *usersid
= get_user_sid();
12966 if (!pMsiEnumProductsExA
)
12968 win_skip("MsiEnumProductsExA not implemented\n");
12972 create_test_guid( product0
, NULL
);
12973 create_test_guid( product1
, product_squashed1
);
12974 create_test_guid( product2
, product_squashed2
);
12975 create_test_guid( product3
, product_squashed3
);
12977 if (is_wow64
) access
|= KEY_WOW64_64KEY
;
12979 strcpy( keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\" );
12980 strcat( keypath2
, usersid
);
12981 strcat( keypath2
, "\\Installer\\Products\\" );
12982 strcat( keypath2
, product_squashed2
);
12984 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
12985 if (r
== ERROR_ACCESS_DENIED
)
12987 skip( "insufficient rights\n" );
12990 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12992 strcpy( keypath1
, "Software\\Classes\\Installer\\Products\\" );
12993 strcat( keypath1
, product_squashed1
);
12995 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
12996 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
12998 strcpy( keypath3
, usersid
);
12999 strcat( keypath3
, "\\Software\\Microsoft\\Installer\\Products\\" );
13000 strcat( keypath3
, product_squashed3
);
13002 r
= RegCreateKeyExA( HKEY_USERS
, keypath3
, 0, NULL
, 0, access
, NULL
, &key3
, NULL
);
13003 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13005 r
= pMsiEnumProductsExA( NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
);
13006 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13009 r
= pMsiEnumProductsExA( NULL
, NULL
, 0, 0, NULL
, NULL
, NULL
, &len
);
13010 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13011 ok( len
== sizeof(sid
), "got %u\n", len
);
13013 r
= pMsiEnumProductsExA( NULL
, NULL
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, NULL
, NULL
);
13014 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13018 r
= pMsiEnumProductsExA( product0
, NULL
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, sid
, &len
);
13019 ok( r
== ERROR_NO_MORE_ITEMS
, "got %u\n", r
);
13020 ok( len
== sizeof(sid
), "got %u\n", len
);
13021 ok( !sid
[0], "got %s\n", sid
);
13025 r
= pMsiEnumProductsExA( product0
, usersid
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, sid
, &len
);
13026 ok( r
== ERROR_NO_MORE_ITEMS
, "got %u\n", r
);
13027 ok( len
== sizeof(sid
), "got %u\n", len
);
13028 ok( !sid
[0], "got %s\n", sid
);
13032 r
= pMsiEnumProductsExA( NULL
, usersid
, MSIINSTALLCONTEXT_USERUNMANAGED
, 0, NULL
, NULL
, sid
, &len
);
13033 ok( r
== ERROR_MORE_DATA
, "got %u\n", r
);
13034 ok( len
, "length unchanged\n" );
13035 ok( !sid
[0], "got %s\n", sid
);
13038 context
= 0xdeadbeef;
13041 r
= pMsiEnumProductsExA( NULL
, NULL
, MSIINSTALLCONTEXT_ALL
, 0, guid
, &context
, sid
, &len
);
13042 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13043 ok( guid
[0], "empty guid\n" );
13044 ok( context
!= 0xdeadbeef, "context unchanged\n" );
13045 ok( !len
, "got %u\n", len
);
13046 ok( !sid
[0], "got %s\n", sid
);
13049 context
= 0xdeadbeef;
13052 r
= pMsiEnumProductsExA( NULL
, usersid
, MSIINSTALLCONTEXT_ALL
, 0, guid
, &context
, sid
, &len
);
13053 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13054 ok( guid
[0], "empty guid\n" );
13055 ok( context
!= 0xdeadbeef, "context unchanged\n" );
13056 ok( !len
, "got %u\n", len
);
13057 ok( !sid
[0], "got %s\n", sid
);
13060 context
= 0xdeadbeef;
13063 r
= pMsiEnumProductsExA( NULL
, "S-1-1-0", MSIINSTALLCONTEXT_ALL
, 0, guid
, &context
, sid
, &len
);
13064 if (r
== ERROR_ACCESS_DENIED
)
13066 skip( "insufficient rights\n" );
13069 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13070 ok( guid
[0], "empty guid\n" );
13071 ok( context
!= 0xdeadbeef, "context unchanged\n" );
13072 ok( !len
, "got %u\n", len
);
13073 ok( !sid
[0], "got %s\n", sid
);
13077 context
= 0xdeadbeef;
13080 while (!pMsiEnumProductsExA( NULL
, "S-1-1-0", MSIINSTALLCONTEXT_ALL
, index
, guid
, &context
, sid
, &len
))
13082 if (!strcmp( product1
, guid
))
13084 ok( context
== MSIINSTALLCONTEXT_MACHINE
, "got %u\n", context
);
13085 ok( !sid
[0], "got \"%s\"\n", sid
);
13086 ok( !len
, "unexpected length %u\n", len
);
13088 if (!strcmp( product2
, guid
))
13090 ok( context
== MSIINSTALLCONTEXT_USERMANAGED
, "got %u\n", context
);
13091 ok( sid
[0], "empty sid\n" );
13092 ok( len
== strlen(sid
), "unexpected length %u\n", len
);
13094 if (!strcmp( product3
, guid
))
13096 ok( context
== MSIINSTALLCONTEXT_USERUNMANAGED
, "got %u\n", context
);
13097 ok( sid
[0], "empty sid\n" );
13098 ok( len
== strlen(sid
), "unexpected length %u\n", len
);
13102 context
= 0xdeadbeef;
13108 delete_key( key1
, "", access
);
13109 delete_key( key2
, "", access
);
13110 delete_key( key3
, "", access
);
13111 RegCloseKey( key1
);
13112 RegCloseKey( key2
);
13113 RegCloseKey( key3
);
13114 LocalFree( usersid
);
13117 static void test_MsiEnumComponents(void)
13120 BOOL found1
, found2
;
13122 char comp1
[39], comp2
[39], guid
[39];
13123 char comp_squashed1
[33], comp_squashed2
[33];
13124 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
];
13125 REGSAM access
= KEY_ALL_ACCESS
;
13126 char *usersid
= get_user_sid();
13127 HKEY key1
= NULL
, key2
= NULL
;
13129 create_test_guid( comp1
, comp_squashed1
);
13130 create_test_guid( comp2
, comp_squashed2
);
13132 if (is_wow64
) access
|= KEY_WOW64_64KEY
;
13134 strcpy( keypath1
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13135 strcat( keypath1
, "S-1-5-18\\Components\\" );
13136 strcat( keypath1
, comp_squashed1
);
13138 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
13139 if (r
== ERROR_ACCESS_DENIED
)
13141 skip( "insufficient rights\n" );
13144 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13146 strcpy( keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13147 strcat( keypath2
, usersid
);
13148 strcat( keypath2
, "\\Components\\" );
13149 strcat( keypath2
, comp_squashed2
);
13151 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
13152 if (r
== ERROR_ACCESS_DENIED
)
13154 skip( "insufficient rights\n" );
13158 r
= MsiEnumComponentsA( 0, NULL
);
13159 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13163 found1
= found2
= FALSE
;
13164 while (!MsiEnumComponentsA( index
, guid
))
13166 if (!strcmp( guid
, comp1
)) found1
= TRUE
;
13167 if (!strcmp( guid
, comp2
)) found2
= TRUE
;
13168 ok( guid
[0], "empty guid\n" );
13172 ok( found1
, "comp1 not found\n" );
13173 ok( found2
, "comp2 not found\n" );
13176 delete_key( key1
, "", access
);
13177 delete_key( key2
, "", access
);
13178 RegCloseKey( key1
);
13179 RegCloseKey( key2
);
13180 LocalFree( usersid
);
13183 static void test_MsiEnumComponentsEx(void)
13186 BOOL found1
, found2
;
13188 MSIINSTALLCONTEXT context
;
13189 char comp1
[39], comp2
[39], guid
[39], sid
[128];
13190 char comp_squashed1
[33], comp_squashed2
[33];
13191 char keypath1
[MAX_PATH
], keypath2
[MAX_PATH
];
13192 HKEY key1
= NULL
, key2
= NULL
;
13193 REGSAM access
= KEY_ALL_ACCESS
;
13194 char *usersid
= get_user_sid();
13196 if (!pMsiEnumComponentsExA
)
13198 win_skip( "MsiEnumComponentsExA not implemented\n" );
13201 create_test_guid( comp1
, comp_squashed1
);
13202 create_test_guid( comp2
, comp_squashed2
);
13204 if (is_wow64
) access
|= KEY_WOW64_64KEY
;
13206 strcpy( keypath1
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13207 strcat( keypath1
, "S-1-5-18\\Components\\" );
13208 strcat( keypath1
, comp_squashed1
);
13210 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath1
, 0, NULL
, 0, access
, NULL
, &key1
, NULL
);
13211 if (r
== ERROR_ACCESS_DENIED
)
13213 skip( "insufficient rights\n" );
13216 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13218 strcpy( keypath2
, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13219 strcat( keypath2
, usersid
);
13220 strcat( keypath2
, "\\Components\\" );
13221 strcat( keypath2
, comp_squashed2
);
13223 r
= RegCreateKeyExA( HKEY_LOCAL_MACHINE
, keypath2
, 0, NULL
, 0, access
, NULL
, &key2
, NULL
);
13224 if (r
== ERROR_ACCESS_DENIED
)
13226 skip( "insufficient rights\n" );
13229 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13230 r
= RegSetValueExA( key2
, comp_squashed2
, 0, REG_SZ
, (const BYTE
*)"c:\\doesnotexist",
13231 sizeof("c:\\doesnotexist"));
13232 ok( r
== ERROR_SUCCESS
, "got %u\n", r
);
13236 context
= 0xdeadbeef;
13239 found1
= found2
= FALSE
;
13240 while (!pMsiEnumComponentsExA( "S-1-1-0", MSIINSTALLCONTEXT_ALL
, index
, guid
, &context
, sid
, &len
))
13242 if (!strcmp( comp1
, guid
))
13244 ok( context
== MSIINSTALLCONTEXT_MACHINE
, "got %u\n", context
);
13245 ok( !sid
[0], "got \"%s\"\n", sid
);
13246 ok( !len
, "unexpected length %u\n", len
);
13249 if (!strcmp( comp2
, guid
))
13251 ok( context
== MSIINSTALLCONTEXT_USERUNMANAGED
, "got %u\n", context
);
13252 ok( sid
[0], "empty sid\n" );
13253 ok( len
== strlen(sid
), "unexpected length %u\n", len
);
13258 context
= 0xdeadbeef;
13262 ok( found1
, "comp1 not found\n" );
13263 ok( found2
, "comp2 not found\n" );
13265 r
= pMsiEnumComponentsExA( NULL
, 0, 0, NULL
, NULL
, NULL
, NULL
);
13266 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13268 r
= pMsiEnumComponentsExA( NULL
, MSIINSTALLCONTEXT_ALL
, 0, NULL
, NULL
, sid
, NULL
);
13269 ok( r
== ERROR_INVALID_PARAMETER
, "got %u\n", r
);
13272 RegDeleteValueA( key2
, comp_squashed2
);
13273 delete_key( key1
, "", access
);
13274 delete_key( key2
, "", access
);
13275 RegCloseKey( key1
);
13276 RegCloseKey( key2
);
13277 LocalFree( usersid
);
13280 static void test_MsiConfigureProductEx(void)
13285 HKEY props
, source
;
13286 CHAR keypath
[MAX_PATH
* 2], localpackage
[MAX_PATH
], packagename
[MAX_PATH
];
13287 REGSAM access
= KEY_ALL_ACCESS
;
13289 if (is_process_limited())
13291 skip("process is limited\n");
13295 CreateDirectoryA("msitest", NULL
);
13296 create_file("msitest\\hydrogen", "hydrogen", 500);
13297 create_file("msitest\\helium", "helium", 500);
13298 create_file("msitest\\lithium", "lithium", 500);
13300 create_database(msifile
, mcp_tables
, sizeof(mcp_tables
) / sizeof(msi_table
));
13303 access
|= KEY_WOW64_64KEY
;
13305 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
13307 /* NULL szProduct */
13308 r
= MsiConfigureProductExA(NULL
, INSTALLLEVEL_DEFAULT
,
13309 INSTALLSTATE_DEFAULT
, "PROPVAR=42");
13310 ok(r
== ERROR_INVALID_PARAMETER
,
13311 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13313 /* empty szProduct */
13314 r
= MsiConfigureProductExA("", INSTALLLEVEL_DEFAULT
,
13315 INSTALLSTATE_DEFAULT
, "PROPVAR=42");
13316 ok(r
== ERROR_INVALID_PARAMETER
,
13317 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13319 /* garbage szProduct */
13320 r
= MsiConfigureProductExA("garbage", INSTALLLEVEL_DEFAULT
,
13321 INSTALLSTATE_DEFAULT
, "PROPVAR=42");
13322 ok(r
== ERROR_INVALID_PARAMETER
,
13323 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13325 /* guid without brackets */
13326 r
= MsiConfigureProductExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
13327 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13329 ok(r
== ERROR_INVALID_PARAMETER
,
13330 "Expected ERROR_INVALID_PARAMETER, got %d\n", r
);
13332 /* guid with brackets */
13333 r
= MsiConfigureProductExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
13334 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13336 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13337 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
13339 /* same length as guid, but random */
13340 r
= MsiConfigureProductExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
13341 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13343 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13344 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
13346 /* product not installed yet */
13347 r
= MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
13348 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13350 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13351 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r
);
13353 /* install the product, per-user unmanaged */
13354 r
= MsiInstallProductA(msifile
, "INSTALLLEVEL=10 PROPVAR=42");
13355 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13357 skip("Not enough rights to perform tests\n");
13360 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13361 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13362 ok(pf_exists("msitest\\helium"), "File not installed\n");
13363 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13364 ok(pf_exists("msitest"), "File not installed\n");
13366 /* product is installed per-user managed, remove it */
13367 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13368 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13370 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13371 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13372 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13373 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13374 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13376 /* product has been removed */
13377 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13378 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13380 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13381 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13383 /* install the product, machine */
13384 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13385 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13386 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13387 ok(pf_exists("msitest\\helium"), "File not installed\n");
13388 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13389 ok(pf_exists("msitest"), "File not installed\n");
13391 /* product is installed machine, remove it */
13392 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13393 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13395 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13396 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13397 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13398 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13399 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13401 /* product has been removed */
13402 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13403 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_DEFAULT
,
13405 ok(r
== ERROR_UNKNOWN_PRODUCT
,
13406 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13408 /* install the product, machine */
13409 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13410 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13411 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13412 ok(pf_exists("msitest\\helium"), "File not installed\n");
13413 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13414 ok(pf_exists("msitest"), "File not installed\n");
13416 DeleteFileA(msifile
);
13418 /* msifile is removed */
13419 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13420 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13422 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13423 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13424 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13425 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13426 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13428 create_database(msifile
, mcp_tables
, sizeof(mcp_tables
) / sizeof(msi_table
));
13430 /* install the product, machine */
13431 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13432 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13433 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13434 ok(pf_exists("msitest\\helium"), "File not installed\n");
13435 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13436 ok(pf_exists("msitest"), "File not installed\n");
13438 DeleteFileA(msifile
);
13440 lstrcpyA(keypath
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13441 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
13442 lstrcatA(keypath
, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13444 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, access
, &props
);
13445 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13449 res
= RegQueryValueExA(props
, "LocalPackage", NULL
, &type
,
13450 (LPBYTE
)localpackage
, &size
);
13451 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13453 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
13454 (const BYTE
*)"C:\\idontexist.msi", 18);
13455 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13457 /* LocalPackage is used to find the cached msi package */
13458 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13459 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13461 ok(r
== ERROR_INSTALL_SOURCE_ABSENT
,
13462 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r
);
13463 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13464 ok(pf_exists("msitest\\helium"), "File not installed\n");
13465 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13466 ok(pf_exists("msitest"), "File not installed\n");
13468 RegCloseKey(props
);
13469 create_database(msifile
, mcp_tables
, sizeof(mcp_tables
) / sizeof(msi_table
));
13471 /* LastUsedSource can be used as a last resort */
13472 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13473 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13475 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13476 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13477 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13478 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13479 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13480 DeleteFileA( localpackage
);
13482 /* install the product, machine */
13483 r
= MsiInstallProductA(msifile
, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13484 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13485 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13486 ok(pf_exists("msitest\\helium"), "File not installed\n");
13487 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13488 ok(pf_exists("msitest"), "File not installed\n");
13490 lstrcpyA(keypath
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13491 lstrcatA(keypath
, "Installer\\UserData\\S-1-5-18\\Products\\");
13492 lstrcatA(keypath
, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13494 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, access
, &props
);
13495 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13499 res
= RegQueryValueExA(props
, "LocalPackage", NULL
, &type
,
13500 (LPBYTE
)localpackage
, &size
);
13501 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13503 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
13504 (const BYTE
*)"C:\\idontexist.msi", 18);
13505 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13507 lstrcpyA(keypath
, "SOFTWARE\\Classes\\Installer\\Products\\");
13508 lstrcatA(keypath
, "83374883CBB1401418CAF2AA7CCEDDDC\\SourceList");
13510 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, keypath
, 0, access
, &source
);
13511 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13515 res
= RegQueryValueExA(source
, "PackageName", NULL
, &type
,
13516 (LPBYTE
)packagename
, &size
);
13517 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13519 res
= RegSetValueExA(source
, "PackageName", 0, REG_SZ
,
13520 (const BYTE
*)"idontexist.msi", 15);
13521 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13523 /* SourceList is altered */
13524 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13525 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13527 ok(r
== ERROR_INSTALL_SOURCE_ABSENT
,
13528 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r
);
13529 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13530 ok(pf_exists("msitest\\helium"), "File not installed\n");
13531 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13532 ok(pf_exists("msitest"), "File not installed\n");
13534 /* restore PackageName */
13535 res
= RegSetValueExA(source
, "PackageName", 0, REG_SZ
,
13536 (const BYTE
*)packagename
, lstrlenA(packagename
) + 1);
13537 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13539 /* restore LocalPackage */
13540 res
= RegSetValueExA(props
, "LocalPackage", 0, REG_SZ
,
13541 (const BYTE
*)localpackage
, lstrlenA(localpackage
) + 1);
13542 ok(res
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", res
);
13544 /* finally remove the product */
13545 r
= MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13546 INSTALLLEVEL_DEFAULT
, INSTALLSTATE_ABSENT
,
13548 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", r
);
13549 ok(!delete_pf("msitest\\hydrogen", TRUE
), "File not removed\n");
13550 ok(!delete_pf("msitest\\helium", TRUE
), "File not removed\n");
13551 ok(!delete_pf("msitest\\lithium", TRUE
), "File not removed\n");
13552 ok(!delete_pf("msitest", FALSE
), "Directory not removed\n");
13554 RegCloseKey(source
);
13555 RegCloseKey(props
);
13558 DeleteFileA("msitest\\hydrogen");
13559 DeleteFileA("msitest\\helium");
13560 DeleteFileA("msitest\\lithium");
13561 RemoveDirectoryA("msitest");
13562 DeleteFileA(msifile
);
13565 static void test_MsiSetFeatureAttributes(void)
13569 char path
[MAX_PATH
];
13572 if (is_process_limited())
13574 skip("process is limited\n");
13577 create_database( msifile
, tables
, sizeof(tables
) / sizeof(tables
[0]) );
13579 strcpy( path
, CURR_DIR
);
13580 strcat( path
, "\\" );
13581 strcat( path
, msifile
);
13583 r
= MsiOpenPackageA( path
, &package
);
13584 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13586 skip("Not enough rights to perform tests\n");
13587 DeleteFileA( msifile
);
13590 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13592 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13593 ok(r
== ERROR_FUNCTION_FAILED
, "Expected ERROR_FUNCTION_FAILED, got %u\n", r
);
13595 r
= MsiDoActionA( package
, "CostInitialize" );
13596 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13598 r
= MsiSetFeatureAttributesA( 0, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13599 ok(r
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %u\n", r
);
13601 r
= MsiSetFeatureAttributesA( package
, "", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13602 ok(r
== ERROR_UNKNOWN_FEATURE
, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
13604 r
= MsiSetFeatureAttributesA( package
, NULL
, INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13605 ok(r
== ERROR_UNKNOWN_FEATURE
, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
13607 r
= MsiSetFeatureAttributesA( package
, "One", 0 );
13608 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13610 attrs
= 0xdeadbeef;
13611 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, NULL
, NULL
, NULL
, NULL
);
13612 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13613 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
,
13614 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs
);
13616 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13617 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13620 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, NULL
, NULL
, NULL
, NULL
);
13621 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13622 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
,
13623 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs
);
13625 r
= MsiDoActionA( package
, "FileCost" );
13626 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13628 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORSOURCE
);
13629 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13632 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, NULL
, NULL
, NULL
, NULL
);
13633 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13634 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORSOURCE
,
13635 "expected INSTALLFEATUREATTRIBUTE_FAVORSOURCE, got 0x%08x\n", attrs
);
13637 r
= MsiDoActionA( package
, "CostFinalize" );
13638 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13640 r
= MsiSetFeatureAttributesA( package
, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL
);
13641 ok(r
== ERROR_FUNCTION_FAILED
, "expected ERROR_FUNCTION_FAILED, got %u\n", r
);
13643 MsiCloseHandle( package
);
13644 DeleteFileA( msifile
);
13647 static void test_MsiGetFeatureInfo(void)
13651 char title
[32], help
[32], path
[MAX_PATH
];
13652 DWORD attrs
, title_len
, help_len
;
13654 if (is_process_limited())
13656 skip("process is limited\n");
13659 create_database( msifile
, tables
, sizeof(tables
) / sizeof(tables
[0]) );
13661 strcpy( path
, CURR_DIR
);
13662 strcat( path
, "\\" );
13663 strcat( path
, msifile
);
13665 r
= MsiOpenPackageA( path
, &package
);
13666 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13668 skip("Not enough rights to perform tests\n");
13669 DeleteFileA( msifile
);
13672 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13674 r
= MsiGetFeatureInfoA( 0, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
13675 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
13677 r
= MsiGetFeatureInfoA( package
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
13678 ok(r
== ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", r
);
13680 r
= MsiGetFeatureInfoA( package
, "", NULL
, NULL
, NULL
, NULL
, NULL
);
13681 ok(r
== ERROR_UNKNOWN_FEATURE
, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r
);
13683 r
= MsiGetFeatureInfoA( package
, "One", NULL
, NULL
, NULL
, NULL
, NULL
);
13684 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13686 r
= MsiGetFeatureInfoA( 0, "One", NULL
, NULL
, NULL
, NULL
, NULL
);
13687 ok(r
== ERROR_INVALID_HANDLE
, "expected ERROR_INVALID_HANDLE, got %u\n", r
);
13689 title_len
= help_len
= 0;
13690 r
= MsiGetFeatureInfoA( package
, "One", NULL
, NULL
, &title_len
, NULL
, &help_len
);
13691 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13692 ok(title_len
== 3, "expected 3, got %u\n", title_len
);
13693 ok(help_len
== 3, "expected 3, got %u\n", help_len
);
13695 title
[0] = help
[0] = 0;
13696 title_len
= help_len
= 0;
13697 r
= MsiGetFeatureInfoA( package
, "One", NULL
, title
, &title_len
, help
, &help_len
);
13698 ok(r
== ERROR_MORE_DATA
, "expected ERROR_MORE_DATA, got %u\n", r
);
13699 ok(title_len
== 3, "expected 3, got %u\n", title_len
);
13700 ok(help_len
== 3, "expected 3, got %u\n", help_len
);
13703 title
[0] = help
[0] = 0;
13704 title_len
= sizeof(title
);
13705 help_len
= sizeof(help
);
13706 r
= MsiGetFeatureInfoA( package
, "One", &attrs
, title
, &title_len
, help
, &help_len
);
13707 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13708 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs
);
13709 ok(title_len
== 3, "expected 3, got %u\n", title_len
);
13710 ok(help_len
== 3, "expected 3, got %u\n", help_len
);
13711 ok(!strcmp(title
, "One"), "expected \"One\", got \"%s\"\n", title
);
13712 ok(!strcmp(help
, "One"), "expected \"One\", got \"%s\"\n", help
);
13715 title
[0] = help
[0] = 0;
13716 title_len
= sizeof(title
);
13717 help_len
= sizeof(help
);
13718 r
= MsiGetFeatureInfoA( package
, "Two", &attrs
, title
, &title_len
, help
, &help_len
);
13719 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13720 ok(attrs
== INSTALLFEATUREATTRIBUTE_FAVORLOCAL
, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs
);
13721 ok(!title_len
, "expected 0, got %u\n", title_len
);
13722 ok(!help_len
, "expected 0, got %u\n", help_len
);
13723 ok(!title
[0], "expected \"\", got \"%s\"\n", title
);
13724 ok(!help
[0], "expected \"\", got \"%s\"\n", help
);
13726 MsiCloseHandle( package
);
13727 DeleteFileA( msifile
);
13730 static INT CALLBACK
handler_a(LPVOID context
, UINT type
, LPCSTR msg
)
13735 static INT CALLBACK
handler_w(LPVOID context
, UINT type
, LPCWSTR msg
)
13740 static INT CALLBACK
handler_record(LPVOID context
, UINT type
, MSIHANDLE record
)
13745 static void test_MsiSetExternalUI(void)
13747 INSTALLUI_HANDLERA ret_a
;
13748 INSTALLUI_HANDLERW ret_w
;
13749 INSTALLUI_HANDLER_RECORD prev
;
13752 ret_a
= MsiSetExternalUIA(handler_a
, INSTALLLOGMODE_ERROR
, NULL
);
13753 ok(ret_a
== NULL
, "expected NULL, got %p\n", ret_a
);
13755 ret_a
= MsiSetExternalUIA(NULL
, 0, NULL
);
13756 ok(ret_a
== handler_a
, "expected %p, got %p\n", handler_a
, ret_a
);
13758 /* Not present before Installer 3.1 */
13759 if (!pMsiSetExternalUIRecord
) {
13760 win_skip("MsiSetExternalUIRecord is not available\n");
13764 error
= pMsiSetExternalUIRecord(handler_record
, INSTALLLOGMODE_ERROR
, NULL
, &prev
);
13765 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13766 ok(prev
== NULL
, "expected NULL, got %p\n", prev
);
13768 prev
= (INSTALLUI_HANDLER_RECORD
)0xdeadbeef;
13769 error
= pMsiSetExternalUIRecord(NULL
, INSTALLLOGMODE_ERROR
, NULL
, &prev
);
13770 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13771 ok(prev
== handler_record
, "expected %p, got %p\n", handler_record
, prev
);
13773 ret_w
= MsiSetExternalUIW(handler_w
, INSTALLLOGMODE_ERROR
, NULL
);
13774 ok(ret_w
== NULL
, "expected NULL, got %p\n", ret_w
);
13776 ret_w
= MsiSetExternalUIW(NULL
, 0, NULL
);
13777 ok(ret_w
== handler_w
, "expected %p, got %p\n", handler_w
, ret_w
);
13779 ret_a
= MsiSetExternalUIA(handler_a
, INSTALLLOGMODE_ERROR
, NULL
);
13780 ok(ret_a
== NULL
, "expected NULL, got %p\n", ret_a
);
13782 ret_w
= MsiSetExternalUIW(handler_w
, INSTALLLOGMODE_ERROR
, NULL
);
13783 ok(ret_w
== NULL
, "expected NULL, got %p\n", ret_w
);
13785 prev
= (INSTALLUI_HANDLER_RECORD
)0xdeadbeef;
13786 error
= pMsiSetExternalUIRecord(handler_record
, INSTALLLOGMODE_ERROR
, NULL
, &prev
);
13787 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13788 ok(prev
== NULL
, "expected NULL, got %p\n", prev
);
13790 ret_a
= MsiSetExternalUIA(NULL
, 0, NULL
);
13791 ok(ret_a
== NULL
, "expected NULL, got %p\n", ret_a
);
13793 ret_w
= MsiSetExternalUIW(NULL
, 0, NULL
);
13794 ok(ret_w
== NULL
, "expected NULL, got %p\n", ret_w
);
13796 prev
= (INSTALLUI_HANDLER_RECORD
)0xdeadbeef;
13797 error
= pMsiSetExternalUIRecord(NULL
, 0, NULL
, &prev
);
13798 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13799 ok(prev
== handler_record
, "expected %p, got %p\n", handler_record
, prev
);
13801 error
= pMsiSetExternalUIRecord(handler_record
, INSTALLLOGMODE_ERROR
, NULL
, NULL
);
13802 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13804 error
= pMsiSetExternalUIRecord(NULL
, 0, NULL
, NULL
);
13805 ok(!error
, "MsiSetExternalUIRecord failed %u\n", error
);
13808 static void test_lastusedsource(void)
13810 static const char prodcode
[] = "{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}";
13811 char value
[MAX_PATH
], path
[MAX_PATH
];
13815 if (!pMsiSourceListGetInfoA
)
13817 win_skip("MsiSourceListGetInfoA is not available\n");
13821 CreateDirectoryA("msitest", NULL
);
13822 create_file("maximus", "maximus", 500);
13823 create_cab_file("test1.cab", MEDIA_SIZE
, "maximus\0");
13824 DeleteFileA("maximus");
13826 create_database("msifile0.msi", lus0_tables
, sizeof(lus0_tables
) / sizeof(msi_table
));
13827 create_database("msifile1.msi", lus1_tables
, sizeof(lus1_tables
) / sizeof(msi_table
));
13828 create_database("msifile2.msi", lus2_tables
, sizeof(lus2_tables
) / sizeof(msi_table
));
13830 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
13832 /* no cabinet file */
13835 lstrcpyA(value
, "aaa");
13836 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13837 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13838 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13839 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13841 r
= MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1");
13842 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13844 skip("Not enough rights to perform tests\n");
13847 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13849 lstrcpyA(path
, CURR_DIR
);
13850 lstrcatA(path
, "\\");
13853 lstrcpyA(value
, "aaa");
13854 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13855 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13856 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13857 ok(!lstrcmpA(value
, path
), "expected \"%s\", got \"%s\"\n", path
, value
);
13858 ok(size
== lstrlenA(path
), "expected %d, got %d\n", lstrlenA(path
), size
);
13860 r
= MsiInstallProductA("msifile0.msi", "REMOVE=ALL");
13861 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13863 /* separate cabinet file */
13866 lstrcpyA(value
, "aaa");
13867 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13868 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13869 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13870 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13872 r
= MsiInstallProductA("msifile1.msi", "PUBLISH_PRODUCT=1");
13873 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13875 lstrcpyA(path
, CURR_DIR
);
13876 lstrcatA(path
, "\\");
13879 lstrcpyA(value
, "aaa");
13880 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13881 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13882 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13883 ok(!lstrcmpA(value
, path
), "expected \"%s\", got \"%s\"\n", path
, value
);
13884 ok(size
== lstrlenA(path
), "expected %d, got %d\n", lstrlenA(path
), size
);
13886 r
= MsiInstallProductA("msifile1.msi", "REMOVE=ALL");
13887 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13890 lstrcpyA(value
, "aaa");
13891 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13892 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13893 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13894 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13896 /* embedded cabinet stream */
13898 add_cabinet_storage("msifile2.msi", "test1.cab");
13900 r
= MsiInstallProductA("msifile2.msi", "PUBLISH_PRODUCT=1");
13901 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13904 lstrcpyA(value
, "aaa");
13905 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13906 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13907 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13908 ok(!lstrcmpA(value
, path
), "expected \"%s\", got \"%s\"\n", path
, value
);
13909 ok(size
== lstrlenA(path
), "expected %d, got %d\n", lstrlenA(path
), size
);
13911 r
= MsiInstallProductA("msifile2.msi", "REMOVE=ALL");
13912 ok(r
== ERROR_SUCCESS
, "expected ERROR_SUCCESS, got %u\n", r
);
13915 lstrcpyA(value
, "aaa");
13916 r
= pMsiSourceListGetInfoA(prodcode
, NULL
, MSIINSTALLCONTEXT_USERUNMANAGED
,
13917 MSICODE_PRODUCT
, INSTALLPROPERTY_LASTUSEDSOURCEA
, value
, &size
);
13918 ok(r
== ERROR_UNKNOWN_PRODUCT
, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r
);
13919 ok(!lstrcmpA(value
, "aaa"), "expected \"aaa\", got \"%s\"\n", value
);
13922 delete_cab_files();
13923 DeleteFileA("msitest\\maximus");
13924 RemoveDirectoryA("msitest");
13925 DeleteFileA("msifile0.msi");
13926 DeleteFileA("msifile1.msi");
13927 DeleteFileA("msifile2.msi");
13930 static void test_setpropertyfolder(void)
13933 CHAR path
[MAX_PATH
];
13936 if (is_process_limited())
13938 skip("process is limited\n");
13942 lstrcpyA(path
, PROG_FILES_DIR
);
13943 lstrcatA(path
, "\\msitest\\added");
13945 CreateDirectoryA("msitest", NULL
);
13946 create_file("msitest\\maximus", "msitest\\maximus", 500);
13948 create_database(msifile
, spf_tables
, sizeof(spf_tables
) / sizeof(msi_table
));
13950 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
13952 r
= MsiInstallProductA(msifile
, NULL
);
13953 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
13955 skip("Not enough rights to perform tests\n");
13958 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13959 attr
= GetFileAttributesA(path
);
13960 if (attr
!= INVALID_FILE_ATTRIBUTES
&& (attr
& FILE_ATTRIBUTE_DIRECTORY
))
13962 ok(delete_pf("msitest\\added\\maximus", TRUE
), "File not installed\n");
13963 ok(delete_pf("msitest\\added", FALSE
), "Directory not created\n");
13964 ok(delete_pf("msitest", FALSE
), "Directory not created\n");
13968 trace("changing folder property not supported\n");
13969 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
13970 ok(delete_pf("msitest", FALSE
), "Directory not created\n");
13974 DeleteFileA(msifile
);
13975 DeleteFileA("msitest\\maximus");
13976 RemoveDirectoryA("msitest");
13979 static void test_sourcedir_props(void)
13983 if (is_process_limited())
13985 skip("process is limited\n");
13989 create_test_files();
13990 create_file("msitest\\sourcedir.txt", "msitest\\sourcedir.txt", 1000);
13991 create_database(msifile
, sd_tables
, sizeof(sd_tables
) / sizeof(msi_table
));
13993 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
13995 /* full UI, no ResolveSource action */
13996 r
= MsiInstallProductA(msifile
, NULL
);
13997 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
13999 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
14000 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14002 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
14003 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
14005 /* full UI, ResolveSource action */
14006 r
= MsiInstallProductA(msifile
, "ResolveSource=1");
14007 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14009 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
14010 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14012 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
14013 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
14015 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
14017 /* no UI, no ResolveSource action */
14018 r
= MsiInstallProductA(msifile
, NULL
);
14019 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14021 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
14022 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14024 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
14025 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
14027 /* no UI, ResolveSource action */
14028 r
= MsiInstallProductA(msifile
, "ResolveSource=1");
14029 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14031 r
= MsiInstallProductA(msifile
, "REMOVE=ALL");
14032 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14034 ok(!delete_pf("msitest\\sourcedir.txt", TRUE
), "file not removed\n");
14035 ok(!delete_pf("msitest", FALSE
), "directory not removed\n");
14037 DeleteFileA("msitest\\sourcedir.txt");
14038 delete_test_files();
14039 DeleteFileA(msifile
);
14042 static void test_concurrentinstall(void)
14045 CHAR path
[MAX_PATH
];
14047 if (is_process_limited())
14049 skip("process is limited\n");
14053 CreateDirectoryA("msitest", NULL
);
14054 CreateDirectoryA("msitest\\msitest", NULL
);
14055 create_file("msitest\\maximus", "msitest\\maximus", 500);
14056 create_file("msitest\\msitest\\augustus", "msitest\\msitest\\augustus", 500);
14058 create_database(msifile
, ci_tables
, sizeof(ci_tables
) / sizeof(msi_table
));
14060 lstrcpyA(path
, CURR_DIR
);
14061 lstrcatA(path
, "\\msitest\\concurrent.msi");
14062 create_database(path
, ci2_tables
, sizeof(ci2_tables
) / sizeof(msi_table
));
14064 MsiSetInternalUI(INSTALLUILEVEL_FULL
, NULL
);
14066 r
= MsiInstallProductA(msifile
, NULL
);
14067 if (r
== ERROR_INSTALL_PACKAGE_REJECTED
)
14069 skip("Not enough rights to perform tests\n");
14073 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14074 if (!delete_pf("msitest\\augustus", TRUE
))
14075 trace("concurrent installs not supported\n");
14076 ok(delete_pf("msitest\\maximus", TRUE
), "File not installed\n");
14077 ok(delete_pf("msitest", FALSE
), "Directory not created\n");
14079 r
= MsiConfigureProductA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", INSTALLLEVEL_DEFAULT
,
14080 INSTALLSTATE_ABSENT
);
14081 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14086 DeleteFileA(msifile
);
14087 DeleteFileA("msitest\\msitest\\augustus");
14088 DeleteFileA("msitest\\maximus");
14089 RemoveDirectoryA("msitest\\msitest");
14090 RemoveDirectoryA("msitest");
14093 static void test_command_line_parsing(void)
14098 if (is_process_limited())
14100 skip("process is limited\n");
14104 create_test_files();
14105 create_database(msifile
, cl_tables
, sizeof(cl_tables
)/sizeof(msi_table
));
14107 MsiSetInternalUI(INSTALLUILEVEL_NONE
, NULL
);
14110 r
= MsiInstallProductA(msifile
, cmd
);
14111 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14114 r
= MsiInstallProductA(msifile
, cmd
);
14115 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14118 r
= MsiInstallProductA(msifile
, cmd
);
14119 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14122 r
= MsiInstallProductA(msifile
, cmd
);
14123 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14126 r
= MsiInstallProductA(msifile
, cmd
);
14127 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14130 r
= MsiInstallProductA(msifile
, cmd
);
14131 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14134 r
= MsiInstallProductA(msifile
, cmd
);
14135 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14138 r
= MsiInstallProductA(msifile
, cmd
);
14139 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14142 r
= MsiInstallProductA(msifile
, cmd
);
14143 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14146 r
= MsiInstallProductA(msifile
, cmd
);
14147 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14150 r
= MsiInstallProductA(msifile
, cmd
);
14151 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14153 cmd
= "P=\"\"\"\"";
14154 r
= MsiInstallProductA(msifile
, cmd
);
14155 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14158 r
= MsiInstallProductA(msifile
, cmd
);
14159 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14162 r
= MsiInstallProductA(msifile
, cmd
);
14163 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14166 r
= MsiInstallProductA(msifile
, cmd
);
14167 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14170 r
= MsiInstallProductA(msifile
, cmd
);
14171 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14174 r
= MsiInstallProductA(msifile
, cmd
);
14175 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14178 r
= MsiInstallProductA(msifile
, cmd
);
14179 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14182 r
= MsiInstallProductA(msifile
, cmd
);
14183 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14186 r
= MsiInstallProductA(msifile
, cmd
);
14187 todo_wine
ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14190 r
= MsiInstallProductA(msifile
, cmd
);
14191 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14193 cmd
= "P= \"one\" ";
14194 r
= MsiInstallProductA(msifile
, cmd
);
14195 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14197 cmd
= "P=\"one\"\"";
14198 r
= MsiInstallProductA(msifile
, cmd
);
14199 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14201 cmd
= "P=\"\"one\"";
14202 r
= MsiInstallProductA(msifile
, cmd
);
14203 ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14205 cmd
= "P=\"\"one\"\"";
14206 r
= MsiInstallProductA(msifile
, cmd
);
14207 todo_wine
ok(r
== ERROR_INVALID_COMMAND_LINE
, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r
);
14209 cmd
= "P=\"one two\"";
14210 r
= MsiInstallProductA(msifile
, cmd
);
14211 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14213 cmd
= "P=\"\"\"one\"\" two\"";
14214 r
= MsiInstallProductA(msifile
, cmd
);
14215 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14217 cmd
= "P=\"\"\"one\"\" two\" Q=three";
14218 r
= MsiInstallProductA(msifile
, cmd
);
14219 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14221 cmd
= "P=\"\" Q=\"two\"";
14222 r
= MsiInstallProductA(msifile
, cmd
);
14223 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14225 cmd
= "P=\"one\" Q=\"two\"";
14226 r
= MsiInstallProductA(msifile
, cmd
);
14227 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14229 cmd
= "P=\"one=two\"";
14230 r
= MsiInstallProductA(msifile
, cmd
);
14231 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14233 cmd
= "Q=\"\" P=\"one\"";
14234 r
= MsiInstallProductA(msifile
, cmd
);
14235 ok(r
== ERROR_INSTALL_FAILURE
, "Expected ERROR_INSTALL_FAILURE, got %u\n", r
);
14237 cmd
= "P=\"\"\"one\"\"\" Q=\"two\"";
14238 r
= MsiInstallProductA(msifile
, cmd
);
14239 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14241 cmd
= "P=\"one \"\"two\"\"\" Q=\"three\"";
14242 r
= MsiInstallProductA(msifile
, cmd
);
14243 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14245 cmd
= "P=\"\"\"one\"\" two\" Q=\"three\"";
14246 r
= MsiInstallProductA(msifile
, cmd
);
14247 ok(r
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %u\n", r
);
14249 DeleteFileA(msifile
);
14250 delete_test_files();
14256 char temp_path
[MAX_PATH
], prev_path
[MAX_PATH
];
14258 init_functionpointers();
14260 if (pIsWow64Process
)
14261 pIsWow64Process(GetCurrentProcess(), &is_wow64
);
14263 GetCurrentDirectoryA(MAX_PATH
, prev_path
);
14264 GetTempPathA(MAX_PATH
, temp_path
);
14265 SetCurrentDirectoryA(temp_path
);
14267 lstrcpyA(CURR_DIR
, temp_path
);
14268 len
= lstrlenA(CURR_DIR
);
14270 if(len
&& (CURR_DIR
[len
- 1] == '\\'))
14271 CURR_DIR
[len
- 1] = 0;
14273 ok(get_system_dirs(), "failed to retrieve system dirs\n");
14277 test_getcomponentpath();
14278 test_MsiGetFileHash();
14280 if (!pConvertSidToStringSidA
)
14281 win_skip("ConvertSidToStringSidA not implemented\n");
14284 /* These tests rely on get_user_sid that needs ConvertSidToStringSidA */
14285 test_MsiQueryProductState();
14286 test_MsiQueryFeatureState();
14287 test_MsiQueryComponentState();
14288 test_MsiGetComponentPath();
14289 test_MsiGetProductCode();
14290 test_MsiEnumClients();
14291 test_MsiGetProductInfo();
14292 test_MsiGetProductInfoEx();
14293 test_MsiGetUserInfo();
14294 test_MsiOpenProduct();
14295 test_MsiEnumPatchesEx();
14296 test_MsiEnumPatches();
14297 test_MsiGetPatchInfoEx();
14298 test_MsiGetPatchInfo();
14299 test_MsiEnumProducts();
14300 test_MsiEnumProductsEx();
14301 test_MsiEnumComponents();
14302 test_MsiEnumComponentsEx();
14304 test_MsiGetFileVersion();
14305 test_MsiGetFileSignatureInformation();
14306 test_MsiConfigureProductEx();
14307 test_MsiSetFeatureAttributes();
14308 test_MsiGetFeatureInfo();
14309 test_MsiSetExternalUI();
14310 test_lastusedsource();
14311 test_setpropertyfolder();
14312 test_sourcedir_props();
14313 test_concurrentinstall();
14314 test_command_line_parsing();
14316 SetCurrentDirectoryA(prev_path
);