mf/session: Forward more events to the application.
[wine/zf.git] / dlls / msi / tests / msi.c
blob5e0fa680c898071a0712fe708c5ceeb2ed0479f1
1 /*
2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define _WIN32_MSI 300
22 #define COBJMACROS
24 #include <stdio.h>
25 #include <windows.h>
26 #include <msi.h>
27 #include <msiquery.h>
28 #include <msidefs.h>
29 #include <sddl.h>
30 #include <fci.h>
31 #include <shellapi.h>
32 #include <objidl.h>
34 #include "wine/test.h"
35 #include "utils.h"
37 #define GUID_SIZE (39)
38 #define SQUASHED_GUID_SIZE (33)
40 static BOOL is_wow64;
41 static const char msifile[] = "winetest.msi";
42 static const WCHAR msifileW[] = L"winetest.msi";
44 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
45 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
47 static INSTALLSTATE (WINAPI *pMsiGetComponentPathA)
48 (LPCSTR, LPCSTR, LPSTR, DWORD*);
49 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)
50 (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
51 static INSTALLSTATE (WINAPI *pMsiProvideComponentA)
52 (LPCSTR, LPCSTR, LPCSTR, DWORD, LPSTR, LPDWORD);
53 static INSTALLSTATE (WINAPI *pMsiProvideComponentW)
54 (LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPWSTR, LPDWORD);
55 static UINT (WINAPI *pMsiGetFileHashA)
56 (LPCSTR, DWORD, PMSIFILEHASHINFO);
57 static UINT (WINAPI *pMsiGetProductInfoExA)
58 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, LPDWORD);
59 static UINT (WINAPI *pMsiOpenPackageExA)
60 (LPCSTR, DWORD, MSIHANDLE*);
61 static UINT (WINAPI *pMsiOpenPackageExW)
62 (LPCWSTR, DWORD, MSIHANDLE*);
63 static UINT (WINAPI *pMsiEnumPatchesExA)
64 (LPCSTR, LPCSTR, DWORD, DWORD, DWORD, LPSTR, LPSTR,
65 MSIINSTALLCONTEXT*, LPSTR, LPDWORD);
66 static UINT (WINAPI *pMsiQueryComponentStateA)
67 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
68 static INSTALLSTATE (WINAPI *pMsiUseFeatureExA)
69 (LPCSTR, LPCSTR ,DWORD, DWORD);
70 static UINT (WINAPI *pMsiGetPatchInfoExA)
71 (LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, LPSTR, DWORD *);
72 static UINT (WINAPI *pMsiEnumProductsExA)
73 (LPCSTR, LPCSTR, DWORD, DWORD, CHAR[39], MSIINSTALLCONTEXT *, LPSTR, LPDWORD);
74 static UINT (WINAPI *pMsiEnumComponentsExA)
75 (LPCSTR, DWORD, DWORD, CHAR[39], MSIINSTALLCONTEXT *, LPSTR, LPDWORD);
76 static UINT (WINAPI *pMsiSetExternalUIRecord)
77 (INSTALLUI_HANDLER_RECORD, DWORD, LPVOID, PINSTALLUI_HANDLER_RECORD);
78 static UINT (WINAPI *pMsiSourceListGetInfoA)
79 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
81 static void init_functionpointers(void)
83 HMODULE hmsi = GetModuleHandleA("msi.dll");
84 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
85 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
87 #define GET_PROC(dll, func) \
88 p ## func = (void *)GetProcAddress(dll, #func); \
89 if(!p ## func) \
90 trace("GetProcAddress(%s) failed\n", #func);
92 GET_PROC(hmsi, MsiGetComponentPathA)
93 GET_PROC(hmsi, MsiGetComponentPathExA);
94 GET_PROC(hmsi, MsiProvideComponentA)
95 GET_PROC(hmsi, MsiProvideComponentW)
96 GET_PROC(hmsi, MsiGetFileHashA)
97 GET_PROC(hmsi, MsiGetProductInfoExA)
98 GET_PROC(hmsi, MsiOpenPackageExA)
99 GET_PROC(hmsi, MsiOpenPackageExW)
100 GET_PROC(hmsi, MsiEnumPatchesExA)
101 GET_PROC(hmsi, MsiQueryComponentStateA)
102 GET_PROC(hmsi, MsiSetExternalUIRecord)
103 GET_PROC(hmsi, MsiUseFeatureExA)
104 GET_PROC(hmsi, MsiGetPatchInfoExA)
105 GET_PROC(hmsi, MsiEnumProductsExA)
106 GET_PROC(hmsi, MsiEnumComponentsExA)
107 GET_PROC(hmsi, MsiSourceListGetInfoA)
109 GET_PROC(hadvapi32, RegDeleteKeyExA)
110 GET_PROC(hkernel32, IsWow64Process)
112 #undef GET_PROC
115 /* cabinet definitions */
117 /* make the max size large so there is only one cab file */
118 #define MEDIA_SIZE 0x7FFFFFFF
119 #define FOLDER_THRESHOLD 900000
121 static BOOL add_cabinet_storage(LPCSTR db, LPCSTR cabinet)
123 WCHAR dbW[MAX_PATH], cabinetW[MAX_PATH];
124 IStorage *stg;
125 IStream *stm;
126 HRESULT hr;
127 HANDLE handle;
129 MultiByteToWideChar(CP_ACP, 0, db, -1, dbW, MAX_PATH);
130 hr = StgOpenStorage(dbW, NULL, STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
131 if (FAILED(hr))
132 return FALSE;
134 MultiByteToWideChar(CP_ACP, 0, cabinet, -1, cabinetW, MAX_PATH);
135 hr = IStorage_CreateStream(stg, cabinetW, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
136 if (FAILED(hr))
138 IStorage_Release(stg);
139 return FALSE;
142 handle = CreateFileW(cabinetW, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
143 if (handle != INVALID_HANDLE_VALUE)
145 DWORD count;
146 char buffer[1024];
147 if (ReadFile(handle, buffer, sizeof(buffer), &count, NULL))
148 IStream_Write(stm, buffer, count, &count);
149 CloseHandle(handle);
152 IStream_Release(stm);
153 IStorage_Release(stg);
155 return TRUE;
158 /* msi database data */
160 static const char directory_dat[] =
161 "Directory\tDirectory_Parent\tDefaultDir\n"
162 "s72\tS72\tl255\n"
163 "Directory\tDirectory\n"
164 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
165 "ProgramFilesFolder\tTARGETDIR\t.\n"
166 "TARGETDIR\t\tSourceDir";
168 static const char component_dat[] =
169 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
170 "s72\tS38\ts72\ti2\tS255\tS72\n"
171 "Component\tComponent\n"
172 "One\t{8F5BAEEF-DD92-40AC-9397-BE3CF9F97C81}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n";
174 static const char feature_dat[] =
175 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
176 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
177 "Feature\tFeature\n"
178 "One\t\tOne\tOne\t1\t3\tMSITESTDIR\t0\n"
179 "Two\t\t\t\t2\t1\tTARGETDIR\t0\n";
181 static const char feature_comp_dat[] =
182 "Feature_\tComponent_\n"
183 "s38\ts72\n"
184 "FeatureComponents\tFeature_\tComponent_\n"
185 "One\tOne\n";
187 static const char file_dat[] =
188 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
189 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
190 "File\tFile\n"
191 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n";
193 static const char install_exec_seq_dat[] =
194 "Action\tCondition\tSequence\n"
195 "s72\tS255\tI2\n"
196 "InstallExecuteSequence\tAction\n"
197 "ValidateProductID\t\t700\n"
198 "CostInitialize\t\t800\n"
199 "FileCost\t\t900\n"
200 "CostFinalize\t\t1000\n"
201 "InstallValidate\t\t1400\n"
202 "InstallInitialize\t\t1500\n"
203 "ProcessComponents\t\t1600\n"
204 "UnpublishFeatures\t\t1800\n"
205 "RemoveFiles\t\t3500\n"
206 "InstallFiles\t\t4000\n"
207 "RegisterProduct\t\t6100\n"
208 "PublishFeatures\t\t6300\n"
209 "PublishProduct\t\t6400\n"
210 "InstallFinalize\t\t6600";
212 static const char media_dat[] =
213 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
214 "i2\ti4\tL64\tS255\tS32\tS72\n"
215 "Media\tDiskId\n"
216 "1\t1\t\t\tDISK1\t\n";
218 static const char property_dat[] =
219 "Property\tValue\n"
220 "s72\tl0\n"
221 "Property\tProperty\n"
222 "INSTALLLEVEL\t3\n"
223 "Manufacturer\tWine\n"
224 "ProductCode\t{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}\n"
225 "ProductName\tMSITEST\n"
226 "ProductVersion\t1.1.1\n"
227 "UpgradeCode\t{9574448F-9B86-4E07-B6F6-8D199DA12127}\n"
228 "MSIFASTINSTALL\t1\n";
230 static const char ci2_property_dat[] =
231 "Property\tValue\n"
232 "s72\tl0\n"
233 "Property\tProperty\n"
234 "INSTALLLEVEL\t3\n"
235 "Manufacturer\tWine\n"
236 "ProductCode\t{FF4AFE9C-6AC2-44F9-A060-9EA6BD16C75E}\n"
237 "ProductName\tMSITEST2\n"
238 "ProductVersion\t1.1.1\n"
239 "UpgradeCode\t{6B60C3CA-B8CA-4FB7-A395-092D98FF5D2A}\n"
240 "MSIFASTINSTALL\t1\n";
242 static const char mcp_component_dat[] =
243 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
244 "s72\tS38\ts72\ti2\tS255\tS72\n"
245 "Component\tComponent\n"
246 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
247 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
248 "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";
250 static const char mcp_feature_dat[] =
251 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
252 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
253 "Feature\tFeature\n"
254 "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
255 "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
256 "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";
258 static const char mcp_feature_comp_dat[] =
259 "Feature_\tComponent_\n"
260 "s38\ts72\n"
261 "FeatureComponents\tFeature_\tComponent_\n"
262 "hydroxyl\thydrogen\n"
263 "heliox\thelium\n"
264 "lithia\tlithium";
266 static const char mcp_file_dat[] =
267 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
268 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
269 "File\tFile\n"
270 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
271 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
272 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
274 static const char lus_component_dat[] =
275 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
276 "s72\tS38\ts72\ti2\tS255\tS72\n"
277 "Component\tComponent\n"
278 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
280 static const char lus_feature_dat[] =
281 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
282 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
283 "Feature\tFeature\n"
284 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
285 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
287 static const char lus_file_dat[] =
288 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
289 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
290 "File\tFile\n"
291 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
293 static const char lus_feature_comp_dat[] =
294 "Feature_\tComponent_\n"
295 "s38\ts72\n"
296 "FeatureComponents\tFeature_\tComponent_\n"
297 "feature\tmaximus\n"
298 "montecristo\tmaximus";
300 static const char lus_install_exec_seq_dat[] =
301 "Action\tCondition\tSequence\n"
302 "s72\tS255\tI2\n"
303 "InstallExecuteSequence\tAction\n"
304 "ValidateProductID\t\t700\n"
305 "CostInitialize\t\t800\n"
306 "FileCost\t\t900\n"
307 "CostFinalize\t\t1000\n"
308 "InstallValidate\t\t1400\n"
309 "InstallInitialize\t\t1500\n"
310 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
311 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
312 "RemoveFiles\t\t3500\n"
313 "InstallFiles\t\t4000\n"
314 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
315 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
316 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
317 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
318 "InstallFinalize\t\t6600";
320 static const char lus0_media_dat[] =
321 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
322 "i2\ti4\tL64\tS255\tS32\tS72\n"
323 "Media\tDiskId\n"
324 "1\t1\t\t\tDISK1\t\n";
326 static const char lus1_media_dat[] =
327 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
328 "i2\ti4\tL64\tS255\tS32\tS72\n"
329 "Media\tDiskId\n"
330 "1\t1\t\ttest1.cab\tDISK1\t\n";
332 static const char lus2_media_dat[] =
333 "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
334 "i2\ti4\tL64\tS255\tS32\tS72\n"
335 "Media\tDiskId\n"
336 "1\t1\t\t#test1.cab\tDISK1\t\n";
338 static const char spf_custom_action_dat[] =
339 "Action\tType\tSource\tTarget\tISComments\n"
340 "s72\ti2\tS64\tS0\tS255\n"
341 "CustomAction\tAction\n"
342 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n"
343 "SetFolderProp2\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\\added2\t\n";
345 static const char spf_install_exec_seq_dat[] =
346 "Action\tCondition\tSequence\n"
347 "s72\tS255\tI2\n"
348 "InstallExecuteSequence\tAction\n"
349 "CostInitialize\t\t800\n"
350 "FileCost\t\t900\n"
351 "SetFolderProp\t\t950\n"
352 "SetFolderProp2\t\t960\n"
353 "CostFinalize\t\t1000\n"
354 "InstallValidate\t\t1400\n"
355 "InstallInitialize\t\t1500\n"
356 "InstallFiles\t\t4000\n"
357 "InstallServices\t\t5000\n"
358 "InstallFinalize\t\t6600\n";
360 static const char spf_install_ui_seq_dat[] =
361 "Action\tCondition\tSequence\n"
362 "s72\tS255\tI2\n"
363 "InstallUISequence\tAction\n"
364 "CostInitialize\t\t800\n"
365 "FileCost\t\t900\n"
366 "CostFinalize\t\t1000\n"
367 "ExecuteAction\t\t1100\n";
369 static const char spf_directory_dat[] =
370 "Directory\tDirectory_Parent\tDefaultDir\n"
371 "s72\tS72\tl255\n"
372 "Directory\tDirectory\n"
373 "PARENTDIR\tTARGETDIR\tparent\n"
374 "CHILDDIR\tPARENTDIR\tchild\n"
375 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
376 "ProgramFilesFolder\tTARGETDIR\t.\n"
377 "TARGETDIR\t\tSourceDir";
379 static const char spf_component_dat[] =
380 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
381 "s72\tS38\ts72\ti2\tS255\tS72\n"
382 "Component\tComponent\n"
383 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
385 static const char spf2_install_exec_seq_dat[] =
386 "Action\tCondition\tSequence\n"
387 "s72\tS255\tI2\n"
388 "InstallExecuteSequence\tAction\n"
389 "CostInitialize\t\t800\n"
390 "FileCost\t\t900\n"
391 "FormatParentFolderCheck\t\t910\n"
392 "FormatChildFolderCheck\t\t920\n"
393 "CheckParentFolder\tNOT PARENTDIR=PARENTDIRCHECK\t930\n"
394 "CheckChildFolder\tNOT CHILDDIR=CHILDDIRCHECK\t940\n"
395 "FormatParentFolderCheck2\t\t945\n"
396 "SetParentFolder\t\t950\n"
397 "CheckParentFolder2\tNOT PARENTDIR=PARENTDIRCHECK\t960\n"
398 "CheckChildFolder2\tNOT CHILDDIR=CHILDDIRCHECK\t970\n"
399 "CostFinalize\t\t1000\n"
400 "FormatParentFolderCheck3\t\t1005\n"
401 "CheckParentFolder3\tNOT PARENTDIR=PARENTDIRCHECK\t1010\n"
402 "CheckChildFolder3\tNOT CHILDDIR=CHILDDIRCHECK\t1020\n"
403 "InstallValidate\t\t1400\n"
404 "InstallInitialize\t\t1500\n"
405 "InstallFiles\t\t4000\n"
406 "CreateShortcuts\t\t4100\n"
407 "InstallFinalize\t\t6600\n";
409 static const char spf2_custom_action_dat[] =
410 "Action\tType\tSource\tTarget\tISComments\n"
411 "s72\ti2\tS64\tS0\tS255\n"
412 "CustomAction\tAction\n"
413 "FormatParentFolderCheck\t51\tPARENTDIRCHECK\t[TARGETDIR]parent\\\t\n"
414 "FormatChildFolderCheck\t51\tCHILDDIRCHECK\t[TARGETDIR]parent\\child\\\t\n"
415 "CheckParentFolder\t19\tPARENTDIR\tparent prop wrong before set: [PARENTDIR]\t\n"
416 "CheckChildFolder\t19\tCHILDDIR\tchild prop wrong before set: [CHILDDIR]\t\n"
417 "FormatParentFolderCheck2\t51\tPARENTDIRCHECK\t[ProgramFilesFolder]msitest\\parent\t\n"
418 "SetParentFolder\t51\tPARENTDIR\t[PARENTDIRCHECK]\t\n"
419 "CheckParentFolder2\t19\tPARENTDIR\tparent prop wrong after set: [PARENTDIR]\t\n"
420 "CheckChildFolder2\t19\tCHILDDIR\tchild prop wrong after set: [CHILDDIR]\t\n"
421 "FormatParentFolderCheck3\t51\tPARENTDIRCHECK\t[ProgramFilesFolder]msitest\\parent\\\t\n"
422 "CheckParentFolder3\t19\tPARENTDIR\tparent prop wrong after CostFinalize: [PARENTDIR]\t\n"
423 "CheckChildFolder3\t19\tCHILDDIR\tchild prop wrong after CostFinalize: [CHILDDIR]\t\n";
425 static const char shortcut_dat[] =
426 "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
427 "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n"
428 "Shortcut\tShortcut\n"
429 "Shortcut\tCHILDDIR\tShortcut\tmaximus\t[#maximus]\t\tShortcut\t\t\t\t\tMSITESTDIR\n";
431 static const char sd_file_dat[] =
432 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
433 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
434 "File\tFile\n"
435 "sourcedir.txt\tsourcedir\tsourcedir.txt\t1000\t\t\t8192\t1\n";
437 static const char sd_feature_dat[] =
438 "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
439 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
440 "Feature\tFeature\n"
441 "sourcedir\t\t\tsourcedir feature\t1\t2\tMSITESTDIR\t0\n";
443 static const char sd_feature_comp_dat[] =
444 "Feature_\tComponent_\n"
445 "s38\ts72\n"
446 "FeatureComponents\tFeature_\tComponent_\n"
447 "sourcedir\tsourcedir\n";
449 static const char sd_component_dat[] =
450 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
451 "s72\tS38\ts72\ti2\tS255\tS72\n"
452 "Component\tComponent\n"
453 "sourcedir\t{DD422F92-3ED8-49B5-A0B7-F266F98357DF}\tMSITESTDIR\t0\t\tsourcedir.txt\n";
455 static const char sd_install_ui_seq_dat[] =
456 "Action\tCondition\tSequence\n"
457 "s72\tS255\tI2\n"
458 "InstallUISequence\tAction\n"
459 "TestSourceDirProp1\tnot SourceDir and not SOURCEDIR and not Installed\t99\n"
460 "AppSearch\t\t100\n"
461 "TestSourceDirProp2\tnot SourceDir and not SOURCEDIR and not Installed\t101\n"
462 "LaunchConditions\tnot Installed \t110\n"
463 "TestSourceDirProp3\tnot SourceDir and not SOURCEDIR and not Installed\t111\n"
464 "FindRelatedProducts\t\t120\n"
465 "TestSourceDirProp4\tnot SourceDir and not SOURCEDIR and not Installed\t121\n"
466 "CCPSearch\t\t130\n"
467 "TestSourceDirProp5\tnot SourceDir and not SOURCEDIR and not Installed\t131\n"
468 "RMCCPSearch\t\t140\n"
469 "TestSourceDirProp6\tnot SourceDir and not SOURCEDIR and not Installed\t141\n"
470 "ValidateProductID\t\t150\n"
471 "TestSourceDirProp7\tnot SourceDir and not SOURCEDIR and not Installed\t151\n"
472 "CostInitialize\t\t800\n"
473 "TestSourceDirProp8\tnot SourceDir and not SOURCEDIR and not Installed\t801\n"
474 "FileCost\t\t900\n"
475 "TestSourceDirProp9\tnot SourceDir and not SOURCEDIR and not Installed\t901\n"
476 "IsolateComponents\t\t1000\n"
477 "TestSourceDirProp10\tnot SourceDir and not SOURCEDIR and not Installed\t1001\n"
478 "CostFinalize\t\t1100\n"
479 "TestSourceDirProp11\tnot SourceDir and not SOURCEDIR and not Installed\t1101\n"
480 "MigrateFeatureStates\t\t1200\n"
481 "TestSourceDirProp12\tnot SourceDir and not SOURCEDIR and not Installed\t1201\n"
482 "ExecuteAction\t\t1300\n"
483 "TestSourceDirProp13\tnot SourceDir and not SOURCEDIR and not Installed\t1301\n";
485 static const char sd_install_exec_seq_dat[] =
486 "Action\tCondition\tSequence\n"
487 "s72\tS255\tI2\n"
488 "InstallExecuteSequence\tAction\n"
489 "TestSourceDirProp14\tSourceDir and SOURCEDIR and not Installed\t99\n"
490 "LaunchConditions\t\t100\n"
491 "TestSourceDirProp15\tSourceDir and SOURCEDIR and not Installed\t101\n"
492 "ValidateProductID\t\t700\n"
493 "TestSourceDirProp16\tSourceDir and SOURCEDIR and not Installed\t701\n"
494 "CostInitialize\t\t800\n"
495 "TestSourceDirProp17\tSourceDir and SOURCEDIR and not Installed\t801\n"
496 "ResolveSource\tResolveSource and not Installed\t850\n"
497 "TestSourceDirProp18\tResolveSource and not SourceDir and not SOURCEDIR and not Installed\t851\n"
498 "TestSourceDirProp19\tnot ResolveSource and SourceDir and SOURCEDIR and not Installed\t852\n"
499 "FileCost\t\t900\n"
500 "TestSourceDirProp20\tSourceDir and SOURCEDIR and not Installed\t901\n"
501 "IsolateComponents\t\t1000\n"
502 "TestSourceDirProp21\tSourceDir and SOURCEDIR and not Installed\t1001\n"
503 "CostFinalize\t\t1100\n"
504 "TestSourceDirProp22\tSourceDir and SOURCEDIR and not Installed\t1101\n"
505 "MigrateFeatureStates\t\t1200\n"
506 "TestSourceDirProp23\tSourceDir and SOURCEDIR and not Installed\t1201\n"
507 "InstallValidate\t\t1400\n"
508 "TestSourceDirProp24\tSourceDir and SOURCEDIR and not Installed\t1401\n"
509 "InstallInitialize\t\t1500\n"
510 "TestSourceDirProp25\tSourceDir and SOURCEDIR and not Installed\t1501\n"
511 "ProcessComponents\t\t1600\n"
512 "TestSourceDirProp26\tnot SourceDir and not SOURCEDIR and not Installed\t1601\n"
513 "UnpublishFeatures\t\t1800\n"
514 "TestSourceDirProp27\tnot SourceDir and not SOURCEDIR and not Installed\t1801\n"
515 "RemoveFiles\t\t3500\n"
516 "TestSourceDirProp28\tnot SourceDir and not SOURCEDIR and not Installed\t3501\n"
517 "InstallFiles\t\t4000\n"
518 "TestSourceDirProp29\tnot SourceDir and not SOURCEDIR and not Installed\t4001\n"
519 "RegisterUser\t\t6000\n"
520 "TestSourceDirProp30\tnot SourceDir and not SOURCEDIR and not Installed\t6001\n"
521 "RegisterProduct\t\t6100\n"
522 "TestSourceDirProp31\tnot SourceDir and not SOURCEDIR and not Installed\t6101\n"
523 "PublishFeatures\t\t6300\n"
524 "TestSourceDirProp32\tnot SourceDir and not SOURCEDIR and not Installed\t6301\n"
525 "PublishProduct\t\t6400\n"
526 "TestSourceDirProp33\tnot SourceDir and not SOURCEDIR and not Installed\t6401\n"
527 "InstallExecute\t\t6500\n"
528 "TestSourceDirProp34\tnot SourceDir and not SOURCEDIR and not Installed\t6501\n"
529 "InstallFinalize\t\t6600\n"
530 "TestSourceDirProp35\tnot SourceDir and not SOURCEDIR and not Installed\t6601\n";
532 static const char sd_custom_action_dat[] =
533 "Action\tType\tSource\tTarget\tISComments\n"
534 "s72\ti2\tS64\tS0\tS255\n"
535 "CustomAction\tAction\n"
536 "TestSourceDirProp1\t19\t\tTest 1 failed\t\n"
537 "TestSourceDirProp2\t19\t\tTest 2 failed\t\n"
538 "TestSourceDirProp3\t19\t\tTest 3 failed\t\n"
539 "TestSourceDirProp4\t19\t\tTest 4 failed\t\n"
540 "TestSourceDirProp5\t19\t\tTest 5 failed\t\n"
541 "TestSourceDirProp6\t19\t\tTest 6 failed\t\n"
542 "TestSourceDirProp7\t19\t\tTest 7 failed\t\n"
543 "TestSourceDirProp8\t19\t\tTest 8 failed\t\n"
544 "TestSourceDirProp9\t19\t\tTest 9 failed\t\n"
545 "TestSourceDirProp10\t19\t\tTest 10 failed\t\n"
546 "TestSourceDirProp11\t19\t\tTest 11 failed\t\n"
547 "TestSourceDirProp12\t19\t\tTest 12 failed\t\n"
548 "TestSourceDirProp13\t19\t\tTest 13 failed\t\n"
549 "TestSourceDirProp14\t19\t\tTest 14 failed\t\n"
550 "TestSourceDirProp15\t19\t\tTest 15 failed\t\n"
551 "TestSourceDirProp16\t19\t\tTest 16 failed\t\n"
552 "TestSourceDirProp17\t19\t\tTest 17 failed\t\n"
553 "TestSourceDirProp18\t19\t\tTest 18 failed\t\n"
554 "TestSourceDirProp19\t19\t\tTest 19 failed\t\n"
555 "TestSourceDirProp20\t19\t\tTest 20 failed\t\n"
556 "TestSourceDirProp21\t19\t\tTest 21 failed\t\n"
557 "TestSourceDirProp22\t19\t\tTest 22 failed\t\n"
558 "TestSourceDirProp23\t19\t\tTest 23 failed\t\n"
559 "TestSourceDirProp24\t19\t\tTest 24 failed\t\n"
560 "TestSourceDirProp25\t19\t\tTest 25 failed\t\n"
561 "TestSourceDirProp26\t19\t\tTest 26 failed\t\n"
562 "TestSourceDirProp27\t19\t\tTest 27 failed\t\n"
563 "TestSourceDirProp28\t19\t\tTest 28 failed\t\n"
564 "TestSourceDirProp29\t19\t\tTest 29 failed\t\n"
565 "TestSourceDirProp30\t19\t\tTest 30 failed\t\n"
566 "TestSourceDirProp31\t19\t\tTest 31 failed\t\n"
567 "TestSourceDirProp32\t19\t\tTest 32 failed\t\n"
568 "TestSourceDirProp33\t19\t\tTest 33 failed\t\n"
569 "TestSourceDirProp34\t19\t\tTest 34 failed\t\n"
570 "TestSourceDirProp35\t19\t\tTest 35 failed\t\n";
572 static const char ci_install_exec_seq_dat[] =
573 "Action\tCondition\tSequence\n"
574 "s72\tS255\tI2\n"
575 "InstallExecuteSequence\tAction\n"
576 "CostInitialize\t\t800\n"
577 "FileCost\t\t900\n"
578 "CostFinalize\t\t1000\n"
579 "InstallValidate\t\t1400\n"
580 "InstallInitialize\t\t1500\n"
581 "RunInstall\tnot Installed\t1550\n"
582 "ProcessComponents\t\t1600\n"
583 "UnpublishFeatures\t\t1800\n"
584 "RemoveFiles\t\t3500\n"
585 "InstallFiles\t\t4000\n"
586 "RegisterProduct\t\t6100\n"
587 "PublishFeatures\t\t6300\n"
588 "PublishProduct\t\t6400\n"
589 "InstallFinalize\t\t6600\n";
591 static const char ci_custom_action_dat[] =
592 "Action\tType\tSource\tTarget\tISComments\n"
593 "s72\ti2\tS64\tS0\tS255\n"
594 "CustomAction\tAction\n"
595 "RunInstall\t23\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
597 static const char ci_component_dat[] =
598 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
599 "s72\tS38\ts72\ti2\tS255\tS72\n"
600 "Component\tComponent\n"
601 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
603 static const char ci2_component_dat[] =
604 "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
605 "s72\tS38\ts72\ti2\tS255\tS72\n"
606 "Component\tComponent\n"
607 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
609 static const char ci2_feature_comp_dat[] =
610 "Feature_\tComponent_\n"
611 "s38\ts72\n"
612 "FeatureComponents\tFeature_\tComponent_\n"
613 "feature\taugustus";
615 static const char ci2_file_dat[] =
616 "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
617 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
618 "File\tFile\n"
619 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
621 static const char cl_custom_action_dat[] =
622 "Action\tType\tSource\tTarget\tISComments\n"
623 "s72\ti2\tS64\tS0\tS255\n"
624 "CustomAction\tAction\n"
625 "TestCommandlineProp\t19\t\tTest1\t\n";
627 static const char cl_install_exec_seq_dat[] =
628 "Action\tCondition\tSequence\n"
629 "s72\tS255\tI2\n"
630 "InstallExecuteSequence\tAction\n"
631 "LaunchConditions\t\t100\n"
632 "ValidateProductID\t\t700\n"
633 "CostInitialize\t\t800\n"
634 "FileCost\t\t900\n"
635 "CostFinalize\t\t1000\n"
636 "TestCommandlineProp\tP=\"one\"\t1100\n"
637 "InstallInitialize\t\t1500\n"
638 "ProcessComponents\t\t1600\n"
639 "InstallValidate\t\t1400\n"
640 "InstallFinalize\t\t5000\n";
642 static const msi_table tables[] =
644 ADD_TABLE(directory),
645 ADD_TABLE(component),
646 ADD_TABLE(feature),
647 ADD_TABLE(feature_comp),
648 ADD_TABLE(file),
649 ADD_TABLE(install_exec_seq),
650 ADD_TABLE(media),
651 ADD_TABLE(property),
654 static const msi_table mcp_tables[] =
656 ADD_TABLE(directory),
657 ADD_TABLE(mcp_component),
658 ADD_TABLE(mcp_feature),
659 ADD_TABLE(mcp_feature_comp),
660 ADD_TABLE(mcp_file),
661 ADD_TABLE(install_exec_seq),
662 ADD_TABLE(media),
663 ADD_TABLE(property)
666 static const msi_table lus0_tables[] =
668 ADD_TABLE(lus_component),
669 ADD_TABLE(directory),
670 ADD_TABLE(lus_feature),
671 ADD_TABLE(lus_feature_comp),
672 ADD_TABLE(lus_file),
673 ADD_TABLE(lus_install_exec_seq),
674 ADD_TABLE(lus0_media),
675 ADD_TABLE(property)
678 static const msi_table lus1_tables[] =
680 ADD_TABLE(lus_component),
681 ADD_TABLE(directory),
682 ADD_TABLE(lus_feature),
683 ADD_TABLE(lus_feature_comp),
684 ADD_TABLE(lus_file),
685 ADD_TABLE(lus_install_exec_seq),
686 ADD_TABLE(lus1_media),
687 ADD_TABLE(property)
690 static const msi_table lus2_tables[] =
692 ADD_TABLE(lus_component),
693 ADD_TABLE(directory),
694 ADD_TABLE(lus_feature),
695 ADD_TABLE(lus_feature_comp),
696 ADD_TABLE(lus_file),
697 ADD_TABLE(lus_install_exec_seq),
698 ADD_TABLE(lus2_media),
699 ADD_TABLE(property)
702 static const msi_table spf_tables[] =
704 ADD_TABLE(lus_component),
705 ADD_TABLE(directory),
706 ADD_TABLE(lus_feature),
707 ADD_TABLE(lus_feature_comp),
708 ADD_TABLE(lus_file),
709 ADD_TABLE(lus0_media),
710 ADD_TABLE(property),
711 ADD_TABLE(spf_custom_action),
712 ADD_TABLE(spf_install_exec_seq),
713 ADD_TABLE(spf_install_ui_seq)
716 static const msi_table spf2_tables[] =
718 ADD_TABLE(spf_component),
719 ADD_TABLE(spf_directory),
720 ADD_TABLE(lus_feature),
721 ADD_TABLE(lus_feature_comp),
722 ADD_TABLE(lus_file),
723 ADD_TABLE(lus0_media),
724 ADD_TABLE(property),
725 ADD_TABLE(spf2_custom_action),
726 ADD_TABLE(spf2_install_exec_seq),
727 ADD_TABLE(spf_install_ui_seq),
728 ADD_TABLE(shortcut)
731 static const msi_table sd_tables[] =
733 ADD_TABLE(directory),
734 ADD_TABLE(sd_component),
735 ADD_TABLE(sd_feature),
736 ADD_TABLE(sd_feature_comp),
737 ADD_TABLE(sd_file),
738 ADD_TABLE(sd_install_exec_seq),
739 ADD_TABLE(sd_install_ui_seq),
740 ADD_TABLE(sd_custom_action),
741 ADD_TABLE(media),
742 ADD_TABLE(property)
745 static const msi_table ci_tables[] =
747 ADD_TABLE(ci_component),
748 ADD_TABLE(directory),
749 ADD_TABLE(lus_feature),
750 ADD_TABLE(lus_feature_comp),
751 ADD_TABLE(lus_file),
752 ADD_TABLE(ci_install_exec_seq),
753 ADD_TABLE(lus0_media),
754 ADD_TABLE(property),
755 ADD_TABLE(ci_custom_action),
758 static const msi_table ci2_tables[] =
760 ADD_TABLE(ci2_component),
761 ADD_TABLE(directory),
762 ADD_TABLE(lus_feature),
763 ADD_TABLE(ci2_feature_comp),
764 ADD_TABLE(ci2_file),
765 ADD_TABLE(install_exec_seq),
766 ADD_TABLE(lus0_media),
767 ADD_TABLE(ci2_property),
770 static const msi_table cl_tables[] =
772 ADD_TABLE(component),
773 ADD_TABLE(directory),
774 ADD_TABLE(feature),
775 ADD_TABLE(feature_comp),
776 ADD_TABLE(file),
777 ADD_TABLE(cl_custom_action),
778 ADD_TABLE(cl_install_exec_seq),
779 ADD_TABLE(media),
780 ADD_TABLE(property)
783 static UINT set_summary_info(MSIHANDLE hdb, LPSTR prodcode)
785 UINT res;
786 MSIHANDLE suminfo;
788 /* build summary info */
789 res = MsiGetSummaryInformationA(hdb, NULL, 7, &suminfo);
790 ok(res == ERROR_SUCCESS, "Failed to open summaryinfo\n");
792 res = MsiSummaryInfoSetPropertyA(suminfo, 2, VT_LPSTR, 0, NULL,
793 "Installation Database");
794 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
796 res = MsiSummaryInfoSetPropertyA(suminfo, 3, VT_LPSTR, 0, NULL,
797 "Installation Database");
798 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
800 res = MsiSummaryInfoSetPropertyA(suminfo, 4, VT_LPSTR, 0, NULL,
801 "Wine Hackers");
802 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
804 res = MsiSummaryInfoSetPropertyA(suminfo, 7, VT_LPSTR, 0, NULL,
805 ";1033");
806 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
808 res = MsiSummaryInfoSetPropertyA(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
809 "{A2078D65-94D6-4205-8DEE-F68D6FD622AA}");
810 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
812 res = MsiSummaryInfoSetPropertyA(suminfo, 14, VT_I4, 100, NULL, NULL);
813 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
815 res = MsiSummaryInfoSetPropertyA(suminfo, 15, VT_I4, 0, NULL, NULL);
816 ok(res == ERROR_SUCCESS, "Failed to set summary info\n");
818 res = MsiSummaryInfoPersist(suminfo);
819 ok(res == ERROR_SUCCESS, "Failed to make summary info persist\n");
821 res = MsiCloseHandle(suminfo);
822 ok(res == ERROR_SUCCESS, "Failed to close suminfo\n");
824 return res;
827 static MSIHANDLE create_package_db(LPSTR prodcode)
829 MSIHANDLE hdb = 0;
830 CHAR query[MAX_PATH + 72];
831 UINT res;
833 DeleteFileA(msifile);
835 /* create an empty database */
836 res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
837 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
838 if (res != ERROR_SUCCESS)
839 return hdb;
841 res = MsiDatabaseCommit(hdb);
842 ok(res == ERROR_SUCCESS, "Failed to commit database\n");
844 set_summary_info(hdb, prodcode);
846 res = run_query(hdb, 0,
847 "CREATE TABLE `Directory` ( "
848 "`Directory` CHAR(255) NOT NULL, "
849 "`Directory_Parent` CHAR(255), "
850 "`DefaultDir` CHAR(255) NOT NULL "
851 "PRIMARY KEY `Directory`)");
852 ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
854 res = run_query(hdb, 0,
855 "CREATE TABLE `Property` ( "
856 "`Property` CHAR(72) NOT NULL, "
857 "`Value` CHAR(255) "
858 "PRIMARY KEY `Property`)");
859 ok(res == ERROR_SUCCESS , "Failed to create directory table\n");
861 sprintf(query, "INSERT INTO `Property` "
862 "(`Property`, `Value`) "
863 "VALUES( 'ProductCode', '%s' )", prodcode);
864 res = run_query(hdb, 0, query);
865 ok(res == ERROR_SUCCESS , "Failed\n");
867 res = MsiDatabaseCommit(hdb);
868 ok(res == ERROR_SUCCESS, "Failed to commit database\n");
870 return hdb;
873 static void test_usefeature(void)
875 INSTALLSTATE r;
877 if (!pMsiUseFeatureExA)
879 win_skip("MsiUseFeatureExA not implemented\n");
880 return;
883 r = MsiQueryFeatureStateA(NULL, NULL);
884 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
886 r = MsiQueryFeatureStateA("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL);
887 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
889 r = pMsiUseFeatureExA(NULL,NULL,0,0);
890 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
892 r = pMsiUseFeatureExA(NULL, "WORDVIEWFiles", -2, 1 );
893 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
895 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
896 NULL, -2, 0 );
897 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
899 r = pMsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
900 "WORDVIEWFiles", -2, 0 );
901 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
903 r = pMsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
904 "WORDVIEWFiles", -2, 0 );
905 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
907 r = pMsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
908 "WORDVIEWFiles", -2, 1 );
909 ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
912 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
914 if (pRegDeleteKeyExA)
915 return pRegDeleteKeyExA( key, subkey, access, 0 );
916 return RegDeleteKeyA( key, subkey );
919 static void test_null(void)
921 MSIHANDLE hpkg;
922 UINT r;
923 HKEY hkey;
924 DWORD dwType, cbData;
925 LPBYTE lpData = NULL;
926 INSTALLSTATE state;
927 REGSAM access = KEY_ALL_ACCESS;
929 if (is_wow64)
930 access |= KEY_WOW64_64KEY;
932 r = pMsiOpenPackageExW(NULL, 0, &hpkg);
933 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
935 state = MsiQueryProductStateW(NULL);
936 ok( state == INSTALLSTATE_INVALIDARG, "wrong return\n");
938 r = MsiEnumFeaturesW(NULL,0,NULL,NULL);
939 ok( r == ERROR_INVALID_PARAMETER,"wrong error\n");
941 r = MsiConfigureFeatureW(NULL, NULL, 0);
942 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
944 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000000}", NULL, 0);
945 ok( r == ERROR_INVALID_PARAMETER, "wrong error\n");
947 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000001}", "foo", 0);
948 ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
950 r = MsiConfigureFeatureA("{00000000-0000-0000-0000-000000000002}", "foo", INSTALLSTATE_DEFAULT);
951 ok( r == ERROR_UNKNOWN_PRODUCT, "wrong error %d\n", r);
953 /* make sure empty string to MsiGetProductInfo is not a handle to default registry value, saving and restoring the
954 * necessary registry values */
956 /* empty product string */
957 r = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, access, &hkey);
958 if (r == ERROR_ACCESS_DENIED)
960 skip("Not enough rights to perform tests\n");
961 return;
963 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
965 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
966 ok ( r == ERROR_SUCCESS || r == ERROR_FILE_NOT_FOUND, "wrong error %d\n", r);
967 if ( r == ERROR_SUCCESS )
969 lpData = HeapAlloc(GetProcessHeap(), 0, cbData);
970 if (!lpData)
971 skip("Out of memory\n");
972 else
974 r = RegQueryValueExA(hkey, NULL, 0, &dwType, lpData, &cbData);
975 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
979 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
980 if (r == ERROR_ACCESS_DENIED)
982 skip("Not enough rights to perform tests\n");
983 HeapFree(GetProcessHeap(), 0, lpData);
984 RegCloseKey(hkey);
985 return;
987 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
989 r = MsiGetProductInfoA("", "", NULL, NULL);
990 ok ( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r);
992 if (lpData)
994 r = RegSetValueExA(hkey, NULL, 0, dwType, lpData, cbData);
995 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
997 HeapFree(GetProcessHeap(), 0, lpData);
999 else
1001 r = RegDeleteValueA(hkey, NULL);
1002 ok ( r == ERROR_SUCCESS, "wrong error %d\n", r);
1005 r = RegCloseKey(hkey);
1006 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1008 /* empty attribute */
1009 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1010 0, NULL, 0, access, NULL, &hkey, NULL);
1011 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1013 r = RegSetValueA(hkey, NULL, REG_SZ, "test", strlen("test"));
1014 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1016 r = MsiGetProductInfoA("{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", "", NULL, NULL);
1017 ok ( r == ERROR_UNKNOWN_PROPERTY, "wrong error %d\n", r);
1019 r = RegCloseKey(hkey);
1020 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1022 r = delete_key(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}",
1023 access & KEY_WOW64_64KEY);
1024 ok( r == ERROR_SUCCESS, "wrong error %d\n", r);
1027 static void test_getcomponentpath(void)
1029 INSTALLSTATE r;
1030 char buffer[0x100];
1031 DWORD sz;
1033 if(!pMsiGetComponentPathA)
1034 return;
1036 r = pMsiGetComponentPathA( NULL, NULL, NULL, NULL );
1037 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1039 r = pMsiGetComponentPathA( "bogus", "bogus", NULL, NULL );
1040 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1042 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", NULL, NULL );
1043 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1045 sz = sizeof buffer;
1046 buffer[0]=0;
1047 r = pMsiGetComponentPathA( "bogus", "{00000000-0000-0000-000000000000}", buffer, &sz );
1048 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1050 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C998E7}",
1051 "{00000000-0000-0000-0000-000000000000}", buffer, &sz );
1052 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
1054 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1055 "{00000000-0000-0000-0000-00000000}", buffer, &sz );
1056 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1058 r = pMsiGetComponentPathA( "{00000409-78E1-11D2-B60F-006097C998E7}",
1059 "{029E403D-A86A-1D11-5B5B0006799C897E}", buffer, &sz );
1060 ok( r == INSTALLSTATE_INVALIDARG, "wrong return value\n");
1062 r = pMsiGetComponentPathA( "{00000000-78E1-11D2-B60F-006097C9987e}",
1063 "{00000000-A68A-11d1-5B5B-0006799C897E}", buffer, &sz );
1064 ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n");
1067 static void create_test_files(void)
1069 CreateDirectoryA("msitest", NULL);
1070 create_file("msitest\\one.txt", 100);
1071 CreateDirectoryA("msitest\\first", NULL);
1072 create_file("msitest\\first\\two.txt", 100);
1073 CreateDirectoryA("msitest\\second", NULL);
1074 create_file("msitest\\second\\three.txt", 100);
1076 create_file("four.txt", 100);
1077 create_file("five.txt", 100);
1078 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1080 create_file("msitest\\filename", 100);
1081 create_file("msitest\\service.exe", 100);
1083 DeleteFileA("four.txt");
1084 DeleteFileA("five.txt");
1087 static void delete_test_files(void)
1089 DeleteFileA("msitest.msi");
1090 DeleteFileA("msitest.cab");
1091 DeleteFileA("msitest\\second\\three.txt");
1092 DeleteFileA("msitest\\first\\two.txt");
1093 DeleteFileA("msitest\\one.txt");
1094 DeleteFileA("msitest\\service.exe");
1095 DeleteFileA("msitest\\filename");
1096 RemoveDirectoryA("msitest\\second");
1097 RemoveDirectoryA("msitest\\first");
1098 RemoveDirectoryA("msitest");
1101 #define HASHSIZE sizeof(MSIFILEHASHINFO)
1103 static const struct
1105 LPCSTR data;
1106 DWORD size;
1107 MSIFILEHASHINFO hash;
1108 } hash_data[] =
1110 { "", 0,
1111 { HASHSIZE,
1112 { 0, 0, 0, 0 },
1116 { "abc", 0,
1117 { HASHSIZE,
1118 { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 },
1122 { "C:\\Program Files\\msitest\\caesar\n", 0,
1123 { HASHSIZE,
1124 { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 },
1128 { "C:\\Program Files\\msitest\\caesar\n", 500,
1129 { HASHSIZE,
1130 { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 },
1135 static void test_MsiGetFileHash(void)
1137 const char name[] = "msitest.bin";
1138 UINT r;
1139 MSIFILEHASHINFO hash;
1140 DWORD i;
1142 if (!pMsiGetFileHashA)
1144 win_skip("MsiGetFileHash not implemented\n");
1145 return;
1148 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
1150 /* szFilePath is NULL */
1151 r = pMsiGetFileHashA(NULL, 0, &hash);
1152 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1154 /* szFilePath is empty */
1155 r = pMsiGetFileHashA("", 0, &hash);
1156 ok(r == ERROR_PATH_NOT_FOUND || r == ERROR_BAD_PATHNAME,
1157 "Expected ERROR_PATH_NOT_FOUND or ERROR_BAD_PATHNAME, got %d\n", r);
1159 /* szFilePath is nonexistent */
1160 r = pMsiGetFileHashA(name, 0, &hash);
1161 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
1163 /* dwOptions is non-zero */
1164 r = pMsiGetFileHashA(name, 1, &hash);
1165 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1167 /* pHash.dwFileHashInfoSize is not correct */
1168 hash.dwFileHashInfoSize = 0;
1169 r = pMsiGetFileHashA(name, 0, &hash);
1170 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1172 /* pHash is NULL */
1173 r = pMsiGetFileHashA(name, 0, NULL);
1174 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
1176 for (i = 0; i < ARRAY_SIZE(hash_data); i++)
1178 int ret;
1180 create_file_data(name, hash_data[i].data, hash_data[i].size);
1182 memset(&hash, 0, sizeof(MSIFILEHASHINFO));
1183 hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
1185 r = pMsiGetFileHashA(name, 0, &hash);
1186 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1188 ret = memcmp(&hash, &hash_data[i].hash, HASHSIZE);
1189 ok(!ret, "Hash incorrect\n");
1191 DeleteFileA(name);
1195 /* copied from dlls/msi/registry.c */
1196 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
1198 DWORD i,n=1;
1199 GUID guid;
1201 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
1202 return FALSE;
1204 for(i=0; i<8; i++)
1205 out[7-i] = in[n++];
1206 n++;
1207 for(i=0; i<4; i++)
1208 out[11-i] = in[n++];
1209 n++;
1210 for(i=0; i<4; i++)
1211 out[15-i] = in[n++];
1212 n++;
1213 for(i=0; i<2; i++)
1215 out[17+i*2] = in[n++];
1216 out[16+i*2] = in[n++];
1218 n++;
1219 for( ; i<8; i++)
1221 out[17+i*2] = in[n++];
1222 out[16+i*2] = in[n++];
1224 out[32]=0;
1225 return TRUE;
1228 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
1230 WCHAR guidW[GUID_SIZE];
1231 WCHAR squashedW[SQUASHED_GUID_SIZE];
1232 GUID guid;
1233 HRESULT hr;
1234 int size;
1236 hr = CoCreateGuid(&guid);
1237 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
1239 size = StringFromGUID2(&guid, guidW, ARRAY_SIZE(guidW));
1240 ok(size == GUID_SIZE, "Expected %d, got %d.\n", GUID_SIZE, size);
1242 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, GUID_SIZE, NULL, NULL);
1243 if (squashed)
1245 squash_guid(guidW, squashedW);
1246 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, SQUASHED_GUID_SIZE, NULL, NULL);
1250 static char *get_user_sid(void)
1252 HANDLE token;
1253 DWORD size = 0;
1254 TOKEN_USER *user;
1255 char *usersid = NULL;
1257 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
1258 GetTokenInformation(token, TokenUser, NULL, size, &size);
1260 user = HeapAlloc(GetProcessHeap(), 0, size);
1261 GetTokenInformation(token, TokenUser, user, size, &size);
1262 ConvertSidToStringSidA(user->User.Sid, &usersid);
1263 HeapFree(GetProcessHeap(), 0, user);
1265 CloseHandle(token);
1266 return usersid;
1269 static void test_MsiQueryProductState(void)
1271 CHAR prodcode[MAX_PATH];
1272 CHAR prod_squashed[MAX_PATH];
1273 CHAR keypath[MAX_PATH*2];
1274 LPSTR usersid;
1275 INSTALLSTATE state;
1276 LONG res;
1277 HKEY userkey, localkey, props;
1278 HKEY prodkey;
1279 DWORD data, error;
1280 REGSAM access = KEY_ALL_ACCESS;
1282 create_test_guid(prodcode, prod_squashed);
1283 usersid = get_user_sid();
1285 if (is_wow64)
1286 access |= KEY_WOW64_64KEY;
1288 /* NULL prodcode */
1289 SetLastError(0xdeadbeef);
1290 state = MsiQueryProductStateA(NULL);
1291 error = GetLastError();
1292 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1293 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1295 /* empty prodcode */
1296 SetLastError(0xdeadbeef);
1297 state = MsiQueryProductStateA("");
1298 error = GetLastError();
1299 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1300 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1302 /* garbage prodcode */
1303 SetLastError(0xdeadbeef);
1304 state = MsiQueryProductStateA("garbage");
1305 error = GetLastError();
1306 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1307 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1309 /* guid without brackets */
1310 SetLastError(0xdeadbeef);
1311 state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
1312 error = GetLastError();
1313 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1314 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1316 /* guid with brackets */
1317 SetLastError(0xdeadbeef);
1318 state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
1319 error = GetLastError();
1320 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1321 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1323 /* same length as guid, but random */
1324 SetLastError(0xdeadbeef);
1325 state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
1326 error = GetLastError();
1327 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1328 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1330 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1332 SetLastError(0xdeadbeef);
1333 state = MsiQueryProductStateA(prodcode);
1334 error = GetLastError();
1335 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1336 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1338 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
1339 lstrcatA(keypath, prod_squashed);
1341 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
1342 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1344 /* user product key exists */
1345 SetLastError(0xdeadbeef);
1346 state = MsiQueryProductStateA(prodcode);
1347 error = GetLastError();
1348 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1349 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1351 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
1352 lstrcatA(keypath, prodcode);
1354 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1355 if (res == ERROR_ACCESS_DENIED)
1357 skip("Not enough rights to perform tests\n");
1358 RegDeleteKeyA(userkey, "");
1359 RegCloseKey(userkey);
1360 LocalFree(usersid);
1361 return;
1363 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1365 /* local uninstall key exists */
1366 SetLastError(0xdeadbeef);
1367 state = MsiQueryProductStateA(prodcode);
1368 error = GetLastError();
1369 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1370 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1372 data = 1;
1373 res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1374 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1376 /* WindowsInstaller value exists */
1377 SetLastError(0xdeadbeef);
1378 state = MsiQueryProductStateA(prodcode);
1379 error = GetLastError();
1380 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1381 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1383 RegDeleteValueA(localkey, "WindowsInstaller");
1384 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1386 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1387 lstrcatA(keypath, usersid);
1388 lstrcatA(keypath, "\\Products\\");
1389 lstrcatA(keypath, prod_squashed);
1391 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1392 if (res == ERROR_ACCESS_DENIED)
1394 skip("Not enough rights to perform tests\n");
1395 RegDeleteKeyA(userkey, "");
1396 RegCloseKey(userkey);
1397 LocalFree(usersid);
1398 return;
1400 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1402 /* local product key exists */
1403 SetLastError(0xdeadbeef);
1404 state = MsiQueryProductStateA(prodcode);
1405 error = GetLastError();
1406 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1407 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1409 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
1410 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1412 /* install properties key exists */
1413 SetLastError(0xdeadbeef);
1414 state = MsiQueryProductStateA(prodcode);
1415 error = GetLastError();
1416 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1417 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1419 data = 1;
1420 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1421 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1423 /* WindowsInstaller value exists */
1424 SetLastError(0xdeadbeef);
1425 state = MsiQueryProductStateA(prodcode);
1426 error = GetLastError();
1427 if (state == INSTALLSTATE_ADVERTISED)
1429 win_skip("broken result\n");
1430 RegDeleteValueA(props, "WindowsInstaller");
1431 delete_key(props, "", access & KEY_WOW64_64KEY);
1432 RegCloseKey(props);
1433 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1434 RegCloseKey(localkey);
1435 RegDeleteKeyA(userkey, "");
1436 RegCloseKey(userkey);
1437 LocalFree(usersid);
1438 return;
1440 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1441 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1443 data = 2;
1444 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1445 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1447 /* WindowsInstaller value is not 1 */
1448 SetLastError(0xdeadbeef);
1449 state = MsiQueryProductStateA(prodcode);
1450 error = GetLastError();
1451 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1452 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1454 RegDeleteKeyA(userkey, "");
1456 /* user product key does not exist */
1457 SetLastError(0xdeadbeef);
1458 state = MsiQueryProductStateA(prodcode);
1459 error = GetLastError();
1460 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
1461 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1463 RegDeleteValueA(props, "WindowsInstaller");
1464 delete_key(props, "", access & KEY_WOW64_64KEY);
1465 RegCloseKey(props);
1466 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1467 RegCloseKey(localkey);
1468 RegDeleteKeyA(userkey, "");
1469 RegCloseKey(userkey);
1471 /* MSIINSTALLCONTEXT_USERMANAGED */
1473 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1474 lstrcatA(keypath, usersid);
1475 lstrcatA(keypath, "\\Installer\\Products\\");
1476 lstrcatA(keypath, prod_squashed);
1478 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
1479 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1481 state = MsiQueryProductStateA(prodcode);
1482 ok(state == INSTALLSTATE_ADVERTISED,
1483 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1485 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1486 lstrcatA(keypath, usersid);
1487 lstrcatA(keypath, "\\Products\\");
1488 lstrcatA(keypath, prod_squashed);
1490 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1491 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1493 state = MsiQueryProductStateA(prodcode);
1494 ok(state == INSTALLSTATE_ADVERTISED,
1495 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1497 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
1498 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1500 state = MsiQueryProductStateA(prodcode);
1501 ok(state == INSTALLSTATE_ADVERTISED,
1502 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1504 data = 1;
1505 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1506 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1508 /* WindowsInstaller value exists */
1509 state = MsiQueryProductStateA(prodcode);
1510 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1512 RegDeleteValueA(props, "WindowsInstaller");
1513 delete_key(props, "", access & KEY_WOW64_64KEY);
1514 RegCloseKey(props);
1515 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1516 RegCloseKey(localkey);
1517 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
1518 RegCloseKey(prodkey);
1520 /* MSIINSTALLCONTEXT_MACHINE */
1522 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
1523 lstrcatA(keypath, prod_squashed);
1525 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
1526 if (res == ERROR_ACCESS_DENIED)
1528 skip( "insufficient rights\n" );
1529 LocalFree( usersid );
1530 return;
1532 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1534 state = MsiQueryProductStateA(prodcode);
1535 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1537 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1538 lstrcatA(keypath, "S-1-5-18\\Products\\");
1539 lstrcatA(keypath, prod_squashed);
1541 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1542 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1544 state = MsiQueryProductStateA(prodcode);
1545 ok(state == INSTALLSTATE_ADVERTISED,
1546 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1548 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
1549 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1551 state = MsiQueryProductStateA(prodcode);
1552 ok(state == INSTALLSTATE_ADVERTISED,
1553 "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1555 data = 1;
1556 res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
1557 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1559 /* WindowsInstaller value exists */
1560 state = MsiQueryProductStateA(prodcode);
1561 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1563 RegDeleteValueA(props, "WindowsInstaller");
1564 delete_key(props, "", access & KEY_WOW64_64KEY);
1565 RegCloseKey(props);
1566 delete_key(localkey, "", access & KEY_WOW64_64KEY);
1567 RegCloseKey(localkey);
1568 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
1569 RegCloseKey(prodkey);
1571 LocalFree(usersid);
1574 static const char table_enc85[] =
1575 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
1576 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
1577 "yz{}~";
1580 * Encodes a base85 guid given a GUID pointer
1581 * Caller should provide a 21 character buffer for the encoded string.
1583 static void encode_base85_guid( GUID *guid, LPWSTR str )
1585 unsigned int x, *p, i;
1587 p = (unsigned int*) guid;
1588 for( i=0; i<4; i++ )
1590 x = p[i];
1591 *str++ = table_enc85[x%85];
1592 x = x/85;
1593 *str++ = table_enc85[x%85];
1594 x = x/85;
1595 *str++ = table_enc85[x%85];
1596 x = x/85;
1597 *str++ = table_enc85[x%85];
1598 x = x/85;
1599 *str++ = table_enc85[x%85];
1601 *str = 0;
1604 static void compose_base85_guid(LPSTR component, LPSTR comp_base85, LPSTR squashed)
1606 WCHAR guidW[MAX_PATH];
1607 WCHAR base85W[MAX_PATH];
1608 WCHAR squashedW[MAX_PATH];
1609 GUID guid;
1610 HRESULT hr;
1611 int size;
1613 hr = CoCreateGuid(&guid);
1614 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
1616 size = StringFromGUID2(&guid, guidW, MAX_PATH);
1617 ok(size == 39, "Expected 39, got %d\n", hr);
1619 WideCharToMultiByte(CP_ACP, 0, guidW, size, component, MAX_PATH, NULL, NULL);
1620 encode_base85_guid(&guid, base85W);
1621 WideCharToMultiByte(CP_ACP, 0, base85W, -1, comp_base85, MAX_PATH, NULL, NULL);
1622 squash_guid(guidW, squashedW);
1623 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
1626 static void test_MsiQueryFeatureState(void)
1628 HKEY userkey, localkey, compkey, compkey2;
1629 CHAR prodcode[MAX_PATH];
1630 CHAR prod_squashed[MAX_PATH];
1631 CHAR component[MAX_PATH];
1632 CHAR comp_base85[MAX_PATH];
1633 CHAR comp_squashed[MAX_PATH], comp_squashed2[MAX_PATH];
1634 CHAR keypath[MAX_PATH*2];
1635 INSTALLSTATE state;
1636 LPSTR usersid;
1637 LONG res;
1638 REGSAM access = KEY_ALL_ACCESS;
1639 DWORD error;
1641 create_test_guid(prodcode, prod_squashed);
1642 compose_base85_guid(component, comp_base85, comp_squashed);
1643 compose_base85_guid(component, comp_base85 + 20, comp_squashed2);
1644 usersid = get_user_sid();
1646 if (is_wow64)
1647 access |= KEY_WOW64_64KEY;
1649 /* NULL prodcode */
1650 SetLastError(0xdeadbeef);
1651 state = MsiQueryFeatureStateA(NULL, "feature");
1652 error = GetLastError();
1653 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1654 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1656 /* empty prodcode */
1657 SetLastError(0xdeadbeef);
1658 state = MsiQueryFeatureStateA("", "feature");
1659 error = GetLastError();
1660 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1661 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1663 /* garbage prodcode */
1664 SetLastError(0xdeadbeef);
1665 state = MsiQueryFeatureStateA("garbage", "feature");
1666 error = GetLastError();
1667 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1668 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1670 /* guid without brackets */
1671 SetLastError(0xdeadbeef);
1672 state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
1673 error = GetLastError();
1674 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1675 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1677 /* guid with brackets */
1678 SetLastError(0xdeadbeef);
1679 state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
1680 error = GetLastError();
1681 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1682 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1684 /* same length as guid, but random */
1685 SetLastError(0xdeadbeef);
1686 state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
1687 error = GetLastError();
1688 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1689 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1691 /* NULL szFeature */
1692 SetLastError(0xdeadbeef);
1693 state = MsiQueryFeatureStateA(prodcode, NULL);
1694 error = GetLastError();
1695 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
1696 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
1698 /* empty szFeature */
1699 SetLastError(0xdeadbeef);
1700 state = MsiQueryFeatureStateA(prodcode, "");
1701 error = GetLastError();
1702 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1703 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1705 /* feature key does not exist yet */
1706 SetLastError(0xdeadbeef);
1707 state = MsiQueryFeatureStateA(prodcode, "feature");
1708 error = GetLastError();
1709 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1710 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1712 /* MSIINSTALLCONTEXT_USERUNMANAGED */
1714 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Features\\");
1715 lstrcatA(keypath, prod_squashed);
1717 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &userkey);
1718 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1720 /* feature key exists */
1721 SetLastError(0xdeadbeef);
1722 state = MsiQueryFeatureStateA(prodcode, "feature");
1723 error = GetLastError();
1724 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1725 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1727 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
1728 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1730 /* feature value exists */
1731 SetLastError(0xdeadbeef);
1732 state = MsiQueryFeatureStateA(prodcode, "feature");
1733 error = GetLastError();
1734 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1735 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1737 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1738 lstrcatA(keypath, usersid);
1739 lstrcatA(keypath, "\\Products\\");
1740 lstrcatA(keypath, prod_squashed);
1741 lstrcatA(keypath, "\\Features");
1743 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1744 if (res == ERROR_ACCESS_DENIED)
1746 skip("Not enough rights to perform tests\n");
1747 RegDeleteKeyA(userkey, "");
1748 RegCloseKey(userkey);
1749 LocalFree(usersid);
1750 return;
1752 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1754 /* userdata features key exists */
1755 SetLastError(0xdeadbeef);
1756 state = MsiQueryFeatureStateA(prodcode, "feature");
1757 error = GetLastError();
1758 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1759 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1761 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
1762 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1764 SetLastError(0xdeadbeef);
1765 state = MsiQueryFeatureStateA(prodcode, "feature");
1766 error = GetLastError();
1767 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
1768 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1770 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
1771 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1773 SetLastError(0xdeadbeef);
1774 state = MsiQueryFeatureStateA(prodcode, "feature");
1775 error = GetLastError();
1776 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1777 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1779 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
1780 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1782 SetLastError(0xdeadbeef);
1783 state = MsiQueryFeatureStateA(prodcode, "feature");
1784 error = GetLastError();
1785 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1786 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1788 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
1789 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1791 SetLastError(0xdeadbeef);
1792 state = MsiQueryFeatureStateA(prodcode, "feature");
1793 error = GetLastError();
1794 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1795 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1797 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1798 lstrcatA(keypath, usersid);
1799 lstrcatA(keypath, "\\Components\\");
1800 lstrcatA(keypath, comp_squashed);
1802 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
1803 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1805 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1806 lstrcatA(keypath, usersid);
1807 lstrcatA(keypath, "\\Components\\");
1808 lstrcatA(keypath, comp_squashed2);
1810 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
1811 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1813 SetLastError(0xdeadbeef);
1814 state = MsiQueryFeatureStateA(prodcode, "feature");
1815 error = GetLastError();
1816 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1817 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1819 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
1820 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1822 SetLastError(0xdeadbeef);
1823 state = MsiQueryFeatureStateA(prodcode, "feature");
1824 error = GetLastError();
1825 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1826 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1828 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
1829 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1831 SetLastError(0xdeadbeef);
1832 state = MsiQueryFeatureStateA(prodcode, "feature");
1833 error = GetLastError();
1834 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1835 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1837 res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
1838 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1840 /* INSTALLSTATE_LOCAL */
1841 SetLastError(0xdeadbeef);
1842 state = MsiQueryFeatureStateA(prodcode, "feature");
1843 error = GetLastError();
1844 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1845 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1847 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
1848 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1850 /* INSTALLSTATE_SOURCE */
1851 SetLastError(0xdeadbeef);
1852 state = MsiQueryFeatureStateA(prodcode, "feature");
1853 error = GetLastError();
1854 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
1855 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1857 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
1858 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1860 /* bad INSTALLSTATE_SOURCE */
1861 SetLastError(0xdeadbeef);
1862 state = MsiQueryFeatureStateA(prodcode, "feature");
1863 error = GetLastError();
1864 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1865 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1867 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
1868 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1870 /* INSTALLSTATE_SOURCE */
1871 SetLastError(0xdeadbeef);
1872 state = MsiQueryFeatureStateA(prodcode, "feature");
1873 error = GetLastError();
1874 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
1875 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1877 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
1878 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1880 /* bad INSTALLSTATE_SOURCE */
1881 SetLastError(0xdeadbeef);
1882 state = MsiQueryFeatureStateA(prodcode, "feature");
1883 error = GetLastError();
1884 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1885 ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
1887 RegDeleteValueA(compkey, prod_squashed);
1888 RegDeleteValueA(compkey2, prod_squashed);
1889 delete_key(compkey, "", access & KEY_WOW64_64KEY);
1890 delete_key(compkey2, "", access & KEY_WOW64_64KEY);
1891 RegDeleteValueA(localkey, "feature");
1892 RegDeleteValueA(userkey, "feature");
1893 RegDeleteKeyA(userkey, "");
1894 RegCloseKey(compkey);
1895 RegCloseKey(compkey2);
1896 RegCloseKey(localkey);
1897 RegCloseKey(userkey);
1899 /* MSIINSTALLCONTEXT_USERMANAGED */
1901 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
1902 lstrcatA(keypath, usersid);
1903 lstrcatA(keypath, "\\Installer\\Features\\");
1904 lstrcatA(keypath, prod_squashed);
1906 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
1907 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1909 /* feature key exists */
1910 state = MsiQueryFeatureStateA(prodcode, "feature");
1911 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1913 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 1);
1914 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1916 /* feature value exists */
1917 state = MsiQueryFeatureStateA(prodcode, "feature");
1918 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1920 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1921 lstrcatA(keypath, usersid);
1922 lstrcatA(keypath, "\\Products\\");
1923 lstrcatA(keypath, prod_squashed);
1924 lstrcatA(keypath, "\\Features");
1926 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
1927 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1929 /* userdata features key exists */
1930 state = MsiQueryFeatureStateA(prodcode, "feature");
1931 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1933 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
1934 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1936 state = MsiQueryFeatureStateA(prodcode, "feature");
1937 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
1939 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
1940 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1942 state = MsiQueryFeatureStateA(prodcode, "feature");
1943 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1945 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
1946 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1948 state = MsiQueryFeatureStateA(prodcode, "feature");
1949 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1951 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
1952 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1954 state = MsiQueryFeatureStateA(prodcode, "feature");
1955 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1957 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1958 lstrcatA(keypath, usersid);
1959 lstrcatA(keypath, "\\Components\\");
1960 lstrcatA(keypath, comp_squashed);
1962 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
1963 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1965 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
1966 lstrcatA(keypath, usersid);
1967 lstrcatA(keypath, "\\Components\\");
1968 lstrcatA(keypath, comp_squashed2);
1970 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
1971 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1973 state = MsiQueryFeatureStateA(prodcode, "feature");
1974 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1976 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
1977 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1979 state = MsiQueryFeatureStateA(prodcode, "feature");
1980 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1982 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
1983 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1985 state = MsiQueryFeatureStateA(prodcode, "feature");
1986 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1988 res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
1989 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1991 state = MsiQueryFeatureStateA(prodcode, "feature");
1992 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1994 RegDeleteValueA(compkey, prod_squashed);
1995 RegDeleteValueA(compkey2, prod_squashed);
1996 delete_key(compkey, "", access & KEY_WOW64_64KEY);
1997 delete_key(compkey2, "", access & KEY_WOW64_64KEY);
1998 RegDeleteValueA(localkey, "feature");
1999 RegDeleteValueA(userkey, "feature");
2000 delete_key(userkey, "", access & KEY_WOW64_64KEY);
2001 RegCloseKey(compkey);
2002 RegCloseKey(compkey2);
2003 RegCloseKey(localkey);
2004 RegCloseKey(userkey);
2006 /* MSIINSTALLCONTEXT_MACHINE */
2008 lstrcpyA(keypath, "Software\\Classes\\Installer\\Features\\");
2009 lstrcatA(keypath, prod_squashed);
2011 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
2012 if (res == ERROR_ACCESS_DENIED)
2014 skip( "insufficient rights\n" );
2015 LocalFree( usersid );
2016 return;
2018 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2020 /* feature key exists */
2021 state = MsiQueryFeatureStateA(prodcode, "feature");
2022 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2024 res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 1);
2025 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2027 /* feature value exists */
2028 state = MsiQueryFeatureStateA(prodcode, "feature");
2029 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2031 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2032 lstrcatA(keypath, "S-1-5-18\\Products\\");
2033 lstrcatA(keypath, prod_squashed);
2034 lstrcatA(keypath, "\\Features");
2036 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
2037 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2039 /* userdata features key exists */
2040 state = MsiQueryFeatureStateA(prodcode, "feature");
2041 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2043 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
2044 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2046 state = MsiQueryFeatureStateA(prodcode, "feature");
2047 ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
2049 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
2050 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2052 state = MsiQueryFeatureStateA(prodcode, "feature");
2053 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2055 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
2056 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2058 state = MsiQueryFeatureStateA(prodcode, "feature");
2059 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2061 res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
2062 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2064 state = MsiQueryFeatureStateA(prodcode, "feature");
2065 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2067 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2068 lstrcatA(keypath, "S-1-5-18\\Components\\");
2069 lstrcatA(keypath, comp_squashed);
2071 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2072 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2074 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2075 lstrcatA(keypath, "S-1-5-18\\Components\\");
2076 lstrcatA(keypath, comp_squashed2);
2078 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
2079 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2081 state = MsiQueryFeatureStateA(prodcode, "feature");
2082 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2084 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
2085 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2087 state = MsiQueryFeatureStateA(prodcode, "feature");
2088 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2090 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
2091 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2093 state = MsiQueryFeatureStateA(prodcode, "feature");
2094 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2096 res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
2097 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2099 state = MsiQueryFeatureStateA(prodcode, "feature");
2100 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2102 RegDeleteValueA(compkey, prod_squashed);
2103 RegDeleteValueA(compkey2, prod_squashed);
2104 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2105 delete_key(compkey2, "", access & KEY_WOW64_64KEY);
2106 RegDeleteValueA(localkey, "feature");
2107 RegDeleteValueA(userkey, "feature");
2108 delete_key(userkey, "", access & KEY_WOW64_64KEY);
2109 RegCloseKey(compkey);
2110 RegCloseKey(compkey2);
2111 RegCloseKey(localkey);
2112 RegCloseKey(userkey);
2113 LocalFree(usersid);
2116 static void test_MsiQueryComponentState(void)
2118 HKEY compkey, prodkey;
2119 CHAR prodcode[MAX_PATH];
2120 CHAR prod_squashed[MAX_PATH];
2121 CHAR component[MAX_PATH];
2122 CHAR comp_base85[MAX_PATH];
2123 CHAR comp_squashed[MAX_PATH];
2124 CHAR keypath[MAX_PATH];
2125 INSTALLSTATE state;
2126 LPSTR usersid;
2127 LONG res;
2128 UINT r;
2129 REGSAM access = KEY_ALL_ACCESS;
2130 DWORD error;
2132 static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef;
2134 if (!pMsiQueryComponentStateA)
2136 win_skip("MsiQueryComponentStateA not implemented\n");
2137 return;
2140 create_test_guid(prodcode, prod_squashed);
2141 compose_base85_guid(component, comp_base85, comp_squashed);
2142 usersid = get_user_sid();
2144 if (is_wow64)
2145 access |= KEY_WOW64_64KEY;
2147 /* NULL szProductCode */
2148 state = MAGIC_ERROR;
2149 SetLastError(0xdeadbeef);
2150 r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2151 error = GetLastError();
2152 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2153 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2154 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2156 /* empty szProductCode */
2157 state = MAGIC_ERROR;
2158 SetLastError(0xdeadbeef);
2159 r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2160 error = GetLastError();
2161 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2162 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2163 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2165 /* random szProductCode */
2166 state = MAGIC_ERROR;
2167 SetLastError(0xdeadbeef);
2168 r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2169 error = GetLastError();
2170 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2171 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2172 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2174 /* GUID-length szProductCode */
2175 state = MAGIC_ERROR;
2176 SetLastError(0xdeadbeef);
2177 r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2178 error = GetLastError();
2179 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2180 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2181 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2183 /* GUID-length with brackets */
2184 state = MAGIC_ERROR;
2185 SetLastError(0xdeadbeef);
2186 r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2187 error = GetLastError();
2188 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2189 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2190 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2192 /* actual GUID */
2193 state = MAGIC_ERROR;
2194 SetLastError(0xdeadbeef);
2195 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2196 error = GetLastError();
2197 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2198 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2199 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2201 state = MAGIC_ERROR;
2202 SetLastError(0xdeadbeef);
2203 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2204 error = GetLastError();
2205 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2206 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2207 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2209 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2210 lstrcatA(keypath, prod_squashed);
2212 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2213 if (res == ERROR_ACCESS_DENIED)
2215 skip("Not enough rights to perform tests\n");
2216 LocalFree(usersid);
2217 return;
2219 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2221 state = MAGIC_ERROR;
2222 SetLastError(0xdeadbeef);
2223 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2224 error = GetLastError();
2225 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2226 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2227 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2229 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2230 RegCloseKey(prodkey);
2232 /* create local system product key */
2233 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
2234 lstrcatA(keypath, prod_squashed);
2235 lstrcatA(keypath, "\\InstallProperties");
2237 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2238 if (res == ERROR_ACCESS_DENIED)
2240 skip("Not enough rights to perform tests\n");
2241 LocalFree(usersid);
2242 return;
2244 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2246 /* local system product key exists */
2247 state = MAGIC_ERROR;
2248 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2249 error = GetLastError();
2250 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2251 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2252 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2254 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
2255 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2257 /* LocalPackage value exists */
2258 state = MAGIC_ERROR;
2259 SetLastError(0xdeadbeef);
2260 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2261 error = GetLastError();
2262 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2263 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2264 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2266 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
2267 lstrcatA(keypath, comp_squashed);
2269 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2270 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2272 /* component key exists */
2273 state = MAGIC_ERROR;
2274 SetLastError(0xdeadbeef);
2275 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2276 error = GetLastError();
2277 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2278 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2279 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2281 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
2282 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2284 /* component\product exists */
2285 state = MAGIC_ERROR;
2286 SetLastError(0xdeadbeef);
2287 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2288 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2289 error = GetLastError();
2290 ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
2291 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
2292 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2294 /* NULL component, product exists */
2295 state = MAGIC_ERROR;
2296 SetLastError(0xdeadbeef);
2297 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &state);
2298 error = GetLastError();
2299 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2300 ok(state == MAGIC_ERROR, "Expected state not changed, got %d\n", state);
2301 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2303 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
2304 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2306 /* INSTALLSTATE_LOCAL */
2307 state = MAGIC_ERROR;
2308 SetLastError(0xdeadbeef);
2309 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2310 error = GetLastError();
2311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2312 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2313 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2315 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
2316 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2318 /* INSTALLSTATE_SOURCE */
2319 state = MAGIC_ERROR;
2320 SetLastError(0xdeadbeef);
2321 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2322 error = GetLastError();
2323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2324 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
2325 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2327 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
2328 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2330 /* bad INSTALLSTATE_SOURCE */
2331 state = MAGIC_ERROR;
2332 SetLastError(0xdeadbeef);
2333 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2334 error = GetLastError();
2335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2336 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2337 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2339 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
2340 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2342 /* INSTALLSTATE_SOURCE */
2343 state = MAGIC_ERROR;
2344 SetLastError(0xdeadbeef);
2345 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2346 error = GetLastError();
2347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2348 ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
2349 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2351 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01:", 4);
2352 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2354 /* registry component */
2355 state = MAGIC_ERROR;
2356 SetLastError(0xdeadbeef);
2357 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
2358 error = GetLastError();
2359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2360 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2361 ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
2363 RegDeleteValueA(prodkey, "LocalPackage");
2364 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2365 RegDeleteValueA(compkey, prod_squashed);
2366 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2367 RegCloseKey(prodkey);
2368 RegCloseKey(compkey);
2370 /* MSIINSTALLCONTEXT_USERUNMANAGED */
2372 state = MAGIC_ERROR;
2373 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2374 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2375 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2377 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2378 lstrcatA(keypath, prod_squashed);
2380 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2381 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2383 state = MAGIC_ERROR;
2384 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2385 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2386 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2388 RegDeleteKeyA(prodkey, "");
2389 RegCloseKey(prodkey);
2391 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2392 lstrcatA(keypath, usersid);
2393 lstrcatA(keypath, "\\Products\\");
2394 lstrcatA(keypath, prod_squashed);
2395 lstrcatA(keypath, "\\InstallProperties");
2397 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2398 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2400 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
2401 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2403 RegCloseKey(prodkey);
2405 state = MAGIC_ERROR;
2406 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2407 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2408 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2410 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2411 lstrcatA(keypath, usersid);
2412 lstrcatA(keypath, "\\Components\\");
2413 lstrcatA(keypath, comp_squashed);
2415 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2416 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2418 /* component key exists */
2419 state = MAGIC_ERROR;
2420 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2421 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2422 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2424 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
2425 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2427 /* component\product exists */
2428 state = MAGIC_ERROR;
2429 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2430 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2431 ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
2432 "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
2434 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
2435 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2437 state = MAGIC_ERROR;
2438 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
2439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2440 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2442 /* MSIINSTALLCONTEXT_USERMANAGED */
2444 state = MAGIC_ERROR;
2445 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2446 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2447 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2449 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2450 lstrcatA(keypath, prod_squashed);
2452 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2453 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2455 state = MAGIC_ERROR;
2456 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2457 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2458 ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
2460 RegDeleteKeyA(prodkey, "");
2461 RegCloseKey(prodkey);
2463 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
2464 lstrcatA(keypath, usersid);
2465 lstrcatA(keypath, "\\Installer\\Products\\");
2466 lstrcatA(keypath, prod_squashed);
2468 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2469 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2471 state = MAGIC_ERROR;
2472 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2473 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2474 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2476 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2477 RegCloseKey(prodkey);
2479 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2480 lstrcatA(keypath, usersid);
2481 lstrcatA(keypath, "\\Products\\");
2482 lstrcatA(keypath, prod_squashed);
2483 lstrcatA(keypath, "\\InstallProperties");
2485 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2486 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2488 res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
2489 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2491 state = MAGIC_ERROR;
2492 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state);
2493 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2494 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2496 RegDeleteValueA(prodkey, "LocalPackage");
2497 RegDeleteValueA(prodkey, "ManagedLocalPackage");
2498 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2499 RegDeleteValueA(compkey, prod_squashed);
2500 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2501 RegCloseKey(prodkey);
2502 RegCloseKey(compkey);
2503 LocalFree(usersid);
2506 static void test_MsiGetComponentPath(void)
2508 HKEY compkey, prodkey, installprop;
2509 CHAR prodcode[MAX_PATH];
2510 CHAR prod_squashed[MAX_PATH];
2511 CHAR component[MAX_PATH];
2512 CHAR comp_base85[MAX_PATH];
2513 CHAR comp_squashed[MAX_PATH];
2514 CHAR keypath[MAX_PATH];
2515 CHAR path[MAX_PATH];
2516 INSTALLSTATE state;
2517 LPSTR usersid;
2518 DWORD size, val;
2519 REGSAM access = KEY_ALL_ACCESS;
2520 LONG res;
2522 create_test_guid(prodcode, prod_squashed);
2523 compose_base85_guid(component, comp_base85, comp_squashed);
2524 usersid = get_user_sid();
2526 if (is_wow64)
2527 access |= KEY_WOW64_64KEY;
2529 /* NULL szProduct */
2530 size = MAX_PATH;
2531 state = MsiGetComponentPathA(NULL, component, path, &size);
2532 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2533 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2535 /* NULL szComponent */
2536 size = MAX_PATH;
2537 state = MsiGetComponentPathA(prodcode, NULL, path, &size);
2538 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2539 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2541 size = MAX_PATH;
2542 state = MsiLocateComponentA(NULL, path, &size);
2543 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2544 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2546 /* NULL lpPathBuf */
2547 size = MAX_PATH;
2548 state = MsiGetComponentPathA(prodcode, component, NULL, &size);
2549 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2550 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2552 size = MAX_PATH;
2553 state = MsiLocateComponentA(component, NULL, &size);
2554 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2555 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2557 /* NULL pcchBuf */
2558 size = MAX_PATH;
2559 state = MsiGetComponentPathA(prodcode, component, path, NULL);
2560 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2561 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2563 size = MAX_PATH;
2564 state = MsiLocateComponentA(component, path, NULL);
2565 ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
2566 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2568 /* all params valid */
2569 size = MAX_PATH;
2570 state = MsiGetComponentPathA(prodcode, component, path, &size);
2571 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2572 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2574 size = MAX_PATH;
2575 state = MsiLocateComponentA(component, path, &size);
2576 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2577 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2579 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2580 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
2581 lstrcatA(keypath, comp_squashed);
2583 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2584 if (res == ERROR_ACCESS_DENIED)
2586 skip("Not enough rights to perform tests\n");
2587 LocalFree(usersid);
2588 return;
2590 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2592 /* local system component key exists */
2593 size = MAX_PATH;
2594 state = MsiGetComponentPathA(prodcode, component, path, &size);
2595 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2596 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2598 size = MAX_PATH;
2599 state = MsiLocateComponentA(component, path, &size);
2600 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2601 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2603 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2604 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2606 /* product value exists */
2607 path[0] = 0;
2608 size = MAX_PATH;
2609 state = MsiGetComponentPathA(prodcode, component, path, &size);
2610 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2611 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2612 ok(size == 10, "Expected 10, got %d\n", size);
2614 path[0] = 0;
2615 size = MAX_PATH;
2616 state = MsiLocateComponentA(component, path, &size);
2617 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2618 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2619 ok(size == 10, "Expected 10, got %d\n", size);
2621 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2622 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
2623 lstrcatA(keypath, prod_squashed);
2624 lstrcatA(keypath, "\\InstallProperties");
2626 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &installprop, NULL);
2627 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2629 val = 1;
2630 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
2631 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2633 /* install properties key exists */
2634 path[0] = 0;
2635 size = MAX_PATH;
2636 state = MsiGetComponentPathA(prodcode, component, path, &size);
2637 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2638 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2639 ok(size == 10, "Expected 10, got %d\n", size);
2641 path[0] = 0;
2642 size = MAX_PATH;
2643 state = MsiLocateComponentA(component, path, &size);
2644 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2645 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2646 ok(size == 10, "Expected 10, got %d\n", size);
2648 create_file("C:\\imapath", 11);
2650 /* file exists */
2651 path[0] = 'a';
2652 size = 0;
2653 state = MsiGetComponentPathA(prodcode, component, path, &size);
2654 ok(state == INSTALLSTATE_MOREDATA, "Expected INSTALLSTATE_MOREDATA, got %d\n", state);
2655 ok(path[0] == 'a', "got %s\n", path);
2656 ok(size == 10, "Expected 10, got %d\n", size);
2658 path[0] = 0;
2659 size = MAX_PATH;
2660 state = MsiGetComponentPathA(prodcode, component, path, &size);
2661 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2662 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2663 ok(size == 10, "Expected 10, got %d\n", size);
2665 size = 0;
2666 path[0] = 'a';
2667 state = MsiLocateComponentA(component, path, &size);
2668 ok(state == INSTALLSTATE_MOREDATA, "Expected INSTALLSTATE_MOREDATA, got %d\n", state);
2669 ok(path[0] == 'a', "got %s\n", path);
2670 ok(size == 10, "Expected 10, got %d\n", size);
2672 path[0] = 0;
2673 size = MAX_PATH;
2674 state = MsiLocateComponentA(component, path, &size);
2675 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2676 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2677 ok(size == 10, "Expected 10, got %d\n", size);
2679 RegDeleteValueA(compkey, prod_squashed);
2680 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2681 RegDeleteValueA(installprop, "WindowsInstaller");
2682 delete_key(installprop, "", access & KEY_WOW64_64KEY);
2683 RegCloseKey(compkey);
2684 RegCloseKey(installprop);
2685 DeleteFileA("C:\\imapath");
2687 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2688 lstrcatA(keypath, "Installer\\UserData\\");
2689 lstrcatA(keypath, usersid);
2690 lstrcatA(keypath, "\\Components\\");
2691 lstrcatA(keypath, comp_squashed);
2693 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2694 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2696 /* user managed component key exists */
2697 size = MAX_PATH;
2698 state = MsiGetComponentPathA(prodcode, component, path, &size);
2699 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2700 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2702 size = MAX_PATH;
2703 state = MsiLocateComponentA(component, path, &size);
2704 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2705 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2707 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2708 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2710 /* product value exists */
2711 path[0] = 0;
2712 size = MAX_PATH;
2713 state = MsiGetComponentPathA(prodcode, component, path, &size);
2714 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2715 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2716 ok(size == 10, "Expected 10, got %d\n", size);
2718 path[0] = 0;
2719 size = MAX_PATH;
2720 state = MsiLocateComponentA(component, path, &size);
2721 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2722 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2723 ok(size == 10, "Expected 10, got %d\n", size);
2725 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2726 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
2727 lstrcatA(keypath, prod_squashed);
2728 lstrcatA(keypath, "\\InstallProperties");
2730 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &installprop, NULL);
2731 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2733 val = 1;
2734 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
2735 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2737 /* install properties key exists */
2738 path[0] = 0;
2739 size = MAX_PATH;
2740 state = MsiGetComponentPathA(prodcode, component, path, &size);
2741 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2742 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2743 ok(size == 10, "Expected 10, got %d\n", size);
2745 path[0] = 0;
2746 size = MAX_PATH;
2747 state = MsiLocateComponentA(component, path, &size);
2748 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2749 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2750 ok(size == 10, "Expected 10, got %d\n", size);
2752 create_file("C:\\imapath", 11);
2754 /* file exists */
2755 path[0] = 0;
2756 size = MAX_PATH;
2757 state = MsiGetComponentPathA(prodcode, component, path, &size);
2758 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2759 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2760 ok(size == 10, "Expected 10, got %d\n", size);
2762 path[0] = 0;
2763 size = MAX_PATH;
2764 state = MsiLocateComponentA(component, path, &size);
2765 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2766 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2767 ok(size == 10, "Expected 10, got %d\n", size);
2769 RegDeleteValueA(compkey, prod_squashed);
2770 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2771 RegDeleteValueA(installprop, "WindowsInstaller");
2772 delete_key(installprop, "", access & KEY_WOW64_64KEY);
2773 RegCloseKey(compkey);
2774 RegCloseKey(installprop);
2775 DeleteFileA("C:\\imapath");
2777 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2778 lstrcatA(keypath, "Installer\\Managed\\");
2779 lstrcatA(keypath, usersid);
2780 lstrcatA(keypath, "\\Installer\\Products\\");
2781 lstrcatA(keypath, prod_squashed);
2783 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2784 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2786 /* user managed product key exists */
2787 size = MAX_PATH;
2788 state = MsiGetComponentPathA(prodcode, component, path, &size);
2789 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2790 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2792 size = MAX_PATH;
2793 state = MsiLocateComponentA(component, path, &size);
2794 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2795 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2797 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2798 lstrcatA(keypath, "Installer\\UserData\\");
2799 lstrcatA(keypath, usersid);
2800 lstrcatA(keypath, "\\Components\\");
2801 lstrcatA(keypath, comp_squashed);
2803 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2804 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2806 /* user managed component key exists */
2807 size = MAX_PATH;
2808 state = MsiGetComponentPathA(prodcode, component, path, &size);
2809 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2810 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2812 size = MAX_PATH;
2813 state = MsiLocateComponentA(component, path, &size);
2814 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2815 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2817 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2818 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2820 /* product value exists */
2821 path[0] = 0;
2822 size = MAX_PATH;
2823 state = MsiGetComponentPathA(prodcode, component, path, &size);
2824 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2825 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2826 ok(size == 10, "Expected 10, got %d\n", size);
2828 path[0] = 0;
2829 size = MAX_PATH;
2830 state = MsiLocateComponentA(component, path, &size);
2831 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2832 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2833 ok(size == 10, "Expected 10, got %d\n", size);
2835 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2836 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
2837 lstrcatA(keypath, prod_squashed);
2838 lstrcatA(keypath, "\\InstallProperties");
2840 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &installprop, NULL);
2841 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2843 val = 1;
2844 res = RegSetValueExA(installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
2845 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2847 /* install properties key exists */
2848 path[0] = 0;
2849 size = MAX_PATH;
2850 state = MsiGetComponentPathA(prodcode, component, path, &size);
2851 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2852 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2853 ok(size == 10, "Expected 10, got %d\n", size);
2855 path[0] = 0;
2856 size = MAX_PATH;
2857 state = MsiLocateComponentA(component, path, &size);
2858 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2859 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2860 ok(size == 10, "Expected 10, got %d\n", size);
2862 create_file("C:\\imapath", 11);
2864 /* file exists */
2865 path[0] = 0;
2866 size = MAX_PATH;
2867 state = MsiGetComponentPathA(prodcode, component, path, &size);
2868 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2869 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2870 ok(size == 10, "Expected 10, got %d\n", size);
2872 path[0] = 0;
2873 size = MAX_PATH;
2874 state = MsiLocateComponentA(component, path, &size);
2875 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2876 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2877 ok(size == 10, "Expected 10, got %d\n", size);
2879 RegDeleteValueA(compkey, prod_squashed);
2880 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
2881 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2882 RegDeleteValueA(installprop, "WindowsInstaller");
2883 delete_key(installprop, "", access & KEY_WOW64_64KEY);
2884 RegCloseKey(prodkey);
2885 RegCloseKey(compkey);
2886 RegCloseKey(installprop);
2887 DeleteFileA("C:\\imapath");
2889 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
2890 lstrcatA(keypath, prod_squashed);
2892 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
2893 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2895 /* user unmanaged product key exists */
2896 size = MAX_PATH;
2897 state = MsiGetComponentPathA(prodcode, component, path, &size);
2898 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2899 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2901 size = MAX_PATH;
2902 state = MsiLocateComponentA(component, path, &size);
2903 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2904 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2906 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2907 lstrcatA(keypath, "Installer\\UserData\\");
2908 lstrcatA(keypath, usersid);
2909 lstrcatA(keypath, "\\Components\\");
2910 lstrcatA(keypath, comp_squashed);
2912 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2913 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2915 /* user unmanaged component key exists */
2916 size = MAX_PATH;
2917 state = MsiGetComponentPathA(prodcode, component, path, &size);
2918 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2919 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2921 size = MAX_PATH;
2922 state = MsiLocateComponentA(component, path, &size);
2923 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2924 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2926 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
2927 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2929 /* product value exists */
2930 path[0] = 0;
2931 size = MAX_PATH;
2932 state = MsiGetComponentPathA(prodcode, component, path, &size);
2933 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2934 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2935 ok(size == 10, "Expected 10, got %d\n", size);
2937 path[0] = 0;
2938 size = MAX_PATH;
2939 state = MsiLocateComponentA(component, path, &size);
2940 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2941 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2942 ok(size == 10, "Expected 10, got %d\n", size);
2944 create_file("C:\\imapath", 11);
2946 /* file exists */
2947 path[0] = 0;
2948 size = MAX_PATH;
2949 state = MsiGetComponentPathA(prodcode, component, path, &size);
2950 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2951 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2952 ok(size == 10, "Expected 10, got %d\n", size);
2954 path[0] = 0;
2955 size = MAX_PATH;
2956 state = MsiLocateComponentA(component, path, &size);
2957 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2958 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
2959 ok(size == 10, "Expected 10, got %d\n", size);
2961 RegDeleteValueA(compkey, prod_squashed);
2962 RegDeleteKeyA(prodkey, "");
2963 delete_key(compkey, "", access & KEY_WOW64_64KEY);
2964 RegCloseKey(prodkey);
2965 RegCloseKey(compkey);
2966 DeleteFileA("C:\\imapath");
2968 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
2969 lstrcatA(keypath, prod_squashed);
2971 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
2972 if (res == ERROR_ACCESS_DENIED)
2974 skip( "insufficient rights\n" );
2975 LocalFree( usersid );
2976 return;
2978 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2980 /* local classes product key exists */
2981 size = MAX_PATH;
2982 state = MsiGetComponentPathA(prodcode, component, path, &size);
2983 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2984 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2986 size = MAX_PATH;
2987 state = MsiLocateComponentA(component, path, &size);
2988 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2989 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
2991 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
2992 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
2993 lstrcatA(keypath, comp_squashed);
2995 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
2996 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2998 /* local user component key exists */
2999 size = MAX_PATH;
3000 state = MsiGetComponentPathA(prodcode, component, path, &size);
3001 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3002 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3004 size = MAX_PATH;
3005 state = MsiLocateComponentA(component, path, &size);
3006 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3007 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
3009 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3010 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3012 /* product value exists */
3013 path[0] = 0;
3014 size = MAX_PATH;
3015 state = MsiGetComponentPathA(prodcode, component, path, &size);
3016 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3017 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3018 ok(size == 10, "Expected 10, got %d\n", size);
3020 path[0] = 0;
3021 size = MAX_PATH;
3022 state = MsiLocateComponentA(component, path, &size);
3023 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
3024 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3025 ok(size == 10, "Expected 10, got %d\n", size);
3027 create_file("C:\\imapath", 11);
3029 /* file exists */
3030 path[0] = 0;
3031 size = MAX_PATH;
3032 state = MsiGetComponentPathA(prodcode, component, path, &size);
3033 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3034 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3035 ok(size == 10, "Expected 10, got %d\n", size);
3037 path[0] = 0;
3038 size = MAX_PATH;
3039 state = MsiLocateComponentA(component, path, &size);
3040 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3041 ok(!lstrcmpA(path, "C:\\imapath"), "Expected C:\\imapath, got %s\n", path);
3042 ok(size == 10, "Expected 10, got %d\n", size);
3044 RegDeleteValueA(compkey, prod_squashed);
3045 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3046 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3047 RegCloseKey(prodkey);
3048 RegCloseKey(compkey);
3049 DeleteFileA("C:\\imapath");
3050 LocalFree(usersid);
3053 static void test_MsiGetComponentPathEx(void)
3055 HKEY key_comp, key_installprop, key_prod;
3056 char prod[MAX_PATH], prod_squashed[MAX_PATH];
3057 char comp[MAX_PATH], comp_base85[MAX_PATH], comp_squashed[MAX_PATH];
3058 char path[MAX_PATH], path_key[MAX_PATH], *usersid;
3059 INSTALLSTATE state;
3060 DWORD size, val;
3061 REGSAM access = KEY_ALL_ACCESS;
3062 LONG res;
3064 if (!pMsiGetComponentPathExA)
3066 win_skip( "MsiGetComponentPathExA not present\n" );
3067 return;
3070 if (is_wow64) access |= KEY_WOW64_64KEY;
3072 create_test_guid( prod, prod_squashed );
3073 compose_base85_guid( comp, comp_base85, comp_squashed );
3074 usersid = get_user_sid();
3076 /* NULL product */
3077 size = MAX_PATH;
3078 state = pMsiGetComponentPathExA( NULL, comp, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3079 ok( state == INSTALLSTATE_INVALIDARG, "got %d\n", state );
3080 todo_wine ok( !size, "got %u\n", size );
3082 /* NULL component */
3083 size = MAX_PATH;
3084 state = pMsiGetComponentPathExA( prod, NULL, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3085 ok( state == INSTALLSTATE_INVALIDARG, "got %d\n", state );
3086 todo_wine ok( !size, "got %u\n", size );
3088 /* non-NULL usersid, MSIINSTALLCONTEXT_MACHINE */
3089 size = MAX_PATH;
3090 state = pMsiGetComponentPathExA( prod, comp, usersid, MSIINSTALLCONTEXT_MACHINE, path, &size);
3091 ok( state == INSTALLSTATE_INVALIDARG, "got %d\n", state );
3092 todo_wine ok( !size, "got %u\n", size );
3094 /* NULL buf */
3095 size = MAX_PATH;
3096 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &size );
3097 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3098 todo_wine ok( size == MAX_PATH * 2, "got %u\n", size );
3100 /* NULL buflen */
3101 size = MAX_PATH;
3102 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, NULL );
3103 ok( state == INSTALLSTATE_INVALIDARG, "got %d\n", state );
3104 ok( size == MAX_PATH, "got %u\n", size );
3106 /* all params valid */
3107 size = MAX_PATH;
3108 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3109 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3110 todo_wine ok( !size, "got %u\n", size );
3112 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3113 lstrcatA( path_key, "Installer\\UserData\\S-1-5-18\\Components\\" );
3114 lstrcatA( path_key, comp_squashed );
3116 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_comp, NULL );
3117 if (res == ERROR_ACCESS_DENIED)
3119 skip( "insufficient rights\n" );
3120 LocalFree( usersid );
3121 return;
3123 ok( res == ERROR_SUCCESS, "got %d\n", res );
3125 /* local system component key exists */
3126 size = MAX_PATH;
3127 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3128 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3130 res = RegSetValueExA( key_comp, prod_squashed, 0, REG_SZ, (const BYTE *)"c:\\testcomponentpath", 20 );
3131 ok( res == ERROR_SUCCESS, "got %d\n", res );
3133 /* product value exists */
3134 path[0] = 0;
3135 size = MAX_PATH;
3136 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3137 ok( state == INSTALLSTATE_ABSENT, "got %d\n", state );
3138 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3139 ok( size == 20, "got %u\n", size );
3141 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3142 lstrcatA( path_key, "Installer\\UserData\\S-1-5-18\\Products\\" );
3143 lstrcatA( path_key, prod_squashed );
3144 lstrcatA( path_key, "\\InstallProperties" );
3146 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_installprop, NULL );
3147 ok( res == ERROR_SUCCESS, "got %d\n", res );
3149 val = 1;
3150 res = RegSetValueExA( key_installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(val) );
3151 ok( res == ERROR_SUCCESS, "got %d\n", res );
3153 /* install properties key exists */
3154 path[0] = 0;
3155 size = MAX_PATH;
3156 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3157 ok( state == INSTALLSTATE_ABSENT, "got %d\n", state );
3158 ok( !lstrcmpA( path, "c:\\testcomponentpath"), "got %s\n", path );
3159 ok( size == 20, "got %u\n", size );
3161 create_file( "c:\\testcomponentpath", 21 );
3163 /* file exists */
3164 path[0] = 0;
3165 size = 0;
3166 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3167 ok( state == INSTALLSTATE_MOREDATA, "got %d\n", state );
3168 ok( !path[0], "got %s\n", path );
3169 todo_wine ok( size == 40, "got %u\n", size );
3171 path[0] = 0;
3172 size = MAX_PATH;
3173 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3174 ok( state == INSTALLSTATE_LOCAL, "got %d\n", state );
3175 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3176 ok( size == 20, "got %d\n", size );
3178 RegDeleteValueA( key_comp, prod_squashed );
3179 delete_key( key_comp, "", access & KEY_WOW64_64KEY );
3180 RegDeleteValueA( key_installprop, "WindowsInstaller" );
3181 delete_key( key_installprop, "", access & KEY_WOW64_64KEY );
3182 RegCloseKey( key_comp );
3183 RegCloseKey( key_installprop );
3184 DeleteFileA( "c:\\testcomponentpath" );
3186 lstrcpyA( path_key, "Software\\Microsoft\\Installer\\Products\\" );
3187 lstrcatA( path_key, prod_squashed );
3189 res = RegCreateKeyA( HKEY_CURRENT_USER, path_key, &key_prod );
3190 ok( res == ERROR_SUCCESS, "got %d\n", res );
3192 /* user unmanaged product key exists */
3193 size = MAX_PATH;
3194 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, path, &size );
3195 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3196 todo_wine ok(!size, "got %u\n", size);
3198 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3199 lstrcatA( path_key, "Installer\\UserData\\" );
3200 lstrcatA( path_key, usersid );
3201 lstrcatA( path_key, "\\Components\\" );
3202 lstrcatA( path_key, comp_squashed );
3204 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_comp, NULL );
3205 ok( res == ERROR_SUCCESS, "got %d\n", res );
3207 /* user unmanaged component key exists */
3208 size = MAX_PATH;
3209 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, path, &size );
3210 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3211 todo_wine ok(!size, "got %u\n", size);
3213 res = RegSetValueExA( key_comp, prod_squashed, 0, REG_SZ, (const BYTE *)"c:\\testcomponentpath", 20 );
3214 ok( res == ERROR_SUCCESS, "got %d\n", res );
3216 /* product value exists */
3217 path[0] = 0;
3218 size = MAX_PATH;
3219 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, path, &size );
3220 ok( state == INSTALLSTATE_ABSENT, "got %d\n", state );
3221 ok( !lstrcmpA( path, "c:\\testcomponentpath"), "got %s\n", path );
3222 ok( size == 20, "got %u\n", size );
3224 create_file( "c:\\testcomponentpath", 21 );
3226 /* file exists */
3227 path[0] = 0;
3228 size = MAX_PATH;
3229 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, path, &size );
3230 ok( state == INSTALLSTATE_LOCAL, "got %d\n", state );
3231 ok( !lstrcmpA( path, "c:\\testcomponentpath"), "got %s\n", path );
3232 ok( size == 20, "got %u\n", size );
3234 RegDeleteValueA( key_comp, prod_squashed );
3235 RegDeleteKeyA( key_prod, "" );
3236 delete_key( key_comp, "", access & KEY_WOW64_64KEY );
3237 RegCloseKey( key_prod );
3238 RegCloseKey( key_comp );
3239 DeleteFileA( "c:\\testcomponentpath" );
3241 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3242 lstrcatA( path_key, "Installer\\Managed\\" );
3243 lstrcatA( path_key, usersid );
3244 lstrcatA( path_key, "\\Installer\\Products\\" );
3245 lstrcatA( path_key, prod_squashed );
3247 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_prod, NULL );
3248 ok( res == ERROR_SUCCESS, "got %d\n", res );
3250 /* user managed product key exists */
3251 size = MAX_PATH;
3252 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3253 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3255 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3256 lstrcatA( path_key, "Installer\\UserData\\" );
3257 lstrcatA( path_key, usersid );
3258 lstrcatA( path_key, "\\Components\\" );
3259 lstrcatA( path_key, comp_squashed );
3261 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_comp, NULL );
3262 ok( res == ERROR_SUCCESS, "got %d\n", res );
3264 /* user managed component key exists */
3265 size = MAX_PATH;
3266 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3267 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3269 res = RegSetValueExA( key_comp, prod_squashed, 0, REG_SZ, (const BYTE *)"c:\\testcomponentpath", 20 );
3270 ok( res == ERROR_SUCCESS, "got %d\n", res );
3272 /* product value exists */
3273 path[0] = 0;
3274 size = MAX_PATH;
3275 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3276 ok( state == INSTALLSTATE_ABSENT, "got %d\n", state );
3277 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3278 ok( size == 20, "got %u\n", size );
3280 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3281 lstrcatA( path_key, "Installer\\UserData\\S-1-5-18\\Products\\" );
3282 lstrcatA( path_key, prod_squashed );
3283 lstrcatA( path_key, "\\InstallProperties" );
3285 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_installprop, NULL );
3286 ok( res == ERROR_SUCCESS, "got %d\n", res );
3288 val = 1;
3289 res = RegSetValueExA( key_installprop, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&val, sizeof(val) );
3290 ok( res == ERROR_SUCCESS, "got %d\n", res );
3292 /* install properties key exists */
3293 path[0] = 0;
3294 size = MAX_PATH;
3295 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3296 ok( state == INSTALLSTATE_ABSENT, "got %d\n", state );
3297 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3298 ok( size == 20, "got %u\n", size );
3300 create_file( "c:\\testcomponentpath", 21 );
3302 /* file exists */
3303 path[0] = 0;
3304 size = MAX_PATH;
3305 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_USERMANAGED, path, &size );
3306 ok( state == INSTALLSTATE_LOCAL, "got %d\n", state );
3307 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3308 ok( size == 20, "got %u\n", size );
3310 RegDeleteValueA( key_comp, prod_squashed );
3311 delete_key( key_prod, "", access & KEY_WOW64_64KEY );
3312 delete_key( key_comp, "", access & KEY_WOW64_64KEY );
3313 RegDeleteValueA( key_installprop, "WindowsInstaller" );
3314 delete_key( key_installprop, "", access & KEY_WOW64_64KEY );
3315 RegCloseKey( key_prod );
3316 RegCloseKey( key_comp );
3317 RegCloseKey( key_installprop );
3318 DeleteFileA( "c:\\testcomponentpath" );
3319 lstrcpyA( path_key, "Software\\Classes\\Installer\\Products\\" );
3320 lstrcatA( path_key, prod_squashed );
3322 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_prod, NULL );
3323 if (res == ERROR_ACCESS_DENIED)
3325 skip( "insufficient rights\n" );
3326 LocalFree( usersid );
3327 return;
3329 ok( res == ERROR_SUCCESS, "got %d\n", res );
3331 /* local classes product key exists */
3332 size = MAX_PATH;
3333 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3334 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3335 todo_wine ok(!size, "got %u\n", size);
3337 lstrcpyA( path_key, "Software\\Microsoft\\Windows\\CurrentVersion\\" );
3338 lstrcatA( path_key, "Installer\\UserData\\S-1-5-18\\Components\\" );
3339 lstrcatA( path_key, comp_squashed );
3341 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, path_key, 0, NULL, 0, access, NULL, &key_comp, NULL );
3342 ok( res == ERROR_SUCCESS, "got %d\n", res );
3344 /* local user component key exists */
3345 size = MAX_PATH;
3346 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3347 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3348 todo_wine ok(!size, "got %u\n", size);
3350 res = RegSetValueExA( key_comp, prod_squashed, 0, REG_SZ, (const BYTE *)"c:\\testcomponentpath", 20 );
3351 ok( res == ERROR_SUCCESS, "got %d\n", res );
3353 /* product value exists */
3354 path[0] = 0;
3355 size = MAX_PATH;
3356 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3357 ok( state == INSTALLSTATE_ABSENT, "got %d\n", state );
3358 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3359 ok( size == 20, "got %u\n", size );
3361 create_file( "c:\\testcomponentpath", 21 );
3363 /* file exists */
3364 path[0] = 0;
3365 size = MAX_PATH;
3366 state = pMsiGetComponentPathExA( prod, comp, NULL, MSIINSTALLCONTEXT_MACHINE, path, &size );
3367 ok( state == INSTALLSTATE_LOCAL, "got %d\n", state );
3368 ok( !lstrcmpA( path, "c:\\testcomponentpath" ), "got %s\n", path );
3369 ok( size == 20, "got %u\n", size );
3371 RegDeleteValueA( key_comp, prod_squashed );
3372 delete_key( key_prod, "", access & KEY_WOW64_64KEY );
3373 delete_key( key_comp, "", access & KEY_WOW64_64KEY );
3374 RegCloseKey( key_prod );
3375 RegCloseKey( key_comp );
3376 DeleteFileA( "c:\\testcomponentpath" );
3377 LocalFree( usersid );
3380 static void test_MsiProvideComponent(void)
3382 INSTALLSTATE state;
3383 char buf[0x100];
3384 WCHAR bufW[0x100];
3385 DWORD len, len2;
3386 UINT r;
3388 if (is_process_limited())
3390 skip("process is limited\n");
3391 return;
3394 create_test_files();
3395 create_file("msitest\\sourcedir.txt", 1000);
3396 create_database(msifile, sd_tables, ARRAY_SIZE(sd_tables));
3398 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3400 buf[0] = 0;
3401 len = sizeof(buf);
3402 r = pMsiProvideComponentA("{90120000-0070-0000-0000-4000000FF1CE}",
3403 "{17961602-C4E2-482E-800A-DF6E627549CF}",
3404 "ProductFiles", INSTALLMODE_NODETECTION, buf, &len);
3405 ok(r == ERROR_INVALID_PARAMETER, "got %u\n", r);
3407 r = MsiInstallProductA(msifile, NULL);
3408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3410 state = MsiQueryFeatureStateA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir");
3411 ok(state == INSTALLSTATE_LOCAL, "got %d\n", state);
3413 buf[0] = 0;
3414 len = sizeof(buf);
3415 r = pMsiProvideComponentA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir",
3416 "{DD422F92-3ED8-49B5-A0B7-F266F98357DF}",
3417 INSTALLMODE_NODETECTION, buf, &len);
3418 ok(r == ERROR_SUCCESS, "got %u\n", r);
3419 ok(buf[0], "empty path\n");
3420 ok(len == lstrlenA(buf), "got %u\n", len);
3422 len2 = 0;
3423 r = pMsiProvideComponentA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir",
3424 "{DD422F92-3ED8-49B5-A0B7-F266F98357DF}",
3425 INSTALLMODE_NODETECTION, NULL, &len2);
3426 ok(r == ERROR_SUCCESS, "got %u\n", r);
3427 ok(len2 == len, "got %u\n", len2);
3429 len2 = 0;
3430 r = pMsiProvideComponentA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", "sourcedir",
3431 "{DD422F92-3ED8-49B5-A0B7-F266F98357DF}",
3432 INSTALLMODE_NODETECTION, buf, &len2);
3433 ok(r == ERROR_MORE_DATA, "got %u\n", r);
3434 ok(len2 == len, "got %u\n", len2);
3436 /* wide version */
3438 bufW[0] = 0;
3439 len = sizeof(buf);
3440 r = pMsiProvideComponentW(L"{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", L"sourcedir",
3441 L"{DD422F92-3ED8-49B5-A0B7-F266F98357DF}", INSTALLMODE_NODETECTION, bufW, &len);
3442 ok(r == ERROR_SUCCESS, "got %u\n", r);
3443 ok(bufW[0], "empty path\n");
3444 ok(len == lstrlenW(bufW), "got %u\n", len);
3446 len2 = 0;
3447 r = pMsiProvideComponentW(L"{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", L"sourcedir",
3448 L"{DD422F92-3ED8-49B5-A0B7-F266F98357DF}", INSTALLMODE_NODETECTION, NULL, &len2);
3449 ok(r == ERROR_SUCCESS, "got %u\n", r);
3450 ok(len2 == len, "got %u\n", len2);
3452 len2 = 0;
3453 r = pMsiProvideComponentW(L"{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", L"sourcedir",
3454 L"{DD422F92-3ED8-49B5-A0B7-F266F98357DF}", INSTALLMODE_NODETECTION, bufW, &len2);
3455 ok(r == ERROR_MORE_DATA, "got %u\n", r);
3456 ok(len2 == len, "got %u\n", len2);
3458 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3459 ok(r == ERROR_SUCCESS, "got %u\n", r);
3461 DeleteFileA("msitest\\sourcedir.txt");
3462 delete_test_files();
3463 DeleteFileA(msifile);
3466 static void test_MsiProvideQualifiedComponentEx(void)
3468 UINT r;
3469 INSTALLSTATE state;
3470 char comp[39], comp_squashed[33], comp2[39], comp2_base85[21], comp2_squashed[33];
3471 char prod[39], prod_base85[21], prod_squashed[33];
3472 char desc[MAX_PATH], buf[MAX_PATH], keypath[MAX_PATH], path[MAX_PATH];
3473 DWORD len = sizeof(buf);
3474 REGSAM access = KEY_ALL_ACCESS;
3475 HKEY hkey, hkey2, hkey3, hkey4, hkey5;
3476 LONG res;
3478 if (is_process_limited())
3480 skip( "process is limited\n" );
3481 return;
3484 create_test_guid( comp, comp_squashed );
3485 compose_base85_guid( comp2, comp2_base85, comp2_squashed );
3486 compose_base85_guid( prod, prod_base85, prod_squashed );
3488 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, prod, 0, 0, buf, &len );
3489 ok( r == ERROR_UNKNOWN_COMPONENT, "got %u\n", r );
3491 lstrcpyA( keypath, "Software\\Classes\\Installer\\Components\\" );
3492 lstrcatA( keypath, comp_squashed );
3494 if (is_wow64) access |= KEY_WOW64_64KEY;
3495 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey, NULL );
3496 ok( res == ERROR_SUCCESS, "got %d\n", res );
3498 lstrcpyA( desc, prod_base85 );
3499 memcpy( desc + lstrlenA(desc), "feature<\0", sizeof("feature<\0") );
3500 res = RegSetValueExA( hkey, "qualifier", 0, REG_MULTI_SZ, (const BYTE *)desc,
3501 lstrlenA(prod_base85) + sizeof("feature<\0") );
3502 ok( res == ERROR_SUCCESS, "got %d\n", res );
3504 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, prod, 0, 0, buf, &len );
3505 ok( r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r );
3507 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, NULL, 0, 0, buf, &len );
3508 ok( r == ERROR_UNKNOWN_PRODUCT, "got %u\n", r );
3510 state = MsiQueryProductStateA( prod );
3511 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3513 lstrcpyA( keypath, "Software\\Classes\\Installer\\Products\\" );
3514 lstrcatA( keypath, prod_squashed );
3516 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey2, NULL );
3517 ok( res == ERROR_SUCCESS, "got %d\n", res );
3519 state = MsiQueryProductStateA( prod );
3520 ok( state == INSTALLSTATE_ADVERTISED, "got %d\n", state );
3522 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, prod, 0, 0, buf, &len );
3523 todo_wine ok( r == ERROR_UNKNOWN_FEATURE, "got %u\n", r );
3525 lstrcpyA( keypath, "Software\\Classes\\Installer\\Features\\" );
3526 lstrcatA( keypath, prod_squashed );
3528 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey3, NULL );
3529 ok( res == ERROR_SUCCESS, "got %d\n", res );
3531 state = MsiQueryFeatureStateA( prod, "feature" );
3532 ok( state == INSTALLSTATE_UNKNOWN, "got %d\n", state );
3534 res = RegSetValueExA( hkey3, "feature", 0, REG_SZ, (const BYTE *)"", 1 );
3535 ok( res == ERROR_SUCCESS, "got %d\n", res );
3537 state = MsiQueryFeatureStateA( prod, "feature" );
3538 ok( state == INSTALLSTATE_ADVERTISED, "got %d\n", state );
3540 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, prod, 0, 0, buf, &len );
3541 ok( r == ERROR_FILE_NOT_FOUND, "got %u\n", r );
3543 len = sizeof(buf);
3544 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, NULL, 0, 0, buf, &len );
3545 ok( r == ERROR_FILE_NOT_FOUND, "got %u\n", r );
3547 lstrcpyA( keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\" );
3548 lstrcatA( keypath, prod_squashed );
3549 lstrcatA( keypath, "\\Features" );
3551 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey4, NULL );
3552 ok( res == ERROR_SUCCESS, "got %d\n", res );
3554 res = RegSetValueExA( hkey4, "feature", 0, REG_SZ, (const BYTE *)comp2_base85, sizeof(comp2_base85) );
3555 ok( res == ERROR_SUCCESS, "got %d\n", res );
3557 state = MsiQueryFeatureStateA( prod, "feature" );
3558 ok( state == INSTALLSTATE_ADVERTISED, "got %d\n", state );
3560 lstrcpyA( keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\" );
3561 lstrcatA( keypath, comp2_squashed );
3563 res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey5, NULL );
3564 ok( res == ERROR_SUCCESS, "got %d\n", res );
3566 res = RegSetValueExA( hkey5, prod_squashed, 0, REG_SZ, (const BYTE *)"c:\\nosuchfile", sizeof("c:\\nosuchfile") );
3567 ok( res == ERROR_SUCCESS, "got %d\n", res );
3569 state = MsiQueryFeatureStateA( prod, "feature" );
3570 ok( state == INSTALLSTATE_LOCAL, "got %d\n", state );
3572 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, prod, 0, 0, buf, &len );
3573 ok( r == ERROR_FILE_NOT_FOUND, "got %u\n", r );
3575 GetCurrentDirectoryA( MAX_PATH, path );
3576 lstrcatA( path, "\\msitest" );
3577 CreateDirectoryA( path, NULL );
3578 lstrcatA( path, "\\test.txt" );
3579 create_file_data( path, "test", 100 );
3581 res = RegSetValueExA( hkey5, prod_squashed, 0, REG_SZ, (const BYTE *)path, lstrlenA(path) + 1 );
3582 ok( res == ERROR_SUCCESS, "got %d\n", res );
3584 buf[0] = 0;
3585 len = sizeof(buf);
3586 r = MsiProvideQualifiedComponentExA( comp, "qualifier", INSTALLMODE_EXISTING, prod, 0, 0, buf, &len );
3587 ok( r == ERROR_SUCCESS, "got %u\n", r );
3588 ok( len == lstrlenA(path), "got %u\n", len );
3589 ok( !lstrcmpA( path, buf ), "got '%s'\n", buf );
3591 DeleteFileA( "msitest\\text.txt" );
3592 RemoveDirectoryA( "msitest" );
3594 delete_key( hkey5, "", access & KEY_WOW64_64KEY );
3595 RegCloseKey( hkey5 );
3596 delete_key( hkey4, "", access & KEY_WOW64_64KEY );
3597 RegCloseKey( hkey4 );
3598 delete_key( hkey3, "", access & KEY_WOW64_64KEY );
3599 RegCloseKey( hkey3 );
3600 delete_key( hkey2, "", access & KEY_WOW64_64KEY );
3601 RegCloseKey( hkey2 );
3602 delete_key( hkey, "", access & KEY_WOW64_64KEY );
3603 RegCloseKey( hkey );
3606 static void test_MsiGetProductCode(void)
3608 HKEY compkey, prodkey;
3609 CHAR prodcode[MAX_PATH];
3610 CHAR prod_squashed[MAX_PATH];
3611 CHAR prodcode2[MAX_PATH];
3612 CHAR prod2_squashed[MAX_PATH];
3613 CHAR component[MAX_PATH];
3614 CHAR comp_base85[MAX_PATH];
3615 CHAR comp_squashed[MAX_PATH];
3616 CHAR keypath[MAX_PATH];
3617 CHAR product[MAX_PATH];
3618 LPSTR usersid;
3619 LONG res;
3620 UINT r;
3621 REGSAM access = KEY_ALL_ACCESS;
3623 create_test_guid(prodcode, prod_squashed);
3624 create_test_guid(prodcode2, prod2_squashed);
3625 compose_base85_guid(component, comp_base85, comp_squashed);
3626 usersid = get_user_sid();
3628 if (is_wow64)
3629 access |= KEY_WOW64_64KEY;
3631 /* szComponent is NULL */
3632 lstrcpyA(product, "prod");
3633 r = MsiGetProductCodeA(NULL, product);
3634 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3635 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3637 /* szComponent is empty */
3638 lstrcpyA(product, "prod");
3639 r = MsiGetProductCodeA("", product);
3640 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3641 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3643 /* garbage szComponent */
3644 lstrcpyA(product, "prod");
3645 r = MsiGetProductCodeA("garbage", product);
3646 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3647 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3649 /* guid without brackets */
3650 lstrcpyA(product, "prod");
3651 r = MsiGetProductCodeA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", product);
3652 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3653 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3655 /* guid with brackets */
3656 lstrcpyA(product, "prod");
3657 r = MsiGetProductCodeA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", product);
3658 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3659 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3661 /* same length as guid, but random */
3662 lstrcpyA(product, "prod");
3663 r = MsiGetProductCodeA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", product);
3664 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3665 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3667 /* all params correct, szComponent not published */
3668 lstrcpyA(product, "prod");
3669 r = MsiGetProductCodeA(component, product);
3670 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3671 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3673 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3674 lstrcatA(keypath, "Installer\\UserData\\");
3675 lstrcatA(keypath, usersid);
3676 lstrcatA(keypath, "\\Components\\");
3677 lstrcatA(keypath, comp_squashed);
3679 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3680 if (res == ERROR_ACCESS_DENIED)
3682 skip("Not enough rights to perform tests\n");
3683 LocalFree(usersid);
3684 return;
3686 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3688 /* user unmanaged component key exists */
3689 lstrcpyA(product, "prod");
3690 r = MsiGetProductCodeA(component, product);
3691 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3692 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3694 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3695 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3697 /* product value exists */
3698 lstrcpyA(product, "prod");
3699 r = MsiGetProductCodeA(component, product);
3700 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3701 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3703 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3704 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3706 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3707 lstrcatA(keypath, "Installer\\Managed\\");
3708 lstrcatA(keypath, usersid);
3709 lstrcatA(keypath, "\\Installer\\Products\\");
3710 lstrcatA(keypath, prod_squashed);
3712 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3713 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3715 /* user managed product key of first product exists */
3716 lstrcpyA(product, "prod");
3717 r = MsiGetProductCodeA(component, product);
3718 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3719 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3721 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3722 RegCloseKey(prodkey);
3724 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3725 lstrcatA(keypath, prod_squashed);
3727 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
3728 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3730 /* user unmanaged product key exists */
3731 lstrcpyA(product, "prod");
3732 r = MsiGetProductCodeA(component, product);
3733 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3734 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3736 RegDeleteKeyA(prodkey, "");
3737 RegCloseKey(prodkey);
3739 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3740 lstrcatA(keypath, prod_squashed);
3742 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3743 if (res == ERROR_ACCESS_DENIED)
3745 skip( "insufficient rights\n" );
3746 LocalFree( usersid );
3747 return;
3749 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3751 /* local classes product key exists */
3752 lstrcpyA(product, "prod");
3753 r = MsiGetProductCodeA(component, product);
3754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3755 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3757 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3758 RegCloseKey(prodkey);
3760 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3761 lstrcatA(keypath, "Installer\\Managed\\");
3762 lstrcatA(keypath, usersid);
3763 lstrcatA(keypath, "\\Installer\\Products\\");
3764 lstrcatA(keypath, prod2_squashed);
3766 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3767 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3769 /* user managed product key of second product exists */
3770 lstrcpyA(product, "prod");
3771 r = MsiGetProductCodeA(component, product);
3772 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3773 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
3775 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3776 RegCloseKey(prodkey);
3777 RegDeleteValueA(compkey, prod_squashed);
3778 RegDeleteValueA(compkey, prod2_squashed);
3779 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3780 RegCloseKey(compkey);
3782 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3783 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
3784 lstrcatA(keypath, comp_squashed);
3786 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3787 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3789 /* local user component key exists */
3790 lstrcpyA(product, "prod");
3791 r = MsiGetProductCodeA(component, product);
3792 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3793 ok(!lstrcmpA(product, "prod"), "Expected product to be unchanged, got %s\n", product);
3795 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3796 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3798 /* product value exists */
3799 lstrcpyA(product, "prod");
3800 r = MsiGetProductCodeA(component, product);
3801 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3802 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3804 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3805 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3807 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3808 lstrcatA(keypath, "Installer\\Managed\\");
3809 lstrcatA(keypath, usersid);
3810 lstrcatA(keypath, "\\Installer\\Products\\");
3811 lstrcatA(keypath, prod_squashed);
3813 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3814 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3816 /* user managed product key of first product exists */
3817 lstrcpyA(product, "prod");
3818 r = MsiGetProductCodeA(component, product);
3819 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3820 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3822 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3823 RegCloseKey(prodkey);
3825 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
3826 lstrcatA(keypath, prod_squashed);
3828 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
3829 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3831 /* user unmanaged product key exists */
3832 lstrcpyA(product, "prod");
3833 r = MsiGetProductCodeA(component, product);
3834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3835 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3837 RegDeleteKeyA(prodkey, "");
3838 RegCloseKey(prodkey);
3840 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
3841 lstrcatA(keypath, prod_squashed);
3843 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3844 if (res == ERROR_ACCESS_DENIED)
3846 skip( "insufficient rights\n" );
3847 LocalFree( usersid );
3848 return;
3850 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3852 /* local classes product key exists */
3853 lstrcpyA(product, "prod");
3854 r = MsiGetProductCodeA(component, product);
3855 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3856 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3858 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3859 RegCloseKey(prodkey);
3861 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3862 lstrcatA(keypath, "Installer\\Managed\\");
3863 lstrcatA(keypath, usersid);
3864 lstrcatA(keypath, "\\Installer\\Products\\");
3865 lstrcatA(keypath, prod2_squashed);
3867 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
3868 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3870 /* user managed product key of second product exists */
3871 lstrcpyA(product, "prod");
3872 r = MsiGetProductCodeA(component, product);
3873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3874 ok(!lstrcmpA(product, prodcode2), "Expected %s, got %s\n", prodcode2, product);
3876 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
3877 RegCloseKey(prodkey);
3878 RegDeleteValueA(compkey, prod_squashed);
3879 RegDeleteValueA(compkey, prod2_squashed);
3880 delete_key(compkey, "", access & KEY_WOW64_64KEY);
3881 RegCloseKey(compkey);
3882 LocalFree(usersid);
3885 static void test_MsiEnumClients(void)
3887 HKEY compkey;
3888 CHAR prodcode[MAX_PATH];
3889 CHAR prod_squashed[MAX_PATH];
3890 CHAR prodcode2[MAX_PATH];
3891 CHAR prod2_squashed[MAX_PATH];
3892 CHAR component[MAX_PATH];
3893 CHAR comp_base85[MAX_PATH];
3894 CHAR comp_squashed[MAX_PATH];
3895 CHAR product[MAX_PATH];
3896 CHAR keypath[MAX_PATH];
3897 LPSTR usersid;
3898 LONG res;
3899 UINT r;
3900 REGSAM access = KEY_ALL_ACCESS;
3902 create_test_guid(prodcode, prod_squashed);
3903 create_test_guid(prodcode2, prod2_squashed);
3904 compose_base85_guid(component, comp_base85, comp_squashed);
3905 usersid = get_user_sid();
3907 if (is_wow64)
3908 access |= KEY_WOW64_64KEY;
3910 /* NULL szComponent */
3911 product[0] = '\0';
3912 r = MsiEnumClientsA(NULL, 0, product);
3913 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3914 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3916 /* empty szComponent */
3917 product[0] = '\0';
3918 r = MsiEnumClientsA("", 0, product);
3919 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3920 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3922 /* NULL lpProductBuf */
3923 r = MsiEnumClientsA(component, 0, NULL);
3924 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3926 /* all params correct, component missing */
3927 product[0] = '\0';
3928 r = MsiEnumClientsA(component, 0, product);
3929 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3930 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3932 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
3933 lstrcatA(keypath, "Installer\\UserData\\");
3934 lstrcatA(keypath, usersid);
3935 lstrcatA(keypath, "\\Components\\");
3936 lstrcatA(keypath, comp_squashed);
3938 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
3939 if (res == ERROR_ACCESS_DENIED)
3941 skip("Not enough rights to perform tests\n");
3942 LocalFree(usersid);
3943 return;
3945 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3947 /* user unmanaged component key exists */
3948 product[0] = '\0';
3949 r = MsiEnumClientsA(component, 0, product);
3950 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
3951 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3953 /* index > 0, no products exist */
3954 product[0] = '\0';
3955 r = MsiEnumClientsA(component, 1, product);
3956 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3957 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3959 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
3960 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3962 /* product value exists */
3963 r = MsiEnumClientsA(component, 0, product);
3964 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3965 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3967 /* try index 0 again */
3968 product[0] = '\0';
3969 r = MsiEnumClientsA(component, 0, product);
3970 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3971 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
3973 /* try index 1, second product value does not exist */
3974 product[0] = '\0';
3975 r = MsiEnumClientsA(component, 1, product);
3976 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3977 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3979 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
3980 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3982 /* try index 1, second product value does exist */
3983 product[0] = '\0';
3984 r = MsiEnumClientsA(component, 1, product);
3985 todo_wine
3987 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3988 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
3991 /* start the enumeration over */
3992 product[0] = '\0';
3993 r = MsiEnumClientsA(component, 0, product);
3994 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3995 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
3996 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
3998 /* correctly query second product */
3999 product[0] = '\0';
4000 r = MsiEnumClientsA(component, 1, product);
4001 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4002 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
4003 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
4005 RegDeleteValueA(compkey, prod_squashed);
4006 RegDeleteValueA(compkey, prod2_squashed);
4007 delete_key(compkey, "", access & KEY_WOW64_64KEY);
4008 RegCloseKey(compkey);
4010 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
4011 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Components\\");
4012 lstrcatA(keypath, comp_squashed);
4014 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey, NULL);
4015 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4017 /* user local component key exists */
4018 product[0] = '\0';
4019 r = MsiEnumClientsA(component, 0, product);
4020 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
4021 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
4023 /* index > 0, no products exist */
4024 product[0] = '\0';
4025 r = MsiEnumClientsA(component, 1, product);
4026 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4027 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
4029 res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"C:\\imapath", 10);
4030 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4032 /* product value exists */
4033 product[0] = '\0';
4034 r = MsiEnumClientsA(component, 0, product);
4035 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4036 ok(!lstrcmpA(product, prodcode), "Expected %s, got %s\n", prodcode, product);
4038 /* try index 0 again */
4039 product[0] = '\0';
4040 r = MsiEnumClientsA(component, 0, product);
4041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4043 /* try index 1, second product value does not exist */
4044 product[0] = '\0';
4045 r = MsiEnumClientsA(component, 1, product);
4046 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
4047 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
4049 res = RegSetValueExA(compkey, prod2_squashed, 0, REG_SZ, (const BYTE *)"C:\\another", 10);
4050 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4052 /* try index 1, second product value does exist */
4053 product[0] = '\0';
4054 r = MsiEnumClientsA(component, 1, product);
4055 todo_wine
4057 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4058 ok(!lstrcmpA(product, ""), "Expected product to be unchanged, got %s\n", product);
4061 /* start the enumeration over */
4062 product[0] = '\0';
4063 r = MsiEnumClientsA(component, 0, product);
4064 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4065 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
4066 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
4068 /* correctly query second product */
4069 product[0] = '\0';
4070 r = MsiEnumClientsA(component, 1, product);
4071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4072 ok(!lstrcmpA(product, prodcode) || !lstrcmpA(product, prodcode2),
4073 "Expected %s or %s, got %s\n", prodcode, prodcode2, product);
4075 RegDeleteValueA(compkey, prod_squashed);
4076 RegDeleteValueA(compkey, prod2_squashed);
4077 delete_key(compkey, "", access & KEY_WOW64_64KEY);
4078 RegCloseKey(compkey);
4079 LocalFree(usersid);
4082 static void get_version_info(LPSTR path, LPSTR *vercheck, LPDWORD verchecksz,
4083 LPSTR *langcheck, LPDWORD langchecksz)
4085 LPSTR version;
4086 VS_FIXEDFILEINFO *ffi;
4087 DWORD size = GetFileVersionInfoSizeA(path, NULL);
4088 USHORT *lang;
4090 version = HeapAlloc(GetProcessHeap(), 0, size);
4091 GetFileVersionInfoA(path, 0, size, version);
4093 VerQueryValueA(version, "\\", (LPVOID *)&ffi, &size);
4094 *vercheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
4095 sprintf(*vercheck, "%d.%d.%d.%d", HIWORD(ffi->dwFileVersionMS),
4096 LOWORD(ffi->dwFileVersionMS), HIWORD(ffi->dwFileVersionLS),
4097 LOWORD(ffi->dwFileVersionLS));
4098 *verchecksz = lstrlenA(*vercheck);
4100 VerQueryValueA(version, "\\VarFileInfo\\Translation", (void **)&lang, &size);
4101 *langcheck = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
4102 sprintf(*langcheck, "%d", *lang);
4103 *langchecksz = lstrlenA(*langcheck);
4105 HeapFree(GetProcessHeap(), 0, version);
4108 static void test_MsiGetFileVersion(void)
4110 UINT r;
4111 DWORD versz, langsz;
4112 char version[MAX_PATH];
4113 char lang[MAX_PATH];
4114 char path[MAX_PATH];
4115 LPSTR vercheck, langcheck;
4116 DWORD verchecksz, langchecksz;
4118 /* NULL szFilePath */
4119 r = MsiGetFileVersionA(NULL, NULL, NULL, NULL, NULL);
4120 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4122 versz = MAX_PATH;
4123 langsz = MAX_PATH;
4124 lstrcpyA(version, "version");
4125 lstrcpyA(lang, "lang");
4126 r = MsiGetFileVersionA(NULL, version, &versz, lang, &langsz);
4127 ok(r == ERROR_INVALID_PARAMETER,
4128 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4129 ok(!lstrcmpA(version, "version"),
4130 "Expected version to be unchanged, got %s\n", version);
4131 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4132 ok(!lstrcmpA(lang, "lang"),
4133 "Expected lang to be unchanged, got %s\n", lang);
4134 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4136 /* empty szFilePath */
4137 r = MsiGetFileVersionA("", NULL, NULL, NULL, NULL);
4138 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4140 versz = MAX_PATH;
4141 langsz = MAX_PATH;
4142 lstrcpyA(version, "version");
4143 lstrcpyA(lang, "lang");
4144 r = MsiGetFileVersionA("", version, &versz, lang, &langsz);
4145 ok(r == ERROR_FILE_NOT_FOUND,
4146 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4147 ok(!lstrcmpA(version, "version"),
4148 "Expected version to be unchanged, got %s\n", version);
4149 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4150 ok(!lstrcmpA(lang, "lang"),
4151 "Expected lang to be unchanged, got %s\n", lang);
4152 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4154 /* nonexistent szFilePath */
4155 versz = MAX_PATH;
4156 langsz = MAX_PATH;
4157 lstrcpyA(version, "version");
4158 lstrcpyA(lang, "lang");
4159 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
4160 ok(r == ERROR_FILE_NOT_FOUND,
4161 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4162 ok(!lstrcmpA(version, "version"),
4163 "Expected version to be unchanged, got %s\n", version);
4164 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4165 ok(!lstrcmpA(lang, "lang"),
4166 "Expected lang to be unchanged, got %s\n", lang);
4167 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4169 /* nonexistent szFilePath, valid lpVersionBuf, NULL pcchVersionBuf */
4170 versz = MAX_PATH;
4171 langsz = MAX_PATH;
4172 lstrcpyA(version, "version");
4173 lstrcpyA(lang, "lang");
4174 r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
4175 ok(r == ERROR_INVALID_PARAMETER,
4176 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4177 ok(!lstrcmpA(version, "version"),
4178 "Expected version to be unchanged, got %s\n", version);
4179 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4180 ok(!lstrcmpA(lang, "lang"),
4181 "Expected lang to be unchanged, got %s\n", lang);
4182 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4184 /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
4185 versz = MAX_PATH;
4186 langsz = MAX_PATH;
4187 lstrcpyA(version, "version");
4188 lstrcpyA(lang, "lang");
4189 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
4190 ok(r == ERROR_INVALID_PARAMETER,
4191 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4192 ok(!lstrcmpA(version, "version"),
4193 "Expected version to be unchanged, got %s\n", version);
4194 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4195 ok(!lstrcmpA(lang, "lang"),
4196 "Expected lang to be unchanged, got %s\n", lang);
4197 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4199 /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
4200 versz = 0;
4201 langsz = MAX_PATH;
4202 lstrcpyA(version, "version");
4203 lstrcpyA(lang, "lang");
4204 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
4205 ok(r == ERROR_FILE_NOT_FOUND,
4206 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4207 ok(!lstrcmpA(version, "version"),
4208 "Expected version to be unchanged, got %s\n", version);
4209 ok(versz == 0, "Expected 0, got %d\n", versz);
4210 ok(!lstrcmpA(lang, "lang"),
4211 "Expected lang to be unchanged, got %s\n", lang);
4212 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4214 /* nonexistent szFilePath, valid lpLangBuf, pcchLangBuf is zero */
4215 versz = MAX_PATH;
4216 langsz = 0;
4217 lstrcpyA(version, "version");
4218 lstrcpyA(lang, "lang");
4219 r = MsiGetFileVersionA("nonexistent", version, &versz, lang, &langsz);
4220 ok(r == ERROR_FILE_NOT_FOUND,
4221 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4222 ok(!lstrcmpA(version, "version"),
4223 "Expected version to be unchanged, got %s\n", version);
4224 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4225 ok(!lstrcmpA(lang, "lang"),
4226 "Expected lang to be unchanged, got %s\n", lang);
4227 ok(langsz == 0, "Expected 0, got %d\n", langsz);
4229 /* nonexistent szFilePath, rest NULL */
4230 r = MsiGetFileVersionA("nonexistent", NULL, NULL, NULL, NULL);
4231 ok(r == ERROR_FILE_NOT_FOUND,
4232 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4234 create_file("ver.txt", 20);
4236 /* file exists, no version information */
4237 r = MsiGetFileVersionA("ver.txt", NULL, NULL, NULL, NULL);
4238 ok(r == ERROR_FILE_INVALID, "Expected ERROR_FILE_INVALID, got %d\n", r);
4240 versz = MAX_PATH;
4241 langsz = MAX_PATH;
4242 lstrcpyA(version, "version");
4243 lstrcpyA(lang, "lang");
4244 r = MsiGetFileVersionA("ver.txt", version, &versz, lang, &langsz);
4245 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4246 ok(!lstrcmpA(version, "version"),
4247 "Expected version to be unchanged, got %s\n", version);
4248 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4249 ok(!lstrcmpA(lang, "lang"),
4250 "Expected lang to be unchanged, got %s\n", lang);
4251 ok(r == ERROR_FILE_INVALID,
4252 "Expected ERROR_FILE_INVALID, got %d\n", r);
4254 DeleteFileA("ver.txt");
4256 /* relative path, has version information */
4257 versz = MAX_PATH;
4258 langsz = MAX_PATH;
4259 lstrcpyA(version, "version");
4260 lstrcpyA(lang, "lang");
4261 r = MsiGetFileVersionA("kernel32.dll", version, &versz, lang, &langsz);
4262 todo_wine
4264 ok(r == ERROR_FILE_NOT_FOUND,
4265 "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
4266 ok(!lstrcmpA(version, "version"),
4267 "Expected version to be unchanged, got %s\n", version);
4268 ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
4269 ok(!lstrcmpA(lang, "lang"),
4270 "Expected lang to be unchanged, got %s\n", lang);
4271 ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
4274 GetSystemDirectoryA(path, MAX_PATH);
4275 lstrcatA(path, "\\kernel32.dll");
4277 get_version_info(path, &vercheck, &verchecksz, &langcheck, &langchecksz);
4279 /* absolute path, has version information */
4280 versz = MAX_PATH;
4281 langsz = MAX_PATH;
4282 lstrcpyA(version, "version");
4283 lstrcpyA(lang, "lang");
4284 r = MsiGetFileVersionA(path, version, &versz, lang, &langsz);
4285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4286 if (langchecksz && !langsz)
4288 win_skip("broken MsiGetFileVersionA detected\n");
4289 HeapFree(GetProcessHeap(), 0, vercheck);
4290 HeapFree(GetProcessHeap(), 0, langcheck);
4291 return;
4293 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4294 ok(strstr(lang, langcheck) != NULL, "Expected \"%s\" in \"%s\"\n", langcheck, lang);
4295 ok(!lstrcmpA(version, vercheck),
4296 "Expected %s, got %s\n", vercheck, version);
4298 /* only check version */
4299 versz = MAX_PATH;
4300 lstrcpyA(version, "version");
4301 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
4302 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4303 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4304 ok(!lstrcmpA(version, vercheck),
4305 "Expected %s, got %s\n", vercheck, version);
4307 /* only check language */
4308 langsz = MAX_PATH;
4309 lstrcpyA(lang, "lang");
4310 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
4311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4312 ok(strstr(lang, langcheck) != NULL, "Expected \"%s\" in \"%s\"\n", langcheck, lang);
4314 /* check neither version nor language */
4315 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
4316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4318 /* get pcchVersionBuf */
4319 versz = MAX_PATH;
4320 r = MsiGetFileVersionA(path, NULL, &versz, NULL, NULL);
4321 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4322 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4324 /* get pcchLangBuf */
4325 langsz = MAX_PATH;
4326 r = MsiGetFileVersionA(path, NULL, NULL, NULL, &langsz);
4327 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4328 ok(langsz >= langchecksz, "Expected %d >= %d\n", langsz, langchecksz);
4330 /* pcchVersionBuf not big enough */
4331 versz = 5;
4332 lstrcpyA(version, "version");
4333 r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
4334 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4335 ok(!strncmp(version, vercheck, 4),
4336 "Expected first 4 characters of \"%s\", got \"%s\"\n", vercheck, version);
4337 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4339 /* pcchLangBuf not big enough */
4340 langsz = 4;
4341 lstrcpyA(lang, "lang");
4342 r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
4343 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4344 ok(lstrcmpA(lang, "lang"), "lang not set\n");
4345 ok(langsz >= langchecksz, "Expected %d >= %d\n", langsz, langchecksz);
4347 /* pcchVersionBuf big enough, pcchLangBuf not big enough */
4348 versz = MAX_PATH;
4349 langsz = 0;
4350 lstrcpyA(version, "version");
4351 r = MsiGetFileVersionA(path, version, &versz, NULL, &langsz);
4352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4353 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4354 ok(!lstrcmpA(version, vercheck), "Expected \"%s\", got \"%s\"\n", vercheck, version);
4355 ok(langsz >= langchecksz && langsz < MAX_PATH, "Expected %d >= %d\n", langsz, langchecksz);
4357 /* pcchVersionBuf not big enough, pcchLangBuf big enough */
4358 versz = 5;
4359 langsz = MAX_PATH;
4360 lstrcpyA(lang, "lang");
4361 r = MsiGetFileVersionA(path, NULL, &versz, lang, &langsz);
4362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4363 ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
4364 ok(langsz >= langchecksz && langsz < MAX_PATH, "Expected %d >= %d\n", langsz, langchecksz);
4365 ok(strstr(lang, langcheck) != NULL, "expected %s in %s\n", langcheck, lang);
4367 /* NULL pcchVersionBuf and pcchLangBuf */
4368 r = MsiGetFileVersionA(path, version, NULL, lang, NULL);
4369 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4371 /* All NULL except szFilePath */
4372 r = MsiGetFileVersionA(path, NULL, NULL, NULL, NULL);
4373 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4375 HeapFree(GetProcessHeap(), 0, vercheck);
4376 HeapFree(GetProcessHeap(), 0, langcheck);
4379 static void test_MsiGetProductInfo(void)
4381 UINT r;
4382 LONG res;
4383 HKEY propkey, source;
4384 HKEY prodkey, localkey;
4385 CHAR prodcode[MAX_PATH];
4386 CHAR prod_squashed[MAX_PATH];
4387 CHAR packcode[MAX_PATH];
4388 CHAR pack_squashed[MAX_PATH];
4389 CHAR buf[MAX_PATH];
4390 CHAR keypath[MAX_PATH];
4391 LPSTR usersid;
4392 DWORD sz, val = 42;
4393 REGSAM access = KEY_ALL_ACCESS;
4395 create_test_guid(prodcode, prod_squashed);
4396 create_test_guid(packcode, pack_squashed);
4397 usersid = get_user_sid();
4399 if (is_wow64)
4400 access |= KEY_WOW64_64KEY;
4402 /* NULL szProduct */
4403 sz = MAX_PATH;
4404 lstrcpyA(buf, "apple");
4405 r = MsiGetProductInfoA(NULL, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4406 ok(r == ERROR_INVALID_PARAMETER,
4407 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4408 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4409 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4411 /* empty szProduct */
4412 sz = MAX_PATH;
4413 lstrcpyA(buf, "apple");
4414 r = MsiGetProductInfoA("", INSTALLPROPERTY_HELPLINKA, buf, &sz);
4415 ok(r == ERROR_INVALID_PARAMETER,
4416 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4417 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4418 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4420 /* garbage szProduct */
4421 sz = MAX_PATH;
4422 lstrcpyA(buf, "apple");
4423 r = MsiGetProductInfoA("garbage", INSTALLPROPERTY_HELPLINKA, buf, &sz);
4424 ok(r == ERROR_INVALID_PARAMETER,
4425 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4426 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4427 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4429 /* guid without brackets */
4430 sz = MAX_PATH;
4431 lstrcpyA(buf, "apple");
4432 r = MsiGetProductInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
4433 INSTALLPROPERTY_HELPLINKA, buf, &sz);
4434 ok(r == ERROR_INVALID_PARAMETER,
4435 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4436 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4437 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4439 /* guid with brackets */
4440 sz = MAX_PATH;
4441 lstrcpyA(buf, "apple");
4442 r = MsiGetProductInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
4443 INSTALLPROPERTY_HELPLINKA, buf, &sz);
4444 ok(r == ERROR_UNKNOWN_PRODUCT,
4445 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4446 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4447 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4449 /* same length as guid, but random */
4450 sz = MAX_PATH;
4451 lstrcpyA(buf, "apple");
4452 r = MsiGetProductInfoA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
4453 INSTALLPROPERTY_HELPLINKA, buf, &sz);
4454 ok(r == ERROR_INVALID_PARAMETER,
4455 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4456 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4457 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4459 /* not installed, NULL szAttribute */
4460 sz = MAX_PATH;
4461 lstrcpyA(buf, "apple");
4462 r = MsiGetProductInfoA(prodcode, NULL, buf, &sz);
4463 ok(r == ERROR_INVALID_PARAMETER,
4464 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4465 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4466 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4468 /* not installed, NULL lpValueBuf */
4469 sz = MAX_PATH;
4470 lstrcpyA(buf, "apple");
4471 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, &sz);
4472 ok(r == ERROR_UNKNOWN_PRODUCT,
4473 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4474 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4475 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4477 /* not installed, NULL pcchValueBuf */
4478 sz = MAX_PATH;
4479 lstrcpyA(buf, "apple");
4480 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, NULL);
4481 ok(r == ERROR_INVALID_PARAMETER,
4482 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
4483 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4484 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4486 /* created guid cannot possibly be an installed product code */
4487 sz = MAX_PATH;
4488 lstrcpyA(buf, "apple");
4489 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4490 ok(r == ERROR_UNKNOWN_PRODUCT,
4491 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4492 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4493 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4495 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4496 lstrcatA(keypath, usersid);
4497 lstrcatA(keypath, "\\Installer\\Products\\");
4498 lstrcatA(keypath, prod_squashed);
4500 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
4501 if (res == ERROR_ACCESS_DENIED)
4503 skip("Not enough rights to perform tests\n");
4504 LocalFree(usersid);
4505 return;
4507 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4509 /* managed product code exists */
4510 sz = MAX_PATH;
4511 lstrcpyA(buf, "apple");
4512 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4513 ok(r == ERROR_UNKNOWN_PROPERTY,
4514 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4515 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4516 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4518 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
4519 RegCloseKey(prodkey);
4521 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4522 lstrcatA(keypath, usersid);
4523 lstrcatA(keypath, "\\Products\\");
4524 lstrcatA(keypath, prod_squashed);
4526 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4527 if (res == ERROR_ACCESS_DENIED)
4529 skip("Not enough rights to perform tests\n");
4530 LocalFree(usersid);
4531 return;
4533 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4535 /* local user product code exists */
4536 sz = MAX_PATH;
4537 lstrcpyA(buf, "apple");
4538 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4539 ok(r == ERROR_UNKNOWN_PRODUCT,
4540 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
4541 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4542 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4544 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
4545 lstrcatA(keypath, usersid);
4546 lstrcatA(keypath, "\\Installer\\Products\\");
4547 lstrcatA(keypath, prod_squashed);
4549 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
4550 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4552 /* both local and managed product code exist */
4553 sz = MAX_PATH;
4554 lstrcpyA(buf, "apple");
4555 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4556 ok(r == ERROR_UNKNOWN_PROPERTY,
4557 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4558 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
4559 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4561 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4562 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4564 /* InstallProperties key exists */
4565 sz = MAX_PATH;
4566 lstrcpyA(buf, "apple");
4567 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4568 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4569 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4570 ok(sz == 0, "Expected 0, got %d\n", sz);
4572 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4573 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4575 /* HelpLink value exists */
4576 sz = MAX_PATH;
4577 lstrcpyA(buf, "apple");
4578 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4579 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4580 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4581 ok(sz == 4, "Expected 4, got %d\n", sz);
4583 /* pcchBuf is NULL */
4584 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, NULL);
4585 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4587 /* lpValueBuf is NULL */
4588 sz = MAX_PATH;
4589 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, &sz);
4590 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4591 ok(sz == 4, "Expected 4, got %d\n", sz);
4593 /* lpValueBuf is NULL, pcchValueBuf is too small */
4594 sz = 2;
4595 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, NULL, &sz);
4596 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4597 ok(sz == 4, "Expected 4, got %d\n", sz);
4599 /* lpValueBuf is non-NULL, pcchValueBuf is too small */
4600 sz = 2;
4601 lstrcpyA(buf, "apple");
4602 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4603 ok(!lstrcmpA(buf, "apple"), "Expected buf to remain unchanged, got \"%s\"\n", buf);
4604 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4605 ok(sz == 4, "Expected 4, got %d\n", sz);
4607 /* lpValueBuf is non-NULL, pcchValueBuf is exactly 4 */
4608 sz = 4;
4609 lstrcpyA(buf, "apple");
4610 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4611 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
4612 ok(!lstrcmpA(buf, "apple"),
4613 "Expected buf to remain unchanged, got \"%s\"\n", buf);
4614 ok(sz == 4, "Expected 4, got %d\n", sz);
4616 res = RegSetValueExA(propkey, "IMadeThis", 0, REG_SZ, (LPBYTE)"random", 7);
4617 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4619 /* random property not supported by MSI, value exists */
4620 sz = MAX_PATH;
4621 lstrcpyA(buf, "apple");
4622 r = MsiGetProductInfoA(prodcode, "IMadeThis", buf, &sz);
4623 ok(r == ERROR_UNKNOWN_PROPERTY,
4624 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4625 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4626 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4628 RegDeleteValueA(propkey, "IMadeThis");
4629 RegDeleteValueA(propkey, "HelpLink");
4630 delete_key(propkey, "", access & KEY_WOW64_64KEY);
4631 delete_key(localkey, "", access & KEY_WOW64_64KEY);
4632 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
4633 RegCloseKey(propkey);
4634 RegCloseKey(localkey);
4635 RegCloseKey(prodkey);
4637 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
4638 lstrcatA(keypath, prod_squashed);
4640 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
4641 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4643 /* user product key exists */
4644 sz = MAX_PATH;
4645 lstrcpyA(buf, "apple");
4646 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4647 ok(r == ERROR_UNKNOWN_PROPERTY,
4648 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4649 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4650 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4652 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4653 lstrcatA(keypath, usersid);
4654 lstrcatA(keypath, "\\Products\\");
4655 lstrcatA(keypath, prod_squashed);
4657 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4658 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4660 /* local user product key exists */
4661 sz = MAX_PATH;
4662 lstrcpyA(buf, "apple");
4663 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4664 ok(r == ERROR_UNKNOWN_PROPERTY,
4665 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4666 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4667 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4669 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4670 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4672 /* InstallProperties key exists */
4673 sz = MAX_PATH;
4674 lstrcpyA(buf, "apple");
4675 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4676 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4677 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4678 ok(sz == 0, "Expected 0, got %d\n", sz);
4680 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4681 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4683 /* HelpLink value exists */
4684 sz = MAX_PATH;
4685 lstrcpyA(buf, "apple");
4686 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4687 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4688 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4689 ok(sz == 4, "Expected 4, got %d\n", sz);
4691 RegDeleteValueA(propkey, "HelpLink");
4692 delete_key(propkey, "", access & KEY_WOW64_64KEY);
4693 delete_key(localkey, "", access & KEY_WOW64_64KEY);
4694 RegDeleteKeyA(prodkey, "");
4695 RegCloseKey(propkey);
4696 RegCloseKey(localkey);
4697 RegCloseKey(prodkey);
4699 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
4700 lstrcatA(keypath, prod_squashed);
4702 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
4703 if (res == ERROR_ACCESS_DENIED)
4705 skip( "insufficient rights\n" );
4706 LocalFree( usersid );
4707 return;
4709 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4711 /* classes product key exists */
4712 sz = MAX_PATH;
4713 lstrcpyA(buf, "apple");
4714 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4715 ok(r == ERROR_UNKNOWN_PROPERTY,
4716 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4717 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4718 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4720 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4721 lstrcatA(keypath, usersid);
4722 lstrcatA(keypath, "\\Products\\");
4723 lstrcatA(keypath, prod_squashed);
4725 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4726 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4728 /* local user product key exists */
4729 sz = MAX_PATH;
4730 lstrcpyA(buf, "apple");
4731 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4732 ok(r == ERROR_UNKNOWN_PROPERTY,
4733 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4734 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4735 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4737 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4738 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4740 /* InstallProperties key exists */
4741 sz = MAX_PATH;
4742 lstrcpyA(buf, "apple");
4743 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4744 ok(r == ERROR_UNKNOWN_PROPERTY,
4745 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4746 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4747 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4749 delete_key(propkey, "", access & KEY_WOW64_64KEY);
4750 delete_key(localkey, "", access & KEY_WOW64_64KEY);
4751 RegCloseKey(propkey);
4752 RegCloseKey(localkey);
4754 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
4755 lstrcatA(keypath, "S-1-5-18\\\\Products\\");
4756 lstrcatA(keypath, prod_squashed);
4758 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
4759 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4761 /* Local System product key exists */
4762 sz = MAX_PATH;
4763 lstrcpyA(buf, "apple");
4764 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4765 ok(r == ERROR_UNKNOWN_PROPERTY,
4766 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
4767 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
4768 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
4770 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
4771 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4773 /* InstallProperties key exists */
4774 sz = MAX_PATH;
4775 lstrcpyA(buf, "apple");
4776 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4777 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4778 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
4779 ok(sz == 0, "Expected 0, got %d\n", sz);
4781 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
4782 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4784 /* HelpLink value exists */
4785 sz = MAX_PATH;
4786 lstrcpyA(buf, "apple");
4787 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, buf, &sz);
4788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4789 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
4790 ok(sz == 4, "Expected 4, got %d\n", sz);
4792 res = RegSetValueExA(propkey, "HelpLink", 0, REG_DWORD,
4793 (const BYTE *)&val, sizeof(DWORD));
4794 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4796 /* HelpLink type is REG_DWORD */
4797 sz = MAX_PATH;
4798 lstrcpyA(buf, "apple");
4799 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPLINKA, 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, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
4805 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4807 /* DisplayName value exists */
4808 sz = MAX_PATH;
4809 lstrcpyA(buf, "apple");
4810 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
4811 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4812 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
4813 ok(sz == 4, "Expected 4, got %d\n", sz);
4815 res = RegSetValueExA(propkey, "DisplayName", 0, REG_DWORD,
4816 (const BYTE *)&val, sizeof(DWORD));
4817 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4819 /* DisplayName type is REG_DWORD */
4820 sz = MAX_PATH;
4821 lstrcpyA(buf, "apple");
4822 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, 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, "DisplayVersion", 0, REG_SZ, (LPBYTE)"1.1.1", 6);
4828 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4830 /* DisplayVersion value exists */
4831 sz = MAX_PATH;
4832 lstrcpyA(buf, "apple");
4833 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
4834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4835 ok(!lstrcmpA(buf, "1.1.1"), "Expected \"1.1.1\", got \"%s\"\n", buf);
4836 ok(sz == 5, "Expected 5, got %d\n", sz);
4838 res = RegSetValueExA(propkey, "DisplayVersion", 0,
4839 REG_DWORD, (const BYTE *)&val, sizeof(DWORD));
4840 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4842 /* DisplayVersion type is REG_DWORD */
4843 sz = MAX_PATH;
4844 lstrcpyA(buf, "apple");
4845 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONSTRINGA, 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, "HelpTelephone", 0, REG_SZ, (LPBYTE)"tele", 5);
4851 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4853 /* HelpTelephone value exists */
4854 sz = MAX_PATH;
4855 lstrcpyA(buf, "apple");
4856 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
4857 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4858 ok(!lstrcmpA(buf, "tele"), "Expected \"tele\", got \"%s\"\n", buf);
4859 ok(sz == 4, "Expected 4, got %d\n", sz);
4861 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_DWORD,
4862 (const BYTE *)&val, sizeof(DWORD));
4863 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4865 /* HelpTelephone type is REG_DWORD */
4866 sz = MAX_PATH;
4867 lstrcpyA(buf, "apple");
4868 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_HELPTELEPHONEA, 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, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
4874 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4876 /* InstallLocation value exists */
4877 sz = MAX_PATH;
4878 lstrcpyA(buf, "apple");
4879 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
4880 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4881 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
4882 ok(sz == 3, "Expected 3, got %d\n", sz);
4884 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_DWORD,
4885 (const BYTE *)&val, sizeof(DWORD));
4886 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4888 /* InstallLocation type is REG_DWORD */
4889 sz = MAX_PATH;
4890 lstrcpyA(buf, "apple");
4891 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLLOCATIONA, 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, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
4897 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4899 /* InstallSource value exists */
4900 sz = MAX_PATH;
4901 lstrcpyA(buf, "apple");
4902 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
4903 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4904 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
4905 ok(sz == 6, "Expected 6, got %d\n", sz);
4907 res = RegSetValueExA(propkey, "InstallSource", 0, REG_DWORD,
4908 (const BYTE *)&val, sizeof(DWORD));
4909 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4911 /* InstallSource type is REG_DWORD */
4912 sz = MAX_PATH;
4913 lstrcpyA(buf, "apple");
4914 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLSOURCEA, 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, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
4920 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4922 /* InstallDate value exists */
4923 sz = MAX_PATH;
4924 lstrcpyA(buf, "apple");
4925 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
4926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4927 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
4928 ok(sz == 4, "Expected 4, got %d\n", sz);
4930 res = RegSetValueExA(propkey, "InstallDate", 0, REG_DWORD,
4931 (const BYTE *)&val, sizeof(DWORD));
4932 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4934 /* InstallDate type is REG_DWORD */
4935 sz = MAX_PATH;
4936 lstrcpyA(buf, "apple");
4937 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
4938 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4939 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4940 ok(sz == 2, "Expected 2, got %d\n", sz);
4942 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
4943 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4945 /* Publisher value exists */
4946 sz = MAX_PATH;
4947 lstrcpyA(buf, "apple");
4948 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHERA, buf, &sz);
4949 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4950 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
4951 ok(sz == 3, "Expected 3, got %d\n", sz);
4953 res = RegSetValueExA(propkey, "Publisher", 0, REG_DWORD,
4954 (const BYTE *)&val, sizeof(DWORD));
4955 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4957 /* Publisher type is REG_DWORD */
4958 sz = MAX_PATH;
4959 lstrcpyA(buf, "apple");
4960 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PUBLISHERA, 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, "LocalPackage", 0, REG_SZ, (LPBYTE)"pack", 5);
4966 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4968 /* LocalPackage value exists */
4969 sz = MAX_PATH;
4970 lstrcpyA(buf, "apple");
4971 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
4972 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4973 ok(!lstrcmpA(buf, "pack"), "Expected \"pack\", got \"%s\"\n", buf);
4974 ok(sz == 4, "Expected 4, got %d\n", sz);
4976 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_DWORD,
4977 (const BYTE *)&val, sizeof(DWORD));
4978 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4980 /* LocalPackage type is REG_DWORD */
4981 sz = MAX_PATH;
4982 lstrcpyA(buf, "apple");
4983 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
4984 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4985 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
4986 ok(sz == 2, "Expected 2, got %d\n", sz);
4988 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
4989 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4991 /* UrlInfoAbout value exists */
4992 sz = MAX_PATH;
4993 lstrcpyA(buf, "apple");
4994 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
4995 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4996 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
4997 ok(sz == 5, "Expected 5, got %d\n", sz);
4999 res = RegSetValueExA(propkey, "UrlInfoAbout", 0, REG_DWORD,
5000 (const BYTE *)&val, sizeof(DWORD));
5001 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5003 /* UrlInfoAbout type is REG_DWORD */
5004 sz = MAX_PATH;
5005 lstrcpyA(buf, "apple");
5006 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLINFOABOUTA, 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, "UrlUpdateInfo", 0, REG_SZ, (LPBYTE)"info", 5);
5012 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5014 /* UrlUpdateInfo value exists */
5015 sz = MAX_PATH;
5016 lstrcpyA(buf, "apple");
5017 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
5018 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5019 ok(!lstrcmpA(buf, "info"), "Expected \"info\", got \"%s\"\n", buf);
5020 ok(sz == 4, "Expected 4, got %d\n", sz);
5022 res = RegSetValueExA(propkey, "UrlUpdateInfo", 0, REG_DWORD,
5023 (const BYTE *)&val, sizeof(DWORD));
5024 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5026 /* UrlUpdateInfo type is REG_DWORD */
5027 sz = MAX_PATH;
5028 lstrcpyA(buf, "apple");
5029 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
5030 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5031 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5032 ok(sz == 2, "Expected 2, got %d\n", sz);
5034 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"1", 2);
5035 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5037 /* VersionMinor value exists */
5038 sz = MAX_PATH;
5039 lstrcpyA(buf, "apple");
5040 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
5041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5042 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5043 ok(sz == 1, "Expected 1, got %d\n", sz);
5045 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_DWORD,
5046 (const BYTE *)&val, sizeof(DWORD));
5047 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5049 /* VersionMinor type is REG_DWORD */
5050 sz = MAX_PATH;
5051 lstrcpyA(buf, "apple");
5052 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMINORA, 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, "VersionMajor", 0, REG_SZ, (LPBYTE)"1", 2);
5058 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5060 /* VersionMajor value exists */
5061 sz = MAX_PATH;
5062 lstrcpyA(buf, "apple");
5063 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
5064 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5065 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
5066 ok(sz == 1, "Expected 1, got %d\n", sz);
5068 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_DWORD,
5069 (const BYTE *)&val, sizeof(DWORD));
5070 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5072 /* VersionMajor type is REG_DWORD */
5073 sz = MAX_PATH;
5074 lstrcpyA(buf, "apple");
5075 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
5076 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5077 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5078 ok(sz == 2, "Expected 2, got %d\n", sz);
5080 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
5081 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5083 /* ProductID value exists */
5084 sz = MAX_PATH;
5085 lstrcpyA(buf, "apple");
5086 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
5087 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5088 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
5089 ok(sz == 2, "Expected 2, got %d\n", sz);
5091 res = RegSetValueExA(propkey, "ProductID", 0, REG_DWORD,
5092 (const BYTE *)&val, sizeof(DWORD));
5093 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5095 /* ProductID type is REG_DWORD */
5096 sz = MAX_PATH;
5097 lstrcpyA(buf, "apple");
5098 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTIDA, 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, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
5104 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5106 /* RegCompany value exists */
5107 sz = MAX_PATH;
5108 lstrcpyA(buf, "apple");
5109 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
5110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5111 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
5112 ok(sz == 4, "Expected 4, got %d\n", sz);
5114 res = RegSetValueExA(propkey, "RegCompany", 0, REG_DWORD,
5115 (const BYTE *)&val, sizeof(DWORD));
5116 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5118 /* RegCompany type is REG_DWORD */
5119 sz = MAX_PATH;
5120 lstrcpyA(buf, "apple");
5121 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
5122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5123 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5124 ok(sz == 2, "Expected 2, got %d\n", sz);
5126 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"own", 4);
5127 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5129 /* RegOwner value exists */
5130 sz = MAX_PATH;
5131 lstrcpyA(buf, "apple");
5132 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNERA, buf, &sz);
5133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5134 ok(!lstrcmpA(buf, "own"), "Expected \"own\", got \"%s\"\n", buf);
5135 ok(sz == 3, "Expected 3, got %d\n", sz);
5137 res = RegSetValueExA(propkey, "RegOwner", 0, REG_DWORD,
5138 (const BYTE *)&val, sizeof(DWORD));
5139 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5141 /* RegOwner type is REG_DWORD */
5142 sz = MAX_PATH;
5143 lstrcpyA(buf, "apple");
5144 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_REGOWNERA, 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, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
5150 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5152 /* InstanceType value exists */
5153 sz = MAX_PATH;
5154 lstrcpyA(buf, "apple");
5155 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, 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, "InstanceType", 0, REG_DWORD,
5161 (const BYTE *)&val, sizeof(DWORD));
5162 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5164 /* InstanceType type is REG_DWORD */
5165 sz = MAX_PATH;
5166 lstrcpyA(buf, "apple");
5167 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, 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, "InstanceType", 0, REG_SZ, (LPBYTE)"type", 5);
5173 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5175 /* InstanceType value exists */
5176 sz = MAX_PATH;
5177 lstrcpyA(buf, "apple");
5178 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, buf, &sz);
5179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5180 ok(!lstrcmpA(buf, "type"), "Expected \"type\", got \"%s\"\n", buf);
5181 ok(sz == 4, "Expected 4, got %d\n", sz);
5183 res = RegSetValueExA(prodkey, "InstanceType", 0, REG_DWORD,
5184 (const BYTE *)&val, sizeof(DWORD));
5185 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5187 /* InstanceType type is REG_DWORD */
5188 sz = MAX_PATH;
5189 lstrcpyA(buf, "apple");
5190 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_INSTANCETYPEA, buf, &sz);
5191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5192 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5193 ok(sz == 2, "Expected 2, got %d\n", sz);
5195 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
5196 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5198 /* Transforms value exists */
5199 sz = MAX_PATH;
5200 lstrcpyA(buf, "apple");
5201 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5202 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5203 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5204 ok(sz == 0, "Expected 0, got %d\n", sz);
5206 res = RegSetValueExA(propkey, "Transforms", 0, REG_DWORD,
5207 (const BYTE *)&val, sizeof(DWORD));
5208 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5210 /* Transforms type is REG_DWORD */
5211 sz = MAX_PATH;
5212 lstrcpyA(buf, "apple");
5213 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, 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(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"tforms", 7);
5219 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5221 /* Transforms value exists */
5222 sz = MAX_PATH;
5223 lstrcpyA(buf, "apple");
5224 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5225 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5226 ok(!lstrcmpA(buf, "tforms"), "Expected \"tforms\", got \"%s\"\n", buf);
5227 ok(sz == 6, "Expected 6, got %d\n", sz);
5229 res = RegSetValueExA(prodkey, "Transforms", 0, REG_DWORD,
5230 (const BYTE *)&val, sizeof(DWORD));
5231 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5233 /* Transforms type is REG_DWORD */
5234 sz = MAX_PATH;
5235 lstrcpyA(buf, "apple");
5236 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
5237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5238 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5239 ok(sz == 2, "Expected 2, got %d\n", sz);
5241 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5242 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5244 /* Language value exists */
5245 sz = MAX_PATH;
5246 lstrcpyA(buf, "apple");
5247 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5249 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5250 ok(sz == 0, "Expected 0, got %d\n", sz);
5252 res = RegSetValueExA(propkey, "Language", 0, REG_DWORD,
5253 (const BYTE *)&val, sizeof(DWORD));
5254 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5256 /* Language type is REG_DWORD */
5257 sz = MAX_PATH;
5258 lstrcpyA(buf, "apple");
5259 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, 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(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
5265 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5267 /* Language value exists */
5268 sz = MAX_PATH;
5269 lstrcpyA(buf, "apple");
5270 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5271 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5272 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
5273 ok(sz == 4, "Expected 4, got %d\n", sz);
5275 res = RegSetValueExA(prodkey, "Language", 0, REG_DWORD,
5276 (const BYTE *)&val, sizeof(DWORD));
5277 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5279 /* Language type is REG_DWORD */
5280 sz = MAX_PATH;
5281 lstrcpyA(buf, "apple");
5282 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_LANGUAGEA, buf, &sz);
5283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5284 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5285 ok(sz == 2, "Expected 2, got %d\n", sz);
5287 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5288 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5290 /* ProductName value exists */
5291 sz = MAX_PATH;
5292 lstrcpyA(buf, "apple");
5293 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5294 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5295 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5296 ok(sz == 0, "Expected 0, got %d\n", sz);
5298 res = RegSetValueExA(propkey, "ProductName", 0, REG_DWORD,
5299 (const BYTE *)&val, sizeof(DWORD));
5300 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5302 /* ProductName type is REG_DWORD */
5303 sz = MAX_PATH;
5304 lstrcpyA(buf, "apple");
5305 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5307 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5308 ok(sz == 0, "Expected 0, got %d\n", sz);
5310 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
5311 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5313 /* ProductName value exists */
5314 sz = MAX_PATH;
5315 lstrcpyA(buf, "apple");
5316 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5318 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
5319 ok(sz == 4, "Expected 4, got %d\n", sz);
5321 res = RegSetValueExA(prodkey, "ProductName", 0, REG_DWORD,
5322 (const BYTE *)&val, sizeof(DWORD));
5323 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5325 /* ProductName type is REG_DWORD */
5326 sz = MAX_PATH;
5327 lstrcpyA(buf, "apple");
5328 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
5329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5330 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5331 ok(sz == 2, "Expected 2, got %d\n", sz);
5333 res = RegSetValueExA(propkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
5334 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5336 /* Assignment value exists */
5337 sz = MAX_PATH;
5338 lstrcpyA(buf, "apple");
5339 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5340 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5341 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5342 ok(sz == 0, "Expected 0, got %d\n", sz);
5344 res = RegSetValueExA(propkey, "Assignment", 0, REG_DWORD,
5345 (const BYTE *)&val, sizeof(DWORD));
5346 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5348 /* Assignment type is REG_DWORD */
5349 sz = MAX_PATH;
5350 lstrcpyA(buf, "apple");
5351 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
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);
5356 res = RegSetValueExA(prodkey, "Assignment", 0, REG_SZ, (LPBYTE)"at", 3);
5357 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5359 /* Assignment value exists */
5360 sz = MAX_PATH;
5361 lstrcpyA(buf, "apple");
5362 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5364 ok(!lstrcmpA(buf, "at"), "Expected \"at\", got \"%s\"\n", buf);
5365 ok(sz == 2, "Expected 2, got %d\n", sz);
5367 res = RegSetValueExA(prodkey, "Assignment", 0, REG_DWORD,
5368 (const BYTE *)&val, sizeof(DWORD));
5369 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5371 /* Assignment type is REG_DWORD */
5372 sz = MAX_PATH;
5373 lstrcpyA(buf, "apple");
5374 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
5375 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5376 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5377 ok(sz == 2, "Expected 2, got %d\n", sz);
5379 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5380 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5382 /* PackageCode value exists */
5383 sz = MAX_PATH;
5384 lstrcpyA(buf, "apple");
5385 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5387 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5388 ok(sz == 0, "Expected 0, got %d\n", sz);
5390 res = RegSetValueExA(propkey, "PackageCode", 0, REG_DWORD,
5391 (const BYTE *)&val, sizeof(DWORD));
5392 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5394 /* PackageCode type is REG_DWORD */
5395 sz = MAX_PATH;
5396 lstrcpyA(buf, "apple");
5397 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5398 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5399 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5400 ok(sz == 0, "Expected 0, got %d\n", sz);
5402 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
5403 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5405 /* PackageCode value exists */
5406 sz = MAX_PATH;
5407 lstrcpyA(buf, "apple");
5408 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5409 ok(r == ERROR_BAD_CONFIGURATION,
5410 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
5411 ok(!lstrcmpA(buf, "code"), "Expected \"code\", got \"%s\"\n", buf);
5412 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5414 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_DWORD,
5415 (const BYTE *)&val, sizeof(DWORD));
5416 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5418 /* PackageCode type is REG_DWORD */
5419 sz = MAX_PATH;
5420 lstrcpyA(buf, "apple");
5421 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5422 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5423 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5424 ok(sz == 2, "Expected 2, got %d\n", sz);
5426 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)pack_squashed, 33);
5427 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5429 /* PackageCode value exists */
5430 sz = MAX_PATH;
5431 lstrcpyA(buf, "apple");
5432 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
5433 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5434 ok(!lstrcmpA(buf, packcode), "Expected \"%s\", got \"%s\"\n", packcode, buf);
5435 ok(sz == 38, "Expected 38, got %d\n", sz);
5437 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5438 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5440 /* Version value exists */
5441 sz = MAX_PATH;
5442 lstrcpyA(buf, "apple");
5443 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5444 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5445 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5446 ok(sz == 0, "Expected 0, got %d\n", sz);
5448 res = RegSetValueExA(propkey, "Version", 0, REG_DWORD,
5449 (const BYTE *)&val, sizeof(DWORD));
5450 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5452 /* Version type is REG_DWORD */
5453 sz = MAX_PATH;
5454 lstrcpyA(buf, "apple");
5455 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5456 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5457 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5458 ok(sz == 0, "Expected 0, got %d\n", sz);
5460 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
5461 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5463 /* Version value exists */
5464 sz = MAX_PATH;
5465 lstrcpyA(buf, "apple");
5466 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5467 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5468 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
5469 ok(sz == 3, "Expected 3, got %d\n", sz);
5471 res = RegSetValueExA(prodkey, "Version", 0, REG_DWORD,
5472 (const BYTE *)&val, sizeof(DWORD));
5473 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5475 /* Version type is REG_DWORD */
5476 sz = MAX_PATH;
5477 lstrcpyA(buf, "apple");
5478 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_VERSIONA, buf, &sz);
5479 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5480 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5481 ok(sz == 2, "Expected 2, got %d\n", sz);
5483 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
5484 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5486 /* ProductIcon value exists */
5487 sz = MAX_PATH;
5488 lstrcpyA(buf, "apple");
5489 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5490 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5491 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5492 ok(sz == 0, "Expected 0, got %d\n", sz);
5494 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_DWORD,
5495 (const BYTE *)&val, sizeof(DWORD));
5496 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5498 /* ProductIcon type is REG_DWORD */
5499 sz = MAX_PATH;
5500 lstrcpyA(buf, "apple");
5501 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5502 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5503 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5504 ok(sz == 0, "Expected 0, got %d\n", sz);
5506 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"ico", 4);
5507 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5509 /* ProductIcon value exists */
5510 sz = MAX_PATH;
5511 lstrcpyA(buf, "apple");
5512 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5513 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5514 ok(!lstrcmpA(buf, "ico"), "Expected \"ico\", got \"%s\"\n", buf);
5515 ok(sz == 3, "Expected 3, got %d\n", sz);
5517 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_DWORD,
5518 (const BYTE *)&val, sizeof(DWORD));
5519 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5521 /* ProductIcon type is REG_DWORD */
5522 sz = MAX_PATH;
5523 lstrcpyA(buf, "apple");
5524 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
5525 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5526 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5527 ok(sz == 2, "Expected 2, got %d\n", sz);
5529 /* SourceList key does not exist */
5530 sz = MAX_PATH;
5531 lstrcpyA(buf, "apple");
5532 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5533 ok(r == ERROR_UNKNOWN_PRODUCT,
5534 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5535 ok(!lstrcmpA(buf, "apple"),
5536 "Expected buf to be unchanged, got \"%s\"\n", buf);
5537 ok(sz == MAX_PATH, "Expected sz to be unchanged, got %d\n", sz);
5539 res = RegCreateKeyExA(prodkey, "SourceList", 0, NULL, 0, access, NULL, &source, NULL);
5540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5542 /* SourceList key exists, but PackageName val does not exist */
5543 sz = MAX_PATH;
5544 lstrcpyA(buf, "apple");
5545 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5546 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5547 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5548 ok(sz == 0, "Expected 0, got %d\n", sz);
5550 res = RegSetValueExA(source, "PackageName", 0, REG_SZ, (LPBYTE)"packname", 9);
5551 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5553 /* PackageName val exists */
5554 sz = MAX_PATH;
5555 lstrcpyA(buf, "apple");
5556 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5557 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5558 ok(!lstrcmpA(buf, "packname"), "Expected \"packname\", got \"%s\"\n", buf);
5559 ok(sz == 8, "Expected 8, got %d\n", sz);
5561 res = RegSetValueExA(source, "PackageName", 0, REG_DWORD,
5562 (const BYTE *)&val, sizeof(DWORD));
5563 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5565 /* PackageName type is REG_DWORD */
5566 sz = MAX_PATH;
5567 lstrcpyA(buf, "apple");
5568 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
5569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5570 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5571 ok(sz == 2, "Expected 2, got %d\n", sz);
5573 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5574 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5576 /* Authorized value exists */
5577 sz = MAX_PATH;
5578 lstrcpyA(buf, "apple");
5579 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5580 if (r != ERROR_UNKNOWN_PROPERTY)
5582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5583 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5584 ok(sz == 0, "Expected 0, got %d\n", sz);
5587 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_DWORD,
5588 (const BYTE *)&val, sizeof(DWORD));
5589 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5591 /* AuthorizedLUAApp type is REG_DWORD */
5592 sz = MAX_PATH;
5593 lstrcpyA(buf, "apple");
5594 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5595 if (r != ERROR_UNKNOWN_PROPERTY)
5597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5598 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5599 ok(sz == 0, "Expected 0, got %d\n", sz);
5602 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
5603 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5605 /* Authorized value exists */
5606 sz = MAX_PATH;
5607 lstrcpyA(buf, "apple");
5608 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5609 if (r != ERROR_UNKNOWN_PROPERTY)
5611 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5612 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
5613 ok(sz == 4, "Expected 4, got %d\n", sz);
5616 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_DWORD,
5617 (const BYTE *)&val, sizeof(DWORD));
5618 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5620 /* AuthorizedLUAApp type is REG_DWORD */
5621 sz = MAX_PATH;
5622 lstrcpyA(buf, "apple");
5623 r = MsiGetProductInfoA(prodcode, INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
5624 if (r != ERROR_UNKNOWN_PROPERTY)
5626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5627 ok(!lstrcmpA(buf, "42"), "Expected \"42\", got \"%s\"\n", buf);
5628 ok(sz == 2, "Expected 2, got %d\n", sz);
5631 RegDeleteValueA(propkey, "HelpLink");
5632 RegDeleteValueA(propkey, "DisplayName");
5633 RegDeleteValueA(propkey, "DisplayVersion");
5634 RegDeleteValueA(propkey, "HelpTelephone");
5635 RegDeleteValueA(propkey, "InstallLocation");
5636 RegDeleteValueA(propkey, "InstallSource");
5637 RegDeleteValueA(propkey, "InstallDate");
5638 RegDeleteValueA(propkey, "Publisher");
5639 RegDeleteValueA(propkey, "LocalPackage");
5640 RegDeleteValueA(propkey, "UrlInfoAbout");
5641 RegDeleteValueA(propkey, "UrlUpdateInfo");
5642 RegDeleteValueA(propkey, "VersionMinor");
5643 RegDeleteValueA(propkey, "VersionMajor");
5644 RegDeleteValueA(propkey, "ProductID");
5645 RegDeleteValueA(propkey, "RegCompany");
5646 RegDeleteValueA(propkey, "RegOwner");
5647 RegDeleteValueA(propkey, "InstanceType");
5648 RegDeleteValueA(propkey, "Transforms");
5649 RegDeleteValueA(propkey, "Language");
5650 RegDeleteValueA(propkey, "ProductName");
5651 RegDeleteValueA(propkey, "Assignment");
5652 RegDeleteValueA(propkey, "PackageCode");
5653 RegDeleteValueA(propkey, "Version");
5654 RegDeleteValueA(propkey, "ProductIcon");
5655 RegDeleteValueA(propkey, "AuthorizedLUAApp");
5656 delete_key(propkey, "", access & KEY_WOW64_64KEY);
5657 delete_key(localkey, "", access & KEY_WOW64_64KEY);
5658 RegDeleteValueA(prodkey, "InstanceType");
5659 RegDeleteValueA(prodkey, "Transforms");
5660 RegDeleteValueA(prodkey, "Language");
5661 RegDeleteValueA(prodkey, "ProductName");
5662 RegDeleteValueA(prodkey, "Assignment");
5663 RegDeleteValueA(prodkey, "PackageCode");
5664 RegDeleteValueA(prodkey, "Version");
5665 RegDeleteValueA(prodkey, "ProductIcon");
5666 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
5667 RegDeleteValueA(source, "PackageName");
5668 delete_key(source, "", access & KEY_WOW64_64KEY);
5669 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
5670 RegCloseKey(propkey);
5671 RegCloseKey(localkey);
5672 RegCloseKey(source);
5673 RegCloseKey(prodkey);
5674 LocalFree(usersid);
5677 static void test_MsiGetProductInfoEx(void)
5679 UINT r;
5680 LONG res;
5681 HKEY propkey, userkey;
5682 HKEY prodkey, localkey;
5683 CHAR prodcode[MAX_PATH];
5684 CHAR prod_squashed[MAX_PATH];
5685 CHAR packcode[MAX_PATH];
5686 CHAR pack_squashed[MAX_PATH];
5687 CHAR buf[MAX_PATH];
5688 CHAR keypath[MAX_PATH];
5689 LPSTR usersid;
5690 DWORD sz;
5691 REGSAM access = KEY_ALL_ACCESS;
5693 if (!pMsiGetProductInfoExA)
5695 win_skip("MsiGetProductInfoExA is not available\n");
5696 return;
5699 create_test_guid(prodcode, prod_squashed);
5700 create_test_guid(packcode, pack_squashed);
5701 usersid = get_user_sid();
5703 if (is_wow64)
5704 access |= KEY_WOW64_64KEY;
5706 /* NULL szProductCode */
5707 sz = MAX_PATH;
5708 lstrcpyA(buf, "apple");
5709 r = pMsiGetProductInfoExA(NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
5710 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5711 ok(r == ERROR_INVALID_PARAMETER,
5712 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5713 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5714 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5716 /* empty szProductCode */
5717 sz = MAX_PATH;
5718 lstrcpyA(buf, "apple");
5719 r = pMsiGetProductInfoExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
5720 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5721 ok(r == ERROR_INVALID_PARAMETER,
5722 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5723 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5724 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5726 /* garbage szProductCode */
5727 sz = MAX_PATH;
5728 lstrcpyA(buf, "apple");
5729 r = pMsiGetProductInfoExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
5730 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5731 ok(r == ERROR_INVALID_PARAMETER,
5732 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5733 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5734 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5736 /* guid without brackets */
5737 sz = MAX_PATH;
5738 lstrcpyA(buf, "apple");
5739 r = pMsiGetProductInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
5740 MSIINSTALLCONTEXT_USERUNMANAGED,
5741 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5742 ok(r == ERROR_INVALID_PARAMETER,
5743 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5744 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5745 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5747 /* guid with brackets */
5748 sz = MAX_PATH;
5749 lstrcpyA(buf, "apple");
5750 r = pMsiGetProductInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", usersid,
5751 MSIINSTALLCONTEXT_USERUNMANAGED,
5752 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5753 ok(r == ERROR_UNKNOWN_PRODUCT,
5754 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5755 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5756 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5758 /* szValue is non-NULL while pcchValue is NULL */
5759 lstrcpyA(buf, "apple");
5760 r = pMsiGetProductInfoExA(prodcode, usersid,
5761 MSIINSTALLCONTEXT_USERUNMANAGED,
5762 INSTALLPROPERTY_PRODUCTSTATEA, buf, NULL);
5763 ok(r == ERROR_INVALID_PARAMETER,
5764 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5765 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5767 /* dwContext is out of range */
5768 sz = MAX_PATH;
5769 lstrcpyA(buf, "apple");
5770 r = pMsiGetProductInfoExA(prodcode, usersid, 42,
5771 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5772 ok(r == ERROR_INVALID_PARAMETER,
5773 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5774 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5775 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5777 /* szProperty is NULL */
5778 sz = MAX_PATH;
5779 lstrcpyA(buf, "apple");
5780 r = pMsiGetProductInfoExA(prodcode, usersid,
5781 MSIINSTALLCONTEXT_USERUNMANAGED,
5782 NULL, buf, &sz);
5783 ok(r == ERROR_INVALID_PARAMETER,
5784 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5785 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5786 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5788 /* szProperty is empty */
5789 sz = MAX_PATH;
5790 lstrcpyA(buf, "apple");
5791 r = pMsiGetProductInfoExA(prodcode, usersid,
5792 MSIINSTALLCONTEXT_USERUNMANAGED,
5793 "", buf, &sz);
5794 ok(r == ERROR_INVALID_PARAMETER,
5795 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5796 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5797 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5799 /* szProperty is not a valid property */
5800 sz = MAX_PATH;
5801 lstrcpyA(buf, "apple");
5802 r = pMsiGetProductInfoExA(prodcode, usersid,
5803 MSIINSTALLCONTEXT_USERUNMANAGED,
5804 "notvalid", buf, &sz);
5805 ok(r == ERROR_UNKNOWN_PRODUCT,
5806 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5807 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5808 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5810 /* same length as guid, but random */
5811 sz = MAX_PATH;
5812 lstrcpyA(buf, "apple");
5813 r = pMsiGetProductInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", usersid,
5814 MSIINSTALLCONTEXT_USERUNMANAGED,
5815 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5816 ok(r == ERROR_INVALID_PARAMETER,
5817 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
5818 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5819 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5821 /* MSIINSTALLCONTEXT_USERUNMANAGED */
5823 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
5824 lstrcatA(keypath, usersid);
5825 lstrcatA(keypath, "\\Products\\");
5826 lstrcatA(keypath, prod_squashed);
5828 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
5829 if (res == ERROR_ACCESS_DENIED)
5831 skip("Not enough rights to perform tests\n");
5832 LocalFree(usersid);
5833 return;
5835 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5837 /* local user product key exists */
5838 sz = MAX_PATH;
5839 lstrcpyA(buf, "apple");
5840 r = pMsiGetProductInfoExA(prodcode, usersid,
5841 MSIINSTALLCONTEXT_USERUNMANAGED,
5842 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5843 ok(r == ERROR_UNKNOWN_PRODUCT,
5844 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5845 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5846 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5848 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
5849 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5851 /* InstallProperties key exists */
5852 sz = MAX_PATH;
5853 lstrcpyA(buf, "apple");
5854 r = pMsiGetProductInfoExA(prodcode, usersid,
5855 MSIINSTALLCONTEXT_USERUNMANAGED,
5856 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5857 ok(r == ERROR_UNKNOWN_PRODUCT,
5858 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5859 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5860 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5862 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5863 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5865 /* LocalPackage value exists */
5866 sz = MAX_PATH;
5867 lstrcpyA(buf, "apple");
5868 r = pMsiGetProductInfoExA(prodcode, usersid,
5869 MSIINSTALLCONTEXT_USERUNMANAGED,
5870 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
5871 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5872 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
5873 ok(sz == 1, "Expected 1, got %d\n", sz);
5875 RegDeleteValueA(propkey, "LocalPackage");
5877 /* LocalPackage value must exist */
5878 sz = MAX_PATH;
5879 lstrcpyA(buf, "apple");
5880 r = pMsiGetProductInfoExA(prodcode, usersid,
5881 MSIINSTALLCONTEXT_USERUNMANAGED,
5882 INSTALLPROPERTY_HELPLINKA, buf, &sz);
5883 ok(r == ERROR_UNKNOWN_PRODUCT,
5884 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5885 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5886 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5888 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
5889 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5891 /* LocalPackage exists, but HelpLink does not exist */
5892 sz = MAX_PATH;
5893 lstrcpyA(buf, "apple");
5894 r = pMsiGetProductInfoExA(prodcode, usersid,
5895 MSIINSTALLCONTEXT_USERUNMANAGED,
5896 INSTALLPROPERTY_HELPLINKA, buf, &sz);
5897 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5898 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
5899 ok(sz == 0, "Expected 0, got %d\n", sz);
5901 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
5902 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5904 /* HelpLink value exists */
5905 sz = MAX_PATH;
5906 lstrcpyA(buf, "apple");
5907 r = pMsiGetProductInfoExA(prodcode, usersid,
5908 MSIINSTALLCONTEXT_USERUNMANAGED,
5909 INSTALLPROPERTY_HELPLINKA, buf, &sz);
5910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5911 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
5912 ok(sz == 4, "Expected 4, got %d\n", sz);
5914 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
5915 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5917 /* HelpTelephone value exists */
5918 sz = MAX_PATH;
5919 lstrcpyA(buf, "apple");
5920 r = pMsiGetProductInfoExA(prodcode, usersid,
5921 MSIINSTALLCONTEXT_USERUNMANAGED,
5922 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
5923 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5924 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
5925 ok(sz == 5, "Expected 5, got %d\n", sz);
5927 /* szValue and pcchValue are NULL */
5928 r = pMsiGetProductInfoExA(prodcode, usersid,
5929 MSIINSTALLCONTEXT_USERUNMANAGED,
5930 INSTALLPROPERTY_HELPTELEPHONEA, NULL, NULL);
5931 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5933 /* pcchValue is exactly 5 */
5934 sz = 5;
5935 lstrcpyA(buf, "apple");
5936 r = pMsiGetProductInfoExA(prodcode, usersid,
5937 MSIINSTALLCONTEXT_USERUNMANAGED,
5938 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
5939 ok(r == ERROR_MORE_DATA,
5940 "Expected ERROR_MORE_DATA, got %d\n", r);
5941 ok(sz == 10, "Expected 10, got %d\n", sz);
5943 /* szValue is NULL, pcchValue is exactly 5 */
5944 sz = 5;
5945 r = pMsiGetProductInfoExA(prodcode, usersid,
5946 MSIINSTALLCONTEXT_USERUNMANAGED,
5947 INSTALLPROPERTY_HELPTELEPHONEA, NULL, &sz);
5948 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5949 ok(sz == 10, "Expected 10, got %d\n", sz);
5951 /* szValue is NULL, pcchValue is MAX_PATH */
5952 sz = MAX_PATH;
5953 r = pMsiGetProductInfoExA(prodcode, usersid,
5954 MSIINSTALLCONTEXT_USERUNMANAGED,
5955 INSTALLPROPERTY_HELPTELEPHONEA, NULL, &sz);
5956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5957 ok(sz == 10, "Expected 10, got %d\n", sz);
5959 /* pcchValue is exactly 0 */
5960 sz = 0;
5961 lstrcpyA(buf, "apple");
5962 r = pMsiGetProductInfoExA(prodcode, usersid,
5963 MSIINSTALLCONTEXT_USERUNMANAGED,
5964 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
5965 ok(r == ERROR_MORE_DATA,
5966 "Expected ERROR_MORE_DATA, got %d\n", r);
5967 ok(!lstrcmpA(buf, "apple"), "Expected \"apple\", got \"%s\"\n", buf);
5968 ok(sz == 10, "Expected 10, got %d\n", sz);
5970 res = RegSetValueExA(propkey, "notvalid", 0, REG_SZ, (LPBYTE)"invalid", 8);
5971 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5973 /* szProperty is not a valid property */
5974 sz = MAX_PATH;
5975 lstrcpyA(buf, "apple");
5976 r = pMsiGetProductInfoExA(prodcode, usersid,
5977 MSIINSTALLCONTEXT_USERUNMANAGED,
5978 "notvalid", buf, &sz);
5979 ok(r == ERROR_UNKNOWN_PROPERTY,
5980 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
5981 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
5982 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
5984 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
5985 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5987 /* InstallDate value exists */
5988 sz = MAX_PATH;
5989 lstrcpyA(buf, "apple");
5990 r = pMsiGetProductInfoExA(prodcode, usersid,
5991 MSIINSTALLCONTEXT_USERUNMANAGED,
5992 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
5993 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5994 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
5995 ok(sz == 4, "Expected 4, got %d\n", sz);
5997 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
5998 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6000 /* DisplayName value exists */
6001 sz = MAX_PATH;
6002 lstrcpyA(buf, "apple");
6003 r = pMsiGetProductInfoExA(prodcode, usersid,
6004 MSIINSTALLCONTEXT_USERUNMANAGED,
6005 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
6006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6007 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6008 ok(sz == 4, "Expected 4, got %d\n", sz);
6010 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6011 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6013 /* InstallLocation value exists */
6014 sz = MAX_PATH;
6015 lstrcpyA(buf, "apple");
6016 r = pMsiGetProductInfoExA(prodcode, usersid,
6017 MSIINSTALLCONTEXT_USERUNMANAGED,
6018 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
6019 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6020 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
6021 ok(sz == 3, "Expected 3, got %d\n", sz);
6023 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6024 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6026 /* InstallSource value exists */
6027 sz = MAX_PATH;
6028 lstrcpyA(buf, "apple");
6029 r = pMsiGetProductInfoExA(prodcode, usersid,
6030 MSIINSTALLCONTEXT_USERUNMANAGED,
6031 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
6032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6033 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
6034 ok(sz == 6, "Expected 6, got %d\n", sz);
6036 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6037 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6039 /* LocalPackage value exists */
6040 sz = MAX_PATH;
6041 lstrcpyA(buf, "apple");
6042 r = pMsiGetProductInfoExA(prodcode, usersid,
6043 MSIINSTALLCONTEXT_USERUNMANAGED,
6044 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
6045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6046 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
6047 ok(sz == 5, "Expected 5, got %d\n", sz);
6049 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6050 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6052 /* Publisher value exists */
6053 sz = MAX_PATH;
6054 lstrcpyA(buf, "apple");
6055 r = pMsiGetProductInfoExA(prodcode, usersid,
6056 MSIINSTALLCONTEXT_USERUNMANAGED,
6057 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
6058 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6059 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
6060 ok(sz == 3, "Expected 3, got %d\n", sz);
6062 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6063 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6065 /* URLInfoAbout value exists */
6066 sz = MAX_PATH;
6067 lstrcpyA(buf, "apple");
6068 r = pMsiGetProductInfoExA(prodcode, usersid,
6069 MSIINSTALLCONTEXT_USERUNMANAGED,
6070 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
6071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6072 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
6073 ok(sz == 5, "Expected 5, got %d\n", sz);
6075 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6076 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6078 /* URLUpdateInfo value exists */
6079 sz = MAX_PATH;
6080 lstrcpyA(buf, "apple");
6081 r = pMsiGetProductInfoExA(prodcode, usersid,
6082 MSIINSTALLCONTEXT_USERUNMANAGED,
6083 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
6084 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6085 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
6086 ok(sz == 6, "Expected 6, got %d\n", sz);
6088 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6089 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6091 /* VersionMinor value exists */
6092 sz = MAX_PATH;
6093 lstrcpyA(buf, "apple");
6094 r = pMsiGetProductInfoExA(prodcode, usersid,
6095 MSIINSTALLCONTEXT_USERUNMANAGED,
6096 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
6097 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6098 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
6099 ok(sz == 1, "Expected 1, got %d\n", sz);
6101 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6102 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6104 /* VersionMajor value exists */
6105 sz = MAX_PATH;
6106 lstrcpyA(buf, "apple");
6107 r = pMsiGetProductInfoExA(prodcode, usersid,
6108 MSIINSTALLCONTEXT_USERUNMANAGED,
6109 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
6110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6111 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
6112 ok(sz == 1, "Expected 1, got %d\n", sz);
6114 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6115 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6117 /* DisplayVersion value exists */
6118 sz = MAX_PATH;
6119 lstrcpyA(buf, "apple");
6120 r = pMsiGetProductInfoExA(prodcode, usersid,
6121 MSIINSTALLCONTEXT_USERUNMANAGED,
6122 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
6123 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6124 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
6125 ok(sz == 5, "Expected 5, got %d\n", sz);
6127 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6128 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6130 /* ProductID value exists */
6131 sz = MAX_PATH;
6132 lstrcpyA(buf, "apple");
6133 r = pMsiGetProductInfoExA(prodcode, usersid,
6134 MSIINSTALLCONTEXT_USERUNMANAGED,
6135 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
6136 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6137 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
6138 ok(sz == 2, "Expected 2, got %d\n", sz);
6140 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6141 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6143 /* RegCompany value exists */
6144 sz = MAX_PATH;
6145 lstrcpyA(buf, "apple");
6146 r = pMsiGetProductInfoExA(prodcode, usersid,
6147 MSIINSTALLCONTEXT_USERUNMANAGED,
6148 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
6149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6150 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
6151 ok(sz == 4, "Expected 4, got %d\n", sz);
6153 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6154 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6156 /* RegOwner value exists */
6157 sz = MAX_PATH;
6158 lstrcpyA(buf, "apple");
6159 r = pMsiGetProductInfoExA(prodcode, usersid,
6160 MSIINSTALLCONTEXT_USERUNMANAGED,
6161 INSTALLPROPERTY_REGOWNERA, buf, &sz);
6162 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6163 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
6164 ok(sz == 5, "Expected 5, got %d\n", sz);
6166 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6167 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6169 /* Transforms value exists */
6170 sz = MAX_PATH;
6171 lstrcpyA(buf, "apple");
6172 r = pMsiGetProductInfoExA(prodcode, usersid,
6173 MSIINSTALLCONTEXT_USERUNMANAGED,
6174 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
6175 ok(r == ERROR_UNKNOWN_PRODUCT,
6176 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6177 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6178 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6180 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6181 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6183 /* Language value exists */
6184 sz = MAX_PATH;
6185 lstrcpyA(buf, "apple");
6186 r = pMsiGetProductInfoExA(prodcode, usersid,
6187 MSIINSTALLCONTEXT_USERUNMANAGED,
6188 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
6189 ok(r == ERROR_UNKNOWN_PRODUCT,
6190 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6191 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6192 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6194 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6195 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6197 /* ProductName value exists */
6198 sz = MAX_PATH;
6199 lstrcpyA(buf, "apple");
6200 r = pMsiGetProductInfoExA(prodcode, usersid,
6201 MSIINSTALLCONTEXT_USERUNMANAGED,
6202 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
6203 ok(r == ERROR_UNKNOWN_PRODUCT,
6204 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6205 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6206 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6208 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6209 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6211 /* FIXME */
6213 /* AssignmentType value exists */
6214 sz = MAX_PATH;
6215 lstrcpyA(buf, "apple");
6216 r = pMsiGetProductInfoExA(prodcode, usersid,
6217 MSIINSTALLCONTEXT_USERUNMANAGED,
6218 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
6219 ok(r == ERROR_UNKNOWN_PRODUCT,
6220 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6221 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6222 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6224 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6225 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6227 /* PackageCode value exists */
6228 sz = MAX_PATH;
6229 lstrcpyA(buf, "apple");
6230 r = pMsiGetProductInfoExA(prodcode, usersid,
6231 MSIINSTALLCONTEXT_USERUNMANAGED,
6232 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
6233 ok(r == ERROR_UNKNOWN_PRODUCT,
6234 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6235 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6236 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6238 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6239 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6241 /* Version value exists */
6242 sz = MAX_PATH;
6243 lstrcpyA(buf, "apple");
6244 r = pMsiGetProductInfoExA(prodcode, usersid,
6245 MSIINSTALLCONTEXT_USERUNMANAGED,
6246 INSTALLPROPERTY_VERSIONA, buf, &sz);
6247 ok(r == ERROR_UNKNOWN_PRODUCT,
6248 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6249 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6250 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6252 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6253 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6255 /* ProductIcon value exists */
6256 sz = MAX_PATH;
6257 lstrcpyA(buf, "apple");
6258 r = pMsiGetProductInfoExA(prodcode, usersid,
6259 MSIINSTALLCONTEXT_USERUNMANAGED,
6260 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
6261 ok(r == ERROR_UNKNOWN_PRODUCT,
6262 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6263 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6264 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6266 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6267 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6269 /* PackageName value exists */
6270 sz = MAX_PATH;
6271 lstrcpyA(buf, "apple");
6272 r = pMsiGetProductInfoExA(prodcode, usersid,
6273 MSIINSTALLCONTEXT_USERUNMANAGED,
6274 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
6275 ok(r == ERROR_UNKNOWN_PRODUCT,
6276 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6277 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6278 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6280 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6283 /* AuthorizedLUAApp value exists */
6284 sz = MAX_PATH;
6285 lstrcpyA(buf, "apple");
6286 r = pMsiGetProductInfoExA(prodcode, usersid,
6287 MSIINSTALLCONTEXT_USERUNMANAGED,
6288 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
6289 ok(r == ERROR_UNKNOWN_PRODUCT,
6290 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6291 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6292 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6294 RegDeleteValueA(propkey, "AuthorizedLUAApp");
6295 RegDeleteValueA(propkey, "PackageName");
6296 RegDeleteValueA(propkey, "ProductIcon");
6297 RegDeleteValueA(propkey, "Version");
6298 RegDeleteValueA(propkey, "PackageCode");
6299 RegDeleteValueA(propkey, "AssignmentType");
6300 RegDeleteValueA(propkey, "ProductName");
6301 RegDeleteValueA(propkey, "Language");
6302 RegDeleteValueA(propkey, "Transforms");
6303 RegDeleteValueA(propkey, "RegOwner");
6304 RegDeleteValueA(propkey, "RegCompany");
6305 RegDeleteValueA(propkey, "ProductID");
6306 RegDeleteValueA(propkey, "DisplayVersion");
6307 RegDeleteValueA(propkey, "VersionMajor");
6308 RegDeleteValueA(propkey, "VersionMinor");
6309 RegDeleteValueA(propkey, "URLUpdateInfo");
6310 RegDeleteValueA(propkey, "URLInfoAbout");
6311 RegDeleteValueA(propkey, "Publisher");
6312 RegDeleteValueA(propkey, "LocalPackage");
6313 RegDeleteValueA(propkey, "InstallSource");
6314 RegDeleteValueA(propkey, "InstallLocation");
6315 RegDeleteValueA(propkey, "DisplayName");
6316 RegDeleteValueA(propkey, "InstallDate");
6317 RegDeleteValueA(propkey, "HelpTelephone");
6318 RegDeleteValueA(propkey, "HelpLink");
6319 RegDeleteValueA(propkey, "LocalPackage");
6320 RegDeleteKeyA(propkey, "");
6321 RegCloseKey(propkey);
6322 RegDeleteKeyA(localkey, "");
6323 RegCloseKey(localkey);
6325 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
6326 lstrcatA(keypath, usersid);
6327 lstrcatA(keypath, "\\Installer\\Products\\");
6328 lstrcatA(keypath, prod_squashed);
6330 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
6331 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6333 /* user product key exists */
6334 sz = MAX_PATH;
6335 lstrcpyA(buf, "apple");
6336 r = pMsiGetProductInfoExA(prodcode, usersid,
6337 MSIINSTALLCONTEXT_USERUNMANAGED,
6338 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6339 ok(r == ERROR_UNKNOWN_PRODUCT,
6340 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6341 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6342 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6344 RegDeleteKeyA(userkey, "");
6345 RegCloseKey(userkey);
6347 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
6348 lstrcatA(keypath, prod_squashed);
6350 res = RegCreateKeyExA(HKEY_CURRENT_USER, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
6351 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6353 sz = MAX_PATH;
6354 lstrcpyA(buf, "apple");
6355 r = pMsiGetProductInfoExA(prodcode, usersid,
6356 MSIINSTALLCONTEXT_USERUNMANAGED,
6357 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6358 ok(r == ERROR_SUCCESS || broken(r == ERROR_UNKNOWN_PRODUCT), "Expected ERROR_SUCCESS, got %d\n", r);
6359 if (r == ERROR_UNKNOWN_PRODUCT)
6361 win_skip("skipping remaining tests for MsiGetProductInfoEx\n");
6362 delete_key(prodkey, "", access);
6363 RegCloseKey(prodkey);
6364 return;
6366 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
6367 ok(sz == 1, "Expected 1, got %d\n", sz);
6369 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
6370 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6372 /* HelpLink value exists */
6373 sz = MAX_PATH;
6374 lstrcpyA(buf, "apple");
6375 r = pMsiGetProductInfoExA(prodcode, usersid,
6376 MSIINSTALLCONTEXT_USERUNMANAGED,
6377 INSTALLPROPERTY_HELPLINKA, buf, &sz);
6378 ok(r == ERROR_UNKNOWN_PROPERTY,
6379 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6380 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6381 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6383 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
6384 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6386 /* HelpTelephone value exists */
6387 sz = MAX_PATH;
6388 lstrcpyA(buf, "apple");
6389 r = pMsiGetProductInfoExA(prodcode, usersid,
6390 MSIINSTALLCONTEXT_USERUNMANAGED,
6391 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
6392 ok(r == ERROR_UNKNOWN_PROPERTY,
6393 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6394 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6395 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6397 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
6398 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6400 /* InstallDate value exists */
6401 sz = MAX_PATH;
6402 lstrcpyA(buf, "apple");
6403 r = pMsiGetProductInfoExA(prodcode, usersid,
6404 MSIINSTALLCONTEXT_USERUNMANAGED,
6405 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
6406 ok(r == ERROR_UNKNOWN_PROPERTY,
6407 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6408 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6409 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6411 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
6412 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6414 /* DisplayName value exists */
6415 sz = MAX_PATH;
6416 lstrcpyA(buf, "apple");
6417 r = pMsiGetProductInfoExA(prodcode, usersid,
6418 MSIINSTALLCONTEXT_USERUNMANAGED,
6419 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
6420 ok(r == ERROR_UNKNOWN_PROPERTY,
6421 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6422 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6423 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6425 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6426 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6428 /* InstallLocation value exists */
6429 sz = MAX_PATH;
6430 lstrcpyA(buf, "apple");
6431 r = pMsiGetProductInfoExA(prodcode, usersid,
6432 MSIINSTALLCONTEXT_USERUNMANAGED,
6433 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
6434 ok(r == ERROR_UNKNOWN_PROPERTY,
6435 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6436 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6437 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6439 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6440 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6442 /* InstallSource value exists */
6443 sz = MAX_PATH;
6444 lstrcpyA(buf, "apple");
6445 r = pMsiGetProductInfoExA(prodcode, usersid,
6446 MSIINSTALLCONTEXT_USERUNMANAGED,
6447 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
6448 ok(r == ERROR_UNKNOWN_PROPERTY,
6449 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6450 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6451 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6453 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6454 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6456 /* LocalPackage value exists */
6457 sz = MAX_PATH;
6458 lstrcpyA(buf, "apple");
6459 r = pMsiGetProductInfoExA(prodcode, usersid,
6460 MSIINSTALLCONTEXT_USERUNMANAGED,
6461 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
6462 ok(r == ERROR_UNKNOWN_PROPERTY,
6463 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6464 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6465 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6467 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6468 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6470 /* Publisher value exists */
6471 sz = MAX_PATH;
6472 lstrcpyA(buf, "apple");
6473 r = pMsiGetProductInfoExA(prodcode, usersid,
6474 MSIINSTALLCONTEXT_USERUNMANAGED,
6475 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
6476 ok(r == ERROR_UNKNOWN_PROPERTY,
6477 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6478 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6479 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6481 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6482 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6484 /* URLInfoAbout value exists */
6485 sz = MAX_PATH;
6486 lstrcpyA(buf, "apple");
6487 r = pMsiGetProductInfoExA(prodcode, usersid,
6488 MSIINSTALLCONTEXT_USERUNMANAGED,
6489 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
6490 ok(r == ERROR_UNKNOWN_PROPERTY,
6491 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6492 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6493 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6495 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6496 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6498 /* URLUpdateInfo value exists */
6499 sz = MAX_PATH;
6500 lstrcpyA(buf, "apple");
6501 r = pMsiGetProductInfoExA(prodcode, usersid,
6502 MSIINSTALLCONTEXT_USERUNMANAGED,
6503 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
6504 ok(r == ERROR_UNKNOWN_PROPERTY,
6505 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6506 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6507 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6509 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6510 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6512 /* VersionMinor value exists */
6513 sz = MAX_PATH;
6514 lstrcpyA(buf, "apple");
6515 r = pMsiGetProductInfoExA(prodcode, usersid,
6516 MSIINSTALLCONTEXT_USERUNMANAGED,
6517 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
6518 ok(r == ERROR_UNKNOWN_PROPERTY,
6519 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6520 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6521 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6523 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6524 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6526 /* VersionMajor value exists */
6527 sz = MAX_PATH;
6528 lstrcpyA(buf, "apple");
6529 r = pMsiGetProductInfoExA(prodcode, usersid,
6530 MSIINSTALLCONTEXT_USERUNMANAGED,
6531 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
6532 ok(r == ERROR_UNKNOWN_PROPERTY,
6533 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6534 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6535 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6537 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6538 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6540 /* DisplayVersion value exists */
6541 sz = MAX_PATH;
6542 lstrcpyA(buf, "apple");
6543 r = pMsiGetProductInfoExA(prodcode, usersid,
6544 MSIINSTALLCONTEXT_USERUNMANAGED,
6545 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
6546 ok(r == ERROR_UNKNOWN_PROPERTY,
6547 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6548 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6549 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6551 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6552 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6554 /* ProductID value exists */
6555 sz = MAX_PATH;
6556 lstrcpyA(buf, "apple");
6557 r = pMsiGetProductInfoExA(prodcode, usersid,
6558 MSIINSTALLCONTEXT_USERUNMANAGED,
6559 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
6560 ok(r == ERROR_UNKNOWN_PROPERTY,
6561 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6562 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6563 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6565 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6566 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6568 /* RegCompany value exists */
6569 sz = MAX_PATH;
6570 lstrcpyA(buf, "apple");
6571 r = pMsiGetProductInfoExA(prodcode, usersid,
6572 MSIINSTALLCONTEXT_USERUNMANAGED,
6573 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
6574 ok(r == ERROR_UNKNOWN_PROPERTY,
6575 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6576 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6577 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6579 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6580 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6582 /* RegOwner value exists */
6583 sz = MAX_PATH;
6584 lstrcpyA(buf, "apple");
6585 r = pMsiGetProductInfoExA(prodcode, usersid,
6586 MSIINSTALLCONTEXT_USERUNMANAGED,
6587 INSTALLPROPERTY_REGOWNERA, buf, &sz);
6588 ok(r == ERROR_UNKNOWN_PROPERTY,
6589 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
6590 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6591 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6593 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
6594 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6596 /* Transforms value exists */
6597 sz = MAX_PATH;
6598 lstrcpyA(buf, "apple");
6599 r = pMsiGetProductInfoExA(prodcode, usersid,
6600 MSIINSTALLCONTEXT_USERUNMANAGED,
6601 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
6602 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6603 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
6604 ok(sz == 5, "Expected 5, got %d\n", sz);
6606 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
6607 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6609 /* Language value exists */
6610 sz = MAX_PATH;
6611 lstrcpyA(buf, "apple");
6612 r = pMsiGetProductInfoExA(prodcode, usersid,
6613 MSIINSTALLCONTEXT_USERUNMANAGED,
6614 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
6615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6616 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
6617 ok(sz == 4, "Expected 4, got %d\n", sz);
6619 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
6620 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6622 /* ProductName value exists */
6623 sz = MAX_PATH;
6624 lstrcpyA(buf, "apple");
6625 r = pMsiGetProductInfoExA(prodcode, usersid,
6626 MSIINSTALLCONTEXT_USERUNMANAGED,
6627 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
6628 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6629 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6630 ok(sz == 4, "Expected 4, got %d\n", sz);
6632 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
6633 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6635 /* FIXME */
6637 /* AssignmentType value exists */
6638 sz = MAX_PATH;
6639 lstrcpyA(buf, "apple");
6640 r = pMsiGetProductInfoExA(prodcode, usersid,
6641 MSIINSTALLCONTEXT_USERUNMANAGED,
6642 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
6643 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6644 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
6645 ok(sz == 0, "Expected 0, got %d\n", sz);
6647 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
6648 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6650 /* FIXME */
6652 /* PackageCode value exists */
6653 sz = MAX_PATH;
6654 lstrcpyA(buf, "apple");
6655 r = pMsiGetProductInfoExA(prodcode, usersid,
6656 MSIINSTALLCONTEXT_USERUNMANAGED,
6657 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
6658 todo_wine
6660 ok(r == ERROR_BAD_CONFIGURATION,
6661 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
6662 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6663 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6666 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
6667 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6669 /* Version value exists */
6670 sz = MAX_PATH;
6671 lstrcpyA(buf, "apple");
6672 r = pMsiGetProductInfoExA(prodcode, usersid,
6673 MSIINSTALLCONTEXT_USERUNMANAGED,
6674 INSTALLPROPERTY_VERSIONA, buf, &sz);
6675 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6676 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
6677 ok(sz == 3, "Expected 3, got %d\n", sz);
6679 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
6680 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6682 /* ProductIcon value exists */
6683 sz = MAX_PATH;
6684 lstrcpyA(buf, "apple");
6685 r = pMsiGetProductInfoExA(prodcode, usersid,
6686 MSIINSTALLCONTEXT_USERUNMANAGED,
6687 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
6688 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6689 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
6690 ok(sz == 4, "Expected 4, got %d\n", sz);
6692 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
6693 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6695 /* PackageName value exists */
6696 sz = MAX_PATH;
6697 lstrcpyA(buf, "apple");
6698 r = pMsiGetProductInfoExA(prodcode, usersid,
6699 MSIINSTALLCONTEXT_USERUNMANAGED,
6700 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
6701 todo_wine
6703 ok(r == ERROR_UNKNOWN_PRODUCT,
6704 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6705 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6706 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6709 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
6710 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6712 /* AuthorizedLUAApp value exists */
6713 sz = MAX_PATH;
6714 lstrcpyA(buf, "apple");
6715 r = pMsiGetProductInfoExA(prodcode, usersid,
6716 MSIINSTALLCONTEXT_USERUNMANAGED,
6717 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
6718 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6719 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
6720 ok(sz == 4, "Expected 4, got %d\n", sz);
6722 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
6723 RegDeleteValueA(prodkey, "PackageName");
6724 RegDeleteValueA(prodkey, "ProductIcon");
6725 RegDeleteValueA(prodkey, "Version");
6726 RegDeleteValueA(prodkey, "PackageCode");
6727 RegDeleteValueA(prodkey, "AssignmentType");
6728 RegDeleteValueA(prodkey, "ProductName");
6729 RegDeleteValueA(prodkey, "Language");
6730 RegDeleteValueA(prodkey, "Transforms");
6731 RegDeleteValueA(prodkey, "RegOwner");
6732 RegDeleteValueA(prodkey, "RegCompany");
6733 RegDeleteValueA(prodkey, "ProductID");
6734 RegDeleteValueA(prodkey, "DisplayVersion");
6735 RegDeleteValueA(prodkey, "VersionMajor");
6736 RegDeleteValueA(prodkey, "VersionMinor");
6737 RegDeleteValueA(prodkey, "URLUpdateInfo");
6738 RegDeleteValueA(prodkey, "URLInfoAbout");
6739 RegDeleteValueA(prodkey, "Publisher");
6740 RegDeleteValueA(prodkey, "LocalPackage");
6741 RegDeleteValueA(prodkey, "InstallSource");
6742 RegDeleteValueA(prodkey, "InstallLocation");
6743 RegDeleteValueA(prodkey, "DisplayName");
6744 RegDeleteValueA(prodkey, "InstallDate");
6745 RegDeleteValueA(prodkey, "HelpTelephone");
6746 RegDeleteValueA(prodkey, "HelpLink");
6747 RegDeleteValueA(prodkey, "LocalPackage");
6748 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
6749 RegCloseKey(prodkey);
6751 /* MSIINSTALLCONTEXT_USERMANAGED */
6753 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
6754 lstrcatA(keypath, usersid);
6755 lstrcatA(keypath, "\\Products\\");
6756 lstrcatA(keypath, prod_squashed);
6758 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
6759 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6761 /* local user product key exists */
6762 sz = MAX_PATH;
6763 lstrcpyA(buf, "apple");
6764 r = pMsiGetProductInfoExA(prodcode, usersid,
6765 MSIINSTALLCONTEXT_USERMANAGED,
6766 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6767 ok(r == ERROR_UNKNOWN_PRODUCT,
6768 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6769 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6770 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6772 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
6773 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6775 /* InstallProperties key exists */
6776 sz = MAX_PATH;
6777 lstrcpyA(buf, "apple");
6778 r = pMsiGetProductInfoExA(prodcode, usersid,
6779 MSIINSTALLCONTEXT_USERMANAGED,
6780 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6781 ok(r == ERROR_UNKNOWN_PRODUCT,
6782 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
6783 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
6784 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
6786 res = RegSetValueExA(propkey, "ManagedLocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6787 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6789 /* ManagedLocalPackage value exists */
6790 sz = MAX_PATH;
6791 lstrcpyA(buf, "apple");
6792 r = pMsiGetProductInfoExA(prodcode, usersid,
6793 MSIINSTALLCONTEXT_USERMANAGED,
6794 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
6795 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6796 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
6797 ok(sz == 1, "Expected 1, got %d\n", sz);
6799 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
6800 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6802 /* HelpLink value exists */
6803 sz = MAX_PATH;
6804 lstrcpyA(buf, "apple");
6805 r = pMsiGetProductInfoExA(prodcode, usersid,
6806 MSIINSTALLCONTEXT_USERMANAGED,
6807 INSTALLPROPERTY_HELPLINKA, buf, &sz);
6808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6809 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
6810 ok(sz == 4, "Expected 4, got %d\n", sz);
6812 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
6813 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6815 /* HelpTelephone value exists */
6816 sz = MAX_PATH;
6817 lstrcpyA(buf, "apple");
6818 r = pMsiGetProductInfoExA(prodcode, usersid,
6819 MSIINSTALLCONTEXT_USERMANAGED,
6820 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
6821 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6822 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
6823 ok(sz == 5, "Expected 5, got %d\n", sz);
6825 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
6826 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6828 /* InstallDate value exists */
6829 sz = MAX_PATH;
6830 lstrcpyA(buf, "apple");
6831 r = pMsiGetProductInfoExA(prodcode, usersid,
6832 MSIINSTALLCONTEXT_USERMANAGED,
6833 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
6834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6835 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
6836 ok(sz == 4, "Expected 4, got %d\n", sz);
6838 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
6839 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6841 /* DisplayName value exists */
6842 sz = MAX_PATH;
6843 lstrcpyA(buf, "apple");
6844 r = pMsiGetProductInfoExA(prodcode, usersid,
6845 MSIINSTALLCONTEXT_USERMANAGED,
6846 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
6847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6848 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
6849 ok(sz == 4, "Expected 4, got %d\n", sz);
6851 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
6852 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6854 /* InstallLocation value exists */
6855 sz = MAX_PATH;
6856 lstrcpyA(buf, "apple");
6857 r = pMsiGetProductInfoExA(prodcode, usersid,
6858 MSIINSTALLCONTEXT_USERMANAGED,
6859 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
6860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6861 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
6862 ok(sz == 3, "Expected 3, got %d\n", sz);
6864 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
6865 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6867 /* InstallSource value exists */
6868 sz = MAX_PATH;
6869 lstrcpyA(buf, "apple");
6870 r = pMsiGetProductInfoExA(prodcode, usersid,
6871 MSIINSTALLCONTEXT_USERMANAGED,
6872 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
6873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6874 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
6875 ok(sz == 6, "Expected 6, got %d\n", sz);
6877 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
6878 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6880 /* LocalPackage value exists */
6881 sz = MAX_PATH;
6882 lstrcpyA(buf, "apple");
6883 r = pMsiGetProductInfoExA(prodcode, usersid,
6884 MSIINSTALLCONTEXT_USERMANAGED,
6885 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
6886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6887 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
6888 ok(sz == 5, "Expected 5, got %d\n", sz);
6890 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
6891 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6893 /* Publisher value exists */
6894 sz = MAX_PATH;
6895 lstrcpyA(buf, "apple");
6896 r = pMsiGetProductInfoExA(prodcode, usersid,
6897 MSIINSTALLCONTEXT_USERMANAGED,
6898 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
6899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6900 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
6901 ok(sz == 3, "Expected 3, got %d\n", sz);
6903 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
6904 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6906 /* URLInfoAbout value exists */
6907 sz = MAX_PATH;
6908 lstrcpyA(buf, "apple");
6909 r = pMsiGetProductInfoExA(prodcode, usersid,
6910 MSIINSTALLCONTEXT_USERMANAGED,
6911 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
6912 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6913 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
6914 ok(sz == 5, "Expected 5, got %d\n", sz);
6916 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
6917 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6919 /* URLUpdateInfo value exists */
6920 sz = MAX_PATH;
6921 lstrcpyA(buf, "apple");
6922 r = pMsiGetProductInfoExA(prodcode, usersid,
6923 MSIINSTALLCONTEXT_USERMANAGED,
6924 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
6925 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6926 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
6927 ok(sz == 6, "Expected 6, got %d\n", sz);
6929 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
6930 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6932 /* VersionMinor value exists */
6933 sz = MAX_PATH;
6934 lstrcpyA(buf, "apple");
6935 r = pMsiGetProductInfoExA(prodcode, usersid,
6936 MSIINSTALLCONTEXT_USERMANAGED,
6937 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
6938 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6939 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
6940 ok(sz == 1, "Expected 1, got %d\n", sz);
6942 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
6943 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6945 /* VersionMajor value exists */
6946 sz = MAX_PATH;
6947 lstrcpyA(buf, "apple");
6948 r = pMsiGetProductInfoExA(prodcode, usersid,
6949 MSIINSTALLCONTEXT_USERMANAGED,
6950 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
6951 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6952 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
6953 ok(sz == 1, "Expected 1, got %d\n", sz);
6955 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
6956 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6958 /* DisplayVersion value exists */
6959 sz = MAX_PATH;
6960 lstrcpyA(buf, "apple");
6961 r = pMsiGetProductInfoExA(prodcode, usersid,
6962 MSIINSTALLCONTEXT_USERMANAGED,
6963 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
6964 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6965 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
6966 ok(sz == 5, "Expected 5, got %d\n", sz);
6968 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
6969 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6971 /* ProductID value exists */
6972 sz = MAX_PATH;
6973 lstrcpyA(buf, "apple");
6974 r = pMsiGetProductInfoExA(prodcode, usersid,
6975 MSIINSTALLCONTEXT_USERMANAGED,
6976 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
6977 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6978 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
6979 ok(sz == 2, "Expected 2, got %d\n", sz);
6981 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
6982 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6984 /* RegCompany value exists */
6985 sz = MAX_PATH;
6986 lstrcpyA(buf, "apple");
6987 r = pMsiGetProductInfoExA(prodcode, usersid,
6988 MSIINSTALLCONTEXT_USERMANAGED,
6989 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
6990 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6991 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
6992 ok(sz == 4, "Expected 4, got %d\n", sz);
6994 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
6995 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6997 /* RegOwner value exists */
6998 sz = MAX_PATH;
6999 lstrcpyA(buf, "apple");
7000 r = pMsiGetProductInfoExA(prodcode, usersid,
7001 MSIINSTALLCONTEXT_USERMANAGED,
7002 INSTALLPROPERTY_REGOWNERA, buf, &sz);
7003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7004 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
7005 ok(sz == 5, "Expected 5, got %d\n", sz);
7007 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
7008 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7010 /* Transforms value exists */
7011 sz = MAX_PATH;
7012 lstrcpyA(buf, "apple");
7013 r = pMsiGetProductInfoExA(prodcode, usersid,
7014 MSIINSTALLCONTEXT_USERMANAGED,
7015 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
7016 ok(r == ERROR_UNKNOWN_PRODUCT,
7017 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7018 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7019 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7021 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
7022 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7024 /* Language value exists */
7025 sz = MAX_PATH;
7026 lstrcpyA(buf, "apple");
7027 r = pMsiGetProductInfoExA(prodcode, usersid,
7028 MSIINSTALLCONTEXT_USERMANAGED,
7029 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
7030 ok(r == ERROR_UNKNOWN_PRODUCT,
7031 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7032 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7033 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7035 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
7036 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7038 /* ProductName value exists */
7039 sz = MAX_PATH;
7040 lstrcpyA(buf, "apple");
7041 r = pMsiGetProductInfoExA(prodcode, usersid,
7042 MSIINSTALLCONTEXT_USERMANAGED,
7043 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
7044 ok(r == ERROR_UNKNOWN_PRODUCT,
7045 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7046 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7047 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7049 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
7050 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7052 /* FIXME */
7054 /* AssignmentType value exists */
7055 sz = MAX_PATH;
7056 lstrcpyA(buf, "apple");
7057 r = pMsiGetProductInfoExA(prodcode, usersid,
7058 MSIINSTALLCONTEXT_USERMANAGED,
7059 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
7060 ok(r == ERROR_UNKNOWN_PRODUCT,
7061 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7062 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7063 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7065 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
7066 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7068 /* PackageCode value exists */
7069 sz = MAX_PATH;
7070 lstrcpyA(buf, "apple");
7071 r = pMsiGetProductInfoExA(prodcode, usersid,
7072 MSIINSTALLCONTEXT_USERMANAGED,
7073 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
7074 ok(r == ERROR_UNKNOWN_PRODUCT,
7075 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7076 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7077 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7079 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
7080 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7082 /* Version value exists */
7083 sz = MAX_PATH;
7084 lstrcpyA(buf, "apple");
7085 r = pMsiGetProductInfoExA(prodcode, usersid,
7086 MSIINSTALLCONTEXT_USERMANAGED,
7087 INSTALLPROPERTY_VERSIONA, buf, &sz);
7088 ok(r == ERROR_UNKNOWN_PRODUCT,
7089 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7090 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7091 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7093 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
7094 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7096 /* ProductIcon value exists */
7097 sz = MAX_PATH;
7098 lstrcpyA(buf, "apple");
7099 r = pMsiGetProductInfoExA(prodcode, usersid,
7100 MSIINSTALLCONTEXT_USERMANAGED,
7101 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
7102 ok(r == ERROR_UNKNOWN_PRODUCT,
7103 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7104 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7105 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7107 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
7108 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7110 /* PackageName value exists */
7111 sz = MAX_PATH;
7112 lstrcpyA(buf, "apple");
7113 r = pMsiGetProductInfoExA(prodcode, usersid,
7114 MSIINSTALLCONTEXT_USERMANAGED,
7115 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
7116 ok(r == ERROR_UNKNOWN_PRODUCT,
7117 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7118 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7119 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7121 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
7122 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7124 /* AuthorizedLUAApp value exists */
7125 sz = MAX_PATH;
7126 lstrcpyA(buf, "apple");
7127 r = pMsiGetProductInfoExA(prodcode, usersid,
7128 MSIINSTALLCONTEXT_USERMANAGED,
7129 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
7130 ok(r == ERROR_UNKNOWN_PRODUCT,
7131 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7132 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7133 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7135 RegDeleteValueA(propkey, "AuthorizedLUAApp");
7136 RegDeleteValueA(propkey, "PackageName");
7137 RegDeleteValueA(propkey, "ProductIcon");
7138 RegDeleteValueA(propkey, "Version");
7139 RegDeleteValueA(propkey, "PackageCode");
7140 RegDeleteValueA(propkey, "AssignmentType");
7141 RegDeleteValueA(propkey, "ProductName");
7142 RegDeleteValueA(propkey, "Language");
7143 RegDeleteValueA(propkey, "Transforms");
7144 RegDeleteValueA(propkey, "RegOwner");
7145 RegDeleteValueA(propkey, "RegCompany");
7146 RegDeleteValueA(propkey, "ProductID");
7147 RegDeleteValueA(propkey, "DisplayVersion");
7148 RegDeleteValueA(propkey, "VersionMajor");
7149 RegDeleteValueA(propkey, "VersionMinor");
7150 RegDeleteValueA(propkey, "URLUpdateInfo");
7151 RegDeleteValueA(propkey, "URLInfoAbout");
7152 RegDeleteValueA(propkey, "Publisher");
7153 RegDeleteValueA(propkey, "LocalPackage");
7154 RegDeleteValueA(propkey, "InstallSource");
7155 RegDeleteValueA(propkey, "InstallLocation");
7156 RegDeleteValueA(propkey, "DisplayName");
7157 RegDeleteValueA(propkey, "InstallDate");
7158 RegDeleteValueA(propkey, "HelpTelephone");
7159 RegDeleteValueA(propkey, "HelpLink");
7160 RegDeleteValueA(propkey, "ManagedLocalPackage");
7161 delete_key(propkey, "", access & KEY_WOW64_64KEY);
7162 RegCloseKey(propkey);
7163 delete_key(localkey, "", access & KEY_WOW64_64KEY);
7164 RegCloseKey(localkey);
7166 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
7167 lstrcatA(keypath, usersid);
7168 lstrcatA(keypath, "\\Installer\\Products\\");
7169 lstrcatA(keypath, prod_squashed);
7171 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
7172 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7174 /* user product key exists */
7175 sz = MAX_PATH;
7176 lstrcpyA(buf, "apple");
7177 r = pMsiGetProductInfoExA(prodcode, usersid,
7178 MSIINSTALLCONTEXT_USERMANAGED,
7179 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7180 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7181 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
7182 ok(sz == 1, "Expected 1, got %d\n", sz);
7184 delete_key(userkey, "", access & KEY_WOW64_64KEY);
7185 RegCloseKey(userkey);
7187 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
7188 lstrcatA(keypath, prod_squashed);
7190 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
7191 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7193 /* current user product key exists */
7194 sz = MAX_PATH;
7195 lstrcpyA(buf, "apple");
7196 r = pMsiGetProductInfoExA(prodcode, usersid,
7197 MSIINSTALLCONTEXT_USERMANAGED,
7198 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7199 ok(r == ERROR_UNKNOWN_PRODUCT,
7200 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7201 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7202 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7204 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7205 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7207 /* HelpLink value exists, user product key does not exist */
7208 sz = MAX_PATH;
7209 lstrcpyA(buf, "apple");
7210 r = pMsiGetProductInfoExA(prodcode, usersid,
7211 MSIINSTALLCONTEXT_USERMANAGED,
7212 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7213 ok(r == ERROR_UNKNOWN_PRODUCT,
7214 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7215 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7216 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7218 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
7219 lstrcatA(keypath, usersid);
7220 lstrcatA(keypath, "\\Installer\\Products\\");
7221 lstrcatA(keypath, prod_squashed);
7223 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
7224 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7226 res = RegSetValueExA(userkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7227 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7229 /* HelpLink value exists, user product key does exist */
7230 sz = MAX_PATH;
7231 lstrcpyA(buf, "apple");
7232 r = pMsiGetProductInfoExA(prodcode, usersid,
7233 MSIINSTALLCONTEXT_USERMANAGED,
7234 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7235 ok(r == ERROR_UNKNOWN_PROPERTY,
7236 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7237 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7238 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7240 res = RegSetValueExA(userkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
7241 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7243 /* HelpTelephone value exists */
7244 sz = MAX_PATH;
7245 lstrcpyA(buf, "apple");
7246 r = pMsiGetProductInfoExA(prodcode, usersid,
7247 MSIINSTALLCONTEXT_USERMANAGED,
7248 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
7249 ok(r == ERROR_UNKNOWN_PROPERTY,
7250 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7251 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7252 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7254 res = RegSetValueExA(userkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
7255 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7257 /* InstallDate value exists */
7258 sz = MAX_PATH;
7259 lstrcpyA(buf, "apple");
7260 r = pMsiGetProductInfoExA(prodcode, usersid,
7261 MSIINSTALLCONTEXT_USERMANAGED,
7262 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
7263 ok(r == ERROR_UNKNOWN_PROPERTY,
7264 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7265 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7266 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7268 res = RegSetValueExA(userkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
7269 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7271 /* DisplayName value exists */
7272 sz = MAX_PATH;
7273 lstrcpyA(buf, "apple");
7274 r = pMsiGetProductInfoExA(prodcode, usersid,
7275 MSIINSTALLCONTEXT_USERMANAGED,
7276 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
7277 ok(r == ERROR_UNKNOWN_PROPERTY,
7278 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7279 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7280 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7282 res = RegSetValueExA(userkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
7283 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7285 /* InstallLocation value exists */
7286 sz = MAX_PATH;
7287 lstrcpyA(buf, "apple");
7288 r = pMsiGetProductInfoExA(prodcode, usersid,
7289 MSIINSTALLCONTEXT_USERMANAGED,
7290 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
7291 ok(r == ERROR_UNKNOWN_PROPERTY,
7292 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7293 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7294 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7296 res = RegSetValueExA(userkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
7297 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7299 /* InstallSource value exists */
7300 sz = MAX_PATH;
7301 lstrcpyA(buf, "apple");
7302 r = pMsiGetProductInfoExA(prodcode, usersid,
7303 MSIINSTALLCONTEXT_USERMANAGED,
7304 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
7305 ok(r == ERROR_UNKNOWN_PROPERTY,
7306 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7307 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7308 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7310 res = RegSetValueExA(userkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
7311 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7313 /* LocalPackage value exists */
7314 sz = MAX_PATH;
7315 lstrcpyA(buf, "apple");
7316 r = pMsiGetProductInfoExA(prodcode, usersid,
7317 MSIINSTALLCONTEXT_USERMANAGED,
7318 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
7319 ok(r == ERROR_UNKNOWN_PROPERTY,
7320 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7321 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7322 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7324 res = RegSetValueExA(userkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
7325 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7327 /* Publisher value exists */
7328 sz = MAX_PATH;
7329 lstrcpyA(buf, "apple");
7330 r = pMsiGetProductInfoExA(prodcode, usersid,
7331 MSIINSTALLCONTEXT_USERMANAGED,
7332 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
7333 ok(r == ERROR_UNKNOWN_PROPERTY,
7334 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7335 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7336 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7338 res = RegSetValueExA(userkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
7339 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7341 /* URLInfoAbout value exists */
7342 sz = MAX_PATH;
7343 lstrcpyA(buf, "apple");
7344 r = pMsiGetProductInfoExA(prodcode, usersid,
7345 MSIINSTALLCONTEXT_USERMANAGED,
7346 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
7347 ok(r == ERROR_UNKNOWN_PROPERTY,
7348 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7349 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7350 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7352 res = RegSetValueExA(userkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
7353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7355 /* URLUpdateInfo value exists */
7356 sz = MAX_PATH;
7357 lstrcpyA(buf, "apple");
7358 r = pMsiGetProductInfoExA(prodcode, usersid,
7359 MSIINSTALLCONTEXT_USERMANAGED,
7360 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
7361 ok(r == ERROR_UNKNOWN_PROPERTY,
7362 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7363 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7364 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7366 res = RegSetValueExA(userkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
7367 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7369 /* VersionMinor value exists */
7370 sz = MAX_PATH;
7371 lstrcpyA(buf, "apple");
7372 r = pMsiGetProductInfoExA(prodcode, usersid,
7373 MSIINSTALLCONTEXT_USERMANAGED,
7374 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
7375 ok(r == ERROR_UNKNOWN_PROPERTY,
7376 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7377 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7378 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7380 res = RegSetValueExA(userkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
7381 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7383 /* VersionMajor value exists */
7384 sz = MAX_PATH;
7385 lstrcpyA(buf, "apple");
7386 r = pMsiGetProductInfoExA(prodcode, usersid,
7387 MSIINSTALLCONTEXT_USERMANAGED,
7388 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
7389 ok(r == ERROR_UNKNOWN_PROPERTY,
7390 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7391 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7392 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7394 res = RegSetValueExA(userkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
7395 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7397 /* DisplayVersion value exists */
7398 sz = MAX_PATH;
7399 lstrcpyA(buf, "apple");
7400 r = pMsiGetProductInfoExA(prodcode, usersid,
7401 MSIINSTALLCONTEXT_USERMANAGED,
7402 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
7403 ok(r == ERROR_UNKNOWN_PROPERTY,
7404 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7405 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7406 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7408 res = RegSetValueExA(userkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
7409 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7411 /* ProductID value exists */
7412 sz = MAX_PATH;
7413 lstrcpyA(buf, "apple");
7414 r = pMsiGetProductInfoExA(prodcode, usersid,
7415 MSIINSTALLCONTEXT_USERMANAGED,
7416 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
7417 ok(r == ERROR_UNKNOWN_PROPERTY,
7418 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7419 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7420 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7422 res = RegSetValueExA(userkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
7423 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7425 /* RegCompany value exists */
7426 sz = MAX_PATH;
7427 lstrcpyA(buf, "apple");
7428 r = pMsiGetProductInfoExA(prodcode, usersid,
7429 MSIINSTALLCONTEXT_USERMANAGED,
7430 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
7431 ok(r == ERROR_UNKNOWN_PROPERTY,
7432 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7433 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7434 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7436 res = RegSetValueExA(userkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
7437 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7439 /* RegOwner value exists */
7440 sz = MAX_PATH;
7441 lstrcpyA(buf, "apple");
7442 r = pMsiGetProductInfoExA(prodcode, usersid,
7443 MSIINSTALLCONTEXT_USERMANAGED,
7444 INSTALLPROPERTY_REGOWNERA, buf, &sz);
7445 ok(r == ERROR_UNKNOWN_PROPERTY,
7446 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
7447 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7448 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7450 res = RegSetValueExA(userkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
7451 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7453 /* Transforms value exists */
7454 sz = MAX_PATH;
7455 lstrcpyA(buf, "apple");
7456 r = pMsiGetProductInfoExA(prodcode, usersid,
7457 MSIINSTALLCONTEXT_USERMANAGED,
7458 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
7459 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7460 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
7461 ok(sz == 5, "Expected 5, got %d\n", sz);
7463 res = RegSetValueExA(userkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
7464 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7466 /* Language value exists */
7467 sz = MAX_PATH;
7468 lstrcpyA(buf, "apple");
7469 r = pMsiGetProductInfoExA(prodcode, usersid,
7470 MSIINSTALLCONTEXT_USERMANAGED,
7471 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
7472 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7473 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
7474 ok(sz == 4, "Expected 4, got %d\n", sz);
7476 res = RegSetValueExA(userkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
7477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7479 /* ProductName value exists */
7480 sz = MAX_PATH;
7481 lstrcpyA(buf, "apple");
7482 r = pMsiGetProductInfoExA(prodcode, usersid,
7483 MSIINSTALLCONTEXT_USERMANAGED,
7484 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
7485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7486 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
7487 ok(sz == 4, "Expected 4, got %d\n", sz);
7489 res = RegSetValueExA(userkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
7490 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7492 /* FIXME */
7494 /* AssignmentType value exists */
7495 sz = MAX_PATH;
7496 lstrcpyA(buf, "apple");
7497 r = pMsiGetProductInfoExA(prodcode, usersid,
7498 MSIINSTALLCONTEXT_USERMANAGED,
7499 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
7500 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7501 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7502 ok(sz == 0, "Expected 0, got %d\n", sz);
7504 res = RegSetValueExA(userkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
7505 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7507 /* FIXME */
7509 /* PackageCode value exists */
7510 sz = MAX_PATH;
7511 lstrcpyA(buf, "apple");
7512 r = pMsiGetProductInfoExA(prodcode, usersid,
7513 MSIINSTALLCONTEXT_USERMANAGED,
7514 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
7515 todo_wine
7517 ok(r == ERROR_BAD_CONFIGURATION,
7518 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
7519 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7520 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7523 res = RegSetValueExA(userkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
7524 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7526 /* Version value exists */
7527 sz = MAX_PATH;
7528 lstrcpyA(buf, "apple");
7529 r = pMsiGetProductInfoExA(prodcode, usersid,
7530 MSIINSTALLCONTEXT_USERMANAGED,
7531 INSTALLPROPERTY_VERSIONA, buf, &sz);
7532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7533 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
7534 ok(sz == 3, "Expected 3, got %d\n", sz);
7536 res = RegSetValueExA(userkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
7537 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7539 /* ProductIcon value exists */
7540 sz = MAX_PATH;
7541 lstrcpyA(buf, "apple");
7542 r = pMsiGetProductInfoExA(prodcode, usersid,
7543 MSIINSTALLCONTEXT_USERMANAGED,
7544 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
7545 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7546 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
7547 ok(sz == 4, "Expected 4, got %d\n", sz);
7549 res = RegSetValueExA(userkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
7550 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7552 /* PackageName value exists */
7553 sz = MAX_PATH;
7554 lstrcpyA(buf, "apple");
7555 r = pMsiGetProductInfoExA(prodcode, usersid,
7556 MSIINSTALLCONTEXT_USERMANAGED,
7557 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
7558 todo_wine
7560 ok(r == ERROR_UNKNOWN_PRODUCT,
7561 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7562 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7563 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7566 res = RegSetValueExA(userkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
7567 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7569 /* AuthorizedLUAApp value exists */
7570 sz = MAX_PATH;
7571 lstrcpyA(buf, "apple");
7572 r = pMsiGetProductInfoExA(prodcode, usersid,
7573 MSIINSTALLCONTEXT_USERMANAGED,
7574 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
7575 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7576 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
7577 ok(sz == 4, "Expected 4, got %d\n", sz);
7579 RegDeleteValueA(userkey, "AuthorizedLUAApp");
7580 RegDeleteValueA(userkey, "PackageName");
7581 RegDeleteValueA(userkey, "ProductIcon");
7582 RegDeleteValueA(userkey, "Version");
7583 RegDeleteValueA(userkey, "PackageCode");
7584 RegDeleteValueA(userkey, "AssignmentType");
7585 RegDeleteValueA(userkey, "ProductName");
7586 RegDeleteValueA(userkey, "Language");
7587 RegDeleteValueA(userkey, "Transforms");
7588 RegDeleteValueA(userkey, "RegOwner");
7589 RegDeleteValueA(userkey, "RegCompany");
7590 RegDeleteValueA(userkey, "ProductID");
7591 RegDeleteValueA(userkey, "DisplayVersion");
7592 RegDeleteValueA(userkey, "VersionMajor");
7593 RegDeleteValueA(userkey, "VersionMinor");
7594 RegDeleteValueA(userkey, "URLUpdateInfo");
7595 RegDeleteValueA(userkey, "URLInfoAbout");
7596 RegDeleteValueA(userkey, "Publisher");
7597 RegDeleteValueA(userkey, "LocalPackage");
7598 RegDeleteValueA(userkey, "InstallSource");
7599 RegDeleteValueA(userkey, "InstallLocation");
7600 RegDeleteValueA(userkey, "DisplayName");
7601 RegDeleteValueA(userkey, "InstallDate");
7602 RegDeleteValueA(userkey, "HelpTelephone");
7603 RegDeleteValueA(userkey, "HelpLink");
7604 delete_key(userkey, "", access & KEY_WOW64_64KEY);
7605 RegCloseKey(userkey);
7606 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
7607 RegCloseKey(prodkey);
7609 /* MSIINSTALLCONTEXT_MACHINE */
7611 /* szUserSid is non-NULL */
7612 sz = MAX_PATH;
7613 lstrcpyA(buf, "apple");
7614 r = pMsiGetProductInfoExA(prodcode, usersid,
7615 MSIINSTALLCONTEXT_MACHINE,
7616 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7617 ok(r == ERROR_INVALID_PARAMETER,
7618 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7619 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7620 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7622 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\");
7623 lstrcatA(keypath, prod_squashed);
7625 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &localkey, NULL);
7626 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7628 /* local system product key exists */
7629 sz = MAX_PATH;
7630 lstrcpyA(buf, "apple");
7631 r = pMsiGetProductInfoExA(prodcode, NULL,
7632 MSIINSTALLCONTEXT_MACHINE,
7633 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7634 ok(r == ERROR_UNKNOWN_PRODUCT,
7635 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7636 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7637 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7639 res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &propkey, NULL);
7640 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7642 /* InstallProperties key exists */
7643 sz = MAX_PATH;
7644 lstrcpyA(buf, "apple");
7645 r = pMsiGetProductInfoExA(prodcode, NULL,
7646 MSIINSTALLCONTEXT_MACHINE,
7647 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7648 ok(r == ERROR_UNKNOWN_PRODUCT,
7649 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7650 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7651 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7653 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
7654 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7656 /* LocalPackage value exists */
7657 sz = MAX_PATH;
7658 lstrcpyA(buf, "apple");
7659 r = pMsiGetProductInfoExA(prodcode, NULL,
7660 MSIINSTALLCONTEXT_MACHINE,
7661 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
7662 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7663 ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
7664 ok(sz == 1, "Expected 1, got %d\n", sz);
7666 res = RegSetValueExA(propkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
7667 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7669 /* HelpLink value exists */
7670 sz = MAX_PATH;
7671 lstrcpyA(buf, "apple");
7672 r = pMsiGetProductInfoExA(prodcode, NULL,
7673 MSIINSTALLCONTEXT_MACHINE,
7674 INSTALLPROPERTY_HELPLINKA, buf, &sz);
7675 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7676 ok(!lstrcmpA(buf, "link"), "Expected \"link\", got \"%s\"\n", buf);
7677 ok(sz == 4, "Expected 4, got %d\n", sz);
7679 res = RegSetValueExA(propkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
7680 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7682 /* HelpTelephone value exists */
7683 sz = MAX_PATH;
7684 lstrcpyA(buf, "apple");
7685 r = pMsiGetProductInfoExA(prodcode, NULL,
7686 MSIINSTALLCONTEXT_MACHINE,
7687 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
7688 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7689 ok(!lstrcmpA(buf, "phone"), "Expected \"phone\", got \"%s\"\n", buf);
7690 ok(sz == 5, "Expected 5, got %d\n", sz);
7692 res = RegSetValueExA(propkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
7693 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7695 /* InstallDate value exists */
7696 sz = MAX_PATH;
7697 lstrcpyA(buf, "apple");
7698 r = pMsiGetProductInfoExA(prodcode, NULL,
7699 MSIINSTALLCONTEXT_MACHINE,
7700 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
7701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7702 ok(!lstrcmpA(buf, "date"), "Expected \"date\", got \"%s\"\n", buf);
7703 ok(sz == 4, "Expected 4, got %d\n", sz);
7705 res = RegSetValueExA(propkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
7706 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7708 /* DisplayName value exists */
7709 sz = MAX_PATH;
7710 lstrcpyA(buf, "apple");
7711 r = pMsiGetProductInfoExA(prodcode, NULL,
7712 MSIINSTALLCONTEXT_MACHINE,
7713 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
7714 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7715 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
7716 ok(sz == 4, "Expected 4, got %d\n", sz);
7718 res = RegSetValueExA(propkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
7719 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7721 /* InstallLocation value exists */
7722 sz = MAX_PATH;
7723 lstrcpyA(buf, "apple");
7724 r = pMsiGetProductInfoExA(prodcode, NULL,
7725 MSIINSTALLCONTEXT_MACHINE,
7726 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
7727 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7728 ok(!lstrcmpA(buf, "loc"), "Expected \"loc\", got \"%s\"\n", buf);
7729 ok(sz == 3, "Expected 3, got %d\n", sz);
7731 res = RegSetValueExA(propkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
7732 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7734 /* InstallSource value exists */
7735 sz = MAX_PATH;
7736 lstrcpyA(buf, "apple");
7737 r = pMsiGetProductInfoExA(prodcode, NULL,
7738 MSIINSTALLCONTEXT_MACHINE,
7739 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
7740 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7741 ok(!lstrcmpA(buf, "source"), "Expected \"source\", got \"%s\"\n", buf);
7742 ok(sz == 6, "Expected 6, got %d\n", sz);
7744 res = RegSetValueExA(propkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
7745 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7747 /* LocalPackage value exists */
7748 sz = MAX_PATH;
7749 lstrcpyA(buf, "apple");
7750 r = pMsiGetProductInfoExA(prodcode, NULL,
7751 MSIINSTALLCONTEXT_MACHINE,
7752 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
7753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7754 ok(!lstrcmpA(buf, "local"), "Expected \"local\", got \"%s\"\n", buf);
7755 ok(sz == 5, "Expected 5, got %d\n", sz);
7757 res = RegSetValueExA(propkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
7758 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7760 /* Publisher value exists */
7761 sz = MAX_PATH;
7762 lstrcpyA(buf, "apple");
7763 r = pMsiGetProductInfoExA(prodcode, NULL,
7764 MSIINSTALLCONTEXT_MACHINE,
7765 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
7766 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7767 ok(!lstrcmpA(buf, "pub"), "Expected \"pub\", got \"%s\"\n", buf);
7768 ok(sz == 3, "Expected 3, got %d\n", sz);
7770 res = RegSetValueExA(propkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
7771 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7773 /* URLInfoAbout value exists */
7774 sz = MAX_PATH;
7775 lstrcpyA(buf, "apple");
7776 r = pMsiGetProductInfoExA(prodcode, NULL,
7777 MSIINSTALLCONTEXT_MACHINE,
7778 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
7779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7780 ok(!lstrcmpA(buf, "about"), "Expected \"about\", got \"%s\"\n", buf);
7781 ok(sz == 5, "Expected 5, got %d\n", sz);
7783 res = RegSetValueExA(propkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
7784 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7786 /* URLUpdateInfo value exists */
7787 sz = MAX_PATH;
7788 lstrcpyA(buf, "apple");
7789 r = pMsiGetProductInfoExA(prodcode, NULL,
7790 MSIINSTALLCONTEXT_MACHINE,
7791 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
7792 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7793 ok(!lstrcmpA(buf, "update"), "Expected \"update\", got \"%s\"\n", buf);
7794 ok(sz == 6, "Expected 6, got %d\n", sz);
7796 res = RegSetValueExA(propkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
7797 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7799 /* VersionMinor value exists */
7800 sz = MAX_PATH;
7801 lstrcpyA(buf, "apple");
7802 r = pMsiGetProductInfoExA(prodcode, NULL,
7803 MSIINSTALLCONTEXT_MACHINE,
7804 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
7805 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7806 ok(!lstrcmpA(buf, "2"), "Expected \"2\", got \"%s\"\n", buf);
7807 ok(sz == 1, "Expected 1, got %d\n", sz);
7809 res = RegSetValueExA(propkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
7810 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7812 /* VersionMajor value exists */
7813 sz = MAX_PATH;
7814 lstrcpyA(buf, "apple");
7815 r = pMsiGetProductInfoExA(prodcode, NULL,
7816 MSIINSTALLCONTEXT_MACHINE,
7817 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
7818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7819 ok(!lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
7820 ok(sz == 1, "Expected 1, got %d\n", sz);
7822 res = RegSetValueExA(propkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
7823 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7825 /* DisplayVersion value exists */
7826 sz = MAX_PATH;
7827 lstrcpyA(buf, "apple");
7828 r = pMsiGetProductInfoExA(prodcode, NULL,
7829 MSIINSTALLCONTEXT_MACHINE,
7830 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
7831 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7832 ok(!lstrcmpA(buf, "3.2.1"), "Expected \"3.2.1\", got \"%s\"\n", buf);
7833 ok(sz == 5, "Expected 5, got %d\n", sz);
7835 res = RegSetValueExA(propkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
7836 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7838 /* ProductID value exists */
7839 sz = MAX_PATH;
7840 lstrcpyA(buf, "apple");
7841 r = pMsiGetProductInfoExA(prodcode, NULL,
7842 MSIINSTALLCONTEXT_MACHINE,
7843 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
7844 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7845 ok(!lstrcmpA(buf, "id"), "Expected \"id\", got \"%s\"\n", buf);
7846 ok(sz == 2, "Expected 2, got %d\n", sz);
7848 res = RegSetValueExA(propkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
7849 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7851 /* RegCompany value exists */
7852 sz = MAX_PATH;
7853 lstrcpyA(buf, "apple");
7854 r = pMsiGetProductInfoExA(prodcode, NULL,
7855 MSIINSTALLCONTEXT_MACHINE,
7856 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
7857 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7858 ok(!lstrcmpA(buf, "comp"), "Expected \"comp\", got \"%s\"\n", buf);
7859 ok(sz == 4, "Expected 4, got %d\n", sz);
7861 res = RegSetValueExA(propkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
7862 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7864 /* RegOwner value exists */
7865 sz = MAX_PATH;
7866 lstrcpyA(buf, "apple");
7867 r = pMsiGetProductInfoExA(prodcode, NULL,
7868 MSIINSTALLCONTEXT_MACHINE,
7869 INSTALLPROPERTY_REGOWNERA, buf, &sz);
7870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7871 ok(!lstrcmpA(buf, "owner"), "Expected \"owner\", got \"%s\"\n", buf);
7872 ok(sz == 5, "Expected 5, got %d\n", sz);
7874 res = RegSetValueExA(propkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
7875 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7877 /* Transforms value exists */
7878 sz = MAX_PATH;
7879 lstrcpyA(buf, "apple");
7880 r = pMsiGetProductInfoExA(prodcode, NULL,
7881 MSIINSTALLCONTEXT_MACHINE,
7882 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
7883 ok(r == ERROR_UNKNOWN_PRODUCT,
7884 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7885 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7886 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7888 res = RegSetValueExA(propkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
7889 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7891 /* Language value exists */
7892 sz = MAX_PATH;
7893 lstrcpyA(buf, "apple");
7894 r = pMsiGetProductInfoExA(prodcode, NULL,
7895 MSIINSTALLCONTEXT_MACHINE,
7896 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
7897 ok(r == ERROR_UNKNOWN_PRODUCT,
7898 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7899 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7900 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7902 res = RegSetValueExA(propkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
7903 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7905 /* ProductName value exists */
7906 sz = MAX_PATH;
7907 lstrcpyA(buf, "apple");
7908 r = pMsiGetProductInfoExA(prodcode, NULL,
7909 MSIINSTALLCONTEXT_MACHINE,
7910 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
7911 ok(r == ERROR_UNKNOWN_PRODUCT,
7912 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7913 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7914 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7916 res = RegSetValueExA(propkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
7917 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7919 /* FIXME */
7921 /* AssignmentType value exists */
7922 sz = MAX_PATH;
7923 lstrcpyA(buf, "apple");
7924 r = pMsiGetProductInfoExA(prodcode, NULL,
7925 MSIINSTALLCONTEXT_MACHINE,
7926 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
7927 ok(r == ERROR_UNKNOWN_PRODUCT,
7928 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7929 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7930 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7932 res = RegSetValueExA(propkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
7933 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7935 /* PackageCode value exists */
7936 sz = MAX_PATH;
7937 lstrcpyA(buf, "apple");
7938 r = pMsiGetProductInfoExA(prodcode, NULL,
7939 MSIINSTALLCONTEXT_MACHINE,
7940 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
7941 ok(r == ERROR_UNKNOWN_PRODUCT,
7942 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7943 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7944 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7946 res = RegSetValueExA(propkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
7947 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7949 /* Version value exists */
7950 sz = MAX_PATH;
7951 lstrcpyA(buf, "apple");
7952 r = pMsiGetProductInfoExA(prodcode, NULL,
7953 MSIINSTALLCONTEXT_MACHINE,
7954 INSTALLPROPERTY_VERSIONA, buf, &sz);
7955 ok(r == ERROR_UNKNOWN_PRODUCT,
7956 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7957 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7958 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7960 res = RegSetValueExA(propkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
7961 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7963 /* ProductIcon value exists */
7964 sz = MAX_PATH;
7965 lstrcpyA(buf, "apple");
7966 r = pMsiGetProductInfoExA(prodcode, NULL,
7967 MSIINSTALLCONTEXT_MACHINE,
7968 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
7969 ok(r == ERROR_UNKNOWN_PRODUCT,
7970 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7971 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7972 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7974 res = RegSetValueExA(propkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
7975 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7977 /* PackageName value exists */
7978 sz = MAX_PATH;
7979 lstrcpyA(buf, "apple");
7980 r = pMsiGetProductInfoExA(prodcode, NULL,
7981 MSIINSTALLCONTEXT_MACHINE,
7982 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
7983 ok(r == ERROR_UNKNOWN_PRODUCT,
7984 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7985 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
7986 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
7988 res = RegSetValueExA(propkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
7989 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7991 /* AuthorizedLUAApp value exists */
7992 sz = MAX_PATH;
7993 lstrcpyA(buf, "apple");
7994 r = pMsiGetProductInfoExA(prodcode, NULL,
7995 MSIINSTALLCONTEXT_MACHINE,
7996 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
7997 ok(r == ERROR_UNKNOWN_PRODUCT,
7998 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7999 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8000 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8002 RegDeleteValueA(propkey, "AuthorizedLUAApp");
8003 RegDeleteValueA(propkey, "PackageName");
8004 RegDeleteValueA(propkey, "ProductIcon");
8005 RegDeleteValueA(propkey, "Version");
8006 RegDeleteValueA(propkey, "PackageCode");
8007 RegDeleteValueA(propkey, "AssignmentType");
8008 RegDeleteValueA(propkey, "ProductName");
8009 RegDeleteValueA(propkey, "Language");
8010 RegDeleteValueA(propkey, "Transforms");
8011 RegDeleteValueA(propkey, "RegOwner");
8012 RegDeleteValueA(propkey, "RegCompany");
8013 RegDeleteValueA(propkey, "ProductID");
8014 RegDeleteValueA(propkey, "DisplayVersion");
8015 RegDeleteValueA(propkey, "VersionMajor");
8016 RegDeleteValueA(propkey, "VersionMinor");
8017 RegDeleteValueA(propkey, "URLUpdateInfo");
8018 RegDeleteValueA(propkey, "URLInfoAbout");
8019 RegDeleteValueA(propkey, "Publisher");
8020 RegDeleteValueA(propkey, "LocalPackage");
8021 RegDeleteValueA(propkey, "InstallSource");
8022 RegDeleteValueA(propkey, "InstallLocation");
8023 RegDeleteValueA(propkey, "DisplayName");
8024 RegDeleteValueA(propkey, "InstallDate");
8025 RegDeleteValueA(propkey, "HelpTelephone");
8026 RegDeleteValueA(propkey, "HelpLink");
8027 RegDeleteValueA(propkey, "LocalPackage");
8028 delete_key(propkey, "", access & KEY_WOW64_64KEY);
8029 RegCloseKey(propkey);
8030 delete_key(localkey, "", access & KEY_WOW64_64KEY);
8031 RegCloseKey(localkey);
8033 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8034 lstrcatA(keypath, prod_squashed);
8036 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8037 if (res == ERROR_ACCESS_DENIED)
8039 skip( "insufficient rights\n" );
8040 LocalFree( usersid );
8041 return;
8043 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8045 /* local classes product key exists */
8046 sz = MAX_PATH;
8047 lstrcpyA(buf, "apple");
8048 r = pMsiGetProductInfoExA(prodcode, NULL,
8049 MSIINSTALLCONTEXT_MACHINE,
8050 INSTALLPROPERTY_PRODUCTSTATEA, buf, &sz);
8051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8052 ok(!lstrcmpA(buf, "1"), "Expected \"1\", got \"%s\"\n", buf);
8053 ok(sz == 1, "Expected 1, got %d\n", sz);
8055 res = RegSetValueExA(prodkey, "HelpLink", 0, REG_SZ, (LPBYTE)"link", 5);
8056 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8058 /* HelpLink value exists */
8059 sz = MAX_PATH;
8060 lstrcpyA(buf, "apple");
8061 r = pMsiGetProductInfoExA(prodcode, NULL,
8062 MSIINSTALLCONTEXT_MACHINE,
8063 INSTALLPROPERTY_HELPLINKA, buf, &sz);
8064 ok(r == ERROR_UNKNOWN_PROPERTY,
8065 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8066 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8067 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8069 res = RegSetValueExA(prodkey, "HelpTelephone", 0, REG_SZ, (LPBYTE)"phone", 6);
8070 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8072 /* HelpTelephone value exists */
8073 sz = MAX_PATH;
8074 lstrcpyA(buf, "apple");
8075 r = pMsiGetProductInfoExA(prodcode, NULL,
8076 MSIINSTALLCONTEXT_MACHINE,
8077 INSTALLPROPERTY_HELPTELEPHONEA, buf, &sz);
8078 ok(r == ERROR_UNKNOWN_PROPERTY,
8079 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8080 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8081 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8083 res = RegSetValueExA(prodkey, "InstallDate", 0, REG_SZ, (LPBYTE)"date", 5);
8084 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8086 /* InstallDate value exists */
8087 sz = MAX_PATH;
8088 lstrcpyA(buf, "apple");
8089 r = pMsiGetProductInfoExA(prodcode, NULL,
8090 MSIINSTALLCONTEXT_MACHINE,
8091 INSTALLPROPERTY_INSTALLDATEA, buf, &sz);
8092 ok(r == ERROR_UNKNOWN_PROPERTY,
8093 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8094 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8095 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8097 res = RegSetValueExA(prodkey, "DisplayName", 0, REG_SZ, (LPBYTE)"name", 5);
8098 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8100 /* DisplayName value exists */
8101 sz = MAX_PATH;
8102 lstrcpyA(buf, "apple");
8103 r = pMsiGetProductInfoExA(prodcode, NULL,
8104 MSIINSTALLCONTEXT_MACHINE,
8105 INSTALLPROPERTY_INSTALLEDPRODUCTNAMEA, buf, &sz);
8106 ok(r == ERROR_UNKNOWN_PROPERTY,
8107 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8108 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8109 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8111 res = RegSetValueExA(prodkey, "InstallLocation", 0, REG_SZ, (LPBYTE)"loc", 4);
8112 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8114 /* InstallLocation value exists */
8115 sz = MAX_PATH;
8116 lstrcpyA(buf, "apple");
8117 r = pMsiGetProductInfoExA(prodcode, NULL,
8118 MSIINSTALLCONTEXT_MACHINE,
8119 INSTALLPROPERTY_INSTALLLOCATIONA, buf, &sz);
8120 ok(r == ERROR_UNKNOWN_PROPERTY,
8121 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8122 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8123 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8125 res = RegSetValueExA(prodkey, "InstallSource", 0, REG_SZ, (LPBYTE)"source", 7);
8126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8128 /* InstallSource value exists */
8129 sz = MAX_PATH;
8130 lstrcpyA(buf, "apple");
8131 r = pMsiGetProductInfoExA(prodcode, NULL,
8132 MSIINSTALLCONTEXT_MACHINE,
8133 INSTALLPROPERTY_INSTALLSOURCEA, buf, &sz);
8134 ok(r == ERROR_UNKNOWN_PROPERTY,
8135 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8136 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8137 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8139 res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (LPBYTE)"local", 6);
8140 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8142 /* LocalPackage value exists */
8143 sz = MAX_PATH;
8144 lstrcpyA(buf, "apple");
8145 r = pMsiGetProductInfoExA(prodcode, NULL,
8146 MSIINSTALLCONTEXT_MACHINE,
8147 INSTALLPROPERTY_LOCALPACKAGEA, buf, &sz);
8148 ok(r == ERROR_UNKNOWN_PROPERTY,
8149 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8150 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8151 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8153 res = RegSetValueExA(prodkey, "Publisher", 0, REG_SZ, (LPBYTE)"pub", 4);
8154 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8156 /* Publisher value exists */
8157 sz = MAX_PATH;
8158 lstrcpyA(buf, "apple");
8159 r = pMsiGetProductInfoExA(prodcode, NULL,
8160 MSIINSTALLCONTEXT_MACHINE,
8161 INSTALLPROPERTY_PUBLISHERA, buf, &sz);
8162 ok(r == ERROR_UNKNOWN_PROPERTY,
8163 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8164 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8165 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8167 res = RegSetValueExA(prodkey, "URLInfoAbout", 0, REG_SZ, (LPBYTE)"about", 6);
8168 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8170 /* URLInfoAbout value exists */
8171 sz = MAX_PATH;
8172 lstrcpyA(buf, "apple");
8173 r = pMsiGetProductInfoExA(prodcode, NULL,
8174 MSIINSTALLCONTEXT_MACHINE,
8175 INSTALLPROPERTY_URLINFOABOUTA, buf, &sz);
8176 ok(r == ERROR_UNKNOWN_PROPERTY,
8177 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8178 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8179 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8181 res = RegSetValueExA(prodkey, "URLUpdateInfo", 0, REG_SZ, (LPBYTE)"update", 7);
8182 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8184 /* URLUpdateInfo value exists */
8185 sz = MAX_PATH;
8186 lstrcpyA(buf, "apple");
8187 r = pMsiGetProductInfoExA(prodcode, NULL,
8188 MSIINSTALLCONTEXT_MACHINE,
8189 INSTALLPROPERTY_URLUPDATEINFOA, buf, &sz);
8190 ok(r == ERROR_UNKNOWN_PROPERTY,
8191 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8192 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8193 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8195 res = RegSetValueExA(prodkey, "VersionMinor", 0, REG_SZ, (LPBYTE)"2", 2);
8196 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8198 /* VersionMinor value exists */
8199 sz = MAX_PATH;
8200 lstrcpyA(buf, "apple");
8201 r = pMsiGetProductInfoExA(prodcode, NULL,
8202 MSIINSTALLCONTEXT_MACHINE,
8203 INSTALLPROPERTY_VERSIONMINORA, buf, &sz);
8204 ok(r == ERROR_UNKNOWN_PROPERTY,
8205 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8206 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8207 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8209 res = RegSetValueExA(prodkey, "VersionMajor", 0, REG_SZ, (LPBYTE)"3", 2);
8210 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8212 /* VersionMajor value exists */
8213 sz = MAX_PATH;
8214 lstrcpyA(buf, "apple");
8215 r = pMsiGetProductInfoExA(prodcode, NULL,
8216 MSIINSTALLCONTEXT_MACHINE,
8217 INSTALLPROPERTY_VERSIONMAJORA, buf, &sz);
8218 ok(r == ERROR_UNKNOWN_PROPERTY,
8219 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8220 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8221 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8223 res = RegSetValueExA(prodkey, "DisplayVersion", 0, REG_SZ, (LPBYTE)"3.2.1", 6);
8224 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8226 /* DisplayVersion value exists */
8227 sz = MAX_PATH;
8228 lstrcpyA(buf, "apple");
8229 r = pMsiGetProductInfoExA(prodcode, NULL,
8230 MSIINSTALLCONTEXT_MACHINE,
8231 INSTALLPROPERTY_VERSIONSTRINGA, buf, &sz);
8232 ok(r == ERROR_UNKNOWN_PROPERTY,
8233 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8234 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8235 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8237 res = RegSetValueExA(prodkey, "ProductID", 0, REG_SZ, (LPBYTE)"id", 3);
8238 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8240 /* ProductID value exists */
8241 sz = MAX_PATH;
8242 lstrcpyA(buf, "apple");
8243 r = pMsiGetProductInfoExA(prodcode, NULL,
8244 MSIINSTALLCONTEXT_MACHINE,
8245 INSTALLPROPERTY_PRODUCTIDA, buf, &sz);
8246 ok(r == ERROR_UNKNOWN_PROPERTY,
8247 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8248 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8249 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8251 res = RegSetValueExA(prodkey, "RegCompany", 0, REG_SZ, (LPBYTE)"comp", 5);
8252 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8254 /* RegCompany value exists */
8255 sz = MAX_PATH;
8256 lstrcpyA(buf, "apple");
8257 r = pMsiGetProductInfoExA(prodcode, NULL,
8258 MSIINSTALLCONTEXT_MACHINE,
8259 INSTALLPROPERTY_REGCOMPANYA, buf, &sz);
8260 ok(r == ERROR_UNKNOWN_PROPERTY,
8261 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8262 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8263 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8265 res = RegSetValueExA(prodkey, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8266 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8268 /* RegOwner value exists */
8269 sz = MAX_PATH;
8270 lstrcpyA(buf, "apple");
8271 r = pMsiGetProductInfoExA(prodcode, NULL,
8272 MSIINSTALLCONTEXT_MACHINE,
8273 INSTALLPROPERTY_REGOWNERA, buf, &sz);
8274 ok(r == ERROR_UNKNOWN_PROPERTY,
8275 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
8276 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8277 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8279 res = RegSetValueExA(prodkey, "Transforms", 0, REG_SZ, (LPBYTE)"trans", 6);
8280 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8282 /* Transforms value exists */
8283 sz = MAX_PATH;
8284 lstrcpyA(buf, "apple");
8285 r = pMsiGetProductInfoExA(prodcode, NULL,
8286 MSIINSTALLCONTEXT_MACHINE,
8287 INSTALLPROPERTY_TRANSFORMSA, buf, &sz);
8288 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8289 ok(!lstrcmpA(buf, "trans"), "Expected \"trans\", got \"%s\"\n", buf);
8290 ok(sz == 5, "Expected 5, got %d\n", sz);
8292 res = RegSetValueExA(prodkey, "Language", 0, REG_SZ, (LPBYTE)"lang", 5);
8293 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8295 /* Language value exists */
8296 sz = MAX_PATH;
8297 lstrcpyA(buf, "apple");
8298 r = pMsiGetProductInfoExA(prodcode, NULL,
8299 MSIINSTALLCONTEXT_MACHINE,
8300 INSTALLPROPERTY_LANGUAGEA, buf, &sz);
8301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8302 ok(!lstrcmpA(buf, "lang"), "Expected \"lang\", got \"%s\"\n", buf);
8303 ok(sz == 4, "Expected 4, got %d\n", sz);
8305 res = RegSetValueExA(prodkey, "ProductName", 0, REG_SZ, (LPBYTE)"name", 5);
8306 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8308 /* ProductName value exists */
8309 sz = MAX_PATH;
8310 lstrcpyA(buf, "apple");
8311 r = pMsiGetProductInfoExA(prodcode, NULL,
8312 MSIINSTALLCONTEXT_MACHINE,
8313 INSTALLPROPERTY_PRODUCTNAMEA, buf, &sz);
8314 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8315 ok(!lstrcmpA(buf, "name"), "Expected \"name\", got \"%s\"\n", buf);
8316 ok(sz == 4, "Expected 4, got %d\n", sz);
8318 res = RegSetValueExA(prodkey, "AssignmentType", 0, REG_SZ, (LPBYTE)"type", 5);
8319 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8321 /* FIXME */
8323 /* AssignmentType value exists */
8324 sz = MAX_PATH;
8325 lstrcpyA(buf, "apple");
8326 r = pMsiGetProductInfoExA(prodcode, NULL,
8327 MSIINSTALLCONTEXT_MACHINE,
8328 INSTALLPROPERTY_ASSIGNMENTTYPEA, buf, &sz);
8329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8330 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8331 ok(sz == 0, "Expected 0, got %d\n", sz);
8333 res = RegSetValueExA(prodkey, "PackageCode", 0, REG_SZ, (LPBYTE)"code", 5);
8334 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8336 /* FIXME */
8338 /* PackageCode value exists */
8339 sz = MAX_PATH;
8340 lstrcpyA(buf, "apple");
8341 r = pMsiGetProductInfoExA(prodcode, NULL,
8342 MSIINSTALLCONTEXT_MACHINE,
8343 INSTALLPROPERTY_PACKAGECODEA, buf, &sz);
8344 todo_wine
8346 ok(r == ERROR_BAD_CONFIGURATION,
8347 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
8348 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8349 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8352 res = RegSetValueExA(prodkey, "Version", 0, REG_SZ, (LPBYTE)"ver", 4);
8353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8355 /* Version value exists */
8356 sz = MAX_PATH;
8357 lstrcpyA(buf, "apple");
8358 r = pMsiGetProductInfoExA(prodcode, NULL,
8359 MSIINSTALLCONTEXT_MACHINE,
8360 INSTALLPROPERTY_VERSIONA, buf, &sz);
8361 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8362 ok(!lstrcmpA(buf, "ver"), "Expected \"ver\", got \"%s\"\n", buf);
8363 ok(sz == 3, "Expected 3, got %d\n", sz);
8365 res = RegSetValueExA(prodkey, "ProductIcon", 0, REG_SZ, (LPBYTE)"icon", 5);
8366 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8368 /* ProductIcon value exists */
8369 sz = MAX_PATH;
8370 lstrcpyA(buf, "apple");
8371 r = pMsiGetProductInfoExA(prodcode, NULL,
8372 MSIINSTALLCONTEXT_MACHINE,
8373 INSTALLPROPERTY_PRODUCTICONA, buf, &sz);
8374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8375 ok(!lstrcmpA(buf, "icon"), "Expected \"icon\", got \"%s\"\n", buf);
8376 ok(sz == 4, "Expected 4, got %d\n", sz);
8378 res = RegSetValueExA(prodkey, "PackageName", 0, REG_SZ, (LPBYTE)"name", 5);
8379 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8381 /* PackageName value exists */
8382 sz = MAX_PATH;
8383 lstrcpyA(buf, "apple");
8384 r = pMsiGetProductInfoExA(prodcode, NULL,
8385 MSIINSTALLCONTEXT_MACHINE,
8386 INSTALLPROPERTY_PACKAGENAMEA, buf, &sz);
8387 todo_wine
8389 ok(r == ERROR_UNKNOWN_PRODUCT,
8390 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
8391 ok(!lstrcmpA(buf, "apple"), "Expected buf to be unchanged, got %s\n", buf);
8392 ok(sz == MAX_PATH, "Expected MAX_PATH, got %d\n", sz);
8395 res = RegSetValueExA(prodkey, "AuthorizedLUAApp", 0, REG_SZ, (LPBYTE)"auth", 5);
8396 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8398 /* AuthorizedLUAApp value exists */
8399 sz = MAX_PATH;
8400 lstrcpyA(buf, "apple");
8401 r = pMsiGetProductInfoExA(prodcode, NULL,
8402 MSIINSTALLCONTEXT_MACHINE,
8403 INSTALLPROPERTY_AUTHORIZED_LUA_APPA, buf, &sz);
8404 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8405 ok(!lstrcmpA(buf, "auth"), "Expected \"auth\", got \"%s\"\n", buf);
8406 ok(sz == 4, "Expected 4, got %d\n", sz);
8408 RegDeleteValueA(prodkey, "AuthorizedLUAApp");
8409 RegDeleteValueA(prodkey, "PackageName");
8410 RegDeleteValueA(prodkey, "ProductIcon");
8411 RegDeleteValueA(prodkey, "Version");
8412 RegDeleteValueA(prodkey, "PackageCode");
8413 RegDeleteValueA(prodkey, "AssignmentType");
8414 RegDeleteValueA(prodkey, "ProductName");
8415 RegDeleteValueA(prodkey, "Language");
8416 RegDeleteValueA(prodkey, "Transforms");
8417 RegDeleteValueA(prodkey, "RegOwner");
8418 RegDeleteValueA(prodkey, "RegCompany");
8419 RegDeleteValueA(prodkey, "ProductID");
8420 RegDeleteValueA(prodkey, "DisplayVersion");
8421 RegDeleteValueA(prodkey, "VersionMajor");
8422 RegDeleteValueA(prodkey, "VersionMinor");
8423 RegDeleteValueA(prodkey, "URLUpdateInfo");
8424 RegDeleteValueA(prodkey, "URLInfoAbout");
8425 RegDeleteValueA(prodkey, "Publisher");
8426 RegDeleteValueA(prodkey, "LocalPackage");
8427 RegDeleteValueA(prodkey, "InstallSource");
8428 RegDeleteValueA(prodkey, "InstallLocation");
8429 RegDeleteValueA(prodkey, "DisplayName");
8430 RegDeleteValueA(prodkey, "InstallDate");
8431 RegDeleteValueA(prodkey, "HelpTelephone");
8432 RegDeleteValueA(prodkey, "HelpLink");
8433 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
8434 RegCloseKey(prodkey);
8435 LocalFree(usersid);
8438 #define INIT_USERINFO() \
8439 lstrcpyA(user, "apple"); \
8440 lstrcpyA(org, "orange"); \
8441 lstrcpyA(serial, "banana"); \
8442 usersz = orgsz = serialsz = MAX_PATH;
8444 static void test_MsiGetUserInfo(void)
8446 USERINFOSTATE state;
8447 CHAR user[MAX_PATH];
8448 CHAR org[MAX_PATH];
8449 CHAR serial[MAX_PATH];
8450 DWORD usersz, orgsz, serialsz;
8451 CHAR keypath[MAX_PATH * 2];
8452 CHAR prodcode[MAX_PATH];
8453 CHAR prod_squashed[MAX_PATH];
8454 HKEY prodkey, userprod, props;
8455 LPSTR usersid;
8456 LONG res;
8457 REGSAM access = KEY_ALL_ACCESS;
8459 create_test_guid(prodcode, prod_squashed);
8460 usersid = get_user_sid();
8462 if (is_wow64)
8463 access |= KEY_WOW64_64KEY;
8465 /* NULL szProduct */
8466 INIT_USERINFO();
8467 state = MsiGetUserInfoA(NULL, user, &usersz, org, &orgsz, serial, &serialsz);
8468 ok(state == USERINFOSTATE_INVALIDARG,
8469 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8470 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8471 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8472 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8473 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8474 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8475 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8477 /* empty szProductCode */
8478 INIT_USERINFO();
8479 state = MsiGetUserInfoA("", user, &usersz, org, &orgsz, serial, &serialsz);
8480 ok(state == USERINFOSTATE_INVALIDARG,
8481 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8482 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8483 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8484 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8485 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8486 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8487 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8489 /* garbage szProductCode */
8490 INIT_USERINFO();
8491 state = MsiGetUserInfoA("garbage", user, &usersz, org, &orgsz, serial, &serialsz);
8492 ok(state == USERINFOSTATE_INVALIDARG,
8493 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8494 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8495 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8496 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8497 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8498 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8499 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8501 /* guid without brackets */
8502 INIT_USERINFO();
8503 state = MsiGetUserInfoA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
8504 user, &usersz, org, &orgsz, serial, &serialsz);
8505 ok(state == USERINFOSTATE_INVALIDARG,
8506 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8507 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8508 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8509 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8510 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8511 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8512 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8514 /* guid with brackets */
8515 INIT_USERINFO();
8516 state = MsiGetUserInfoA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
8517 user, &usersz, org, &orgsz, serial, &serialsz);
8518 ok(state == USERINFOSTATE_UNKNOWN,
8519 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8520 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8521 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8522 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8523 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8524 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8525 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8527 /* NULL lpUserNameBuf */
8528 INIT_USERINFO();
8529 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
8530 ok(state == USERINFOSTATE_UNKNOWN,
8531 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
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 == MAX_PATH, "Expected MAX_PATH, 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 /* NULL pcchUserNameBuf */
8539 INIT_USERINFO();
8540 state = MsiGetUserInfoA(prodcode, user, NULL, org, &orgsz, serial, &serialsz);
8541 ok(state == USERINFOSTATE_INVALIDARG,
8542 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8543 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8544 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8545 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8546 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8547 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8549 /* both lpUserNameBuf and pcchUserNameBuf NULL */
8550 INIT_USERINFO();
8551 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8552 ok(state == USERINFOSTATE_UNKNOWN,
8553 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8554 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8555 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8556 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8557 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8559 /* NULL lpOrgNameBuf */
8560 INIT_USERINFO();
8561 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, &orgsz, serial, &serialsz);
8562 ok(state == USERINFOSTATE_UNKNOWN,
8563 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8564 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8565 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8566 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8567 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8568 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8570 /* NULL pcchOrgNameBuf */
8571 INIT_USERINFO();
8572 state = MsiGetUserInfoA(prodcode, user, &usersz, org, NULL, serial, &serialsz);
8573 ok(state == USERINFOSTATE_INVALIDARG,
8574 "Expected USERINFOSTATE_INVALIDARG, 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(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8581 /* both lpOrgNameBuf and pcchOrgNameBuf NULL */
8582 INIT_USERINFO();
8583 state = MsiGetUserInfoA(prodcode, user, &usersz, NULL, NULL, serial, &serialsz);
8584 ok(state == USERINFOSTATE_UNKNOWN,
8585 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8586 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8587 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8588 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8589 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8591 /* NULL lpSerialBuf */
8592 INIT_USERINFO();
8593 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, &serialsz);
8594 ok(state == USERINFOSTATE_UNKNOWN,
8595 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8596 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8597 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8598 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8599 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8600 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8602 /* NULL pcchSerialBuf */
8603 INIT_USERINFO();
8604 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, NULL);
8605 ok(state == USERINFOSTATE_INVALIDARG,
8606 "Expected USERINFOSTATE_INVALIDARG, got %d\n", state);
8607 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8608 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8609 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8610 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8611 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8613 /* both lpSerialBuf and pcchSerialBuf NULL */
8614 INIT_USERINFO();
8615 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, NULL, NULL);
8616 ok(state == USERINFOSTATE_UNKNOWN,
8617 "Expected USERINFOSTATE_UNKNOWN, got %d\n", state);
8618 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8619 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8620 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8621 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8623 /* MSIINSTALLCONTEXT_USERMANAGED */
8625 /* create local system product key */
8626 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
8627 lstrcatA(keypath, usersid);
8628 lstrcatA(keypath, "\\Installer\\Products\\");
8629 lstrcatA(keypath, prod_squashed);
8631 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8632 if (res == ERROR_ACCESS_DENIED)
8634 skip("Not enough rights to perform tests\n");
8635 LocalFree(usersid);
8636 return;
8638 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8640 /* managed product key exists */
8641 INIT_USERINFO();
8642 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8643 ok(state == USERINFOSTATE_ABSENT,
8644 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8645 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8646 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8647 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8648 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8649 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8650 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8652 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8653 lstrcatA(keypath, "Installer\\UserData\\");
8654 lstrcatA(keypath, usersid);
8655 lstrcatA(keypath, "\\Products\\");
8656 lstrcatA(keypath, prod_squashed);
8658 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userprod, NULL);
8659 if (res == ERROR_ACCESS_DENIED)
8661 skip("Not enough rights to perform tests\n");
8662 LocalFree(usersid);
8663 return;
8665 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8667 res = RegCreateKeyExA(userprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8668 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8670 /* InstallProperties key exists */
8671 INIT_USERINFO();
8672 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8673 ok(state == USERINFOSTATE_ABSENT,
8674 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8675 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8676 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8677 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8678 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
8679 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8680 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8682 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8683 INIT_USERINFO();
8684 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8685 ok(state == USERINFOSTATE_ABSENT,
8686 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8687 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8688 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8689 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8690 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8692 /* RegOwner, RegCompany don't exist, out params are NULL */
8693 INIT_USERINFO();
8694 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
8695 ok(state == USERINFOSTATE_ABSENT,
8696 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8697 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8698 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8700 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8701 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8703 /* RegOwner value exists */
8704 INIT_USERINFO();
8705 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8706 ok(state == USERINFOSTATE_ABSENT,
8707 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8708 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8709 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8710 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8711 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8712 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8713 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8715 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
8716 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8718 /* RegCompany value exists */
8719 INIT_USERINFO();
8720 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8721 ok(state == USERINFOSTATE_ABSENT,
8722 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8723 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8724 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8725 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8726 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8727 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8728 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8730 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
8731 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8733 /* ProductID value exists */
8734 INIT_USERINFO();
8735 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8736 ok(state == USERINFOSTATE_PRESENT,
8737 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8738 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8739 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8740 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8741 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8742 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8743 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8745 /* pcchUserNameBuf is too small */
8746 INIT_USERINFO();
8747 usersz = 0;
8748 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8749 ok(state == USERINFOSTATE_MOREDATA,
8750 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
8751 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8752 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8753 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8754 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8755 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8756 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8758 /* pcchUserNameBuf has no room for NULL terminator */
8759 INIT_USERINFO();
8760 usersz = 5;
8761 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8762 ok(state == USERINFOSTATE_MOREDATA,
8763 "Expected USERINFOSTATE_MOREDATA, got %d\n", state);
8764 todo_wine
8766 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8768 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8769 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8770 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8771 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8772 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8774 /* pcchUserNameBuf is too small, lpUserNameBuf is NULL */
8775 INIT_USERINFO();
8776 usersz = 0;
8777 state = MsiGetUserInfoA(prodcode, NULL, &usersz, org, &orgsz, serial, &serialsz);
8778 ok(state == USERINFOSTATE_PRESENT,
8779 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8780 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8781 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8782 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8783 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8784 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8785 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8787 RegDeleteValueA(props, "ProductID");
8788 RegDeleteValueA(props, "RegCompany");
8789 RegDeleteValueA(props, "RegOwner");
8790 delete_key(props, "", access & KEY_WOW64_64KEY);
8791 RegCloseKey(props);
8792 delete_key(userprod, "", access & KEY_WOW64_64KEY);
8793 RegCloseKey(userprod);
8794 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
8795 RegCloseKey(prodkey);
8797 /* MSIINSTALLCONTEXT_USERUNMANAGED */
8799 /* create local system product key */
8800 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
8801 lstrcatA(keypath, prod_squashed);
8803 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
8804 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8806 /* product key exists */
8807 INIT_USERINFO();
8808 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8809 ok(state == USERINFOSTATE_ABSENT,
8810 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8811 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8812 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8813 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8814 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8815 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8816 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8818 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8819 lstrcatA(keypath, "Installer\\UserData\\");
8820 lstrcatA(keypath, usersid);
8821 lstrcatA(keypath, "\\Products\\");
8822 lstrcatA(keypath, prod_squashed);
8824 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userprod, NULL);
8825 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8827 res = RegCreateKeyExA(userprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8828 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8830 /* InstallProperties key exists */
8831 INIT_USERINFO();
8832 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8833 ok(state == USERINFOSTATE_ABSENT,
8834 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8835 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8836 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8837 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8838 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
8839 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8840 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8842 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8843 INIT_USERINFO();
8844 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8845 ok(state == USERINFOSTATE_ABSENT,
8846 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8847 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8848 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8849 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8850 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8852 /* RegOwner, RegCompany don't exist, out params are NULL */
8853 INIT_USERINFO();
8854 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
8855 ok(state == USERINFOSTATE_ABSENT,
8856 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8857 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8858 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8860 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8861 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8863 /* RegOwner value exists */
8864 INIT_USERINFO();
8865 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8866 ok(state == USERINFOSTATE_ABSENT,
8867 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8868 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8869 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8870 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8871 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8872 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8873 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8875 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
8876 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8878 /* RegCompany value exists */
8879 INIT_USERINFO();
8880 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8881 ok(state == USERINFOSTATE_ABSENT,
8882 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8883 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8884 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8885 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8886 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8887 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8888 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8890 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
8891 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8893 /* ProductID value exists */
8894 INIT_USERINFO();
8895 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8896 ok(state == USERINFOSTATE_PRESENT,
8897 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
8898 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8899 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
8900 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
8901 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8902 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
8903 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
8905 RegDeleteValueA(props, "ProductID");
8906 RegDeleteValueA(props, "RegCompany");
8907 RegDeleteValueA(props, "RegOwner");
8908 delete_key(props, "", access & KEY_WOW64_64KEY);
8909 RegCloseKey(props);
8910 delete_key(userprod, "", access & KEY_WOW64_64KEY);
8911 RegCloseKey(userprod);
8912 RegDeleteKeyA(prodkey, "");
8913 RegCloseKey(prodkey);
8915 /* MSIINSTALLCONTEXT_MACHINE */
8917 /* create local system product key */
8918 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8919 lstrcatA(keypath, prod_squashed);
8921 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8922 if (res == ERROR_ACCESS_DENIED)
8924 skip( "insufficient rights\n" );
8925 LocalFree( usersid );
8926 return;
8928 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8930 /* product key exists */
8931 INIT_USERINFO();
8932 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8933 ok(state == USERINFOSTATE_ABSENT,
8934 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8935 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8936 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8937 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8938 ok(usersz == MAX_PATH, "Expected MAX_PATH, got %d\n", usersz);
8939 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8940 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8942 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8943 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18");
8944 lstrcatA(keypath, "\\Products\\");
8945 lstrcatA(keypath, prod_squashed);
8947 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userprod, NULL);
8948 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8950 res = RegCreateKeyExA(userprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8951 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8953 /* InstallProperties key exists */
8954 INIT_USERINFO();
8955 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8956 ok(state == USERINFOSTATE_ABSENT,
8957 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8958 ok(!lstrcmpA(user, "apple"), "Expected user to be unchanged, got \"%s\"\n", user);
8959 ok(!lstrcmpA(org, "orange"), "Expected org to be unchanged, got \"%s\"\n", org);
8960 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8961 ok(usersz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", usersz);
8962 ok(orgsz == MAX_PATH, "Expected MAX_PATH, got %d\n", orgsz);
8963 ok(serialsz == MAX_PATH, "Expected MAX_PATH, got %d\n", serialsz);
8965 /* RegOwner doesn't exist, lpUserNameBuf and pcchUserNameBuf are NULL */
8966 INIT_USERINFO();
8967 state = MsiGetUserInfoA(prodcode, NULL, NULL, org, &orgsz, serial, &serialsz);
8968 ok(state == USERINFOSTATE_ABSENT,
8969 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8970 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8971 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8972 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8973 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8975 /* RegOwner, RegCompany don't exist, out params are NULL */
8976 INIT_USERINFO();
8977 state = MsiGetUserInfoA(prodcode, NULL, NULL, NULL, NULL, serial, &serialsz);
8978 ok(state == USERINFOSTATE_ABSENT,
8979 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8980 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8981 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8983 res = RegSetValueExA(props, "RegOwner", 0, REG_SZ, (LPBYTE)"owner", 6);
8984 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8986 /* RegOwner value exists */
8987 INIT_USERINFO();
8988 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
8989 ok(state == USERINFOSTATE_ABSENT,
8990 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
8991 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
8992 ok(!lstrcmpA(org, ""), "Expected empty string, got \"%s\"\n", org);
8993 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
8994 ok(usersz == 5, "Expected 5, got %d\n", usersz);
8995 ok(orgsz == 0, "Expected 0, got %d\n", orgsz);
8996 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
8998 res = RegSetValueExA(props, "RegCompany", 0, REG_SZ, (LPBYTE)"company", 8);
8999 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9001 /* RegCompany value exists */
9002 INIT_USERINFO();
9003 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
9004 ok(state == USERINFOSTATE_ABSENT,
9005 "Expected USERINFOSTATE_ABSENT, got %d\n", state);
9006 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
9007 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
9008 ok(!lstrcmpA(serial, "banana"), "Expected serial to be unchanged, got \"%s\"\n", serial);
9009 ok(usersz == 5, "Expected 5, got %d\n", usersz);
9010 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
9011 ok(serialsz == MAX_PATH - 1, "Expected MAX_PATH - 1, got %d\n", serialsz);
9013 res = RegSetValueExA(props, "ProductID", 0, REG_SZ, (LPBYTE)"ID", 3);
9014 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9016 /* ProductID value exists */
9017 INIT_USERINFO();
9018 state = MsiGetUserInfoA(prodcode, user, &usersz, org, &orgsz, serial, &serialsz);
9019 ok(state == USERINFOSTATE_PRESENT,
9020 "Expected USERINFOSTATE_PRESENT, got %d\n", state);
9021 ok(!lstrcmpA(user, "owner"), "Expected \"owner\", got \"%s\"\n", user);
9022 ok(!lstrcmpA(org, "company"), "Expected \"company\", got \"%s\"\n", org);
9023 ok(!lstrcmpA(serial, "ID"), "Expected \"ID\", got \"%s\"\n", serial);
9024 ok(usersz == 5, "Expected 5, got %d\n", usersz);
9025 ok(orgsz == 7, "Expected 7, got %d\n", orgsz);
9026 ok(serialsz == 2, "Expected 2, got %d\n", serialsz);
9028 RegDeleteValueA(props, "ProductID");
9029 RegDeleteValueA(props, "RegCompany");
9030 RegDeleteValueA(props, "RegOwner");
9031 delete_key(props, "", access & KEY_WOW64_64KEY);
9032 RegCloseKey(props);
9033 delete_key(userprod, "", access & KEY_WOW64_64KEY);
9034 RegCloseKey(userprod);
9035 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9036 RegCloseKey(prodkey);
9037 LocalFree(usersid);
9040 static void test_MsiOpenProduct(void)
9042 MSIHANDLE hprod, hdb;
9043 CHAR val[MAX_PATH];
9044 CHAR path[MAX_PATH];
9045 CHAR keypath[MAX_PATH*2];
9046 CHAR prodcode[MAX_PATH];
9047 CHAR prod_squashed[MAX_PATH];
9048 HKEY prodkey, userkey, props;
9049 LPSTR usersid;
9050 DWORD size;
9051 LONG res;
9052 UINT r;
9053 REGSAM access = KEY_ALL_ACCESS;
9055 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9057 GetCurrentDirectoryA(MAX_PATH, path);
9058 lstrcatA(path, "\\");
9060 create_test_guid(prodcode, prod_squashed);
9061 usersid = get_user_sid();
9063 if (is_wow64)
9064 access |= KEY_WOW64_64KEY;
9066 hdb = create_package_db(prodcode);
9067 MsiCloseHandle(hdb);
9069 /* NULL szProduct */
9070 hprod = 0xdeadbeef;
9071 r = MsiOpenProductA(NULL, &hprod);
9072 ok(r == ERROR_INVALID_PARAMETER,
9073 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9074 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9076 /* empty szProduct */
9077 hprod = 0xdeadbeef;
9078 r = MsiOpenProductA("", &hprod);
9079 ok(r == ERROR_INVALID_PARAMETER,
9080 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9081 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9083 /* garbage szProduct */
9084 hprod = 0xdeadbeef;
9085 r = MsiOpenProductA("garbage", &hprod);
9086 ok(r == ERROR_INVALID_PARAMETER,
9087 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9088 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9090 /* guid without brackets */
9091 hprod = 0xdeadbeef;
9092 r = MsiOpenProductA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", &hprod);
9093 ok(r == ERROR_INVALID_PARAMETER,
9094 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9095 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9097 /* guid with brackets */
9098 hprod = 0xdeadbeef;
9099 r = MsiOpenProductA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", &hprod);
9100 ok(r == ERROR_UNKNOWN_PRODUCT,
9101 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9102 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9104 /* same length as guid, but random */
9105 hprod = 0xdeadbeef;
9106 r = MsiOpenProductA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", &hprod);
9107 ok(r == ERROR_INVALID_PARAMETER,
9108 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9109 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9111 /* hProduct is NULL */
9112 hprod = 0xdeadbeef;
9113 r = MsiOpenProductA(prodcode, NULL);
9114 ok(r == ERROR_INVALID_PARAMETER,
9115 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9116 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9118 /* MSIINSTALLCONTEXT_USERMANAGED */
9120 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9121 lstrcatA(keypath, "Installer\\Managed\\");
9122 lstrcatA(keypath, usersid);
9123 lstrcatA(keypath, "\\Installer\\Products\\");
9124 lstrcatA(keypath, prod_squashed);
9126 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
9127 if (res == ERROR_ACCESS_DENIED)
9129 skip("Not enough rights to perform tests\n");
9130 LocalFree(usersid);
9131 return;
9133 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9135 /* managed product key exists */
9136 hprod = 0xdeadbeef;
9137 r = MsiOpenProductA(prodcode, &hprod);
9138 ok(r == ERROR_UNKNOWN_PRODUCT,
9139 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9140 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9142 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9143 lstrcatA(keypath, "Installer\\UserData\\");
9144 lstrcatA(keypath, usersid);
9145 lstrcatA(keypath, "\\Products\\");
9146 lstrcatA(keypath, prod_squashed);
9148 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
9149 if (res == ERROR_ACCESS_DENIED)
9151 skip("Not enough rights to perform tests\n");
9152 LocalFree(usersid);
9153 return;
9155 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9157 /* user product key exists */
9158 hprod = 0xdeadbeef;
9159 r = MsiOpenProductA(prodcode, &hprod);
9160 ok(r == ERROR_UNKNOWN_PRODUCT,
9161 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9162 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9164 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
9165 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9167 /* InstallProperties key exists */
9168 hprod = 0xdeadbeef;
9169 r = MsiOpenProductA(prodcode, &hprod);
9170 ok(r == ERROR_UNKNOWN_PRODUCT,
9171 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9172 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9174 lstrcpyA(val, path);
9175 lstrcatA(val, "\\winetest.msi");
9176 res = RegSetValueExA(props, "ManagedLocalPackage", 0, REG_SZ,
9177 (const BYTE *)val, lstrlenA(val) + 1);
9178 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9180 /* ManagedLocalPackage value exists */
9181 hprod = 0xdeadbeef;
9182 r = MsiOpenProductA(prodcode, &hprod);
9183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9184 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
9186 size = MAX_PATH;
9187 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
9188 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9189 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
9190 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
9192 MsiCloseHandle(hprod);
9194 RegDeleteValueA(props, "ManagedLocalPackage");
9195 delete_key(props, "", access & KEY_WOW64_64KEY);
9196 RegCloseKey(props);
9197 delete_key(userkey, "", access & KEY_WOW64_64KEY);
9198 RegCloseKey(userkey);
9199 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9200 RegCloseKey(prodkey);
9202 /* MSIINSTALLCONTEXT_USERUNMANAGED */
9204 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
9205 lstrcatA(keypath, prod_squashed);
9207 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
9208 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9210 /* unmanaged product key exists */
9211 hprod = 0xdeadbeef;
9212 r = MsiOpenProductA(prodcode, &hprod);
9213 ok(r == ERROR_UNKNOWN_PRODUCT,
9214 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9215 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9217 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9218 lstrcatA(keypath, "Installer\\UserData\\");
9219 lstrcatA(keypath, usersid);
9220 lstrcatA(keypath, "\\Products\\");
9221 lstrcatA(keypath, prod_squashed);
9223 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
9224 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9226 /* user product key exists */
9227 hprod = 0xdeadbeef;
9228 r = MsiOpenProductA(prodcode, &hprod);
9229 ok(r == ERROR_UNKNOWN_PRODUCT,
9230 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9231 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9233 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
9234 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9236 /* InstallProperties key exists */
9237 hprod = 0xdeadbeef;
9238 r = MsiOpenProductA(prodcode, &hprod);
9239 ok(r == ERROR_UNKNOWN_PRODUCT,
9240 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9241 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9243 lstrcpyA(val, path);
9244 lstrcatA(val, "\\winetest.msi");
9245 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9246 (const BYTE *)val, lstrlenA(val) + 1);
9247 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9249 /* LocalPackage value exists */
9250 hprod = 0xdeadbeef;
9251 r = MsiOpenProductA(prodcode, &hprod);
9252 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9253 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
9255 size = MAX_PATH;
9256 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
9257 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9258 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
9259 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
9261 MsiCloseHandle(hprod);
9263 RegDeleteValueA(props, "LocalPackage");
9264 delete_key(props, "", access & KEY_WOW64_64KEY);
9265 RegCloseKey(props);
9266 delete_key(userkey, "", access & KEY_WOW64_64KEY);
9267 RegCloseKey(userkey);
9268 RegDeleteKeyA(prodkey, "");
9269 RegCloseKey(prodkey);
9271 /* MSIINSTALLCONTEXT_MACHINE */
9273 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
9274 lstrcatA(keypath, prod_squashed);
9276 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
9277 if (res == ERROR_ACCESS_DENIED)
9279 skip( "insufficient rights\n" );
9280 LocalFree( usersid );
9281 return;
9283 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9285 /* managed product key exists */
9286 hprod = 0xdeadbeef;
9287 r = MsiOpenProductA(prodcode, &hprod);
9288 ok(r == ERROR_UNKNOWN_PRODUCT,
9289 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9290 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9292 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
9293 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
9294 lstrcatA(keypath, prod_squashed);
9296 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
9297 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9299 /* user product key exists */
9300 hprod = 0xdeadbeef;
9301 r = MsiOpenProductA(prodcode, &hprod);
9302 ok(r == ERROR_UNKNOWN_PRODUCT,
9303 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9304 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9306 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
9307 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9309 /* InstallProperties key exists */
9310 hprod = 0xdeadbeef;
9311 r = MsiOpenProductA(prodcode, &hprod);
9312 ok(r == ERROR_UNKNOWN_PRODUCT,
9313 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9314 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9316 lstrcpyA(val, path);
9317 lstrcatA(val, "\\winetest.msi");
9318 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9319 (const BYTE *)val, lstrlenA(val) + 1);
9320 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9322 /* LocalPackage value exists */
9323 hprod = 0xdeadbeef;
9324 r = MsiOpenProductA(prodcode, &hprod);
9325 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9326 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
9328 size = MAX_PATH;
9329 r = MsiGetPropertyA(hprod, "ProductCode", val, &size);
9330 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9331 ok(!lstrcmpA(val, prodcode), "Expected \"%s\", got \"%s\"\n", prodcode, val);
9332 ok(size == lstrlenA(prodcode), "Expected %d, got %d\n", lstrlenA(prodcode), size);
9334 MsiCloseHandle(hprod);
9336 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9337 (const BYTE *)"winetest.msi", 13);
9338 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9340 lstrcpyA(val, path);
9341 lstrcatA(val, "\\winetest.msi");
9342 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
9343 (const BYTE *)val, lstrlenA(val) + 1);
9344 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9346 DeleteFileA(msifile);
9348 /* local package does not exist */
9349 hprod = 0xdeadbeef;
9350 r = MsiOpenProductA(prodcode, &hprod);
9351 ok(r == ERROR_UNKNOWN_PRODUCT,
9352 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
9353 ok(hprod == 0xdeadbeef, "Expected hprod to be unchanged\n");
9355 RegDeleteValueA(props, "LocalPackage");
9356 delete_key(props, "", access & KEY_WOW64_64KEY);
9357 RegCloseKey(props);
9358 delete_key(userkey, "", access & KEY_WOW64_64KEY);
9359 RegCloseKey(userkey);
9360 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9361 RegCloseKey(prodkey);
9363 DeleteFileA(msifile);
9364 LocalFree(usersid);
9367 static void test_MsiEnumPatchesEx_usermanaged(LPCSTR usersid, LPCSTR expectedsid)
9369 MSIINSTALLCONTEXT context;
9370 CHAR keypath[MAX_PATH], patch[MAX_PATH];
9371 CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
9372 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
9373 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
9374 HKEY prodkey, patches, udprod, udpatch, hpatch;
9375 DWORD size, data;
9376 LONG res;
9377 UINT r;
9378 REGSAM access = KEY_ALL_ACCESS;
9380 create_test_guid(prodcode, prod_squashed);
9381 create_test_guid(patch, patch_squashed);
9383 if (is_wow64)
9384 access |= KEY_WOW64_64KEY;
9386 /* MSIPATCHSTATE_APPLIED */
9388 lstrcpyA(patchcode, "apple");
9389 lstrcpyA(targetprod, "banana");
9390 context = 0xdeadbeef;
9391 lstrcpyA(targetsid, "kiwi");
9392 size = MAX_PATH;
9393 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9394 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9395 &context, targetsid, &size);
9396 if (r == ERROR_ACCESS_DENIED)
9398 skip("Not enough rights to perform tests\n");
9399 return;
9401 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9402 ok(!lstrcmpA(patchcode, "apple"),
9403 "Expected patchcode to be unchanged, got %s\n", patchcode);
9404 ok(!lstrcmpA(targetprod, "banana"),
9405 "Expected targetprod to be unchanged, got %s\n", targetprod);
9406 ok(context == 0xdeadbeef,
9407 "Expected context to be unchanged, got %d\n", context);
9408 ok(!lstrcmpA(targetsid, "kiwi"),
9409 "Expected targetsid to be unchanged, got %s\n", targetsid);
9410 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9412 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
9413 lstrcatA(keypath, expectedsid);
9414 lstrcatA(keypath, "\\Installer\\Products\\");
9415 lstrcatA(keypath, prod_squashed);
9417 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
9418 if (res == ERROR_ACCESS_DENIED)
9420 skip("Not enough rights to perform tests\n");
9421 return;
9423 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9425 /* managed product key exists */
9426 lstrcpyA(patchcode, "apple");
9427 lstrcpyA(targetprod, "banana");
9428 context = 0xdeadbeef;
9429 lstrcpyA(targetsid, "kiwi");
9430 size = MAX_PATH;
9431 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9432 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9433 &context, targetsid, &size);
9434 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9435 ok(!lstrcmpA(patchcode, "apple"),
9436 "Expected patchcode to be unchanged, got %s\n", patchcode);
9437 ok(!lstrcmpA(targetprod, "banana"),
9438 "Expected targetprod to be unchanged, got %s\n", targetprod);
9439 ok(context == 0xdeadbeef,
9440 "Expected context to be unchanged, got %d\n", context);
9441 ok(!lstrcmpA(targetsid, "kiwi"),
9442 "Expected targetsid to be unchanged, got %s\n", targetsid);
9443 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9445 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
9446 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9448 /* patches key exists */
9449 lstrcpyA(patchcode, "apple");
9450 lstrcpyA(targetprod, "banana");
9451 context = 0xdeadbeef;
9452 lstrcpyA(targetsid, "kiwi");
9453 size = MAX_PATH;
9454 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9455 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9456 &context, targetsid, &size);
9457 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9458 ok(!lstrcmpA(patchcode, "apple"),
9459 "Expected patchcode to be unchanged, got %s\n", patchcode);
9460 ok(!lstrcmpA(targetprod, "banana"),
9461 "Expected targetprod to be unchanged, got %s\n", targetprod);
9462 ok(context == 0xdeadbeef,
9463 "Expected context to be unchanged, got %d\n", context);
9464 ok(!lstrcmpA(targetsid, "kiwi"),
9465 "Expected targetsid to be unchanged, got %s\n", targetsid);
9466 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9468 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
9469 (const BYTE *)patch_squashed,
9470 lstrlenA(patch_squashed) + 1);
9471 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9473 /* Patches value exists, is not REG_MULTI_SZ */
9474 lstrcpyA(patchcode, "apple");
9475 lstrcpyA(targetprod, "banana");
9476 context = 0xdeadbeef;
9477 lstrcpyA(targetsid, "kiwi");
9478 size = MAX_PATH;
9479 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9480 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9481 &context, targetsid, &size);
9482 ok(r == ERROR_BAD_CONFIGURATION,
9483 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9484 ok(!lstrcmpA(patchcode, "apple"),
9485 "Expected patchcode to be unchanged, got %s\n", patchcode);
9486 ok(!lstrcmpA(targetprod, "banana"),
9487 "Expected targetprod to be unchanged, got %s\n", targetprod);
9488 ok(context == 0xdeadbeef,
9489 "Expected context to be unchanged, got %d\n", context);
9490 ok(!lstrcmpA(targetsid, "kiwi"),
9491 "Expected targetsid to be unchanged, got %s\n", targetsid);
9492 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9494 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
9495 (const BYTE *)"a\0b\0c\0\0", 7);
9496 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9498 /* Patches value exists, is not a squashed guid */
9499 lstrcpyA(patchcode, "apple");
9500 lstrcpyA(targetprod, "banana");
9501 context = 0xdeadbeef;
9502 lstrcpyA(targetsid, "kiwi");
9503 size = MAX_PATH;
9504 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9505 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9506 &context, targetsid, &size);
9507 ok(r == ERROR_BAD_CONFIGURATION,
9508 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9509 ok(!lstrcmpA(patchcode, "apple"),
9510 "Expected patchcode to be unchanged, got %s\n", patchcode);
9511 ok(!lstrcmpA(targetprod, "banana"),
9512 "Expected targetprod to be unchanged, got %s\n", targetprod);
9513 ok(context == 0xdeadbeef,
9514 "Expected context to be unchanged, got %d\n", context);
9515 ok(!lstrcmpA(targetsid, "kiwi"),
9516 "Expected targetsid to be unchanged, got %s\n", targetsid);
9517 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9519 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
9520 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
9521 (const BYTE *)patch_squashed,
9522 lstrlenA(patch_squashed) + 2);
9523 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9525 /* Patches value exists */
9526 lstrcpyA(patchcode, "apple");
9527 lstrcpyA(targetprod, "banana");
9528 context = 0xdeadbeef;
9529 lstrcpyA(targetsid, "kiwi");
9530 size = MAX_PATH;
9531 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9532 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9533 &context, targetsid, &size);
9534 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9535 ok(!lstrcmpA(patchcode, "apple"),
9536 "Expected patchcode to be unchanged, got %s\n", patchcode);
9537 ok(!lstrcmpA(targetprod, "banana"),
9538 "Expected targetprod to be unchanged, got %s\n", targetprod);
9539 ok(context == 0xdeadbeef,
9540 "Expected context to be unchanged, got %d\n", context);
9541 ok(!lstrcmpA(targetsid, "kiwi"),
9542 "Expected targetsid to be unchanged, got %s\n", targetsid);
9543 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9545 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
9546 (const BYTE *)"whatever", 9);
9547 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9549 /* patch squashed value exists */
9550 lstrcpyA(patchcode, "apple");
9551 lstrcpyA(targetprod, "banana");
9552 context = 0xdeadbeef;
9553 lstrcpyA(targetsid, "kiwi");
9554 size = MAX_PATH;
9555 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9556 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9557 &context, targetsid, &size);
9558 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9559 ok(!lstrcmpA(patchcode, patch),
9560 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9561 ok(!lstrcmpA(targetprod, prodcode),
9562 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9563 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9564 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9565 ok(!lstrcmpA(targetsid, expectedsid),
9566 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9567 ok(size == lstrlenA(expectedsid),
9568 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9570 /* increase the index */
9571 lstrcpyA(patchcode, "apple");
9572 lstrcpyA(targetprod, "banana");
9573 context = 0xdeadbeef;
9574 lstrcpyA(targetsid, "kiwi");
9575 size = MAX_PATH;
9576 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9577 MSIPATCHSTATE_APPLIED, 1, patchcode, targetprod,
9578 &context, targetsid, &size);
9579 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9580 ok(!lstrcmpA(patchcode, "apple"),
9581 "Expected patchcode to be unchanged, got %s\n", patchcode);
9582 ok(!lstrcmpA(targetprod, "banana"),
9583 "Expected targetprod to be unchanged, got %s\n", targetprod);
9584 ok(context == 0xdeadbeef,
9585 "Expected context to be unchanged, got %d\n", context);
9586 ok(!lstrcmpA(targetsid, "kiwi"),
9587 "Expected targetsid to be unchanged, got %s\n", targetsid);
9588 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9590 /* increase again */
9591 lstrcpyA(patchcode, "apple");
9592 lstrcpyA(targetprod, "banana");
9593 context = 0xdeadbeef;
9594 lstrcpyA(targetsid, "kiwi");
9595 size = MAX_PATH;
9596 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9597 MSIPATCHSTATE_APPLIED, 2, patchcode, targetprod,
9598 &context, targetsid, &size);
9599 ok(r == ERROR_INVALID_PARAMETER,
9600 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9601 ok(!lstrcmpA(patchcode, "apple"),
9602 "Expected patchcode to be unchanged, got %s\n", patchcode);
9603 ok(!lstrcmpA(targetprod, "banana"),
9604 "Expected targetprod to be unchanged, got %s\n", targetprod);
9605 ok(context == 0xdeadbeef,
9606 "Expected context to be unchanged, got %d\n", context);
9607 ok(!lstrcmpA(targetsid, "kiwi"),
9608 "Expected targetsid to be unchanged, got %s\n", targetsid);
9609 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9611 /* szPatchCode is NULL */
9612 lstrcpyA(targetprod, "banana");
9613 context = 0xdeadbeef;
9614 lstrcpyA(targetsid, "kiwi");
9615 size = MAX_PATH;
9616 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9617 MSIPATCHSTATE_APPLIED, 0, NULL, targetprod,
9618 &context, targetsid, &size);
9619 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9620 ok(!lstrcmpA(targetprod, prodcode),
9621 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9622 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9623 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9624 ok(!lstrcmpA(targetsid, expectedsid),
9625 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9626 ok(size == lstrlenA(expectedsid),
9627 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9629 /* szTargetProductCode is NULL */
9630 lstrcpyA(patchcode, "apple");
9631 context = 0xdeadbeef;
9632 lstrcpyA(targetsid, "kiwi");
9633 size = MAX_PATH;
9634 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9635 MSIPATCHSTATE_APPLIED, 0, patchcode, NULL,
9636 &context, targetsid, &size);
9637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9638 ok(!lstrcmpA(patchcode, patch),
9639 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9640 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9641 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9642 ok(!lstrcmpA(targetsid, expectedsid),
9643 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9644 ok(size == lstrlenA(expectedsid),
9645 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9647 /* pdwTargetProductContext is NULL */
9648 lstrcpyA(patchcode, "apple");
9649 lstrcpyA(targetprod, "banana");
9650 lstrcpyA(targetsid, "kiwi");
9651 size = MAX_PATH;
9652 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9653 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9654 NULL, targetsid, &size);
9655 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9656 ok(!lstrcmpA(patchcode, patch),
9657 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9658 ok(!lstrcmpA(targetprod, prodcode),
9659 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9660 ok(!lstrcmpA(targetsid, expectedsid),
9661 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9662 ok(size == lstrlenA(expectedsid),
9663 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9665 /* szTargetUserSid is NULL */
9666 lstrcpyA(patchcode, "apple");
9667 lstrcpyA(targetprod, "banana");
9668 context = 0xdeadbeef;
9669 size = MAX_PATH;
9670 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9671 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9672 &context, NULL, &size);
9673 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9674 ok(!lstrcmpA(patchcode, patch),
9675 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9676 ok(!lstrcmpA(targetprod, prodcode),
9677 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9678 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9679 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9680 ok(size == lstrlenA(expectedsid) * sizeof(WCHAR),
9681 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid), size);
9683 /* pcchTargetUserSid is exactly the length of szTargetUserSid */
9684 lstrcpyA(patchcode, "apple");
9685 lstrcpyA(targetprod, "banana");
9686 context = 0xdeadbeef;
9687 lstrcpyA(targetsid, "kiwi");
9688 size = lstrlenA(expectedsid);
9689 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9690 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9691 &context, targetsid, &size);
9692 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
9693 ok(!lstrcmpA(patchcode, patch),
9694 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9695 ok(!lstrcmpA(targetprod, prodcode),
9696 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9697 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9698 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9699 ok(!strncmp(targetsid, expectedsid, lstrlenA(expectedsid) - 1),
9700 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9701 ok(size == lstrlenA(expectedsid) * sizeof(WCHAR),
9702 "Expected %d*sizeof(WCHAR), got %d\n", lstrlenA(expectedsid), size);
9704 /* pcchTargetUserSid has enough room for NULL terminator */
9705 lstrcpyA(patchcode, "apple");
9706 lstrcpyA(targetprod, "banana");
9707 context = 0xdeadbeef;
9708 lstrcpyA(targetsid, "kiwi");
9709 size = lstrlenA(expectedsid) + 1;
9710 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9711 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9712 &context, targetsid, &size);
9713 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9714 ok(!lstrcmpA(patchcode, patch),
9715 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9716 ok(!lstrcmpA(targetprod, prodcode),
9717 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9718 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9719 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9720 ok(!lstrcmpA(targetsid, expectedsid),
9721 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9722 ok(size == lstrlenA(expectedsid),
9723 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9725 /* both szTargetuserSid and pcchTargetUserSid are NULL */
9726 lstrcpyA(patchcode, "apple");
9727 lstrcpyA(targetprod, "banana");
9728 context = 0xdeadbeef;
9729 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9730 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
9731 &context, NULL, NULL);
9732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9733 ok(!lstrcmpA(patchcode, patch),
9734 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9735 ok(!lstrcmpA(targetprod, prodcode),
9736 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9737 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9738 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9740 /* MSIPATCHSTATE_SUPERSEDED */
9742 lstrcpyA(patchcode, "apple");
9743 lstrcpyA(targetprod, "banana");
9744 context = 0xdeadbeef;
9745 lstrcpyA(targetsid, "kiwi");
9746 size = MAX_PATH;
9747 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9748 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9749 &context, targetsid, &size);
9750 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9751 ok(!lstrcmpA(patchcode, "apple"),
9752 "Expected patchcode to be unchanged, got %s\n", patchcode);
9753 ok(!lstrcmpA(targetprod, "banana"),
9754 "Expected targetprod to be unchanged, got %s\n", targetprod);
9755 ok(context == 0xdeadbeef,
9756 "Expected context to be unchanged, got %d\n", context);
9757 ok(!lstrcmpA(targetsid, "kiwi"),
9758 "Expected targetsid to be unchanged, got %s\n", targetsid);
9759 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9761 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
9762 lstrcatA(keypath, expectedsid);
9763 lstrcatA(keypath, "\\Products\\");
9764 lstrcatA(keypath, prod_squashed);
9766 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
9767 if (res == ERROR_ACCESS_DENIED)
9769 skip("Not enough rights to perform tests\n");
9770 return;
9772 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9774 /* UserData product key exists */
9775 lstrcpyA(patchcode, "apple");
9776 lstrcpyA(targetprod, "banana");
9777 context = 0xdeadbeef;
9778 lstrcpyA(targetsid, "kiwi");
9779 size = MAX_PATH;
9780 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9781 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9782 &context, targetsid, &size);
9783 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9784 ok(!lstrcmpA(patchcode, "apple"),
9785 "Expected patchcode to be unchanged, got %s\n", patchcode);
9786 ok(!lstrcmpA(targetprod, "banana"),
9787 "Expected targetprod to be unchanged, got %s\n", targetprod);
9788 ok(context == 0xdeadbeef,
9789 "Expected context to be unchanged, got %d\n", context);
9790 ok(!lstrcmpA(targetsid, "kiwi"),
9791 "Expected targetsid to be unchanged, got %s\n", targetsid);
9792 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9794 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
9795 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9797 /* UserData patches key exists */
9798 lstrcpyA(patchcode, "apple");
9799 lstrcpyA(targetprod, "banana");
9800 context = 0xdeadbeef;
9801 lstrcpyA(targetsid, "kiwi");
9802 size = MAX_PATH;
9803 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9804 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9805 &context, targetsid, &size);
9806 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9807 ok(!lstrcmpA(patchcode, "apple"),
9808 "Expected patchcode to be unchanged, got %s\n", patchcode);
9809 ok(!lstrcmpA(targetprod, "banana"),
9810 "Expected targetprod to be unchanged, got %s\n", targetprod);
9811 ok(context == 0xdeadbeef,
9812 "Expected context to be unchanged, got %d\n", context);
9813 ok(!lstrcmpA(targetsid, "kiwi"),
9814 "Expected targetsid to be unchanged, got %s\n", targetsid);
9815 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9817 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
9818 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9820 /* specific UserData patch key exists */
9821 lstrcpyA(patchcode, "apple");
9822 lstrcpyA(targetprod, "banana");
9823 context = 0xdeadbeef;
9824 lstrcpyA(targetsid, "kiwi");
9825 size = MAX_PATH;
9826 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9827 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9828 &context, targetsid, &size);
9829 ok(r == ERROR_BAD_CONFIGURATION,
9830 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
9831 ok(!lstrcmpA(patchcode, "apple"),
9832 "Expected patchcode to be unchanged, got %s\n", patchcode);
9833 ok(!lstrcmpA(targetprod, "banana"),
9834 "Expected targetprod to be unchanged, got %s\n", targetprod);
9835 ok(context == 0xdeadbeef,
9836 "Expected context to be unchanged, got %d\n", context);
9837 ok(!lstrcmpA(targetsid, "kiwi"),
9838 "Expected targetsid to be unchanged, got %s\n", targetsid);
9839 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9841 data = MSIPATCHSTATE_SUPERSEDED;
9842 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
9843 (const BYTE *)&data, sizeof(DWORD));
9844 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9846 /* State value exists */
9847 lstrcpyA(patchcode, "apple");
9848 lstrcpyA(targetprod, "banana");
9849 context = 0xdeadbeef;
9850 lstrcpyA(targetsid, "kiwi");
9851 size = MAX_PATH;
9852 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9853 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
9854 &context, targetsid, &size);
9855 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9856 ok(!lstrcmpA(patchcode, patch),
9857 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9858 ok(!lstrcmpA(targetprod, prodcode),
9859 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9860 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9861 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9862 ok(!lstrcmpA(targetsid, expectedsid),
9863 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9864 ok(size == lstrlenA(expectedsid),
9865 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9867 /* MSIPATCHSTATE_OBSOLETED */
9869 lstrcpyA(patchcode, "apple");
9870 lstrcpyA(targetprod, "banana");
9871 context = 0xdeadbeef;
9872 lstrcpyA(targetsid, "kiwi");
9873 size = MAX_PATH;
9874 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9875 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
9876 &context, targetsid, &size);
9877 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9878 ok(!lstrcmpA(patchcode, "apple"),
9879 "Expected patchcode to be unchanged, got %s\n", patchcode);
9880 ok(!lstrcmpA(targetprod, "banana"),
9881 "Expected targetprod to be unchanged, got %s\n", targetprod);
9882 ok(context == 0xdeadbeef,
9883 "Expected context to be unchanged, got %d\n", context);
9884 ok(!lstrcmpA(targetsid, "kiwi"),
9885 "Expected targetsid to be unchanged, got %s\n", targetsid);
9886 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9888 data = MSIPATCHSTATE_OBSOLETED;
9889 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
9890 (const BYTE *)&data, sizeof(DWORD));
9891 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9893 /* State value is obsoleted */
9894 lstrcpyA(patchcode, "apple");
9895 lstrcpyA(targetprod, "banana");
9896 context = 0xdeadbeef;
9897 lstrcpyA(targetsid, "kiwi");
9898 size = MAX_PATH;
9899 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9900 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
9901 &context, targetsid, &size);
9902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9903 ok(!lstrcmpA(patchcode, patch),
9904 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9905 ok(!lstrcmpA(targetprod, prodcode),
9906 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9907 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9908 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9909 ok(!lstrcmpA(targetsid, expectedsid),
9910 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9911 ok(size == lstrlenA(expectedsid),
9912 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9914 /* MSIPATCHSTATE_REGISTERED */
9915 /* FIXME */
9917 /* MSIPATCHSTATE_ALL */
9919 /* 1st */
9920 lstrcpyA(patchcode, "apple");
9921 lstrcpyA(targetprod, "banana");
9922 context = 0xdeadbeef;
9923 lstrcpyA(targetsid, "kiwi");
9924 size = MAX_PATH;
9925 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9926 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
9927 &context, targetsid, &size);
9928 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9929 ok(!lstrcmpA(patchcode, patch),
9930 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
9931 ok(!lstrcmpA(targetprod, prodcode),
9932 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
9933 ok(context == MSIINSTALLCONTEXT_USERMANAGED,
9934 "Expected MSIINSTALLCONTEXT_USERMANAGED, got %d\n", context);
9935 ok(!lstrcmpA(targetsid, expectedsid),
9936 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
9937 ok(size == lstrlenA(expectedsid),
9938 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
9940 /* same patch in multiple places, only one is enumerated */
9941 lstrcpyA(patchcode, "apple");
9942 lstrcpyA(targetprod, "banana");
9943 context = 0xdeadbeef;
9944 lstrcpyA(targetsid, "kiwi");
9945 size = MAX_PATH;
9946 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERMANAGED,
9947 MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
9948 &context, targetsid, &size);
9949 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9950 ok(!lstrcmpA(patchcode, "apple"),
9951 "Expected patchcode to be unchanged, got %s\n", patchcode);
9952 ok(!lstrcmpA(targetprod, "banana"),
9953 "Expected targetprod to be unchanged, got %s\n", targetprod);
9954 ok(context == 0xdeadbeef,
9955 "Expected context to be unchanged, got %d\n", context);
9956 ok(!lstrcmpA(targetsid, "kiwi"),
9957 "Expected targetsid to be unchanged, got %s\n", targetsid);
9958 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
9960 RegDeleteValueA(hpatch, "State");
9961 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
9962 RegCloseKey(hpatch);
9963 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
9964 RegCloseKey(udpatch);
9965 delete_key(udprod, "", access & KEY_WOW64_64KEY);
9966 RegCloseKey(udprod);
9967 RegDeleteValueA(patches, "Patches");
9968 delete_key(patches, "", access & KEY_WOW64_64KEY);
9969 RegCloseKey(patches);
9970 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
9971 RegCloseKey(prodkey);
9974 static void test_MsiEnumPatchesEx_userunmanaged(LPCSTR usersid, LPCSTR expectedsid)
9976 MSIINSTALLCONTEXT context;
9977 CHAR keypath[MAX_PATH], patch[MAX_PATH];
9978 CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
9979 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
9980 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
9981 HKEY prodkey, patches, udprod, udpatch;
9982 HKEY userkey, hpatch;
9983 DWORD size, data;
9984 LONG res;
9985 UINT r;
9986 REGSAM access = KEY_ALL_ACCESS;
9988 create_test_guid(prodcode, prod_squashed);
9989 create_test_guid(patch, patch_squashed);
9991 if (is_wow64)
9992 access |= KEY_WOW64_64KEY;
9994 /* MSIPATCHSTATE_APPLIED */
9996 lstrcpyA(patchcode, "apple");
9997 lstrcpyA(targetprod, "banana");
9998 context = 0xdeadbeef;
9999 lstrcpyA(targetsid, "kiwi");
10000 size = MAX_PATH;
10001 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10002 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10003 &context, targetsid, &size);
10004 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10005 ok(!lstrcmpA(patchcode, "apple"),
10006 "Expected patchcode to be unchanged, got %s\n", patchcode);
10007 ok(!lstrcmpA(targetprod, "banana"),
10008 "Expected targetprod to be unchanged, got %s\n", targetprod);
10009 ok(context == 0xdeadbeef,
10010 "Expected context to be unchanged, got %d\n", context);
10011 ok(!lstrcmpA(targetsid, "kiwi"),
10012 "Expected targetsid to be unchanged, got %s\n", targetsid);
10013 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10015 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
10016 lstrcatA(keypath, prod_squashed);
10018 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
10019 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10021 /* current user product key exists */
10022 lstrcpyA(patchcode, "apple");
10023 lstrcpyA(targetprod, "banana");
10024 context = 0xdeadbeef;
10025 lstrcpyA(targetsid, "kiwi");
10026 size = MAX_PATH;
10027 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10028 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10029 &context, targetsid, &size);
10030 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10031 ok(!lstrcmpA(patchcode, "apple"),
10032 "Expected patchcode to be unchanged, got %s\n", patchcode);
10033 ok(!lstrcmpA(targetprod, "banana"),
10034 "Expected targetprod to be unchanged, got %s\n", targetprod);
10035 ok(context == 0xdeadbeef,
10036 "Expected context to be unchanged, got %d\n", context);
10037 ok(!lstrcmpA(targetsid, "kiwi"),
10038 "Expected targetsid to be unchanged, got %s\n", targetsid);
10039 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10041 res = RegCreateKeyA(prodkey, "Patches", &patches);
10042 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10044 /* Patches key exists */
10045 lstrcpyA(patchcode, "apple");
10046 lstrcpyA(targetprod, "banana");
10047 context = 0xdeadbeef;
10048 lstrcpyA(targetsid, "kiwi");
10049 size = MAX_PATH;
10050 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10051 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10052 &context, targetsid, &size);
10053 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10054 ok(!lstrcmpA(patchcode, "apple"),
10055 "Expected patchcode to be unchanged, got %s\n", patchcode);
10056 ok(!lstrcmpA(targetprod, "banana"),
10057 "Expected targetprod to be unchanged, got %s\n", targetprod);
10058 ok(context == 0xdeadbeef,
10059 "Expected context to be unchanged, got %d\n", context);
10060 ok(!lstrcmpA(targetsid, "kiwi"),
10061 "Expected targetsid to be unchanged, got %s\n", targetsid);
10062 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10064 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
10065 (const BYTE *)patch_squashed,
10066 lstrlenA(patch_squashed) + 1);
10067 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10069 /* Patches value exists, is not REG_MULTI_SZ */
10070 lstrcpyA(patchcode, "apple");
10071 lstrcpyA(targetprod, "banana");
10072 context = 0xdeadbeef;
10073 lstrcpyA(targetsid, "kiwi");
10074 size = MAX_PATH;
10075 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10076 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10077 &context, targetsid, &size);
10078 ok(r == ERROR_BAD_CONFIGURATION,
10079 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10080 ok(!lstrcmpA(patchcode, "apple"),
10081 "Expected patchcode to be unchanged, got %s\n", patchcode);
10082 ok(!lstrcmpA(targetprod, "banana"),
10083 "Expected targetprod to be unchanged, got %s\n", targetprod);
10084 ok(context == 0xdeadbeef,
10085 "Expected context to be unchanged, got %d\n", context);
10086 ok(!lstrcmpA(targetsid, "kiwi"),
10087 "Expected targetsid to be unchanged, got %s\n", targetsid);
10088 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10090 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
10091 (const BYTE *)"a\0b\0c\0\0", 7);
10092 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10094 /* Patches value exists, is not a squashed guid */
10095 lstrcpyA(patchcode, "apple");
10096 lstrcpyA(targetprod, "banana");
10097 context = 0xdeadbeef;
10098 lstrcpyA(targetsid, "kiwi");
10099 size = MAX_PATH;
10100 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10101 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10102 &context, targetsid, &size);
10103 ok(r == ERROR_BAD_CONFIGURATION,
10104 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10105 ok(!lstrcmpA(patchcode, "apple"),
10106 "Expected patchcode to be unchanged, got %s\n", patchcode);
10107 ok(!lstrcmpA(targetprod, "banana"),
10108 "Expected targetprod to be unchanged, got %s\n", targetprod);
10109 ok(context == 0xdeadbeef,
10110 "Expected context to be unchanged, got %d\n", context);
10111 ok(!lstrcmpA(targetsid, "kiwi"),
10112 "Expected targetsid to be unchanged, got %s\n", targetsid);
10113 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10115 patch_squashed[lstrlenA(patch_squashed) + 1] = 0;
10116 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
10117 (const BYTE *)patch_squashed,
10118 lstrlenA(patch_squashed) + 2);
10119 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10121 /* Patches value exists */
10122 lstrcpyA(patchcode, "apple");
10123 lstrcpyA(targetprod, "banana");
10124 context = 0xdeadbeef;
10125 lstrcpyA(targetsid, "kiwi");
10126 size = MAX_PATH;
10127 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10128 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10129 &context, targetsid, &size);
10130 ok(r == ERROR_NO_MORE_ITEMS ||
10131 broken(r == ERROR_BAD_CONFIGURATION), /* Windows Installer 3.0 */
10132 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10133 ok(!lstrcmpA(patchcode, "apple"),
10134 "Expected patchcode to be unchanged, got %s\n", patchcode);
10135 ok(!lstrcmpA(targetprod, "banana"),
10136 "Expected targetprod to be unchanged, got %s\n", targetprod);
10137 ok(context == 0xdeadbeef,
10138 "Expected context to be unchanged, got %d\n", context);
10139 ok(!lstrcmpA(targetsid, "kiwi"),
10140 "Expected targetsid to be unchanged, got %s\n", targetsid);
10141 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10143 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
10144 (const BYTE *)"whatever", 9);
10145 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10147 /* patch code value exists */
10148 lstrcpyA(patchcode, "apple");
10149 lstrcpyA(targetprod, "banana");
10150 context = 0xdeadbeef;
10151 lstrcpyA(targetsid, "kiwi");
10152 size = MAX_PATH;
10153 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10154 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10155 &context, targetsid, &size);
10156 ok(r == ERROR_NO_MORE_ITEMS ||
10157 broken(r == ERROR_BAD_CONFIGURATION), /* Windows Installer 3.0 */
10158 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10159 ok(!lstrcmpA(patchcode, "apple"),
10160 "Expected patchcode to be unchanged, got %s\n", patchcode);
10161 ok(!lstrcmpA(targetprod, "banana"),
10162 "Expected targetprod to be unchanged, got %s\n", targetprod);
10163 ok(context == 0xdeadbeef,
10164 "Expected context to be unchanged, got %d\n", context);
10165 ok(!lstrcmpA(targetsid, "kiwi"),
10166 "Expected targetsid to be unchanged, got %s\n", targetsid);
10167 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10169 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
10170 lstrcatA(keypath, expectedsid);
10171 lstrcatA(keypath, "\\Patches\\");
10172 lstrcatA(keypath, patch_squashed);
10174 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
10175 if (res == ERROR_ACCESS_DENIED)
10177 skip("Not enough rights to perform tests\n");
10178 goto error;
10180 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10182 /* userdata patch key exists */
10183 lstrcpyA(patchcode, "apple");
10184 lstrcpyA(targetprod, "banana");
10185 context = 0xdeadbeef;
10186 lstrcpyA(targetsid, "kiwi");
10187 size = MAX_PATH;
10188 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10189 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10190 &context, targetsid, &size);
10191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10192 ok(!lstrcmpA(patchcode, patch),
10193 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10194 ok(!lstrcmpA(targetprod, prodcode),
10195 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10196 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10197 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10198 ok(!lstrcmpA(targetsid, expectedsid),
10199 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10200 ok(size == lstrlenA(expectedsid),
10201 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10203 /* MSIPATCHSTATE_SUPERSEDED */
10205 lstrcpyA(patchcode, "apple");
10206 lstrcpyA(targetprod, "banana");
10207 context = 0xdeadbeef;
10208 lstrcpyA(targetsid, "kiwi");
10209 size = MAX_PATH;
10210 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10211 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10212 &context, targetsid, &size);
10213 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10214 ok(!lstrcmpA(patchcode, "apple"),
10215 "Expected patchcode to be unchanged, got %s\n", patchcode);
10216 ok(!lstrcmpA(targetprod, "banana"),
10217 "Expected targetprod to be unchanged, got %s\n", targetprod);
10218 ok(context == 0xdeadbeef,
10219 "Expected context to be unchanged, got %d\n", context);
10220 ok(!lstrcmpA(targetsid, "kiwi"),
10221 "Expected targetsid to be unchanged, got %s\n", targetsid);
10222 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10224 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
10225 lstrcatA(keypath, expectedsid);
10226 lstrcatA(keypath, "\\Products\\");
10227 lstrcatA(keypath, prod_squashed);
10229 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
10230 if (res == ERROR_ACCESS_DENIED)
10232 skip("Not enough rights to perform tests\n");
10233 goto error;
10235 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10237 /* UserData product key exists */
10238 lstrcpyA(patchcode, "apple");
10239 lstrcpyA(targetprod, "banana");
10240 context = 0xdeadbeef;
10241 lstrcpyA(targetsid, "kiwi");
10242 size = MAX_PATH;
10243 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10244 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10245 &context, targetsid, &size);
10246 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10247 ok(!lstrcmpA(patchcode, "apple"),
10248 "Expected patchcode to be unchanged, got %s\n", patchcode);
10249 ok(!lstrcmpA(targetprod, "banana"),
10250 "Expected targetprod to be unchanged, got %s\n", targetprod);
10251 ok(context == 0xdeadbeef,
10252 "Expected context to be unchanged, got %d\n", context);
10253 ok(!lstrcmpA(targetsid, "kiwi"),
10254 "Expected targetsid to be unchanged, got %s\n", targetsid);
10255 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10257 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
10258 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10260 /* UserData patches key exists */
10261 lstrcpyA(patchcode, "apple");
10262 lstrcpyA(targetprod, "banana");
10263 context = 0xdeadbeef;
10264 lstrcpyA(targetsid, "kiwi");
10265 size = MAX_PATH;
10266 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10267 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10268 &context, targetsid, &size);
10269 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10270 ok(!lstrcmpA(patchcode, "apple"),
10271 "Expected patchcode to be unchanged, got %s\n", patchcode);
10272 ok(!lstrcmpA(targetprod, "banana"),
10273 "Expected targetprod to be unchanged, got %s\n", targetprod);
10274 ok(context == 0xdeadbeef,
10275 "Expected context to be unchanged, got %d\n", context);
10276 ok(!lstrcmpA(targetsid, "kiwi"),
10277 "Expected targetsid to be unchanged, got %s\n", targetsid);
10278 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10280 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
10281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10283 /* specific UserData patch key exists */
10284 lstrcpyA(patchcode, "apple");
10285 lstrcpyA(targetprod, "banana");
10286 context = 0xdeadbeef;
10287 lstrcpyA(targetsid, "kiwi");
10288 size = MAX_PATH;
10289 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10290 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10291 &context, targetsid, &size);
10292 ok(r == ERROR_BAD_CONFIGURATION,
10293 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10294 ok(!lstrcmpA(patchcode, "apple"),
10295 "Expected patchcode to be unchanged, got %s\n", patchcode);
10296 ok(!lstrcmpA(targetprod, "banana"),
10297 "Expected targetprod to be unchanged, got %s\n", targetprod);
10298 ok(context == 0xdeadbeef,
10299 "Expected context to be unchanged, got %d\n", context);
10300 ok(!lstrcmpA(targetsid, "kiwi"),
10301 "Expected targetsid to be unchanged, got %s\n", targetsid);
10302 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10304 data = MSIPATCHSTATE_SUPERSEDED;
10305 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10306 (const BYTE *)&data, sizeof(DWORD));
10307 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10309 /* State value exists */
10310 lstrcpyA(patchcode, "apple");
10311 lstrcpyA(targetprod, "banana");
10312 context = 0xdeadbeef;
10313 lstrcpyA(targetsid, "kiwi");
10314 size = MAX_PATH;
10315 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10316 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10317 &context, targetsid, &size);
10318 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10319 ok(!lstrcmpA(patchcode, patch),
10320 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10321 ok(!lstrcmpA(targetprod, prodcode),
10322 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10323 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10324 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10325 ok(!lstrcmpA(targetsid, expectedsid),
10326 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10327 ok(size == lstrlenA(expectedsid),
10328 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10330 /* MSIPATCHSTATE_OBSOLETED */
10332 lstrcpyA(patchcode, "apple");
10333 lstrcpyA(targetprod, "banana");
10334 context = 0xdeadbeef;
10335 lstrcpyA(targetsid, "kiwi");
10336 size = MAX_PATH;
10337 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10338 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10339 &context, targetsid, &size);
10340 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10341 ok(!lstrcmpA(patchcode, "apple"),
10342 "Expected patchcode to be unchanged, got %s\n", patchcode);
10343 ok(!lstrcmpA(targetprod, "banana"),
10344 "Expected targetprod to be unchanged, got %s\n", targetprod);
10345 ok(context == 0xdeadbeef,
10346 "Expected context to be unchanged, got %d\n", context);
10347 ok(!lstrcmpA(targetsid, "kiwi"),
10348 "Expected targetsid to be unchanged, got %s\n", targetsid);
10349 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10351 data = MSIPATCHSTATE_OBSOLETED;
10352 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10353 (const BYTE *)&data, sizeof(DWORD));
10354 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10356 /* State value is obsoleted */
10357 lstrcpyA(patchcode, "apple");
10358 lstrcpyA(targetprod, "banana");
10359 context = 0xdeadbeef;
10360 lstrcpyA(targetsid, "kiwi");
10361 size = MAX_PATH;
10362 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10363 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10364 &context, targetsid, &size);
10365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10366 ok(!lstrcmpA(patchcode, patch),
10367 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10368 ok(!lstrcmpA(targetprod, prodcode),
10369 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10370 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10371 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10372 ok(!lstrcmpA(targetsid, expectedsid),
10373 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10374 ok(size == lstrlenA(expectedsid),
10375 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10377 /* MSIPATCHSTATE_REGISTERED */
10378 /* FIXME */
10380 /* MSIPATCHSTATE_ALL */
10382 /* 1st */
10383 lstrcpyA(patchcode, "apple");
10384 lstrcpyA(targetprod, "banana");
10385 context = 0xdeadbeef;
10386 lstrcpyA(targetsid, "kiwi");
10387 size = MAX_PATH;
10388 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10389 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10390 &context, targetsid, &size);
10391 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10392 ok(!lstrcmpA(patchcode, patch),
10393 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10394 ok(!lstrcmpA(targetprod, prodcode),
10395 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10396 ok(context == MSIINSTALLCONTEXT_USERUNMANAGED,
10397 "Expected MSIINSTALLCONTEXT_USERUNMANAGED, got %d\n", context);
10398 ok(!lstrcmpA(targetsid, expectedsid),
10399 "Expected \"%s\", got \"%s\"\n", expectedsid, targetsid);
10400 ok(size == lstrlenA(expectedsid),
10401 "Expected %d, got %d\n", lstrlenA(expectedsid), size);
10403 /* same patch in multiple places, only one is enumerated */
10404 lstrcpyA(patchcode, "apple");
10405 lstrcpyA(targetprod, "banana");
10406 context = 0xdeadbeef;
10407 lstrcpyA(targetsid, "kiwi");
10408 size = MAX_PATH;
10409 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10410 MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
10411 &context, targetsid, &size);
10412 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10413 ok(!lstrcmpA(patchcode, "apple"),
10414 "Expected patchcode to be unchanged, got %s\n", patchcode);
10415 ok(!lstrcmpA(targetprod, "banana"),
10416 "Expected targetprod to be unchanged, got %s\n", targetprod);
10417 ok(context == 0xdeadbeef,
10418 "Expected context to be unchanged, got %d\n", context);
10419 ok(!lstrcmpA(targetsid, "kiwi"),
10420 "Expected targetsid to be unchanged, got %s\n", targetsid);
10421 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10423 RegDeleteValueA(hpatch, "State");
10424 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
10425 RegCloseKey(hpatch);
10426 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
10427 RegCloseKey(udpatch);
10428 delete_key(udprod, "", access & KEY_WOW64_64KEY);
10429 RegCloseKey(udprod);
10430 delete_key(userkey, "", access & KEY_WOW64_64KEY);
10431 RegCloseKey(userkey);
10432 RegDeleteValueA(patches, patch_squashed);
10433 RegDeleteValueA(patches, "Patches");
10435 error:
10436 RegDeleteKeyA(patches, "");
10437 RegCloseKey(patches);
10438 RegDeleteKeyA(prodkey, "");
10439 RegCloseKey(prodkey);
10442 static void test_MsiEnumPatchesEx_machine(void)
10444 CHAR keypath[MAX_PATH], patch[MAX_PATH];
10445 CHAR patch_squashed[MAX_PATH], patchcode[MAX_PATH];
10446 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
10447 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
10448 HKEY prodkey, patches, udprod, udpatch;
10449 HKEY hpatch;
10450 MSIINSTALLCONTEXT context;
10451 DWORD size, data;
10452 LONG res;
10453 UINT r;
10454 REGSAM access = KEY_ALL_ACCESS;
10456 create_test_guid(prodcode, prod_squashed);
10457 create_test_guid(patch, patch_squashed);
10459 if (is_wow64)
10460 access |= KEY_WOW64_64KEY;
10462 /* MSIPATCHSTATE_APPLIED */
10464 lstrcpyA(patchcode, "apple");
10465 lstrcpyA(targetprod, "banana");
10466 context = 0xdeadbeef;
10467 lstrcpyA(targetsid, "kiwi");
10468 size = MAX_PATH;
10469 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10470 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10471 &context, targetsid, &size);
10472 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10473 ok(!lstrcmpA(patchcode, "apple"),
10474 "Expected patchcode to be unchanged, got %s\n", patchcode);
10475 ok(!lstrcmpA(targetprod, "banana"),
10476 "Expected targetprod to be unchanged, got %s\n", targetprod);
10477 ok(context == 0xdeadbeef,
10478 "Expected context to be unchanged, got %d\n", context);
10479 ok(!lstrcmpA(targetsid, "kiwi"),
10480 "Expected targetsid to be unchanged, got %s\n", targetsid);
10481 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10483 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
10484 lstrcatA(keypath, prod_squashed);
10486 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
10487 if (res == ERROR_ACCESS_DENIED)
10489 skip("Not enough rights to perform tests\n");
10490 return;
10492 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10494 /* local product key exists */
10495 lstrcpyA(patchcode, "apple");
10496 lstrcpyA(targetprod, "banana");
10497 context = 0xdeadbeef;
10498 lstrcpyA(targetsid, "kiwi");
10499 size = MAX_PATH;
10500 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10501 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10502 &context, targetsid, &size);
10503 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10504 ok(!lstrcmpA(patchcode, "apple"),
10505 "Expected patchcode to be unchanged, got %s\n", patchcode);
10506 ok(!lstrcmpA(targetprod, "banana"),
10507 "Expected targetprod to be unchanged, got %s\n", targetprod);
10508 ok(context == 0xdeadbeef,
10509 "Expected context to be unchanged, got %d\n", context);
10510 ok(!lstrcmpA(targetsid, "kiwi"),
10511 "Expected targetsid to be unchanged, got %s\n", targetsid);
10512 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10514 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
10515 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10517 /* Patches key exists */
10518 lstrcpyA(patchcode, "apple");
10519 lstrcpyA(targetprod, "banana");
10520 context = 0xdeadbeef;
10521 lstrcpyA(targetsid, "kiwi");
10522 size = MAX_PATH;
10523 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10524 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10525 &context, targetsid, &size);
10526 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10527 ok(!lstrcmpA(patchcode, "apple"),
10528 "Expected patchcode to be unchanged, got %s\n", patchcode);
10529 ok(!lstrcmpA(targetprod, "banana"),
10530 "Expected targetprod to be unchanged, got %s\n", targetprod);
10531 ok(context == 0xdeadbeef,
10532 "Expected context to be unchanged, got %d\n", context);
10533 ok(!lstrcmpA(targetsid, "kiwi"),
10534 "Expected targetsid to be unchanged, got %s\n", targetsid);
10535 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10537 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
10538 (const BYTE *)patch_squashed,
10539 lstrlenA(patch_squashed) + 1);
10540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10542 /* Patches value exists, is not REG_MULTI_SZ */
10543 lstrcpyA(patchcode, "apple");
10544 lstrcpyA(targetprod, "banana");
10545 context = 0xdeadbeef;
10546 lstrcpyA(targetsid, "kiwi");
10547 size = MAX_PATH;
10548 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10549 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10550 &context, targetsid, &size);
10551 ok(r == ERROR_BAD_CONFIGURATION,
10552 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10553 ok(!lstrcmpA(patchcode, "apple"),
10554 "Expected patchcode to be unchanged, got %s\n", patchcode);
10555 ok(!lstrcmpA(targetprod, "banana"),
10556 "Expected targetprod to be unchanged, got %s\n", targetprod);
10557 ok(context == 0xdeadbeef,
10558 "Expected context to be unchanged, got %d\n", context);
10559 ok(!lstrcmpA(targetsid, "kiwi"),
10560 "Expected targetsid to be unchanged, got %s\n", targetsid);
10561 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10563 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
10564 (const BYTE *)"a\0b\0c\0\0", 7);
10565 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10567 /* Patches value exists, is not a squashed guid */
10568 lstrcpyA(patchcode, "apple");
10569 lstrcpyA(targetprod, "banana");
10570 context = 0xdeadbeef;
10571 lstrcpyA(targetsid, "kiwi");
10572 size = MAX_PATH;
10573 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10574 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10575 &context, targetsid, &size);
10576 ok(r == ERROR_BAD_CONFIGURATION,
10577 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
10578 ok(!lstrcmpA(patchcode, "apple"),
10579 "Expected patchcode to be unchanged, got %s\n", patchcode);
10580 ok(!lstrcmpA(targetprod, "banana"),
10581 "Expected targetprod to be unchanged, got %s\n", targetprod);
10582 ok(context == 0xdeadbeef,
10583 "Expected context to be unchanged, got %d\n", context);
10584 ok(!lstrcmpA(targetsid, "kiwi"),
10585 "Expected targetsid to be unchanged, got %s\n", targetsid);
10586 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10588 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
10589 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
10590 (const BYTE *)patch_squashed,
10591 lstrlenA(patch_squashed) + 2);
10592 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10594 /* Patches value exists */
10595 lstrcpyA(patchcode, "apple");
10596 lstrcpyA(targetprod, "banana");
10597 context = 0xdeadbeef;
10598 lstrcpyA(targetsid, "kiwi");
10599 size = MAX_PATH;
10600 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10601 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10602 &context, targetsid, &size);
10603 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10604 ok(!lstrcmpA(patchcode, "apple"),
10605 "Expected patchcode to be unchanged, got %s\n", patchcode);
10606 ok(!lstrcmpA(targetprod, "banana"),
10607 "Expected targetprod to be unchanged, got %s\n", targetprod);
10608 ok(context == 0xdeadbeef,
10609 "Expected context to be unchanged, got %d\n", context);
10610 ok(!lstrcmpA(targetsid, "kiwi"),
10611 "Expected targetsid to be unchanged, got %s\n", targetsid);
10612 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10614 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
10615 (const BYTE *)"whatever", 9);
10616 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10618 /* patch code value exists */
10619 lstrcpyA(patchcode, "apple");
10620 lstrcpyA(targetprod, "banana");
10621 context = 0xdeadbeef;
10622 lstrcpyA(targetsid, "kiwi");
10623 size = MAX_PATH;
10624 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10625 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10626 &context, targetsid, &size);
10627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10628 ok(!lstrcmpA(patchcode, patch),
10629 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10630 ok(!lstrcmpA(targetprod, prodcode),
10631 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10632 ok(context == MSIINSTALLCONTEXT_MACHINE,
10633 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10634 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10635 ok(size == 0, "Expected 0, got %d\n", size);
10637 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
10638 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
10639 lstrcatA(keypath, prod_squashed);
10641 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
10642 if (res == ERROR_ACCESS_DENIED)
10644 skip("Not enough rights to perform tests\n");
10645 goto done;
10647 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10649 /* local UserData product key exists */
10650 lstrcpyA(patchcode, "apple");
10651 lstrcpyA(targetprod, "banana");
10652 context = 0xdeadbeef;
10653 lstrcpyA(targetsid, "kiwi");
10654 size = MAX_PATH;
10655 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10656 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10657 &context, targetsid, &size);
10658 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10659 ok(!lstrcmpA(patchcode, patch),
10660 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10661 ok(!lstrcmpA(targetprod, prodcode),
10662 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10663 ok(context == MSIINSTALLCONTEXT_MACHINE,
10664 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10665 ok(!lstrcmpA(targetsid, ""),
10666 "Expected \"\", got \"%s\"\n", targetsid);
10667 ok(size == 0, "Expected 0, got %d\n", size);
10669 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
10670 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10672 /* local UserData Patches key exists */
10673 lstrcpyA(patchcode, "apple");
10674 lstrcpyA(targetprod, "banana");
10675 context = 0xdeadbeef;
10676 lstrcpyA(targetsid, "kiwi");
10677 size = MAX_PATH;
10678 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10679 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10680 &context, targetsid, &size);
10681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10682 ok(!lstrcmpA(patchcode, patch),
10683 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10684 ok(!lstrcmpA(targetprod, prodcode),
10685 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10686 ok(context == MSIINSTALLCONTEXT_MACHINE,
10687 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10688 ok(!lstrcmpA(targetsid, ""),
10689 "Expected \"\", got \"%s\"\n", targetsid);
10690 ok(size == 0, "Expected 0, got %d\n", size);
10692 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
10693 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10695 /* local UserData Product patch key exists */
10696 lstrcpyA(patchcode, "apple");
10697 lstrcpyA(targetprod, "banana");
10698 context = 0xdeadbeef;
10699 lstrcpyA(targetsid, "kiwi");
10700 size = MAX_PATH;
10701 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10702 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10703 &context, targetsid, &size);
10704 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10705 ok(!lstrcmpA(patchcode, "apple"),
10706 "Expected patchcode to be unchanged, got %s\n", patchcode);
10707 ok(!lstrcmpA(targetprod, "banana"),
10708 "Expected targetprod to be unchanged, got %s\n", targetprod);
10709 ok(context == 0xdeadbeef,
10710 "Expected context to be unchanged, got %d\n", context);
10711 ok(!lstrcmpA(targetsid, "kiwi"),
10712 "Expected targetsid to be unchanged, got %s\n", targetsid);
10713 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10715 data = MSIPATCHSTATE_APPLIED;
10716 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10717 (const BYTE *)&data, sizeof(DWORD));
10718 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10720 /* State value exists */
10721 lstrcpyA(patchcode, "apple");
10722 lstrcpyA(targetprod, "banana");
10723 context = 0xdeadbeef;
10724 lstrcpyA(targetsid, "kiwi");
10725 size = MAX_PATH;
10726 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10727 MSIPATCHSTATE_APPLIED, 0, patchcode, targetprod,
10728 &context, targetsid, &size);
10729 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10730 ok(!lstrcmpA(patchcode, patch),
10731 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10732 ok(!lstrcmpA(targetprod, prodcode),
10733 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10734 ok(context == MSIINSTALLCONTEXT_MACHINE,
10735 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10736 ok(!lstrcmpA(targetsid, ""),
10737 "Expected \"\", got \"%s\"\n", targetsid);
10738 ok(size == 0, "Expected 0, got %d\n", size);
10740 /* MSIPATCHSTATE_SUPERSEDED */
10742 lstrcpyA(patchcode, "apple");
10743 lstrcpyA(targetprod, "banana");
10744 context = 0xdeadbeef;
10745 lstrcpyA(targetsid, "kiwi");
10746 size = MAX_PATH;
10747 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10748 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10749 &context, targetsid, &size);
10750 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10751 ok(!lstrcmpA(patchcode, "apple"),
10752 "Expected patchcode to be unchanged, got %s\n", patchcode);
10753 ok(!lstrcmpA(targetprod, "banana"),
10754 "Expected targetprod to be unchanged, got %s\n", targetprod);
10755 ok(context == 0xdeadbeef,
10756 "Expected context to be unchanged, got %d\n", context);
10757 ok(!lstrcmpA(targetsid, "kiwi"),
10758 "Expected targetsid to be unchanged, got %s\n", targetsid);
10759 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10761 data = MSIPATCHSTATE_SUPERSEDED;
10762 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10763 (const BYTE *)&data, sizeof(DWORD));
10764 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10766 /* State value is MSIPATCHSTATE_SUPERSEDED */
10767 lstrcpyA(patchcode, "apple");
10768 lstrcpyA(targetprod, "banana");
10769 context = 0xdeadbeef;
10770 lstrcpyA(targetsid, "kiwi");
10771 size = MAX_PATH;
10772 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10773 MSIPATCHSTATE_SUPERSEDED, 0, patchcode, targetprod,
10774 &context, targetsid, &size);
10775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10776 ok(!lstrcmpA(patchcode, patch),
10777 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10778 ok(!lstrcmpA(targetprod, prodcode),
10779 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10780 ok(context == MSIINSTALLCONTEXT_MACHINE,
10781 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10782 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10783 ok(size == 0, "Expected 0, got %d\n", size);
10785 /* MSIPATCHSTATE_OBSOLETED */
10787 lstrcpyA(patchcode, "apple");
10788 lstrcpyA(targetprod, "banana");
10789 context = 0xdeadbeef;
10790 lstrcpyA(targetsid, "kiwi");
10791 size = MAX_PATH;
10792 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10793 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10794 &context, targetsid, &size);
10795 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10796 ok(!lstrcmpA(patchcode, "apple"),
10797 "Expected patchcode to be unchanged, got %s\n", patchcode);
10798 ok(!lstrcmpA(targetprod, "banana"),
10799 "Expected targetprod to be unchanged, got %s\n", targetprod);
10800 ok(context == 0xdeadbeef,
10801 "Expected context to be unchanged, got %d\n", context);
10802 ok(!lstrcmpA(targetsid, "kiwi"),
10803 "Expected targetsid to be unchanged, got %s\n", targetsid);
10804 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10806 data = MSIPATCHSTATE_OBSOLETED;
10807 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
10808 (const BYTE *)&data, sizeof(DWORD));
10809 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
10811 /* State value is obsoleted */
10812 lstrcpyA(patchcode, "apple");
10813 lstrcpyA(targetprod, "banana");
10814 context = 0xdeadbeef;
10815 lstrcpyA(targetsid, "kiwi");
10816 size = MAX_PATH;
10817 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10818 MSIPATCHSTATE_OBSOLETED, 0, patchcode, targetprod,
10819 &context, targetsid, &size);
10820 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10821 ok(!lstrcmpA(patchcode, patch),
10822 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10823 ok(!lstrcmpA(targetprod, prodcode),
10824 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10825 ok(context == MSIINSTALLCONTEXT_MACHINE,
10826 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10827 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10828 ok(size == 0, "Expected 0, got %d\n", size);
10830 /* MSIPATCHSTATE_REGISTERED */
10831 /* FIXME */
10833 /* MSIPATCHSTATE_ALL */
10835 /* 1st */
10836 lstrcpyA(patchcode, "apple");
10837 lstrcpyA(targetprod, "banana");
10838 context = 0xdeadbeef;
10839 lstrcpyA(targetsid, "kiwi");
10840 size = MAX_PATH;
10841 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10842 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
10843 &context, targetsid, &size);
10844 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
10845 ok(!lstrcmpA(patchcode, patch),
10846 "Expected \"%s\", got \"%s\"\n", patch, patchcode);
10847 ok(!lstrcmpA(targetprod, prodcode),
10848 "Expected \"%s\", got \"%s\"\n", prodcode, targetprod);
10849 ok(context == MSIINSTALLCONTEXT_MACHINE,
10850 "Expected MSIINSTALLCONTEXT_MACHINE, got %d\n", context);
10851 ok(!lstrcmpA(targetsid, ""), "Expected \"\", got \"%s\"\n", targetsid);
10852 ok(size == 0, "Expected 0, got %d\n", size);
10854 /* same patch in multiple places, only one is enumerated */
10855 lstrcpyA(patchcode, "apple");
10856 lstrcpyA(targetprod, "banana");
10857 context = 0xdeadbeef;
10858 lstrcpyA(targetsid, "kiwi");
10859 size = MAX_PATH;
10860 r = pMsiEnumPatchesExA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE,
10861 MSIPATCHSTATE_ALL, 1, patchcode, targetprod,
10862 &context, targetsid, &size);
10863 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10864 ok(!lstrcmpA(patchcode, "apple"),
10865 "Expected patchcode to be unchanged, got %s\n", patchcode);
10866 ok(!lstrcmpA(targetprod, "banana"),
10867 "Expected targetprod to be unchanged, got %s\n", targetprod);
10868 ok(context == 0xdeadbeef,
10869 "Expected context to be unchanged, got %d\n", context);
10870 ok(!lstrcmpA(targetsid, "kiwi"),
10871 "Expected targetsid to be unchanged, got %s\n", targetsid);
10872 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10874 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
10875 RegDeleteValueA(hpatch, "State");
10876 RegCloseKey(hpatch);
10877 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
10878 RegCloseKey(udpatch);
10879 delete_key(udprod, "", access & KEY_WOW64_64KEY);
10880 RegCloseKey(udprod);
10882 done:
10883 RegDeleteValueA(patches, patch_squashed);
10884 RegDeleteValueA(patches, "Patches");
10885 delete_key(patches, "", access & KEY_WOW64_64KEY);
10886 RegCloseKey(patches);
10887 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
10888 RegCloseKey(prodkey);
10891 static void test_MsiEnumPatchesEx(void)
10893 CHAR targetsid[MAX_PATH], targetprod[MAX_PATH];
10894 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
10895 CHAR patchcode[MAX_PATH];
10896 MSIINSTALLCONTEXT context;
10897 LPSTR usersid;
10898 DWORD size;
10899 UINT r;
10901 if (!pMsiEnumPatchesExA)
10903 win_skip("MsiEnumPatchesExA not implemented\n");
10904 return;
10907 create_test_guid(prodcode, prod_squashed);
10908 usersid = get_user_sid();
10910 /* empty szProductCode */
10911 lstrcpyA(patchcode, "apple");
10912 lstrcpyA(targetprod, "banana");
10913 context = 0xdeadbeef;
10914 lstrcpyA(targetsid, "kiwi");
10915 size = MAX_PATH;
10916 r = pMsiEnumPatchesExA("", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10917 MSIPATCHSTATE_ALL, 0, patchcode, targetprod, &context,
10918 targetsid, &size);
10919 ok(r == ERROR_INVALID_PARAMETER,
10920 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10921 ok(!lstrcmpA(patchcode, "apple"),
10922 "Expected patchcode to be unchanged, got %s\n", patchcode);
10923 ok(!lstrcmpA(targetprod, "banana"),
10924 "Expected targetprod to be unchanged, got %s\n", targetprod);
10925 ok(context == 0xdeadbeef,
10926 "Expected context to be unchanged, got %d\n", context);
10927 ok(!lstrcmpA(targetsid, "kiwi"),
10928 "Expected targetsid to be unchanged, got %s\n", targetsid);
10929 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10931 /* garbage szProductCode */
10932 lstrcpyA(patchcode, "apple");
10933 lstrcpyA(targetprod, "banana");
10934 context = 0xdeadbeef;
10935 lstrcpyA(targetsid, "kiwi");
10936 size = MAX_PATH;
10937 r = pMsiEnumPatchesExA("garbage", usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
10938 MSIPATCHSTATE_ALL, 0, patchcode, targetprod, &context,
10939 targetsid, &size);
10940 ok(r == ERROR_INVALID_PARAMETER,
10941 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10942 ok(!lstrcmpA(patchcode, "apple"),
10943 "Expected patchcode to be unchanged, got %s\n", patchcode);
10944 ok(!lstrcmpA(targetprod, "banana"),
10945 "Expected targetprod to be unchanged, got %s\n", targetprod);
10946 ok(context == 0xdeadbeef,
10947 "Expected context to be unchanged, got %d\n", context);
10948 ok(!lstrcmpA(targetsid, "kiwi"),
10949 "Expected targetsid to be unchanged, got %s\n", targetsid);
10950 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10952 /* guid without brackets */
10953 lstrcpyA(patchcode, "apple");
10954 lstrcpyA(targetprod, "banana");
10955 context = 0xdeadbeef;
10956 lstrcpyA(targetsid, "kiwi");
10957 size = MAX_PATH;
10958 r = pMsiEnumPatchesExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", usersid,
10959 MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
10960 0, patchcode, targetprod, &context,
10961 targetsid, &size);
10962 ok(r == ERROR_INVALID_PARAMETER,
10963 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
10964 ok(!lstrcmpA(patchcode, "apple"),
10965 "Expected patchcode to be unchanged, got %s\n", patchcode);
10966 ok(!lstrcmpA(targetprod, "banana"),
10967 "Expected targetprod to be unchanged, got %s\n", targetprod);
10968 ok(context == 0xdeadbeef,
10969 "Expected context to be unchanged, got %d\n", context);
10970 ok(!lstrcmpA(targetsid, "kiwi"),
10971 "Expected targetsid to be unchanged, got %s\n", targetsid);
10972 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10974 /* guid with brackets */
10975 lstrcpyA(patchcode, "apple");
10976 lstrcpyA(targetprod, "banana");
10977 context = 0xdeadbeef;
10978 lstrcpyA(targetsid, "kiwi");
10979 size = MAX_PATH;
10980 r = pMsiEnumPatchesExA("{6700E8CF-95AB-4D9C-BC2C-15840DDA7A5D}", usersid,
10981 MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
10982 0, patchcode, targetprod, &context,
10983 targetsid, &size);
10984 ok(r == ERROR_NO_MORE_ITEMS,
10985 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
10986 ok(!lstrcmpA(patchcode, "apple"),
10987 "Expected patchcode to be unchanged, got %s\n", patchcode);
10988 ok(!lstrcmpA(targetprod, "banana"),
10989 "Expected targetprod to be unchanged, got %s\n", targetprod);
10990 ok(context == 0xdeadbeef,
10991 "Expected context to be unchanged, got %d\n", context);
10992 ok(!lstrcmpA(targetsid, "kiwi"),
10993 "Expected targetsid to be unchanged, got %s\n", targetsid);
10994 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
10996 /* szUserSid is S-1-5-18 */
10997 lstrcpyA(patchcode, "apple");
10998 lstrcpyA(targetprod, "banana");
10999 context = 0xdeadbeef;
11000 lstrcpyA(targetsid, "kiwi");
11001 size = MAX_PATH;
11002 r = pMsiEnumPatchesExA(prodcode, "S-1-5-18",
11003 MSIINSTALLCONTEXT_USERUNMANAGED, MSIPATCHSTATE_ALL,
11004 0, patchcode, targetprod, &context,
11005 targetsid, &size);
11006 ok(r == ERROR_INVALID_PARAMETER,
11007 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11008 ok(!lstrcmpA(patchcode, "apple"),
11009 "Expected patchcode to be unchanged, got %s\n", patchcode);
11010 ok(!lstrcmpA(targetprod, "banana"),
11011 "Expected targetprod to be unchanged, got %s\n", targetprod);
11012 ok(context == 0xdeadbeef,
11013 "Expected context to be unchanged, got %d\n", context);
11014 ok(!lstrcmpA(targetsid, "kiwi"),
11015 "Expected targetsid to be unchanged, got %s\n", targetsid);
11016 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11018 /* dwContext is MSIINSTALLCONTEXT_MACHINE, but szUserSid is non-NULL */
11019 lstrcpyA(patchcode, "apple");
11020 lstrcpyA(targetprod, "banana");
11021 context = 0xdeadbeef;
11022 lstrcpyA(targetsid, "kiwi");
11023 size = MAX_PATH;
11024 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_MACHINE,
11025 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
11026 &context, targetsid, &size);
11027 ok(r == ERROR_INVALID_PARAMETER,
11028 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11029 ok(!lstrcmpA(patchcode, "apple"),
11030 "Expected patchcode to be unchanged, got %s\n", patchcode);
11031 ok(!lstrcmpA(targetprod, "banana"),
11032 "Expected targetprod to be unchanged, got %s\n", targetprod);
11033 ok(context == 0xdeadbeef,
11034 "Expected context to be unchanged, got %d\n", context);
11035 ok(!lstrcmpA(targetsid, "kiwi"),
11036 "Expected targetsid to be unchanged, got %s\n", targetsid);
11037 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11039 /* dwContext is out of bounds */
11040 lstrcpyA(patchcode, "apple");
11041 lstrcpyA(targetprod, "banana");
11042 context = 0xdeadbeef;
11043 lstrcpyA(targetsid, "kiwi");
11044 size = MAX_PATH;
11045 r = pMsiEnumPatchesExA(prodcode, usersid, 0,
11046 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
11047 &context, targetsid, &size);
11048 ok(r == ERROR_INVALID_PARAMETER,
11049 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11050 ok(!lstrcmpA(patchcode, "apple"),
11051 "Expected patchcode to be unchanged, got %s\n", patchcode);
11052 ok(!lstrcmpA(targetprod, "banana"),
11053 "Expected targetprod to be unchanged, got %s\n", targetprod);
11054 ok(context == 0xdeadbeef,
11055 "Expected context to be unchanged, got %d\n", context);
11056 ok(!lstrcmpA(targetsid, "kiwi"),
11057 "Expected targetsid to be unchanged, got %s\n", targetsid);
11058 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11060 /* dwContext is out of bounds */
11061 lstrcpyA(patchcode, "apple");
11062 lstrcpyA(targetprod, "banana");
11063 context = 0xdeadbeef;
11064 lstrcpyA(targetsid, "kiwi");
11065 size = MAX_PATH;
11066 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_ALL + 1,
11067 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
11068 &context, targetsid, &size);
11069 ok(r == ERROR_INVALID_PARAMETER,
11070 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11071 ok(!lstrcmpA(patchcode, "apple"),
11072 "Expected patchcode to be unchanged, got %s\n", patchcode);
11073 ok(!lstrcmpA(targetprod, "banana"),
11074 "Expected targetprod to be unchanged, got %s\n", targetprod);
11075 ok(context == 0xdeadbeef,
11076 "Expected context to be unchanged, got %d\n", context);
11077 ok(!lstrcmpA(targetsid, "kiwi"),
11078 "Expected targetsid to be unchanged, got %s\n", targetsid);
11079 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11081 /* dwFilter is out of bounds */
11082 lstrcpyA(patchcode, "apple");
11083 lstrcpyA(targetprod, "banana");
11084 context = 0xdeadbeef;
11085 lstrcpyA(targetsid, "kiwi");
11086 size = MAX_PATH;
11087 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
11088 MSIPATCHSTATE_INVALID, 0, patchcode, targetprod,
11089 &context, targetsid, &size);
11090 ok(r == ERROR_INVALID_PARAMETER,
11091 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11092 ok(!lstrcmpA(patchcode, "apple"),
11093 "Expected patchcode to be unchanged, got %s\n", patchcode);
11094 ok(!lstrcmpA(targetprod, "banana"),
11095 "Expected targetprod to be unchanged, got %s\n", targetprod);
11096 ok(context == 0xdeadbeef,
11097 "Expected context to be unchanged, got %d\n", context);
11098 ok(!lstrcmpA(targetsid, "kiwi"),
11099 "Expected targetsid to be unchanged, got %s\n", targetsid);
11100 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11102 /* dwFilter is out of bounds */
11103 lstrcpyA(patchcode, "apple");
11104 lstrcpyA(targetprod, "banana");
11105 context = 0xdeadbeef;
11106 lstrcpyA(targetsid, "kiwi");
11107 size = MAX_PATH;
11108 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
11109 MSIPATCHSTATE_ALL + 1, 0, patchcode, targetprod,
11110 &context, targetsid, &size);
11111 ok(r == ERROR_INVALID_PARAMETER,
11112 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11113 ok(!lstrcmpA(patchcode, "apple"),
11114 "Expected patchcode to be unchanged, got %s\n", patchcode);
11115 ok(!lstrcmpA(targetprod, "banana"),
11116 "Expected targetprod to be unchanged, got %s\n", targetprod);
11117 ok(context == 0xdeadbeef,
11118 "Expected context to be unchanged, got %d\n", context);
11119 ok(!lstrcmpA(targetsid, "kiwi"),
11120 "Expected targetsid to be unchanged, got %s\n", targetsid);
11121 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11123 /* pcchTargetUserSid is NULL while szTargetUserSid is non-NULL */
11124 lstrcpyA(patchcode, "apple");
11125 lstrcpyA(targetprod, "banana");
11126 context = 0xdeadbeef;
11127 lstrcpyA(targetsid, "kiwi");
11128 r = pMsiEnumPatchesExA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
11129 MSIPATCHSTATE_ALL, 0, patchcode, targetprod,
11130 &context, targetsid, NULL);
11131 ok(r == ERROR_INVALID_PARAMETER,
11132 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11133 ok(!lstrcmpA(patchcode, "apple"),
11134 "Expected patchcode to be unchanged, got %s\n", patchcode);
11135 ok(!lstrcmpA(targetprod, "banana"),
11136 "Expected targetprod to be unchanged, got %s\n", targetprod);
11137 ok(context == 0xdeadbeef,
11138 "Expected context to be unchanged, got %d\n", context);
11139 ok(!lstrcmpA(targetsid, "kiwi"),
11140 "Expected targetsid to be unchanged, got %s\n", targetsid);
11142 test_MsiEnumPatchesEx_usermanaged(usersid, usersid);
11143 test_MsiEnumPatchesEx_usermanaged(NULL, usersid);
11144 test_MsiEnumPatchesEx_usermanaged("S-1-2-34", "S-1-2-34");
11145 test_MsiEnumPatchesEx_userunmanaged(usersid, usersid);
11146 test_MsiEnumPatchesEx_userunmanaged(NULL, usersid);
11147 /* FIXME: Successfully test userunmanaged with a different user */
11148 test_MsiEnumPatchesEx_machine();
11149 LocalFree(usersid);
11152 static void test_MsiEnumPatches(void)
11154 CHAR keypath[MAX_PATH], patch[MAX_PATH];
11155 CHAR patchcode[MAX_PATH], patch_squashed[MAX_PATH];
11156 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
11157 CHAR transforms[MAX_PATH];
11158 WCHAR patchW[MAX_PATH], prodcodeW[MAX_PATH], transformsW[MAX_PATH];
11159 HKEY prodkey, patches, udprod;
11160 HKEY userkey, hpatch, udpatch;
11161 DWORD size, data;
11162 LPSTR usersid;
11163 LONG res;
11164 UINT r;
11165 REGSAM access = KEY_ALL_ACCESS;
11167 create_test_guid(prodcode, prod_squashed);
11168 create_test_guid(patchcode, patch_squashed);
11169 usersid = get_user_sid();
11171 if (is_wow64)
11172 access |= KEY_WOW64_64KEY;
11174 /* NULL szProduct */
11175 size = MAX_PATH;
11176 lstrcpyA(patch, "apple");
11177 lstrcpyA(transforms, "banana");
11178 r = MsiEnumPatchesA(NULL, 0, patch, transforms, &size);
11179 ok(r == ERROR_INVALID_PARAMETER,
11180 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11181 ok(!lstrcmpA(patch, "apple"),
11182 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11183 ok(!lstrcmpA(transforms, "banana"),
11184 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11185 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11187 /* empty szProduct */
11188 size = MAX_PATH;
11189 lstrcpyA(patch, "apple");
11190 lstrcpyA(transforms, "banana");
11191 r = MsiEnumPatchesA("", 0, patch, transforms, &size);
11192 ok(r == ERROR_INVALID_PARAMETER,
11193 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11194 ok(!lstrcmpA(patch, "apple"),
11195 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11196 ok(!lstrcmpA(transforms, "banana"),
11197 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11198 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11200 /* garbage szProduct */
11201 size = MAX_PATH;
11202 lstrcpyA(patch, "apple");
11203 lstrcpyA(transforms, "banana");
11204 r = MsiEnumPatchesA("garbage", 0, patch, transforms, &size);
11205 ok(r == ERROR_INVALID_PARAMETER,
11206 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11207 ok(!lstrcmpA(patch, "apple"),
11208 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11209 ok(!lstrcmpA(transforms, "banana"),
11210 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11211 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11213 /* guid without brackets */
11214 size = MAX_PATH;
11215 lstrcpyA(patch, "apple");
11216 lstrcpyA(transforms, "banana");
11217 r = MsiEnumPatchesA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", 0, patch,
11218 transforms, &size);
11219 ok(r == ERROR_INVALID_PARAMETER,
11220 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11221 ok(!lstrcmpA(patch, "apple"),
11222 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11223 ok(!lstrcmpA(transforms, "banana"),
11224 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11225 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11227 /* guid with brackets */
11228 size = MAX_PATH;
11229 lstrcpyA(patch, "apple");
11230 lstrcpyA(transforms, "banana");
11231 r = MsiEnumPatchesA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", 0, patch,
11232 transforms, &size);
11233 ok(r == ERROR_UNKNOWN_PRODUCT,
11234 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11235 ok(!lstrcmpA(patch, "apple"),
11236 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11237 ok(!lstrcmpA(transforms, "banana"),
11238 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11239 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11241 /* same length as guid, but random */
11242 size = MAX_PATH;
11243 lstrcpyA(patch, "apple");
11244 lstrcpyA(transforms, "banana");
11245 r = MsiEnumPatchesA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", 0, patch,
11246 transforms, &size);
11247 ok(r == ERROR_INVALID_PARAMETER,
11248 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11249 ok(!lstrcmpA(patch, "apple"),
11250 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11251 ok(!lstrcmpA(transforms, "banana"),
11252 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11253 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11255 /* MSIINSTALLCONTEXT_USERMANAGED */
11257 size = MAX_PATH;
11258 lstrcpyA(patch, "apple");
11259 lstrcpyA(transforms, "banana");
11260 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11261 ok(r == ERROR_UNKNOWN_PRODUCT,
11262 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11263 ok(!lstrcmpA(patch, "apple"),
11264 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11265 ok(!lstrcmpA(transforms, "banana"),
11266 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11267 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11269 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
11270 lstrcatA(keypath, usersid);
11271 lstrcatA(keypath, "\\Installer\\Products\\");
11272 lstrcatA(keypath, prod_squashed);
11274 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
11275 if (res == ERROR_ACCESS_DENIED)
11277 skip("Not enough rights to perform tests\n");
11278 LocalFree(usersid);
11279 return;
11281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11283 /* managed product key exists */
11284 size = MAX_PATH;
11285 lstrcpyA(patch, "apple");
11286 lstrcpyA(transforms, "banana");
11287 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11288 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11289 ok(!lstrcmpA(patch, "apple"),
11290 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11291 ok(!lstrcmpA(transforms, "banana"),
11292 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11293 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11295 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
11296 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11298 /* patches key exists */
11299 size = MAX_PATH;
11300 lstrcpyA(patch, "apple");
11301 lstrcpyA(transforms, "banana");
11302 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11303 ok(r == ERROR_NO_MORE_ITEMS ||
11304 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11305 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11306 ok(!lstrcmpA(patch, "apple"),
11307 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11308 ok(!lstrcmpA(transforms, "banana"),
11309 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11310 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11312 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
11313 (const BYTE *)patch_squashed,
11314 lstrlenA(patch_squashed) + 1);
11315 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11317 /* Patches value exists, is not REG_MULTI_SZ */
11318 size = MAX_PATH;
11319 lstrcpyA(patch, "apple");
11320 lstrcpyA(transforms, "banana");
11321 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11322 ok(r == ERROR_BAD_CONFIGURATION ||
11323 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11324 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11325 ok(!lstrcmpA(patch, "apple"),
11326 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11327 ok(!lstrcmpA(transforms, "banana"),
11328 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11329 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11331 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11332 (const BYTE *)"a\0b\0c\0\0", 7);
11333 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11335 /* Patches value exists, is not a squashed guid */
11336 size = MAX_PATH;
11337 lstrcpyA(patch, "apple");
11338 lstrcpyA(transforms, "banana");
11339 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11340 ok(r == ERROR_BAD_CONFIGURATION,
11341 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11342 ok(!lstrcmpA(patch, "apple"),
11343 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11344 ok(!lstrcmpA(transforms, "banana"),
11345 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11346 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11348 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
11349 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11350 (const BYTE *)patch_squashed,
11351 lstrlenA(patch_squashed) + 2);
11352 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11354 /* Patches value exists */
11355 size = MAX_PATH;
11356 lstrcpyA(patch, "apple");
11357 lstrcpyA(transforms, "banana");
11358 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11359 ok(r == ERROR_NO_MORE_ITEMS ||
11360 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11361 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11362 ok(!lstrcmpA(patch, "apple") ||
11363 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11364 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11365 ok(!lstrcmpA(transforms, "banana"),
11366 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11367 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11369 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
11370 (const BYTE *)"whatever", 9);
11371 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11373 /* patch squashed value exists */
11374 size = MAX_PATH;
11375 lstrcpyA(patch, "apple");
11376 lstrcpyA(transforms, "banana");
11377 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11378 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11379 ok(!lstrcmpA(patch, patchcode),
11380 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11381 ok(!lstrcmpA(transforms, "whatever"),
11382 "Expected \"whatever\", got \"%s\"\n", transforms);
11383 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11385 /* lpPatchBuf is NULL */
11386 size = MAX_PATH;
11387 lstrcpyA(transforms, "banana");
11388 r = MsiEnumPatchesA(prodcode, 0, NULL, transforms, &size);
11389 ok(r == ERROR_INVALID_PARAMETER,
11390 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11391 ok(!lstrcmpA(transforms, "banana"),
11392 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11393 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11395 /* lpTransformsBuf is NULL, pcchTransformsBuf is not */
11396 size = MAX_PATH;
11397 lstrcpyA(patch, "apple");
11398 r = MsiEnumPatchesA(prodcode, 0, patch, NULL, &size);
11399 ok(r == ERROR_INVALID_PARAMETER,
11400 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11401 ok(!lstrcmpA(patch, "apple"),
11402 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11403 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11405 /* pcchTransformsBuf is NULL, lpTransformsBuf is not */
11406 lstrcpyA(patch, "apple");
11407 lstrcpyA(transforms, "banana");
11408 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, NULL);
11409 ok(r == ERROR_INVALID_PARAMETER,
11410 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11411 ok(!lstrcmpA(patch, "apple"),
11412 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11413 ok(!lstrcmpA(transforms, "banana"),
11414 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11416 /* pcchTransformsBuf is too small */
11417 size = 6;
11418 lstrcpyA(patch, "apple");
11419 lstrcpyA(transforms, "banana");
11420 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11421 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11422 ok(!lstrcmpA(patch, patchcode),
11423 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11424 ok(!lstrcmpA(transforms, "whate") ||
11425 broken(!lstrcmpA(transforms, "banana")), /* Windows Installer < 3.0 */
11426 "Expected \"whate\", got \"%s\"\n", transforms);
11427 ok(size == 8 || size == 16, "Expected 8 or 16, got %d\n", size);
11429 /* increase the index */
11430 size = MAX_PATH;
11431 lstrcpyA(patch, "apple");
11432 lstrcpyA(transforms, "banana");
11433 r = MsiEnumPatchesA(prodcode, 1, patch, transforms, &size);
11434 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11435 ok(!lstrcmpA(patch, "apple"),
11436 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11437 ok(!lstrcmpA(transforms, "banana"),
11438 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11439 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11441 /* increase again */
11442 size = MAX_PATH;
11443 lstrcpyA(patch, "apple");
11444 lstrcpyA(transforms, "banana");
11445 r = MsiEnumPatchesA(prodcode, 2, patch, transforms, &size);
11446 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11447 ok(!lstrcmpA(patch, "apple"),
11448 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11449 ok(!lstrcmpA(transforms, "banana"),
11450 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11451 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11453 RegDeleteValueA(patches, "Patches");
11454 delete_key(patches, "", access & KEY_WOW64_64KEY);
11455 RegCloseKey(patches);
11456 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
11457 RegCloseKey(prodkey);
11459 /* MSIINSTALLCONTEXT_USERUNMANAGED */
11461 size = MAX_PATH;
11462 lstrcpyA(patch, "apple");
11463 lstrcpyA(transforms, "banana");
11464 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11465 ok(r == ERROR_UNKNOWN_PRODUCT,
11466 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11467 ok(!lstrcmpA(patch, "apple"),
11468 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11469 ok(!lstrcmpA(transforms, "banana"),
11470 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11471 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11473 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
11474 lstrcatA(keypath, prod_squashed);
11476 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
11477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11479 /* current user product key exists */
11480 size = MAX_PATH;
11481 lstrcpyA(patch, "apple");
11482 lstrcpyA(transforms, "banana");
11483 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11484 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11485 ok(!lstrcmpA(patch, "apple"),
11486 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11487 ok(!lstrcmpA(transforms, "banana"),
11488 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11489 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11491 res = RegCreateKeyA(prodkey, "Patches", &patches);
11492 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11494 /* Patches key exists */
11495 size = MAX_PATH;
11496 lstrcpyA(patch, "apple");
11497 lstrcpyA(transforms, "banana");
11498 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11499 ok(r == ERROR_NO_MORE_ITEMS ||
11500 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11501 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11502 ok(!lstrcmpA(patch, "apple"),
11503 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11504 ok(!lstrcmpA(transforms, "banana"),
11505 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11506 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11508 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
11509 (const BYTE *)patch_squashed,
11510 lstrlenA(patch_squashed) + 1);
11511 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11513 /* Patches value exists, is not REG_MULTI_SZ */
11514 size = MAX_PATH;
11515 lstrcpyA(patch, "apple");
11516 lstrcpyA(transforms, "banana");
11517 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11518 ok(r == ERROR_BAD_CONFIGURATION ||
11519 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11520 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11521 ok(!lstrcmpA(patch, "apple"),
11522 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11523 ok(!lstrcmpA(transforms, "banana"),
11524 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11525 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11527 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11528 (const BYTE *)"a\0b\0c\0\0", 7);
11529 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11531 /* Patches value exists, is not a squashed guid */
11532 size = MAX_PATH;
11533 lstrcpyA(patch, "apple");
11534 lstrcpyA(transforms, "banana");
11535 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11536 ok(r == ERROR_BAD_CONFIGURATION,
11537 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11538 ok(!lstrcmpA(patch, "apple"),
11539 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11540 ok(!lstrcmpA(transforms, "banana"),
11541 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11542 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11544 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
11545 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11546 (const BYTE *)patch_squashed,
11547 lstrlenA(patch_squashed) + 2);
11548 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11550 /* Patches value exists */
11551 size = MAX_PATH;
11552 lstrcpyA(patch, "apple");
11553 lstrcpyA(transforms, "banana");
11554 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11555 ok(r == ERROR_NO_MORE_ITEMS ||
11556 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11557 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11558 ok(!lstrcmpA(patch, "apple") ||
11559 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11560 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11561 ok(!lstrcmpA(transforms, "banana"),
11562 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11563 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11565 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
11566 (const BYTE *)"whatever", 9);
11567 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11569 /* patch code value exists */
11570 size = MAX_PATH;
11571 lstrcpyA(patch, "apple");
11572 lstrcpyA(transforms, "banana");
11573 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11574 ok(r == ERROR_NO_MORE_ITEMS ||
11575 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11576 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11577 ok(!lstrcmpA(patch, "apple") ||
11578 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11579 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11580 ok(!lstrcmpA(transforms, "banana") ||
11581 broken(!lstrcmpA(transforms, "whatever")), /* Windows Installer < 3.0 */
11582 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11583 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11585 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
11586 lstrcatA(keypath, usersid);
11587 lstrcatA(keypath, "\\Patches\\");
11588 lstrcatA(keypath, patch_squashed);
11590 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
11591 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11593 /* userdata patch key exists */
11594 size = MAX_PATH;
11595 lstrcpyA(patch, "apple");
11596 lstrcpyA(transforms, "banana");
11597 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11598 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11599 ok(!lstrcmpA(patch, patchcode),
11600 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11601 ok(!lstrcmpA(transforms, "whatever"),
11602 "Expected \"whatever\", got \"%s\"\n", transforms);
11603 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11605 delete_key(userkey, "", access & KEY_WOW64_64KEY);
11606 RegCloseKey(userkey);
11607 RegDeleteValueA(patches, patch_squashed);
11608 RegDeleteValueA(patches, "Patches");
11609 RegDeleteKeyA(patches, "");
11610 RegCloseKey(patches);
11611 RegDeleteKeyA(prodkey, "");
11612 RegCloseKey(prodkey);
11614 /* MSIINSTALLCONTEXT_MACHINE */
11616 size = MAX_PATH;
11617 lstrcpyA(patch, "apple");
11618 lstrcpyA(transforms, "banana");
11619 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11620 ok(r == ERROR_UNKNOWN_PRODUCT,
11621 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11622 ok(!lstrcmpA(patch, "apple"),
11623 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11624 ok(!lstrcmpA(transforms, "banana"),
11625 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11626 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11628 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
11629 lstrcatA(keypath, prod_squashed);
11631 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
11632 if (res == ERROR_ACCESS_DENIED)
11634 skip("Not enough rights to perform tests\n");
11635 LocalFree(usersid);
11636 return;
11638 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11640 /* local product key exists */
11641 size = MAX_PATH;
11642 lstrcpyA(patch, "apple");
11643 lstrcpyA(transforms, "banana");
11644 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11645 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11646 ok(!lstrcmpA(patch, "apple"),
11647 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11648 ok(!lstrcmpA(transforms, "banana"),
11649 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11650 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11652 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
11653 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11655 /* Patches key exists */
11656 size = MAX_PATH;
11657 lstrcpyA(patch, "apple");
11658 lstrcpyA(transforms, "banana");
11659 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11660 ok(r == ERROR_NO_MORE_ITEMS ||
11661 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11662 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11663 ok(!lstrcmpA(patch, "apple"),
11664 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11665 ok(!lstrcmpA(transforms, "banana"),
11666 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11667 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11669 res = RegSetValueExA(patches, "Patches", 0, REG_SZ,
11670 (const BYTE *)patch_squashed,
11671 lstrlenA(patch_squashed) + 1);
11672 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11674 /* Patches value exists, is not REG_MULTI_SZ */
11675 size = MAX_PATH;
11676 lstrcpyA(patch, "apple");
11677 lstrcpyA(transforms, "banana");
11678 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11679 ok(r == ERROR_BAD_CONFIGURATION ||
11680 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11681 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11682 ok(!lstrcmpA(patch, "apple"),
11683 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11684 ok(!lstrcmpA(transforms, "banana"),
11685 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11686 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11688 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11689 (const BYTE *)"a\0b\0c\0\0", 7);
11690 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11692 /* Patches value exists, is not a squashed guid */
11693 size = MAX_PATH;
11694 lstrcpyA(patch, "apple");
11695 lstrcpyA(transforms, "banana");
11696 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11697 ok(r == ERROR_BAD_CONFIGURATION,
11698 "Expected ERROR_BAD_CONFIGURATION, got %d\n", r);
11699 ok(!lstrcmpA(patch, "apple"),
11700 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11701 ok(!lstrcmpA(transforms, "banana"),
11702 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11703 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11705 patch_squashed[lstrlenA(patch_squashed) + 1] = '\0';
11706 res = RegSetValueExA(patches, "Patches", 0, REG_MULTI_SZ,
11707 (const BYTE *)patch_squashed,
11708 lstrlenA(patch_squashed) + 2);
11709 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11711 /* Patches value exists */
11712 size = MAX_PATH;
11713 lstrcpyA(patch, "apple");
11714 lstrcpyA(transforms, "banana");
11715 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11716 ok(r == ERROR_NO_MORE_ITEMS ||
11717 broken(r == ERROR_FILE_NOT_FOUND), /* Windows Installer < 3.0 */
11718 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11719 ok(!lstrcmpA(patch, "apple") ||
11720 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11721 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11722 ok(!lstrcmpA(transforms, "banana"),
11723 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11724 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11726 res = RegSetValueExA(patches, patch_squashed, 0, REG_SZ,
11727 (const BYTE *)"whatever", 9);
11728 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11730 /* patch code value exists */
11731 size = MAX_PATH;
11732 lstrcpyA(patch, "apple");
11733 lstrcpyA(transforms, "banana");
11734 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11735 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11736 ok(!lstrcmpA(patch, patchcode),
11737 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11738 ok(!lstrcmpA(transforms, "whatever"),
11739 "Expected \"whatever\", got \"%s\"\n", transforms);
11740 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11742 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
11743 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
11744 lstrcatA(keypath, prod_squashed);
11746 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
11747 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11749 /* local UserData product key exists */
11750 size = MAX_PATH;
11751 lstrcpyA(patch, "apple");
11752 lstrcpyA(transforms, "banana");
11753 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11754 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11755 ok(!lstrcmpA(patch, patchcode),
11756 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11757 ok(!lstrcmpA(transforms, "whatever"),
11758 "Expected \"whatever\", got \"%s\"\n", transforms);
11759 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11761 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &udpatch, NULL);
11762 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11764 /* local UserData Patches key exists */
11765 size = MAX_PATH;
11766 lstrcpyA(patch, "apple");
11767 lstrcpyA(transforms, "banana");
11768 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11769 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11770 ok(!lstrcmpA(patch, patchcode),
11771 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11772 ok(!lstrcmpA(transforms, "whatever"),
11773 "Expected \"whatever\", got \"%s\"\n", transforms);
11774 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11776 res = RegCreateKeyExA(udpatch, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
11777 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11779 /* local UserData Product patch key exists */
11780 size = MAX_PATH;
11781 lstrcpyA(patch, "apple");
11782 lstrcpyA(transforms, "banana");
11783 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11784 ok(r == ERROR_NO_MORE_ITEMS ||
11785 broken(r == ERROR_SUCCESS), /* Windows Installer < 3.0 */
11786 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
11787 ok(!lstrcmpA(patch, "apple") ||
11788 broken(!lstrcmpA(patch, patchcode)), /* Windows Installer < 3.0 */
11789 "Expected lpPatchBuf to be unchanged, got \"%s\"\n", patch);
11790 ok(!lstrcmpA(transforms, "banana") ||
11791 broken(!lstrcmpA(transforms, "whatever")), /* Windows Installer < 3.0 */
11792 "Expected lpTransformsBuf to be unchanged, got \"%s\"\n", transforms);
11793 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11795 data = MSIPATCHSTATE_APPLIED;
11796 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
11797 (const BYTE *)&data, sizeof(DWORD));
11798 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
11800 /* State value exists */
11801 size = MAX_PATH;
11802 lstrcpyA(patch, "apple");
11803 lstrcpyA(transforms, "banana");
11804 r = MsiEnumPatchesA(prodcode, 0, patch, transforms, &size);
11805 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11806 ok(!lstrcmpA(patch, patchcode),
11807 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11808 ok(!lstrcmpA(transforms, "whatever"),
11809 "Expected \"whatever\", got \"%s\"\n", transforms);
11810 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11812 /* now duplicate some of the tests for the W version */
11814 /* pcchTransformsBuf is too small */
11815 size = 6;
11816 MultiByteToWideChar( CP_ACP, 0, prodcode, -1, prodcodeW, MAX_PATH );
11817 MultiByteToWideChar( CP_ACP, 0, "apple", -1, patchW, MAX_PATH );
11818 MultiByteToWideChar( CP_ACP, 0, "banana", -1, transformsW, MAX_PATH );
11819 r = MsiEnumPatchesW(prodcodeW, 0, patchW, transformsW, &size);
11820 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
11821 WideCharToMultiByte( CP_ACP, 0, patchW, -1, patch, MAX_PATH, NULL, NULL );
11822 WideCharToMultiByte( CP_ACP, 0, transformsW, -1, transforms, MAX_PATH, NULL, NULL );
11823 ok(!lstrcmpA(patch, patchcode),
11824 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11825 ok(!lstrcmpA(transforms, "whate") ||
11826 broken(!lstrcmpA(transforms, "banana")), /* Windows Installer < 3.0 */
11827 "Expected \"whate\", got \"%s\"\n", transforms);
11828 ok(size == 8, "Expected 8, got %d\n", size);
11830 /* patch code value exists */
11831 size = MAX_PATH;
11832 MultiByteToWideChar( CP_ACP, 0, "apple", -1, patchW, MAX_PATH );
11833 MultiByteToWideChar( CP_ACP, 0, "banana", -1, transformsW, MAX_PATH );
11834 r = MsiEnumPatchesW(prodcodeW, 0, patchW, transformsW, &size);
11835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
11836 WideCharToMultiByte( CP_ACP, 0, patchW, -1, patch, MAX_PATH, NULL, NULL );
11837 WideCharToMultiByte( CP_ACP, 0, transformsW, -1, transforms, MAX_PATH, NULL, NULL );
11838 ok(!lstrcmpA(patch, patchcode),
11839 "Expected \"%s\", got \"%s\"\n", patchcode, patch);
11840 ok(!lstrcmpA(transforms, "whatever"),
11841 "Expected \"whatever\", got \"%s\"\n", transforms);
11842 ok(size == 8 || size == MAX_PATH, "Expected 8 or MAX_PATH, got %d\n", size);
11844 RegDeleteValueA(patches, patch_squashed);
11845 RegDeleteValueA(patches, "Patches");
11846 delete_key(patches, "", access & KEY_WOW64_64KEY);
11847 RegCloseKey(patches);
11848 RegDeleteValueA(hpatch, "State");
11849 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
11850 RegCloseKey(hpatch);
11851 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
11852 RegCloseKey(udpatch);
11853 delete_key(udprod, "", access & KEY_WOW64_64KEY);
11854 RegCloseKey(udprod);
11855 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
11856 RegCloseKey(prodkey);
11857 LocalFree(usersid);
11860 static void test_MsiGetPatchInfoEx(void)
11862 CHAR keypath[MAX_PATH], val[MAX_PATH];
11863 CHAR patchcode[MAX_PATH], patch_squashed[MAX_PATH];
11864 CHAR prodcode[MAX_PATH], prod_squashed[MAX_PATH];
11865 HKEY prodkey, patches, udprod, props;
11866 HKEY hpatch, udpatch, prodpatches;
11867 LPSTR usersid;
11868 DWORD size;
11869 LONG res;
11870 UINT r;
11871 REGSAM access = KEY_ALL_ACCESS;
11873 if (!pMsiGetPatchInfoExA)
11875 win_skip("MsiGetPatchInfoEx not implemented\n");
11876 return;
11879 create_test_guid(prodcode, prod_squashed);
11880 create_test_guid(patchcode, patch_squashed);
11881 usersid = get_user_sid();
11883 if (is_wow64)
11884 access |= KEY_WOW64_64KEY;
11886 /* NULL szPatchCode */
11887 lstrcpyA(val, "apple");
11888 size = MAX_PATH;
11889 r = pMsiGetPatchInfoExA(NULL, prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED,
11890 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11891 ok(r == ERROR_INVALID_PARAMETER,
11892 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11893 ok(!lstrcmpA(val, "apple"),
11894 "Expected val to be unchanged, got \"%s\"\n", val);
11895 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11897 /* empty szPatchCode */
11898 size = MAX_PATH;
11899 lstrcpyA(val, "apple");
11900 r = pMsiGetPatchInfoExA("", prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED,
11901 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11902 ok(r == ERROR_INVALID_PARAMETER,
11903 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11904 ok(!lstrcmpA(val, "apple"),
11905 "Expected val to be unchanged, got \"%s\"\n", val);
11906 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11908 /* garbage szPatchCode */
11909 size = MAX_PATH;
11910 lstrcpyA(val, "apple");
11911 r = pMsiGetPatchInfoExA("garbage", prodcode, NULL,
11912 MSIINSTALLCONTEXT_USERMANAGED,
11913 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11914 ok(r == ERROR_INVALID_PARAMETER,
11915 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11916 ok(!lstrcmpA(val, "apple"),
11917 "Expected val to be unchanged, got \"%s\"\n", val);
11918 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11920 /* guid without brackets */
11921 size = MAX_PATH;
11922 lstrcpyA(val, "apple");
11923 r = pMsiGetPatchInfoExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", prodcode,
11924 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11925 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11926 ok(r == ERROR_INVALID_PARAMETER,
11927 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11928 ok(!lstrcmpA(val, "apple"),
11929 "Expected val to be unchanged, got \"%s\"\n", val);
11930 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11932 /* guid with brackets */
11933 size = MAX_PATH;
11934 lstrcpyA(val, "apple");
11935 r = pMsiGetPatchInfoExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", prodcode,
11936 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11937 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11938 ok(r == ERROR_UNKNOWN_PRODUCT,
11939 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
11940 ok(!lstrcmpA(val, "apple"),
11941 "Expected val to be unchanged, got \"%s\"\n", val);
11942 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11944 /* same length as guid, but random */
11945 size = MAX_PATH;
11946 lstrcpyA(val, "apple");
11947 r = pMsiGetPatchInfoExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", prodcode,
11948 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11949 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11950 ok(r == ERROR_INVALID_PARAMETER,
11951 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11952 ok(!lstrcmpA(val, "apple"),
11953 "Expected val to be unchanged, got \"%s\"\n", val);
11954 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11956 /* NULL szProductCode */
11957 lstrcpyA(val, "apple");
11958 size = MAX_PATH;
11959 r = pMsiGetPatchInfoExA(patchcode, NULL, NULL, MSIINSTALLCONTEXT_USERMANAGED,
11960 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11961 ok(r == ERROR_INVALID_PARAMETER,
11962 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11963 ok(!lstrcmpA(val, "apple"),
11964 "Expected val to be unchanged, got \"%s\"\n", val);
11965 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11967 /* empty szProductCode */
11968 size = MAX_PATH;
11969 lstrcpyA(val, "apple");
11970 r = pMsiGetPatchInfoExA(patchcode, "", NULL, MSIINSTALLCONTEXT_USERMANAGED,
11971 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11972 ok(r == ERROR_INVALID_PARAMETER,
11973 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11974 ok(!lstrcmpA(val, "apple"),
11975 "Expected val to be unchanged, got \"%s\"\n", val);
11976 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
11978 /* garbage szProductCode */
11979 size = MAX_PATH;
11980 lstrcpyA(val, "apple");
11981 r = pMsiGetPatchInfoExA(patchcode, "garbage", NULL,
11982 MSIINSTALLCONTEXT_USERMANAGED,
11983 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11984 ok(r == ERROR_INVALID_PARAMETER,
11985 "Expected ERROR_INVALID_PARAMETER, 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 /* guid without brackets */
11991 size = MAX_PATH;
11992 lstrcpyA(val, "apple");
11993 r = pMsiGetPatchInfoExA(patchcode, "6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
11994 NULL, MSIINSTALLCONTEXT_USERMANAGED,
11995 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
11996 ok(r == ERROR_INVALID_PARAMETER,
11997 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
11998 ok(!lstrcmpA(val, "apple"),
11999 "Expected val to be unchanged, got \"%s\"\n", val);
12000 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12002 /* guid with brackets */
12003 size = MAX_PATH;
12004 lstrcpyA(val, "apple");
12005 r = pMsiGetPatchInfoExA(patchcode, "{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
12006 NULL, MSIINSTALLCONTEXT_USERMANAGED,
12007 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12008 ok(r == ERROR_UNKNOWN_PRODUCT,
12009 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12010 ok(!lstrcmpA(val, "apple"),
12011 "Expected val to be unchanged, got \"%s\"\n", val);
12012 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12014 /* same length as guid, but random */
12015 size = MAX_PATH;
12016 lstrcpyA(val, "apple");
12017 r = pMsiGetPatchInfoExA(patchcode, "A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
12018 NULL, MSIINSTALLCONTEXT_USERMANAGED,
12019 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12020 ok(r == ERROR_INVALID_PARAMETER,
12021 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12022 ok(!lstrcmpA(val, "apple"),
12023 "Expected val to be unchanged, got \"%s\"\n", val);
12024 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12026 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERMANAGED */
12027 size = MAX_PATH;
12028 lstrcpyA(val, "apple");
12029 r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
12030 MSIINSTALLCONTEXT_USERMANAGED,
12031 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12032 ok(r == ERROR_INVALID_PARAMETER,
12033 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12034 ok(!lstrcmpA(val, "apple"),
12035 "Expected val to be unchanged, got \"%s\"\n", val);
12036 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12038 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_USERUNMANAGED */
12039 size = MAX_PATH;
12040 lstrcpyA(val, "apple");
12041 r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
12042 MSIINSTALLCONTEXT_USERUNMANAGED,
12043 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12044 ok(r == ERROR_INVALID_PARAMETER,
12045 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12046 ok(!lstrcmpA(val, "apple"),
12047 "Expected val to be unchanged, got \"%s\"\n", val);
12048 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12050 /* szUserSid cannot be S-1-5-18 for MSIINSTALLCONTEXT_MACHINE */
12051 size = MAX_PATH;
12052 lstrcpyA(val, "apple");
12053 r = pMsiGetPatchInfoExA(patchcode, prodcode, "S-1-5-18",
12054 MSIINSTALLCONTEXT_MACHINE,
12055 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12056 ok(r == ERROR_INVALID_PARAMETER,
12057 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12058 ok(!lstrcmpA(val, "apple"),
12059 "Expected val to be unchanged, got \"%s\"\n", val);
12060 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12062 /* szUserSid must be NULL for MSIINSTALLCONTEXT_MACHINE */
12063 size = MAX_PATH;
12064 lstrcpyA(val, "apple");
12065 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12066 MSIINSTALLCONTEXT_MACHINE,
12067 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12068 ok(r == ERROR_INVALID_PARAMETER,
12069 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12070 ok(!lstrcmpA(val, "apple"),
12071 "Expected val to be unchanged, got \"%s\"\n", val);
12072 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12074 /* dwContext is out of range */
12075 size = MAX_PATH;
12076 lstrcpyA(val, "apple");
12077 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12078 MSIINSTALLCONTEXT_NONE,
12079 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12080 ok(r == ERROR_INVALID_PARAMETER,
12081 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12082 ok(!lstrcmpA(val, "apple"),
12083 "Expected val to be unchanged, got \"%s\"\n", val);
12084 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12086 /* dwContext is out of range */
12087 size = MAX_PATH;
12088 lstrcpyA(val, "apple");
12089 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12090 MSIINSTALLCONTEXT_ALL,
12091 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12092 ok(r == ERROR_INVALID_PARAMETER,
12093 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12094 ok(!lstrcmpA(val, "apple"),
12095 "Expected val to be unchanged, got \"%s\"\n", val);
12096 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12098 /* dwContext is invalid */
12099 size = MAX_PATH;
12100 lstrcpyA(val, "apple");
12101 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid, 3,
12102 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12103 ok(r == ERROR_INVALID_PARAMETER,
12104 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12105 ok(!lstrcmpA(val, "apple"),
12106 "Expected val to be unchanged, got \"%s\"\n", val);
12107 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12109 /* MSIINSTALLCONTEXT_USERMANAGED */
12111 size = MAX_PATH;
12112 lstrcpyA(val, "apple");
12113 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12114 MSIINSTALLCONTEXT_USERMANAGED,
12115 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12116 ok(r == ERROR_UNKNOWN_PRODUCT,
12117 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12118 ok(!lstrcmpA(val, "apple"),
12119 "Expected val to be unchanged, got \"%s\"\n", val);
12120 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12122 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12123 lstrcatA(keypath, usersid);
12124 lstrcatA(keypath, "\\Products\\");
12125 lstrcatA(keypath, prod_squashed);
12127 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
12128 if (res == ERROR_ACCESS_DENIED)
12130 skip("Not enough rights to perform tests\n");
12131 LocalFree(usersid);
12132 return;
12134 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12136 /* local UserData product key exists */
12137 size = MAX_PATH;
12138 lstrcpyA(val, "apple");
12139 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12140 MSIINSTALLCONTEXT_USERMANAGED,
12141 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12142 ok(r == ERROR_UNKNOWN_PRODUCT,
12143 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12144 ok(!lstrcmpA(val, "apple"),
12145 "Expected val to be unchanged, got \"%s\"\n", val);
12146 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12148 res = RegCreateKeyExA(udprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12149 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12151 /* InstallProperties key exists */
12152 size = MAX_PATH;
12153 lstrcpyA(val, "apple");
12154 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12155 MSIINSTALLCONTEXT_USERMANAGED,
12156 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12157 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12158 ok(!lstrcmpA(val, "apple"),
12159 "Expected val to be unchanged, got \"%s\"\n", val);
12160 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12162 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
12163 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12165 /* Patches key exists */
12166 size = MAX_PATH;
12167 lstrcpyA(val, "apple");
12168 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12169 MSIINSTALLCONTEXT_USERMANAGED,
12170 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12171 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCHA, got %d\n", r);
12172 ok(!lstrcmpA(val, "apple"),
12173 "Expected val to be unchanged, got \"%s\"\n", val);
12174 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12176 res = RegCreateKeyExA(patches, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
12177 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12179 /* Patches key exists */
12180 size = MAX_PATH;
12181 lstrcpyA(val, "apple");
12182 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12183 MSIINSTALLCONTEXT_USERMANAGED,
12184 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12185 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12186 ok(!lstrcmpA(val, "apple"),
12187 "Expected val to be unchanged, got \"%s\"\n", val);
12188 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12190 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
12191 lstrcatA(keypath, usersid);
12192 lstrcatA(keypath, "\\Installer\\Products\\");
12193 lstrcatA(keypath, prod_squashed);
12195 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12196 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12198 /* managed product key exists */
12199 size = MAX_PATH;
12200 lstrcpyA(val, "apple");
12201 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12202 MSIINSTALLCONTEXT_USERMANAGED,
12203 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12204 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12205 ok(!lstrcmpA(val, "apple"),
12206 "Expected val to be unchanged, got \"%s\"\n", val);
12207 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12209 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &prodpatches, NULL);
12210 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12212 /* Patches key exists */
12213 size = MAX_PATH;
12214 lstrcpyA(val, "apple");
12215 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12216 MSIINSTALLCONTEXT_USERMANAGED,
12217 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12218 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12219 ok(!lstrcmpA(val, "apple"),
12220 "Expected val to be unchanged, got \"%s\"\n", val);
12221 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12223 res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
12224 (const BYTE *)"transforms", 11);
12225 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12227 /* specific patch value exists */
12228 size = MAX_PATH;
12229 lstrcpyA(val, "apple");
12230 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12231 MSIINSTALLCONTEXT_USERMANAGED,
12232 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12233 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12234 ok(!lstrcmpA(val, "apple"),
12235 "Expected val to be unchanged, got \"%s\"\n", val);
12236 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12238 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12239 lstrcatA(keypath, usersid);
12240 lstrcatA(keypath, "\\Patches\\");
12241 lstrcatA(keypath, patch_squashed);
12243 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udpatch, NULL);
12244 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12246 /* UserData Patches key exists */
12247 size = MAX_PATH;
12248 lstrcpyA(val, "apple");
12249 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12250 MSIINSTALLCONTEXT_USERMANAGED,
12251 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12252 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12253 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12254 ok(size == 0, "Expected 0, got %d\n", size);
12256 res = RegSetValueExA(udpatch, "ManagedLocalPackage", 0, REG_SZ,
12257 (const BYTE *)"pack", 5);
12258 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12260 /* ManagedLocalPatch value exists */
12261 size = MAX_PATH;
12262 lstrcpyA(val, "apple");
12263 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12264 MSIINSTALLCONTEXT_USERMANAGED,
12265 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12266 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12267 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12268 ok(size == 4, "Expected 4, got %d\n", size);
12270 size = MAX_PATH;
12271 lstrcpyA(val, "apple");
12272 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12273 MSIINSTALLCONTEXT_USERMANAGED,
12274 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12275 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12276 ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
12277 ok(size == 10, "Expected 10, got %d\n", size);
12279 res = RegSetValueExA(hpatch, "Installed", 0, REG_SZ,
12280 (const BYTE *)"mydate", 7);
12281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12283 /* Installed value exists */
12284 size = MAX_PATH;
12285 lstrcpyA(val, "apple");
12286 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12287 MSIINSTALLCONTEXT_USERMANAGED,
12288 INSTALLPROPERTY_INSTALLDATEA, val, &size);
12289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12290 ok(!lstrcmpA(val, "mydate"), "Expected \"mydate\", got \"%s\"\n", val);
12291 ok(size == 6, "Expected 6, got %d\n", size);
12293 res = RegSetValueExA(hpatch, "Uninstallable", 0, REG_SZ,
12294 (const BYTE *)"yes", 4);
12295 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12297 /* Uninstallable value exists */
12298 size = MAX_PATH;
12299 lstrcpyA(val, "apple");
12300 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12301 MSIINSTALLCONTEXT_USERMANAGED,
12302 INSTALLPROPERTY_UNINSTALLABLEA, val, &size);
12303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12304 ok(!lstrcmpA(val, "yes"), "Expected \"yes\", got \"%s\"\n", val);
12305 ok(size == 3, "Expected 3, got %d\n", size);
12307 res = RegSetValueExA(hpatch, "State", 0, REG_SZ,
12308 (const BYTE *)"good", 5);
12309 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12311 /* State value exists */
12312 size = MAX_PATH;
12313 lstrcpyA(val, "apple");
12314 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12315 MSIINSTALLCONTEXT_USERMANAGED,
12316 INSTALLPROPERTY_PATCHSTATEA, val, &size);
12317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12318 ok(!lstrcmpA(val, "good"), "Expected \"good\", got \"%s\"\n", val);
12319 ok(size == 4, "Expected 4, got %d\n", size);
12321 size = 1;
12322 res = RegSetValueExA(hpatch, "State", 0, REG_DWORD,
12323 (const BYTE *)&size, sizeof(DWORD));
12324 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12326 /* State value exists */
12327 size = MAX_PATH;
12328 lstrcpyA(val, "apple");
12329 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12330 MSIINSTALLCONTEXT_USERMANAGED,
12331 INSTALLPROPERTY_PATCHSTATEA, val, &size);
12332 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12333 ok(!lstrcmpA(val, "1"), "Expected \"1\", got \"%s\"\n", val);
12334 ok(size == 1, "Expected 1, got %d\n", size);
12336 size = 1;
12337 res = RegSetValueExA(hpatch, "Uninstallable", 0, REG_DWORD,
12338 (const BYTE *)&size, sizeof(DWORD));
12339 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12341 /* Uninstallable value exists */
12342 size = MAX_PATH;
12343 lstrcpyA(val, "apple");
12344 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12345 MSIINSTALLCONTEXT_USERMANAGED,
12346 INSTALLPROPERTY_UNINSTALLABLEA, val, &size);
12347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12348 ok(!lstrcmpA(val, "1"), "Expected \"1\", got \"%s\"\n", val);
12349 ok(size == 1, "Expected 1, got %d\n", size);
12351 res = RegSetValueExA(hpatch, "DisplayName", 0, REG_SZ,
12352 (const BYTE *)"display", 8);
12353 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12355 /* DisplayName value exists */
12356 size = MAX_PATH;
12357 lstrcpyA(val, "apple");
12358 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12359 MSIINSTALLCONTEXT_USERMANAGED,
12360 INSTALLPROPERTY_DISPLAYNAMEA, val, &size);
12361 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12362 ok(!lstrcmpA(val, "display"), "Expected \"display\", got \"%s\"\n", val);
12363 ok(size == 7, "Expected 7, got %d\n", size);
12365 res = RegSetValueExA(hpatch, "MoreInfoURL", 0, REG_SZ,
12366 (const BYTE *)"moreinfo", 9);
12367 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12369 /* MoreInfoURL value exists */
12370 size = MAX_PATH;
12371 lstrcpyA(val, "apple");
12372 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12373 MSIINSTALLCONTEXT_USERMANAGED,
12374 INSTALLPROPERTY_MOREINFOURLA, val, &size);
12375 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12376 ok(!lstrcmpA(val, "moreinfo"), "Expected \"moreinfo\", got \"%s\"\n", val);
12377 ok(size == 8, "Expected 8, got %d\n", size);
12379 /* szProperty is invalid */
12380 size = MAX_PATH;
12381 lstrcpyA(val, "apple");
12382 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12383 MSIINSTALLCONTEXT_USERMANAGED,
12384 "IDontExist", val, &size);
12385 ok(r == ERROR_UNKNOWN_PROPERTY,
12386 "Expected ERROR_UNKNOWN_PROPERTY, got %d\n", r);
12387 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12388 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12390 /* lpValue is NULL, while pcchValue is non-NULL */
12391 size = MAX_PATH;
12392 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12393 MSIINSTALLCONTEXT_USERMANAGED,
12394 INSTALLPROPERTY_MOREINFOURLA, NULL, &size);
12395 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12396 ok(size == 16, "Expected 16, got %d\n", size);
12398 /* pcchValue is NULL, while lpValue is non-NULL */
12399 lstrcpyA(val, "apple");
12400 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12401 MSIINSTALLCONTEXT_USERMANAGED,
12402 INSTALLPROPERTY_MOREINFOURLA, val, NULL);
12403 ok(r == ERROR_INVALID_PARAMETER,
12404 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
12405 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12407 /* both lpValue and pcchValue are NULL */
12408 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12409 MSIINSTALLCONTEXT_USERMANAGED,
12410 INSTALLPROPERTY_MOREINFOURLA, NULL, NULL);
12411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12413 /* pcchValue doesn't have enough room for NULL terminator */
12414 size = 8;
12415 lstrcpyA(val, "apple");
12416 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12417 MSIINSTALLCONTEXT_USERMANAGED,
12418 INSTALLPROPERTY_MOREINFOURLA, val, &size);
12419 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
12420 ok(!lstrcmpA(val, "moreinf"),
12421 "Expected \"moreinf\", got \"%s\"\n", val);
12422 ok(size == 16, "Expected 16, got %d\n", size);
12424 /* pcchValue has exactly enough room for NULL terminator */
12425 size = 9;
12426 lstrcpyA(val, "apple");
12427 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12428 MSIINSTALLCONTEXT_USERMANAGED,
12429 INSTALLPROPERTY_MOREINFOURLA, val, &size);
12430 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12431 ok(!lstrcmpA(val, "moreinfo"),
12432 "Expected \"moreinfo\", got \"%s\"\n", val);
12433 ok(size == 8, "Expected 8, got %d\n", size);
12435 /* pcchValue is too small, lpValue is NULL */
12436 size = 0;
12437 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12438 MSIINSTALLCONTEXT_USERMANAGED,
12439 INSTALLPROPERTY_MOREINFOURLA, NULL, &size);
12440 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12441 ok(size == 16, "Expected 16, got %d\n", size);
12443 RegDeleteValueA(prodpatches, patch_squashed);
12444 delete_key(prodpatches, "", access & KEY_WOW64_64KEY);
12445 RegCloseKey(prodpatches);
12446 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
12447 RegCloseKey(prodkey);
12449 /* UserData is sufficient for all properties
12450 * except INSTALLPROPERTY_TRANSFORMS
12452 size = MAX_PATH;
12453 lstrcpyA(val, "apple");
12454 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12455 MSIINSTALLCONTEXT_USERMANAGED,
12456 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12457 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12458 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12459 ok(size == 4, "Expected 4, got %d\n", size);
12461 /* UserData is sufficient for all properties
12462 * except INSTALLPROPERTY_TRANSFORMS
12464 size = MAX_PATH;
12465 lstrcpyA(val, "apple");
12466 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12467 MSIINSTALLCONTEXT_USERMANAGED,
12468 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12469 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12470 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12471 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12473 RegDeleteValueA(hpatch, "MoreInfoURL");
12474 RegDeleteValueA(hpatch, "Display");
12475 RegDeleteValueA(hpatch, "State");
12476 RegDeleteValueA(hpatch, "Uninstallable");
12477 RegDeleteValueA(hpatch, "Installed");
12478 RegDeleteValueA(udpatch, "ManagedLocalPackage");
12479 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
12480 RegCloseKey(udpatch);
12481 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
12482 RegCloseKey(hpatch);
12483 delete_key(patches, "", access & KEY_WOW64_64KEY);
12484 RegCloseKey(patches);
12485 delete_key(props, "", access & KEY_WOW64_64KEY);
12486 RegCloseKey(props);
12487 delete_key(udprod, "", access & KEY_WOW64_64KEY);
12488 RegCloseKey(udprod);
12490 /* MSIINSTALLCONTEXT_USERUNMANAGED */
12492 size = MAX_PATH;
12493 lstrcpyA(val, "apple");
12494 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12495 MSIINSTALLCONTEXT_USERUNMANAGED,
12496 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12497 ok(r == ERROR_UNKNOWN_PRODUCT,
12498 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12499 ok(!lstrcmpA(val, "apple"),
12500 "Expected val to be unchanged, got \"%s\"\n", val);
12501 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12503 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12504 lstrcatA(keypath, usersid);
12505 lstrcatA(keypath, "\\Products\\");
12506 lstrcatA(keypath, prod_squashed);
12508 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
12509 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12511 /* local UserData product key exists */
12512 size = MAX_PATH;
12513 lstrcpyA(val, "apple");
12514 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12515 MSIINSTALLCONTEXT_USERUNMANAGED,
12516 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12517 ok(r == ERROR_UNKNOWN_PRODUCT,
12518 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12519 ok(!lstrcmpA(val, "apple"),
12520 "Expected val to be unchanged, got \"%s\"\n", val);
12521 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12523 res = RegCreateKeyExA(udprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12524 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12526 /* InstallProperties key exists */
12527 size = MAX_PATH;
12528 lstrcpyA(val, "apple");
12529 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12530 MSIINSTALLCONTEXT_USERUNMANAGED,
12531 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12532 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12533 ok(!lstrcmpA(val, "apple"),
12534 "Expected val to be unchanged, got \"%s\"\n", val);
12535 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12537 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
12538 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12540 /* Patches key exists */
12541 size = MAX_PATH;
12542 lstrcpyA(val, "apple");
12543 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12544 MSIINSTALLCONTEXT_USERUNMANAGED,
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 res = RegCreateKeyExA(patches, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
12552 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12554 /* Patches key exists */
12555 size = MAX_PATH;
12556 lstrcpyA(val, "apple");
12557 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12558 MSIINSTALLCONTEXT_USERUNMANAGED,
12559 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12560 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12561 ok(!lstrcmpA(val, "apple"),
12562 "Expected val to be unchanged, got \"%s\"\n", val);
12563 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12565 lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
12566 lstrcatA(keypath, prod_squashed);
12568 res = RegCreateKeyA(HKEY_CURRENT_USER, keypath, &prodkey);
12569 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12571 /* current user product key exists */
12572 size = MAX_PATH;
12573 lstrcpyA(val, "apple");
12574 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12575 MSIINSTALLCONTEXT_USERUNMANAGED,
12576 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12577 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12578 ok(!lstrcmpA(val, "apple"),
12579 "Expected val to be unchanged, got \"%s\"\n", val);
12580 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12582 res = RegCreateKeyA(prodkey, "Patches", &prodpatches);
12583 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12585 /* Patches key exists */
12586 size = MAX_PATH;
12587 lstrcpyA(val, "apple");
12588 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12589 MSIINSTALLCONTEXT_USERUNMANAGED,
12590 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12591 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12592 ok(!lstrcmpA(val, "apple"),
12593 "Expected val to be unchanged, got \"%s\"\n", val);
12594 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12596 res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
12597 (const BYTE *)"transforms", 11);
12598 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12600 /* specific patch value exists */
12601 size = MAX_PATH;
12602 lstrcpyA(val, "apple");
12603 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12604 MSIINSTALLCONTEXT_USERUNMANAGED,
12605 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12606 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12607 ok(!lstrcmpA(val, "apple"),
12608 "Expected val to be unchanged, got \"%s\"\n", val);
12609 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12611 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
12612 lstrcatA(keypath, usersid);
12613 lstrcatA(keypath, "\\Patches\\");
12614 lstrcatA(keypath, patch_squashed);
12616 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udpatch, NULL);
12617 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12619 /* UserData Patches key exists */
12620 size = MAX_PATH;
12621 lstrcpyA(val, "apple");
12622 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12623 MSIINSTALLCONTEXT_USERUNMANAGED,
12624 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12625 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12626 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12627 ok(size == 0, "Expected 0, got %d\n", size);
12629 res = RegSetValueExA(udpatch, "LocalPackage", 0, REG_SZ,
12630 (const BYTE *)"pack", 5);
12631 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12633 /* LocalPatch value exists */
12634 size = MAX_PATH;
12635 lstrcpyA(val, "apple");
12636 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12637 MSIINSTALLCONTEXT_USERUNMANAGED,
12638 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12639 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12640 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12641 ok(size == 4, "Expected 4, got %d\n", size);
12643 size = MAX_PATH;
12644 lstrcpyA(val, "apple");
12645 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12646 MSIINSTALLCONTEXT_USERUNMANAGED,
12647 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12648 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12649 ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
12650 ok(size == 10, "Expected 10, got %d\n", size);
12652 RegDeleteValueA(prodpatches, patch_squashed);
12653 delete_key(prodpatches, "", access & KEY_WOW64_64KEY);
12654 RegCloseKey(prodpatches);
12655 RegDeleteKeyA(prodkey, "");
12656 RegCloseKey(prodkey);
12658 /* UserData is sufficient for all properties
12659 * except INSTALLPROPERTY_TRANSFORMS
12661 size = MAX_PATH;
12662 lstrcpyA(val, "apple");
12663 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12664 MSIINSTALLCONTEXT_USERUNMANAGED,
12665 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12666 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12667 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12668 ok(size == 4, "Expected 4, got %d\n", size);
12670 /* UserData is sufficient for all properties
12671 * except INSTALLPROPERTY_TRANSFORMS
12673 size = MAX_PATH;
12674 lstrcpyA(val, "apple");
12675 r = pMsiGetPatchInfoExA(patchcode, prodcode, usersid,
12676 MSIINSTALLCONTEXT_USERUNMANAGED,
12677 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12678 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12679 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12680 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12682 RegDeleteValueA(udpatch, "LocalPackage");
12683 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
12684 RegCloseKey(udpatch);
12685 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
12686 RegCloseKey(hpatch);
12687 delete_key(patches, "", access & KEY_WOW64_64KEY);
12688 RegCloseKey(patches);
12689 delete_key(props, "", access & KEY_WOW64_64KEY);
12690 RegCloseKey(props);
12691 delete_key(udprod, "", access & KEY_WOW64_64KEY);
12692 RegCloseKey(udprod);
12694 /* MSIINSTALLCONTEXT_MACHINE */
12696 size = MAX_PATH;
12697 lstrcpyA(val, "apple");
12698 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12699 MSIINSTALLCONTEXT_MACHINE,
12700 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12701 ok(r == ERROR_UNKNOWN_PRODUCT,
12702 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12703 ok(!lstrcmpA(val, "apple"),
12704 "Expected val to be unchanged, got \"%s\"\n", val);
12705 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12707 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12708 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\");
12709 lstrcatA(keypath, prod_squashed);
12711 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udprod, NULL);
12712 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12714 /* local UserData product key exists */
12715 size = MAX_PATH;
12716 lstrcpyA(val, "apple");
12717 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12718 MSIINSTALLCONTEXT_MACHINE,
12719 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12720 ok(r == ERROR_UNKNOWN_PRODUCT,
12721 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
12722 ok(!lstrcmpA(val, "apple"),
12723 "Expected val to be unchanged, got \"%s\"\n", val);
12724 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12726 res = RegCreateKeyExA(udprod, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
12727 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12729 /* InstallProperties key exists */
12730 size = MAX_PATH;
12731 lstrcpyA(val, "apple");
12732 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12733 MSIINSTALLCONTEXT_MACHINE,
12734 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12735 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12736 ok(!lstrcmpA(val, "apple"),
12737 "Expected val to be unchanged, got \"%s\"\n", val);
12738 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12740 res = RegCreateKeyExA(udprod, "Patches", 0, NULL, 0, access, NULL, &patches, NULL);
12741 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12743 /* Patches key exists */
12744 size = MAX_PATH;
12745 lstrcpyA(val, "apple");
12746 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12747 MSIINSTALLCONTEXT_MACHINE,
12748 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12749 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12750 ok(!lstrcmpA(val, "apple"),
12751 "Expected val to be unchanged, got \"%s\"\n", val);
12752 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12754 res = RegCreateKeyExA(patches, patch_squashed, 0, NULL, 0, access, NULL, &hpatch, NULL);
12755 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12757 /* Patches key exists */
12758 size = MAX_PATH;
12759 lstrcpyA(val, "apple");
12760 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12761 MSIINSTALLCONTEXT_MACHINE,
12762 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12763 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12764 ok(!lstrcmpA(val, "apple"),
12765 "Expected val to be unchanged, got \"%s\"\n", val);
12766 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12768 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12769 lstrcatA(keypath, prod_squashed);
12771 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
12772 if (res == ERROR_ACCESS_DENIED)
12774 skip( "insufficient rights\n" );
12775 LocalFree( usersid );
12776 return;
12778 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12780 /* local product key exists */
12781 size = MAX_PATH;
12782 lstrcpyA(val, "apple");
12783 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12784 MSIINSTALLCONTEXT_MACHINE,
12785 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12786 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12787 ok(!lstrcmpA(val, "apple"),
12788 "Expected val to be unchanged, got \"%s\"\n", val);
12789 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12791 res = RegCreateKeyExA(prodkey, "Patches", 0, NULL, 0, access, NULL, &prodpatches, NULL);
12792 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12794 /* Patches key exists */
12795 size = MAX_PATH;
12796 lstrcpyA(val, "apple");
12797 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12798 MSIINSTALLCONTEXT_MACHINE,
12799 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12800 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12801 ok(!lstrcmpA(val, "apple"),
12802 "Expected val to be unchanged, got \"%s\"\n", val);
12803 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12805 res = RegSetValueExA(prodpatches, patch_squashed, 0, REG_SZ,
12806 (const BYTE *)"transforms", 11);
12807 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12809 /* specific patch value exists */
12810 size = MAX_PATH;
12811 lstrcpyA(val, "apple");
12812 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12813 MSIINSTALLCONTEXT_MACHINE,
12814 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12815 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12816 ok(!lstrcmpA(val, "apple"),
12817 "Expected val to be unchanged, got \"%s\"\n", val);
12818 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
12820 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12821 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\");
12822 lstrcatA(keypath, patch_squashed);
12824 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &udpatch, NULL);
12825 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12827 /* UserData Patches key exists */
12828 size = MAX_PATH;
12829 lstrcpyA(val, "apple");
12830 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12831 MSIINSTALLCONTEXT_MACHINE,
12832 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12833 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12834 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
12835 ok(size == 0, "Expected 0, got %d\n", size);
12837 res = RegSetValueExA(udpatch, "LocalPackage", 0, REG_SZ,
12838 (const BYTE *)"pack", 5);
12839 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
12841 /* LocalPatch value exists */
12842 size = MAX_PATH;
12843 lstrcpyA(val, "apple");
12844 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12845 MSIINSTALLCONTEXT_MACHINE,
12846 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12848 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12849 ok(size == 4, "Expected 4, got %d\n", size);
12851 size = MAX_PATH;
12852 lstrcpyA(val, "apple");
12853 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12854 MSIINSTALLCONTEXT_MACHINE,
12855 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12856 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12857 ok(!lstrcmpA(val, "transforms"), "Expected \"transforms\", got \"%s\"\n", val);
12858 ok(size == 10, "Expected 10, got %d\n", size);
12860 RegDeleteValueA(prodpatches, patch_squashed);
12861 delete_key(prodpatches, "", access & KEY_WOW64_64KEY);
12862 RegCloseKey(prodpatches);
12863 delete_key(prodkey, "", access & KEY_WOW64_64KEY);
12864 RegCloseKey(prodkey);
12866 /* UserData is sufficient for all properties
12867 * except INSTALLPROPERTY_TRANSFORMS
12869 size = MAX_PATH;
12870 lstrcpyA(val, "apple");
12871 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12872 MSIINSTALLCONTEXT_MACHINE,
12873 INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12874 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
12875 ok(!lstrcmpA(val, "pack"), "Expected \"pack\", got \"%s\"\n", val);
12876 ok(size == 4, "Expected 4, got %d\n", size);
12878 /* UserData is sufficient for all properties
12879 * except INSTALLPROPERTY_TRANSFORMS
12881 size = MAX_PATH;
12882 lstrcpyA(val, "apple");
12883 r = pMsiGetPatchInfoExA(patchcode, prodcode, NULL,
12884 MSIINSTALLCONTEXT_MACHINE,
12885 INSTALLPROPERTY_TRANSFORMSA, val, &size);
12886 ok(r == ERROR_UNKNOWN_PATCH, "Expected ERROR_UNKNOWN_PATCH, got %d\n", r);
12887 ok(!lstrcmpA(val, "apple"), "Expected \"apple\", got \"%s\"\n", val);
12888 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
12890 RegDeleteValueA(udpatch, "LocalPackage");
12891 delete_key(udpatch, "", access & KEY_WOW64_64KEY);
12892 RegCloseKey(udpatch);
12893 delete_key(hpatch, "", access & KEY_WOW64_64KEY);
12894 RegCloseKey(hpatch);
12895 delete_key(patches, "", access & KEY_WOW64_64KEY);
12896 RegCloseKey(patches);
12897 delete_key(props, "", access & KEY_WOW64_64KEY);
12898 RegCloseKey(props);
12899 delete_key(udprod, "", access & KEY_WOW64_64KEY);
12900 RegCloseKey(udprod);
12901 LocalFree(usersid);
12904 static void test_MsiGetPatchInfo(void)
12906 UINT r;
12907 char prod_code[MAX_PATH], prod_squashed[MAX_PATH], val[MAX_PATH];
12908 char patch_code[MAX_PATH], patch_squashed[MAX_PATH], keypath[MAX_PATH];
12909 WCHAR valW[MAX_PATH], patch_codeW[MAX_PATH];
12910 HKEY hkey_product, hkey_patch, hkey_patches, hkey_udprops, hkey_udproduct;
12911 HKEY hkey_udpatch, hkey_udpatches, hkey_udproductpatches, hkey_udproductpatch;
12912 DWORD size;
12913 LONG res;
12914 REGSAM access = KEY_ALL_ACCESS;
12916 create_test_guid(patch_code, patch_squashed);
12917 create_test_guid(prod_code, prod_squashed);
12918 MultiByteToWideChar(CP_ACP, 0, patch_code, -1, patch_codeW, MAX_PATH);
12920 if (is_wow64)
12921 access |= KEY_WOW64_64KEY;
12923 r = MsiGetPatchInfoA(NULL, NULL, NULL, NULL);
12924 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
12926 r = MsiGetPatchInfoA(patch_code, NULL, NULL, NULL);
12927 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
12929 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, NULL, NULL);
12930 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
12932 size = 0;
12933 r = MsiGetPatchInfoA(patch_code, NULL, NULL, &size);
12934 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
12936 r = MsiGetPatchInfoA(patch_code, "", NULL, &size);
12937 ok(r == ERROR_UNKNOWN_PROPERTY, "expected ERROR_UNKNOWN_PROPERTY, got %u\n", r);
12939 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
12940 lstrcatA(keypath, prod_squashed);
12942 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_product, NULL);
12943 if (res == ERROR_ACCESS_DENIED)
12945 skip("Not enough rights to perform tests\n");
12946 return;
12948 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12950 /* product key exists */
12951 size = MAX_PATH;
12952 lstrcpyA(val, "apple");
12953 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12954 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12955 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val);
12956 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12958 res = RegCreateKeyExA(hkey_product, "Patches", 0, NULL, 0, access, NULL, &hkey_patches, NULL);
12959 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12961 /* patches key exists */
12962 size = MAX_PATH;
12963 lstrcpyA(val, "apple");
12964 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12965 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12966 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12967 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12969 res = RegCreateKeyExA(hkey_patches, patch_squashed, 0, NULL, 0, access, NULL, &hkey_patch, NULL);
12970 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
12972 /* patch key exists */
12973 size = MAX_PATH;
12974 lstrcpyA(val, "apple");
12975 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12976 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12977 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12978 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
12980 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
12981 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Products\\");
12982 lstrcatA(keypath, prod_squashed);
12984 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_udproduct, NULL);
12985 if (res == ERROR_ACCESS_DENIED)
12987 skip("Not enough rights to perform tests\n");
12988 goto done;
12990 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
12992 /* UserData product key exists */
12993 size = MAX_PATH;
12994 lstrcpyA(val, "apple");
12995 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
12996 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
12997 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
12998 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
13000 res = RegCreateKeyExA(hkey_udproduct, "InstallProperties", 0, NULL, 0, access, NULL, &hkey_udprops, NULL);
13001 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
13003 /* InstallProperties key exists */
13004 size = MAX_PATH;
13005 lstrcpyA(val, "apple");
13006 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
13007 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
13008 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged, got \"%s\"\n", val);
13009 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
13011 res = RegCreateKeyExA(hkey_udproduct, "Patches", 0, NULL, 0, access, NULL, &hkey_udpatches, NULL);
13012 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
13014 /* UserData Patches key exists */
13015 size = MAX_PATH;
13016 lstrcpyA(val, "apple");
13017 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
13018 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
13019 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
13020 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
13022 res = RegCreateKeyExA(hkey_udproduct, "Patches", 0, NULL, 0, access, NULL, &hkey_udproductpatches, NULL);
13023 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13025 res = RegCreateKeyExA(hkey_udproductpatches, patch_squashed, 0, NULL, 0, access, NULL, &hkey_udproductpatch, NULL);
13026 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13028 /* UserData product patch key exists */
13029 size = MAX_PATH;
13030 lstrcpyA(val, "apple");
13031 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
13032 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT got %u\n", r);
13033 ok(!lstrcmpA(val, "apple"), "expected val to be unchanged got \"%s\"\n", val);
13034 ok(size == MAX_PATH, "expected size to be unchanged got %u\n", size);
13036 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer");
13037 lstrcatA(keypath, "\\UserData\\S-1-5-18\\Patches\\");
13038 lstrcatA(keypath, patch_squashed);
13040 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &hkey_udpatch, NULL);
13041 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
13043 res = RegSetValueExA(hkey_udpatch, "LocalPackage", 0, REG_SZ, (const BYTE *)"c:\\test.msp", 12);
13044 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS got %d\n", res);
13046 /* UserData Patch key exists */
13047 size = 0;
13048 lstrcpyA(val, "apple");
13049 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
13050 ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r);
13051 ok(!lstrcmpA(val, "apple"), "expected \"apple\", got \"%s\"\n", val);
13052 ok(size == 11, "expected 11 got %u\n", size);
13054 size = MAX_PATH;
13055 lstrcpyA(val, "apple");
13056 r = MsiGetPatchInfoA(patch_code, INSTALLPROPERTY_LOCALPACKAGEA, val, &size);
13057 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r);
13058 ok(!lstrcmpA(val, "c:\\test.msp"), "expected \"c:\\test.msp\", got \"%s\"\n", val);
13059 ok(size == 11, "expected 11 got %u\n", size);
13061 size = 0;
13062 valW[0] = 0;
13063 r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size);
13064 ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", r);
13065 ok(!valW[0], "expected 0 got %u\n", valW[0]);
13066 ok(size == 11, "expected 11 got %u\n", size);
13068 size = MAX_PATH;
13069 valW[0] = 0;
13070 r = MsiGetPatchInfoW(patch_codeW, INSTALLPROPERTY_LOCALPACKAGEW, valW, &size);
13071 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS got %u\n", r);
13072 ok(valW[0], "expected > 0 got %u\n", valW[0]);
13073 ok(size == 11, "expected 11 got %u\n", size);
13075 delete_key(hkey_udproductpatch, "", access & KEY_WOW64_64KEY);
13076 RegCloseKey(hkey_udproductpatch);
13077 delete_key(hkey_udproductpatches, "", access & KEY_WOW64_64KEY);
13078 RegCloseKey(hkey_udproductpatches);
13079 delete_key(hkey_udpatch, "", access & KEY_WOW64_64KEY);
13080 RegCloseKey(hkey_udpatch);
13081 delete_key(hkey_udpatches, "", access & KEY_WOW64_64KEY);
13082 RegCloseKey(hkey_udpatches);
13083 delete_key(hkey_udprops, "", access & KEY_WOW64_64KEY);
13084 RegCloseKey(hkey_udprops);
13085 delete_key(hkey_udproduct, "", access & KEY_WOW64_64KEY);
13086 RegCloseKey(hkey_udproduct);
13088 done:
13089 delete_key(hkey_patches, "", access & KEY_WOW64_64KEY);
13090 RegCloseKey(hkey_patches);
13091 delete_key(hkey_product, "", access & KEY_WOW64_64KEY);
13092 RegCloseKey(hkey_product);
13093 delete_key(hkey_patch, "", access & KEY_WOW64_64KEY);
13094 RegCloseKey(hkey_patch);
13097 static void test_MsiEnumProducts(void)
13099 UINT r;
13100 BOOL found1, found2, found3;
13101 DWORD index;
13102 char product1[39], product2[39], product3[39], guid[39];
13103 char product_squashed1[33], product_squashed2[33], product_squashed3[33];
13104 char keypath1[MAX_PATH], keypath2[MAX_PATH], keypath3[MAX_PATH];
13105 char *usersid;
13106 HKEY key1, key2, key3;
13107 REGSAM access = KEY_ALL_ACCESS;
13109 if (is_process_limited())
13111 skip( "process is limited\n" );
13112 return;
13115 create_test_guid(product1, product_squashed1);
13116 create_test_guid(product2, product_squashed2);
13117 create_test_guid(product3, product_squashed3);
13118 usersid = get_user_sid();
13120 if (is_wow64)
13121 access |= KEY_WOW64_64KEY;
13123 strcpy(keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\");
13124 strcat(keypath2, usersid);
13125 strcat(keypath2, "\\Installer\\Products\\");
13126 strcat(keypath2, product_squashed2);
13128 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL);
13129 if (r == ERROR_ACCESS_DENIED)
13131 skip("Not enough rights to perform tests\n");
13132 LocalFree(usersid);
13133 return;
13135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13137 strcpy(keypath1, "Software\\Classes\\Installer\\Products\\");
13138 strcat(keypath1, product_squashed1);
13140 r = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL);
13141 if (r == ERROR_ACCESS_DENIED)
13143 skip( "insufficient rights\n" );
13144 LocalFree( usersid );
13145 return;
13147 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13149 strcpy(keypath3, "Software\\Microsoft\\Installer\\Products\\");
13150 strcat(keypath3, product_squashed3);
13152 r = RegCreateKeyA(HKEY_CURRENT_USER, keypath3, &key3);
13153 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13155 index = 0;
13156 r = MsiEnumProductsA(index, guid);
13157 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13159 r = MsiEnumProductsA(index, NULL);
13160 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
13162 index = 2;
13163 r = MsiEnumProductsA(index, guid);
13164 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
13166 index = 0;
13167 r = MsiEnumProductsA(index, guid);
13168 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13170 found1 = found2 = found3 = FALSE;
13171 while ((r = MsiEnumProductsA(index, guid)) == ERROR_SUCCESS)
13173 if (!strcmp(product1, guid)) found1 = TRUE;
13174 if (!strcmp(product2, guid)) found2 = TRUE;
13175 if (!strcmp(product3, guid)) found3 = TRUE;
13176 if (found1 && found2 && found3) break;
13177 index++;
13179 ok(found1, "product1 not found\n");
13180 ok(found2, "product2 not found\n");
13181 ok(found3, "product3 not found\n");
13183 delete_key(key1, "", access & KEY_WOW64_64KEY);
13184 delete_key(key2, "", access & KEY_WOW64_64KEY);
13185 RegDeleteKeyA(key3, "");
13186 RegCloseKey(key1);
13187 RegCloseKey(key2);
13188 RegCloseKey(key3);
13189 LocalFree(usersid);
13192 static void test_MsiGetFileSignatureInformation(void)
13194 HRESULT hr;
13195 const CERT_CONTEXT *cert;
13196 DWORD len;
13198 hr = MsiGetFileSignatureInformationA( NULL, 0, NULL, NULL, NULL );
13199 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13201 hr = MsiGetFileSignatureInformationA( NULL, 0, NULL, NULL, &len );
13202 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13204 hr = MsiGetFileSignatureInformationA( NULL, 0, &cert, NULL, &len );
13205 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13207 hr = MsiGetFileSignatureInformationA( "", 0, NULL, NULL, NULL );
13208 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13210 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, NULL );
13211 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13213 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, &len );
13214 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13216 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, &cert, NULL, &len );
13217 todo_wine ok(hr == CRYPT_E_FILE_ERROR, "expected CRYPT_E_FILE_ERROR got 0x%08x\n", hr);
13219 create_file_data( "signature.bin", "signature", sizeof("signature") );
13221 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, NULL );
13222 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13224 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, NULL, NULL, &len );
13225 ok(hr == E_INVALIDARG, "expected E_INVALIDARG got 0x%08x\n", hr);
13227 cert = (const CERT_CONTEXT *)0xdeadbeef;
13228 hr = MsiGetFileSignatureInformationA( "signature.bin", 0, &cert, NULL, &len );
13229 todo_wine ok(hr == HRESULT_FROM_WIN32(ERROR_FUNCTION_FAILED), "got 0x%08x\n", hr);
13230 ok(cert == NULL, "got %p\n", cert);
13232 DeleteFileA( "signature.bin" );
13235 static void test_MsiEnumProductsEx(void)
13237 UINT r;
13238 DWORD len, index;
13239 MSIINSTALLCONTEXT context;
13240 char product0[39], product1[39], product2[39], product3[39], guid[39], sid[128];
13241 char product_squashed1[33], product_squashed2[33], product_squashed3[33];
13242 char keypath1[MAX_PATH], keypath2[MAX_PATH], keypath3[MAX_PATH];
13243 HKEY key1 = NULL, key2 = NULL, key3 = NULL;
13244 REGSAM access = KEY_ALL_ACCESS;
13245 char *usersid = get_user_sid();
13246 BOOL found1, found2, found3;
13248 if (!pMsiEnumProductsExA)
13250 win_skip("MsiEnumProductsExA not implemented\n");
13251 return;
13254 create_test_guid( product0, NULL );
13255 create_test_guid( product1, product_squashed1 );
13256 create_test_guid( product2, product_squashed2 );
13257 create_test_guid( product3, product_squashed3 );
13259 if (is_wow64) access |= KEY_WOW64_64KEY;
13261 strcpy( keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Managed\\" );
13262 strcat( keypath2, usersid );
13263 strcat( keypath2, "\\Installer\\Products\\" );
13264 strcat( keypath2, product_squashed2 );
13266 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL );
13267 if (r == ERROR_ACCESS_DENIED)
13269 skip( "insufficient rights\n" );
13270 goto done;
13272 ok( r == ERROR_SUCCESS, "got %u\n", r );
13274 strcpy( keypath1, "Software\\Classes\\Installer\\Products\\" );
13275 strcat( keypath1, product_squashed1 );
13277 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL );
13278 if (r == ERROR_ACCESS_DENIED)
13280 skip( "insufficient rights\n" );
13281 goto done;
13283 ok( r == ERROR_SUCCESS, "got %u\n", r );
13285 strcpy( keypath3, usersid );
13286 strcat( keypath3, "\\Software\\Microsoft\\Installer\\Products\\" );
13287 strcat( keypath3, product_squashed3 );
13289 r = RegCreateKeyExA( HKEY_USERS, keypath3, 0, NULL, 0, access, NULL, &key3, NULL );
13290 ok( r == ERROR_SUCCESS, "got %u\n", r );
13292 r = pMsiEnumProductsExA( NULL, NULL, 0, 0, NULL, NULL, NULL, NULL );
13293 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13295 len = sizeof(sid);
13296 r = pMsiEnumProductsExA( NULL, NULL, 0, 0, NULL, NULL, NULL, &len );
13297 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13298 ok( len == sizeof(sid), "got %u\n", len );
13300 r = pMsiEnumProductsExA( NULL, NULL, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, NULL, NULL );
13301 ok( r == ERROR_SUCCESS, "got %u\n", r );
13303 sid[0] = 0;
13304 len = sizeof(sid);
13305 r = pMsiEnumProductsExA( product0, NULL, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, sid, &len );
13306 ok( r == ERROR_NO_MORE_ITEMS, "got %u\n", r );
13307 ok( len == sizeof(sid), "got %u\n", len );
13308 ok( !sid[0], "got %s\n", sid );
13310 sid[0] = 0;
13311 len = sizeof(sid);
13312 r = pMsiEnumProductsExA( product0, usersid, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, sid, &len );
13313 ok( r == ERROR_NO_MORE_ITEMS, "got %u\n", r );
13314 ok( len == sizeof(sid), "got %u\n", len );
13315 ok( !sid[0], "got %s\n", sid );
13317 sid[0] = 0;
13318 len = 0;
13319 r = pMsiEnumProductsExA( NULL, usersid, MSIINSTALLCONTEXT_USERUNMANAGED, 0, NULL, NULL, sid, &len );
13320 ok( r == ERROR_MORE_DATA, "got %u\n", r );
13321 ok( len, "length unchanged\n" );
13322 ok( !sid[0], "got %s\n", sid );
13324 guid[0] = 0;
13325 context = 0xdeadbeef;
13326 sid[0] = 0;
13327 len = sizeof(sid);
13328 r = pMsiEnumProductsExA( NULL, NULL, MSIINSTALLCONTEXT_ALL, 0, guid, &context, sid, &len );
13329 ok( r == ERROR_SUCCESS, "got %u\n", r );
13330 ok( guid[0], "empty guid\n" );
13331 ok( context != 0xdeadbeef, "context unchanged\n" );
13332 ok( !len, "got %u\n", len );
13333 ok( !sid[0], "got %s\n", sid );
13335 guid[0] = 0;
13336 context = 0xdeadbeef;
13337 sid[0] = 0;
13338 len = sizeof(sid);
13339 r = pMsiEnumProductsExA( NULL, usersid, MSIINSTALLCONTEXT_ALL, 0, guid, &context, sid, &len );
13340 ok( r == ERROR_SUCCESS, "got %u\n", r );
13341 ok( guid[0], "empty guid\n" );
13342 ok( context != 0xdeadbeef, "context unchanged\n" );
13343 ok( !len, "got %u\n", len );
13344 ok( !sid[0], "got %s\n", sid );
13346 guid[0] = 0;
13347 context = 0xdeadbeef;
13348 sid[0] = 0;
13349 len = sizeof(sid);
13350 r = pMsiEnumProductsExA( NULL, "S-1-1-0", MSIINSTALLCONTEXT_ALL, 0, guid, &context, sid, &len );
13351 if (r == ERROR_ACCESS_DENIED)
13353 skip( "insufficient rights\n" );
13354 goto done;
13356 ok( r == ERROR_SUCCESS, "got %u\n", r );
13357 ok( guid[0], "empty guid\n" );
13358 ok( context != 0xdeadbeef, "context unchanged\n" );
13359 ok( !len, "got %u\n", len );
13360 ok( !sid[0], "got %s\n", sid );
13362 index = 0;
13363 guid[0] = 0;
13364 context = 0xdeadbeef;
13365 sid[0] = 0;
13366 len = sizeof(sid);
13367 found1 = found2 = found3 = FALSE;
13368 while (!pMsiEnumProductsExA( NULL, "S-1-1-0", MSIINSTALLCONTEXT_ALL, index, guid, &context, sid, &len ))
13370 if (!strcmp( product1, guid ))
13372 ok( context == MSIINSTALLCONTEXT_MACHINE, "got %u\n", context );
13373 ok( !sid[0], "got \"%s\"\n", sid );
13374 ok( !len, "unexpected length %u\n", len );
13375 found1 = TRUE;
13377 if (!strcmp( product2, guid ))
13379 ok( context == MSIINSTALLCONTEXT_USERMANAGED, "got %u\n", context );
13380 ok( sid[0], "empty sid\n" );
13381 ok( len == strlen(sid), "unexpected length %u\n", len );
13382 found2 = TRUE;
13384 if (!strcmp( product3, guid ))
13386 ok( context == MSIINSTALLCONTEXT_USERUNMANAGED, "got %u\n", context );
13387 ok( sid[0], "empty sid\n" );
13388 ok( len == strlen(sid), "unexpected length %u\n", len );
13389 found3 = TRUE;
13391 if (found1 && found2 && found3) break;
13392 index++;
13393 guid[0] = 0;
13394 context = 0xdeadbeef;
13395 sid[0] = 0;
13396 len = sizeof(sid);
13398 ok(found1, "product1 not found\n");
13399 ok(found2, "product2 not found\n");
13400 ok(found3, "product3 not found\n");
13402 done:
13403 delete_key( key1, "", access );
13404 delete_key( key2, "", access );
13405 delete_key( key3, "", access );
13406 RegCloseKey( key1 );
13407 RegCloseKey( key2 );
13408 RegCloseKey( key3 );
13409 LocalFree( usersid );
13412 static void test_MsiEnumComponents(void)
13414 UINT r;
13415 BOOL found1, found2;
13416 DWORD index;
13417 char comp1[39], comp2[39], guid[39];
13418 char comp_squashed1[33], comp_squashed2[33];
13419 char keypath1[MAX_PATH], keypath2[MAX_PATH];
13420 REGSAM access = KEY_ALL_ACCESS;
13421 char *usersid = get_user_sid();
13422 HKEY key1 = NULL, key2 = NULL;
13424 if (is_process_limited())
13426 skip("process is limited\n");
13427 return;
13430 create_test_guid( comp1, comp_squashed1 );
13431 create_test_guid( comp2, comp_squashed2 );
13433 if (is_wow64) access |= KEY_WOW64_64KEY;
13435 strcpy( keypath1, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13436 strcat( keypath1, "S-1-5-18\\Components\\" );
13437 strcat( keypath1, comp_squashed1 );
13439 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL );
13440 if (r == ERROR_ACCESS_DENIED)
13442 skip( "insufficient rights\n" );
13443 goto done;
13445 ok( r == ERROR_SUCCESS, "got %u\n", r );
13447 strcpy( keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13448 strcat( keypath2, usersid );
13449 strcat( keypath2, "\\Components\\" );
13450 strcat( keypath2, comp_squashed2 );
13452 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL );
13453 if (r == ERROR_ACCESS_DENIED)
13455 skip( "insufficient rights\n" );
13456 goto done;
13459 r = MsiEnumComponentsA( 0, NULL );
13460 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13462 index = 0;
13463 guid[0] = 0;
13464 found1 = found2 = FALSE;
13465 while (!MsiEnumComponentsA( index, guid ))
13467 if (!strcmp( guid, comp1 )) found1 = TRUE;
13468 if (!strcmp( guid, comp2 )) found2 = TRUE;
13469 ok( guid[0], "empty guid\n" );
13470 if (found1 && found2) break;
13471 guid[0] = 0;
13472 index++;
13474 ok( found1, "comp1 not found\n" );
13475 ok( found2, "comp2 not found\n" );
13477 done:
13478 delete_key( key1, "", access );
13479 delete_key( key2, "", access );
13480 RegCloseKey( key1 );
13481 RegCloseKey( key2 );
13482 LocalFree( usersid );
13485 static void test_MsiEnumComponentsEx(void)
13487 UINT r;
13488 BOOL found1, found2;
13489 DWORD len, index;
13490 MSIINSTALLCONTEXT context;
13491 char comp1[39], comp2[39], guid[39], sid[128];
13492 char comp_squashed1[33], comp_squashed2[33];
13493 char keypath1[MAX_PATH], keypath2[MAX_PATH];
13494 HKEY key1 = NULL, key2 = NULL;
13495 REGSAM access = KEY_ALL_ACCESS;
13496 char *usersid = get_user_sid();
13498 if (!pMsiEnumComponentsExA)
13500 win_skip( "MsiEnumComponentsExA not implemented\n" );
13501 return;
13503 if (is_process_limited())
13505 skip("process is limited\n");
13506 return;
13509 create_test_guid( comp1, comp_squashed1 );
13510 create_test_guid( comp2, comp_squashed2 );
13512 if (is_wow64) access |= KEY_WOW64_64KEY;
13514 strcpy( keypath1, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13515 strcat( keypath1, "S-1-5-18\\Components\\" );
13516 strcat( keypath1, comp_squashed1 );
13518 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath1, 0, NULL, 0, access, NULL, &key1, NULL );
13519 if (r == ERROR_ACCESS_DENIED)
13521 skip( "insufficient rights\n" );
13522 goto done;
13524 ok( r == ERROR_SUCCESS, "got %u\n", r );
13526 strcpy( keypath2, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\" );
13527 strcat( keypath2, usersid );
13528 strcat( keypath2, "\\Components\\" );
13529 strcat( keypath2, comp_squashed2 );
13531 r = RegCreateKeyExA( HKEY_LOCAL_MACHINE, keypath2, 0, NULL, 0, access, NULL, &key2, NULL );
13532 if (r == ERROR_ACCESS_DENIED)
13534 skip( "insufficient rights\n" );
13535 goto done;
13537 ok( r == ERROR_SUCCESS, "got %u\n", r );
13538 r = RegSetValueExA( key2, comp_squashed2, 0, REG_SZ, (const BYTE *)"c:\\doesnotexist",
13539 sizeof("c:\\doesnotexist"));
13540 ok( r == ERROR_SUCCESS, "got %u\n", r );
13542 index = 0;
13543 guid[0] = 0;
13544 context = 0xdeadbeef;
13545 sid[0] = 0;
13546 len = sizeof(sid);
13547 found1 = found2 = FALSE;
13548 while (!pMsiEnumComponentsExA( "S-1-1-0", MSIINSTALLCONTEXT_ALL, index, guid, &context, sid, &len ))
13550 if (!strcmp( comp1, guid ))
13552 ok( context == MSIINSTALLCONTEXT_MACHINE, "got %u\n", context );
13553 ok( !sid[0], "got \"%s\"\n", sid );
13554 ok( !len, "unexpected length %u\n", len );
13555 found1 = TRUE;
13556 if (found2) break;
13558 if (!strcmp( comp2, guid ))
13560 ok( context == MSIINSTALLCONTEXT_USERUNMANAGED, "got %u\n", context );
13561 ok( sid[0], "empty sid\n" );
13562 ok( len == strlen(sid), "unexpected length %u\n", len );
13563 found2 = TRUE;
13564 if (found1) break;
13566 index++;
13567 guid[0] = 0;
13568 context = 0xdeadbeef;
13569 sid[0] = 0;
13570 len = sizeof(sid);
13572 ok( found1, "comp1 not found\n" );
13573 ok( found2, "comp2 not found\n" );
13575 r = pMsiEnumComponentsExA( NULL, 0, 0, NULL, NULL, NULL, NULL );
13576 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13578 r = pMsiEnumComponentsExA( NULL, MSIINSTALLCONTEXT_ALL, 0, NULL, NULL, sid, NULL );
13579 ok( r == ERROR_INVALID_PARAMETER, "got %u\n", r );
13581 done:
13582 RegDeleteValueA( key2, comp_squashed2 );
13583 delete_key( key1, "", access );
13584 delete_key( key2, "", access );
13585 RegCloseKey( key1 );
13586 RegCloseKey( key2 );
13587 LocalFree( usersid );
13590 static void test_MsiConfigureProductEx(void)
13592 UINT r;
13593 LONG res;
13594 DWORD type, size;
13595 HKEY props, source;
13596 CHAR keypath[MAX_PATH * 2], localpackage[MAX_PATH], packagename[MAX_PATH];
13597 REGSAM access = KEY_ALL_ACCESS;
13599 if (is_process_limited())
13601 skip("process is limited\n");
13602 return;
13605 CreateDirectoryA("msitest", NULL);
13606 create_file_data("msitest\\hydrogen", "hydrogen", 500);
13607 create_file_data("msitest\\helium", "helium", 500);
13608 create_file_data("msitest\\lithium", "lithium", 500);
13610 create_database(msifile, mcp_tables, ARRAY_SIZE(mcp_tables));
13612 if (is_wow64)
13613 access |= KEY_WOW64_64KEY;
13615 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
13617 /* NULL szProduct */
13618 r = MsiConfigureProductExA(NULL, INSTALLLEVEL_DEFAULT,
13619 INSTALLSTATE_DEFAULT, "PROPVAR=42");
13620 ok(r == ERROR_INVALID_PARAMETER,
13621 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13623 /* empty szProduct */
13624 r = MsiConfigureProductExA("", INSTALLLEVEL_DEFAULT,
13625 INSTALLSTATE_DEFAULT, "PROPVAR=42");
13626 ok(r == ERROR_INVALID_PARAMETER,
13627 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13629 /* garbage szProduct */
13630 r = MsiConfigureProductExA("garbage", INSTALLLEVEL_DEFAULT,
13631 INSTALLSTATE_DEFAULT, "PROPVAR=42");
13632 ok(r == ERROR_INVALID_PARAMETER,
13633 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13635 /* guid without brackets */
13636 r = MsiConfigureProductExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
13637 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13638 "PROPVAR=42");
13639 ok(r == ERROR_INVALID_PARAMETER,
13640 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
13642 /* guid with brackets */
13643 r = MsiConfigureProductExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
13644 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13645 "PROPVAR=42");
13646 ok(r == ERROR_UNKNOWN_PRODUCT,
13647 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
13649 /* same length as guid, but random */
13650 r = MsiConfigureProductExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
13651 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13652 "PROPVAR=42");
13653 ok(r == ERROR_UNKNOWN_PRODUCT,
13654 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
13656 /* product not installed yet */
13657 r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
13658 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13659 "PROPVAR=42");
13660 ok(r == ERROR_UNKNOWN_PRODUCT,
13661 "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
13663 /* install the product, per-user unmanaged */
13664 r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
13665 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13667 skip("Not enough rights to perform tests\n");
13668 goto error;
13670 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13671 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13672 ok(pf_exists("msitest\\helium"), "File not installed\n");
13673 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13674 ok(pf_exists("msitest"), "File not installed\n");
13676 /* product is installed per-user managed, remove it */
13677 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13678 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13679 "PROPVAR=42");
13680 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13681 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13682 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13683 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13684 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13686 /* product has been removed */
13687 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13688 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13689 "PROPVAR=42");
13690 ok(r == ERROR_UNKNOWN_PRODUCT,
13691 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
13693 /* install the product, machine */
13694 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13695 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13696 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13697 ok(pf_exists("msitest\\helium"), "File not installed\n");
13698 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13699 ok(pf_exists("msitest"), "File not installed\n");
13701 /* product is installed machine, remove it */
13702 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13703 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13704 "PROPVAR=42");
13705 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13706 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13707 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13708 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13709 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13711 /* product has been removed */
13712 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13713 INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
13714 "PROPVAR=42");
13715 ok(r == ERROR_UNKNOWN_PRODUCT,
13716 "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
13718 /* install the product, machine */
13719 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13720 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13721 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13722 ok(pf_exists("msitest\\helium"), "File not installed\n");
13723 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13724 ok(pf_exists("msitest"), "File not installed\n");
13726 DeleteFileA(msifile);
13728 /* msifile is removed */
13729 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13730 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13731 "PROPVAR=42");
13732 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13733 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13734 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13735 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13736 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13738 create_database(msifile, mcp_tables, ARRAY_SIZE(mcp_tables));
13740 /* install the product, machine */
13741 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13742 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13743 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13744 ok(pf_exists("msitest\\helium"), "File not installed\n");
13745 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13746 ok(pf_exists("msitest"), "File not installed\n");
13748 DeleteFileA(msifile);
13750 lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13751 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
13752 lstrcatA(keypath, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13754 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
13755 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13757 type = REG_SZ;
13758 size = MAX_PATH;
13759 res = RegQueryValueExA(props, "LocalPackage", NULL, &type,
13760 (LPBYTE)localpackage, &size);
13761 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13763 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
13764 (const BYTE *)"C:\\idontexist.msi", 18);
13765 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13767 /* LocalPackage is used to find the cached msi package */
13768 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13769 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13770 "PROPVAR=42");
13771 ok(r == ERROR_INSTALL_SOURCE_ABSENT,
13772 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
13773 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13774 ok(pf_exists("msitest\\helium"), "File not installed\n");
13775 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13776 ok(pf_exists("msitest"), "File not installed\n");
13778 RegCloseKey(props);
13779 create_database(msifile, mcp_tables, ARRAY_SIZE(mcp_tables));
13781 /* LastUsedSource can be used as a last resort */
13782 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13783 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13784 "PROPVAR=42");
13785 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13786 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13787 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13788 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13789 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13790 DeleteFileA( localpackage );
13792 /* install the product, machine */
13793 r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
13794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13795 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13796 ok(pf_exists("msitest\\helium"), "File not installed\n");
13797 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13798 ok(pf_exists("msitest"), "File not installed\n");
13800 lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
13801 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
13802 lstrcatA(keypath, "83374883CBB1401418CAF2AA7CCEDDDC\\InstallProperties");
13804 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &props);
13805 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13807 type = REG_SZ;
13808 size = MAX_PATH;
13809 res = RegQueryValueExA(props, "LocalPackage", NULL, &type,
13810 (LPBYTE)localpackage, &size);
13811 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13813 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
13814 (const BYTE *)"C:\\idontexist.msi", 18);
13815 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13817 lstrcpyA(keypath, "SOFTWARE\\Classes\\Installer\\Products\\");
13818 lstrcatA(keypath, "83374883CBB1401418CAF2AA7CCEDDDC\\SourceList");
13820 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, access, &source);
13821 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13823 type = REG_SZ;
13824 size = MAX_PATH;
13825 res = RegQueryValueExA(source, "PackageName", NULL, &type,
13826 (LPBYTE)packagename, &size);
13827 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13829 res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
13830 (const BYTE *)"idontexist.msi", 15);
13831 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13833 /* SourceList is altered */
13834 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13835 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13836 "PROPVAR=42");
13837 ok(r == ERROR_INSTALL_SOURCE_ABSENT,
13838 "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
13839 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
13840 ok(pf_exists("msitest\\helium"), "File not installed\n");
13841 ok(pf_exists("msitest\\lithium"), "File not installed\n");
13842 ok(pf_exists("msitest"), "File not installed\n");
13844 /* restore PackageName */
13845 res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
13846 (const BYTE *)packagename, lstrlenA(packagename) + 1);
13847 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13849 /* restore LocalPackage */
13850 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
13851 (const BYTE *)localpackage, lstrlenA(localpackage) + 1);
13852 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
13854 /* finally remove the product */
13855 r = MsiConfigureProductExA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}",
13856 INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
13857 "PROPVAR=42");
13858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
13859 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
13860 ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
13861 ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
13862 ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
13864 RegCloseKey(source);
13865 RegCloseKey(props);
13867 error:
13868 DeleteFileA("msitest\\hydrogen");
13869 DeleteFileA("msitest\\helium");
13870 DeleteFileA("msitest\\lithium");
13871 RemoveDirectoryA("msitest");
13872 DeleteFileA(msifile);
13875 static void test_MsiSetFeatureAttributes(void)
13877 UINT r;
13878 DWORD attrs;
13879 char path[MAX_PATH];
13880 MSIHANDLE package;
13882 if (is_process_limited())
13884 skip("process is limited\n");
13885 return;
13887 create_database( msifile, tables, ARRAY_SIZE( tables ));
13889 strcpy( path, CURR_DIR );
13890 strcat( path, "\\" );
13891 strcat( path, msifile );
13893 r = MsiOpenPackageA( path, &package );
13894 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13896 skip("Not enough rights to perform tests\n");
13897 DeleteFileA( msifile );
13898 return;
13900 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13902 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13903 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %u\n", r);
13905 r = MsiDoActionA( package, "CostInitialize" );
13906 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13908 r = MsiSetFeatureAttributesA( 0, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13909 ok(r == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", r);
13911 r = MsiSetFeatureAttributesA( package, "", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13912 ok(r == ERROR_UNKNOWN_FEATURE, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
13914 r = MsiSetFeatureAttributesA( package, NULL, INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13915 ok(r == ERROR_UNKNOWN_FEATURE, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
13917 r = MsiSetFeatureAttributesA( package, "One", 0 );
13918 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13920 attrs = 0xdeadbeef;
13921 r = MsiGetFeatureInfoA( package, "One", &attrs, NULL, NULL, NULL, NULL );
13922 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13923 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL,
13924 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs);
13926 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13927 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13929 attrs = 0;
13930 r = MsiGetFeatureInfoA( package, "One", &attrs, NULL, NULL, NULL, NULL );
13931 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13932 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL,
13933 "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got 0x%08x\n", attrs);
13935 r = MsiDoActionA( package, "FileCost" );
13936 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13938 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORSOURCE );
13939 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13941 attrs = 0;
13942 r = MsiGetFeatureInfoA( package, "One", &attrs, NULL, NULL, NULL, NULL );
13943 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13944 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORSOURCE,
13945 "expected INSTALLFEATUREATTRIBUTE_FAVORSOURCE, got 0x%08x\n", attrs);
13947 r = MsiDoActionA( package, "CostFinalize" );
13948 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13950 r = MsiSetFeatureAttributesA( package, "One", INSTALLFEATUREATTRIBUTE_FAVORLOCAL );
13951 ok(r == ERROR_FUNCTION_FAILED, "expected ERROR_FUNCTION_FAILED, got %u\n", r);
13953 MsiCloseHandle( package );
13954 DeleteFileA( msifile );
13957 static void test_MsiGetFeatureInfo(void)
13959 UINT r;
13960 MSIHANDLE package;
13961 char title[32], help[32], path[MAX_PATH];
13962 DWORD attrs, title_len, help_len;
13964 if (is_process_limited())
13966 skip("process is limited\n");
13967 return;
13969 create_database( msifile, tables, ARRAY_SIZE( tables ));
13971 strcpy( path, CURR_DIR );
13972 strcat( path, "\\" );
13973 strcat( path, msifile );
13975 r = MsiOpenPackageA( path, &package );
13976 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
13978 skip("Not enough rights to perform tests\n");
13979 DeleteFileA( msifile );
13980 return;
13982 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
13984 r = MsiGetFeatureInfoA( 0, NULL, NULL, NULL, NULL, NULL, NULL );
13985 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
13987 r = MsiGetFeatureInfoA( package, NULL, NULL, NULL, NULL, NULL, NULL );
13988 ok(r == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", r);
13990 r = MsiGetFeatureInfoA( package, "", NULL, NULL, NULL, NULL, NULL );
13991 ok(r == ERROR_UNKNOWN_FEATURE, "expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
13993 r = MsiGetFeatureInfoA( package, "One", NULL, NULL, NULL, NULL, NULL );
13994 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
13996 r = MsiGetFeatureInfoA( 0, "One", NULL, NULL, NULL, NULL, NULL );
13997 ok(r == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %u\n", r);
13999 title_len = help_len = 0;
14000 r = MsiGetFeatureInfoA( package, "One", NULL, NULL, &title_len, NULL, &help_len );
14001 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14002 ok(title_len == 3, "expected 3, got %u\n", title_len);
14003 ok(help_len == 3, "expected 3, got %u\n", help_len);
14005 title[0] = help[0] = 0;
14006 title_len = help_len = 0;
14007 r = MsiGetFeatureInfoA( package, "One", NULL, title, &title_len, help, &help_len );
14008 ok(r == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %u\n", r);
14009 ok(title_len == 3, "expected 3, got %u\n", title_len);
14010 ok(help_len == 3, "expected 3, got %u\n", help_len);
14012 attrs = 0;
14013 title[0] = help[0] = 0;
14014 title_len = sizeof(title);
14015 help_len = sizeof(help);
14016 r = MsiGetFeatureInfoA( package, "One", &attrs, title, &title_len, help, &help_len );
14017 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14018 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs);
14019 ok(title_len == 3, "expected 3, got %u\n", title_len);
14020 ok(help_len == 3, "expected 3, got %u\n", help_len);
14021 ok(!strcmp(title, "One"), "expected \"One\", got \"%s\"\n", title);
14022 ok(!strcmp(help, "One"), "expected \"One\", got \"%s\"\n", help);
14024 attrs = 0;
14025 title[0] = help[0] = 0;
14026 title_len = sizeof(title);
14027 help_len = sizeof(help);
14028 r = MsiGetFeatureInfoA( package, "Two", &attrs, title, &title_len, help, &help_len );
14029 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14030 ok(attrs == INSTALLFEATUREATTRIBUTE_FAVORLOCAL, "expected INSTALLFEATUREATTRIBUTE_FAVORLOCAL, got %u\n", attrs);
14031 ok(!title_len, "expected 0, got %u\n", title_len);
14032 ok(!help_len, "expected 0, got %u\n", help_len);
14033 ok(!title[0], "expected \"\", got \"%s\"\n", title);
14034 ok(!help[0], "expected \"\", got \"%s\"\n", help);
14036 MsiCloseHandle( package );
14037 DeleteFileA( msifile );
14040 static INT CALLBACK handler_a(LPVOID context, UINT type, LPCSTR msg)
14042 return IDOK;
14045 static INT CALLBACK handler_w(LPVOID context, UINT type, LPCWSTR msg)
14047 return IDOK;
14050 static INT CALLBACK handler_record(LPVOID context, UINT type, MSIHANDLE record)
14052 return IDOK;
14055 static void test_MsiSetInternalUI(void)
14057 INSTALLUILEVEL level;
14059 level = MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14060 ok(level == INSTALLUILEVEL_DEFAULT, "expected INSTALLUILEVEL_DEFAULT, got %d\n", level);
14062 level = MsiSetInternalUI(INSTALLUILEVEL_DEFAULT, NULL);
14063 ok(level == INSTALLUILEVEL_FULL, "expected INSTALLUILEVEL_FULL, got %d\n", level);
14065 level = MsiSetInternalUI(INSTALLUILEVEL_NOCHANGE, NULL);
14066 ok(level == INSTALLUILEVEL_DEFAULT, "expected INSTALLUILEVEL_DEFAULT, got %d\n", level);
14068 level = MsiSetInternalUI(0xdeadbeef, NULL);
14069 ok(level == INSTALLUILEVEL_NOCHANGE, "expected INSTALLUILEVEL_NOCHANGE, got %d\n", level);
14072 static void test_MsiSetExternalUI(void)
14074 INSTALLUI_HANDLERA ret_a;
14075 INSTALLUI_HANDLERW ret_w;
14076 INSTALLUI_HANDLER_RECORD prev;
14077 UINT error;
14079 ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
14080 ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
14082 ret_a = MsiSetExternalUIA(NULL, 0, NULL);
14083 ok(ret_a == handler_a, "expected %p, got %p\n", handler_a, ret_a);
14085 /* Not present before Installer 3.1 */
14086 if (!pMsiSetExternalUIRecord) {
14087 win_skip("MsiSetExternalUIRecord is not available\n");
14088 return;
14091 error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
14092 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
14093 ok(prev == NULL, "expected NULL, got %p\n", prev);
14095 prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
14096 error = pMsiSetExternalUIRecord(NULL, INSTALLLOGMODE_ERROR, NULL, &prev);
14097 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
14098 ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
14100 ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
14101 ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
14103 ret_w = MsiSetExternalUIW(NULL, 0, NULL);
14104 ok(ret_w == handler_w, "expected %p, got %p\n", handler_w, ret_w);
14106 ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
14107 ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
14109 ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
14110 ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
14112 prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
14113 error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
14114 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
14115 ok(prev == NULL, "expected NULL, got %p\n", prev);
14117 ret_a = MsiSetExternalUIA(NULL, 0, NULL);
14118 ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
14120 ret_w = MsiSetExternalUIW(NULL, 0, NULL);
14121 ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
14123 prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
14124 error = pMsiSetExternalUIRecord(NULL, 0, NULL, &prev);
14125 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
14126 ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
14128 error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, NULL);
14129 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
14131 error = pMsiSetExternalUIRecord(NULL, 0, NULL, NULL);
14132 ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
14135 static void test_lastusedsource(void)
14137 static const char prodcode[] = "{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}";
14138 char value[MAX_PATH], path[MAX_PATH];
14139 DWORD size;
14140 UINT r;
14142 if (!pMsiSourceListGetInfoA)
14144 win_skip("MsiSourceListGetInfoA is not available\n");
14145 return;
14148 CreateDirectoryA("msitest", NULL);
14149 create_file("maximus", 500);
14150 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
14151 DeleteFileA("maximus");
14153 create_database("msifile0.msi", lus0_tables, ARRAY_SIZE(lus0_tables));
14154 create_database("msifile1.msi", lus1_tables, ARRAY_SIZE(lus1_tables));
14155 create_database("msifile2.msi", lus2_tables, ARRAY_SIZE(lus2_tables));
14157 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
14159 /* no cabinet file */
14161 size = MAX_PATH;
14162 lstrcpyA(value, "aaa");
14163 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14164 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14165 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
14166 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
14168 r = MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1");
14169 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
14171 skip("Not enough rights to perform tests\n");
14172 goto error;
14174 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14176 lstrcpyA(path, CURR_DIR);
14177 lstrcatA(path, "\\");
14179 size = MAX_PATH;
14180 lstrcpyA(value, "aaa");
14181 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14182 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14183 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14184 ok(!lstrcmpA(value, path), "expected \"%s\", got \"%s\"\n", path, value);
14185 ok(size == lstrlenA(path), "expected %d, got %d\n", lstrlenA(path), size);
14187 r = MsiInstallProductA("msifile0.msi", "REMOVE=ALL FULL=1");
14188 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14190 /* separate cabinet file */
14192 size = MAX_PATH;
14193 lstrcpyA(value, "aaa");
14194 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14195 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14196 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
14197 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
14199 r = MsiInstallProductA("msifile1.msi", "PUBLISH_PRODUCT=1");
14200 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14202 lstrcpyA(path, CURR_DIR);
14203 lstrcatA(path, "\\");
14205 size = MAX_PATH;
14206 lstrcpyA(value, "aaa");
14207 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14208 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14209 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14210 ok(!lstrcmpA(value, path), "expected \"%s\", got \"%s\"\n", path, value);
14211 ok(size == lstrlenA(path), "expected %d, got %d\n", lstrlenA(path), size);
14213 r = MsiInstallProductA("msifile1.msi", "REMOVE=ALL FULL=1");
14214 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14216 size = MAX_PATH;
14217 lstrcpyA(value, "aaa");
14218 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14219 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14220 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
14221 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
14223 /* embedded cabinet stream */
14225 add_cabinet_storage("msifile2.msi", "test1.cab");
14227 r = MsiInstallProductA("msifile2.msi", "PUBLISH_PRODUCT=1");
14228 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14230 size = MAX_PATH;
14231 lstrcpyA(value, "aaa");
14232 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14233 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14234 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14235 ok(!lstrcmpA(value, path), "expected \"%s\", got \"%s\"\n", path, value);
14236 ok(size == lstrlenA(path), "expected %d, got %d\n", lstrlenA(path), size);
14238 r = MsiInstallProductA("msifile2.msi", "REMOVE=ALL FULL=1");
14239 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r);
14241 size = MAX_PATH;
14242 lstrcpyA(value, "aaa");
14243 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
14244 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCEA, value, &size);
14245 ok(r == ERROR_UNKNOWN_PRODUCT, "expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
14246 ok(!lstrcmpA(value, "aaa"), "expected \"aaa\", got \"%s\"\n", value);
14248 error:
14249 delete_cab_files();
14250 DeleteFileA("msitest\\maximus");
14251 RemoveDirectoryA("msitest");
14252 DeleteFileA("msifile0.msi");
14253 DeleteFileA("msifile1.msi");
14254 DeleteFileA("msifile2.msi");
14257 static void test_setpropertyfolder(void)
14259 UINT r;
14261 if (is_process_limited())
14263 skip("process is limited\n");
14264 return;
14267 CreateDirectoryA("msitest", NULL);
14268 create_file("msitest\\maximus", 500);
14270 create_database(msifile, spf_tables, ARRAY_SIZE(spf_tables));
14272 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14274 r = MsiInstallProductA(msifile, NULL);
14275 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
14277 skip("Not enough rights to perform tests\n");
14278 goto error;
14280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14281 ok(delete_pf("msitest\\added\\added2\\maximus", TRUE), "File not installed\n");
14282 ok(delete_pf("msitest\\added\\added2", FALSE), "Directory not created\n");
14283 ok(delete_pf("msitest\\added", FALSE), "Directory not created\n");
14284 ok(delete_pf("msitest", FALSE), "Directory not created\n");
14286 CreateDirectoryA("parent", NULL);
14287 CreateDirectoryA("parent\\child", NULL);
14288 create_file("parent\\child\\maximus", 500);
14290 create_database(msifile, spf2_tables, ARRAY_SIZE(spf2_tables));
14292 r = MsiInstallProductA(msifile, "TARGETDIR=c:\\");
14293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14295 ok(delete_pf("msitest\\maximus", TRUE), "file not installed\n");
14296 ok(delete_pf("msitest", FALSE), "directory not created\n");
14298 ok(DeleteFileA("c:\\parent\\child\\Shortcut.lnk"), "file not installed\n");
14299 ok(RemoveDirectoryA("c:\\parent\\child"), "directory not created\n");
14300 ok(RemoveDirectoryA("c:\\parent"), "directory not created\n");
14302 DeleteFileA("parent\\child\\maximus");
14303 RemoveDirectoryA("parent\\child");
14304 RemoveDirectoryA("parent");
14306 error:
14307 DeleteFileA(msifile);
14308 DeleteFileA("msitest\\maximus");
14309 RemoveDirectoryA("msitest");
14312 static void test_sourcedir_props(void)
14314 UINT r;
14316 if (is_process_limited())
14318 skip("process is limited\n");
14319 return;
14322 create_test_files();
14323 create_file("msitest\\sourcedir.txt", 1000);
14324 create_database(msifile, sd_tables, ARRAY_SIZE(sd_tables));
14326 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14328 /* full UI, no ResolveSource action */
14329 r = MsiInstallProductA(msifile, NULL);
14330 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14332 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14335 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14336 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14338 /* full UI, ResolveSource action */
14339 r = MsiInstallProductA(msifile, "ResolveSource=1");
14340 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14342 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14345 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14346 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14348 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
14350 /* no UI, no ResolveSource action */
14351 r = MsiInstallProductA(msifile, NULL);
14352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14354 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14357 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14358 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14360 /* no UI, ResolveSource action */
14361 r = MsiInstallProductA(msifile, "ResolveSource=1");
14362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14364 r = MsiInstallProductA(msifile, "REMOVE=ALL");
14365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14367 ok(!delete_pf("msitest\\sourcedir.txt", TRUE), "file not removed\n");
14368 ok(!delete_pf("msitest", FALSE), "directory not removed\n");
14370 DeleteFileA("msitest\\sourcedir.txt");
14371 delete_test_files();
14372 DeleteFileA(msifile);
14375 static void test_concurrentinstall(void)
14377 UINT r;
14378 CHAR path[MAX_PATH];
14380 if (is_process_limited())
14382 skip("process is limited\n");
14383 return;
14386 CreateDirectoryA("msitest", NULL);
14387 CreateDirectoryA("msitest\\msitest", NULL);
14388 create_file("msitest\\maximus", 500);
14389 create_file("msitest\\msitest\\augustus", 500);
14391 create_database(msifile, ci_tables, ARRAY_SIZE(ci_tables));
14393 lstrcpyA(path, CURR_DIR);
14394 lstrcatA(path, "\\msitest\\concurrent.msi");
14395 create_database(path, ci2_tables, ARRAY_SIZE(ci2_tables));
14397 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
14399 r = MsiInstallProductA(msifile, NULL);
14400 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
14402 skip("Not enough rights to perform tests\n");
14403 goto error;
14405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14406 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
14407 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
14408 ok(delete_pf("msitest", FALSE), "Directory not created\n");
14410 r = MsiConfigureProductA("{38847338-1BBC-4104-81AC-2FAAC7ECDDCD}", INSTALLLEVEL_DEFAULT,
14411 INSTALLSTATE_ABSENT);
14412 ok(r == ERROR_SUCCESS, "got %u\n", r);
14414 r = MsiConfigureProductA("{FF4AFE9C-6AC2-44F9-A060-9EA6BD16C75E}", INSTALLLEVEL_DEFAULT,
14415 INSTALLSTATE_ABSENT);
14416 ok(r == ERROR_SUCCESS, "got %u\n", r);
14418 error:
14419 DeleteFileA(path);
14420 DeleteFileA(msifile);
14421 DeleteFileA("msitest\\msitest\\augustus");
14422 DeleteFileA("msitest\\maximus");
14423 RemoveDirectoryA("msitest\\msitest");
14424 RemoveDirectoryA("msitest");
14427 static void test_command_line_parsing(void)
14429 UINT r;
14430 const char *cmd;
14432 if (is_process_limited())
14434 skip("process is limited\n");
14435 return;
14438 create_test_files();
14439 create_database(msifile, cl_tables, ARRAY_SIZE(cl_tables));
14441 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
14443 cmd = " ";
14444 r = MsiInstallProductA(msifile, cmd);
14445 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14447 cmd = "=";
14448 r = MsiInstallProductA(msifile, cmd);
14449 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14451 cmd = "==";
14452 r = MsiInstallProductA(msifile, cmd);
14453 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14455 cmd = "one";
14456 r = MsiInstallProductA(msifile, cmd);
14457 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14459 cmd = "=one";
14460 r = MsiInstallProductA(msifile, cmd);
14461 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14463 cmd = "P=";
14464 r = MsiInstallProductA(msifile, cmd);
14465 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14467 cmd = " P=";
14468 r = MsiInstallProductA(msifile, cmd);
14469 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14471 cmd = "P= ";
14472 r = MsiInstallProductA(msifile, cmd);
14473 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14475 cmd = "P=\"";
14476 r = MsiInstallProductA(msifile, cmd);
14477 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14479 cmd = "P=\"\"";
14480 r = MsiInstallProductA(msifile, cmd);
14481 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14483 cmd = "P=\"\"\"";
14484 r = MsiInstallProductA(msifile, cmd);
14485 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14487 cmd = "P=\"\"\"\"";
14488 r = MsiInstallProductA(msifile, cmd);
14489 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14491 cmd = "P=\" ";
14492 r = MsiInstallProductA(msifile, cmd);
14493 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14495 cmd = "P= \"";
14496 r = MsiInstallProductA(msifile, cmd);
14497 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14499 cmd = "P= \"\" ";
14500 r = MsiInstallProductA(msifile, cmd);
14501 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14503 cmd = "P=\" \"";
14504 r = MsiInstallProductA(msifile, cmd);
14505 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14507 cmd = "P=one";
14508 r = MsiInstallProductA(msifile, cmd);
14509 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14511 cmd = "P= one";
14512 r = MsiInstallProductA(msifile, cmd);
14513 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14515 cmd = "P=\"one";
14516 r = MsiInstallProductA(msifile, cmd);
14517 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14519 cmd = "P=one\"";
14520 r = MsiInstallProductA(msifile, cmd);
14521 todo_wine ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14523 cmd = "P=\"one\"";
14524 r = MsiInstallProductA(msifile, cmd);
14525 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14527 cmd = "P= \"one\" ";
14528 r = MsiInstallProductA(msifile, cmd);
14529 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14531 cmd = "P=\"one\"\"";
14532 r = MsiInstallProductA(msifile, cmd);
14533 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14535 cmd = "P=\"\"one\"";
14536 r = MsiInstallProductA(msifile, cmd);
14537 ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14539 cmd = "P=\"\"one\"\"";
14540 r = MsiInstallProductA(msifile, cmd);
14541 todo_wine ok(r == ERROR_INVALID_COMMAND_LINE, "Expected ERROR_INVALID_COMMAND_LINE, got %u\n", r);
14543 cmd = "P=\"one two\"";
14544 r = MsiInstallProductA(msifile, cmd);
14545 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14547 cmd = "P=\"\"\"one\"\" two\"";
14548 r = MsiInstallProductA(msifile, cmd);
14549 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14551 cmd = "P=\"\"\"one\"\" two\" Q=three";
14552 r = MsiInstallProductA(msifile, cmd);
14553 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14555 cmd = "P=\"\" Q=\"two\"";
14556 r = MsiInstallProductA(msifile, cmd);
14557 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14559 cmd = "P=\"one\" Q=\"two\"";
14560 r = MsiInstallProductA(msifile, cmd);
14561 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14563 cmd = "P=\"one=two\"";
14564 r = MsiInstallProductA(msifile, cmd);
14565 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14567 cmd = "Q=\"\" P=\"one\"";
14568 r = MsiInstallProductA(msifile, cmd);
14569 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
14571 cmd = "P=\"\"\"one\"\"\" Q=\"two\"";
14572 r = MsiInstallProductA(msifile, cmd);
14573 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14575 cmd = "P=\"one \"\"two\"\"\" Q=\"three\"";
14576 r = MsiInstallProductA(msifile, cmd);
14577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14579 cmd = "P=\"\"\"one\"\" two\" Q=\"three\"";
14580 r = MsiInstallProductA(msifile, cmd);
14581 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
14583 DeleteFileA(msifile);
14584 delete_test_files();
14587 START_TEST(msi)
14589 DWORD len;
14590 char temp_path[MAX_PATH], prev_path[MAX_PATH];
14592 init_functionpointers();
14594 if (pIsWow64Process)
14595 pIsWow64Process(GetCurrentProcess(), &is_wow64);
14597 GetCurrentDirectoryA(MAX_PATH, prev_path);
14598 GetTempPathA(MAX_PATH, temp_path);
14599 SetCurrentDirectoryA(temp_path);
14601 lstrcpyA(CURR_DIR, temp_path);
14602 len = lstrlenA(CURR_DIR);
14604 if(len && (CURR_DIR[len - 1] == '\\'))
14605 CURR_DIR[len - 1] = 0;
14607 ok(get_system_dirs(), "failed to retrieve system dirs\n");
14609 test_usefeature();
14610 test_null();
14611 test_getcomponentpath();
14612 test_MsiGetFileHash();
14613 test_MsiSetInternalUI();
14614 test_MsiSetExternalUI();
14615 test_MsiQueryProductState();
14616 test_MsiQueryFeatureState();
14617 test_MsiQueryComponentState();
14618 test_MsiGetComponentPath();
14619 test_MsiGetComponentPathEx();
14620 test_MsiProvideComponent();
14621 test_MsiGetProductCode();
14622 test_MsiEnumClients();
14623 test_MsiGetProductInfo();
14624 test_MsiGetProductInfoEx();
14625 test_MsiGetUserInfo();
14626 test_MsiOpenProduct();
14627 test_MsiEnumPatchesEx();
14628 test_MsiEnumPatches();
14629 test_MsiGetPatchInfoEx();
14630 test_MsiGetPatchInfo();
14631 test_MsiEnumProducts();
14632 test_MsiEnumProductsEx();
14633 test_MsiEnumComponents();
14634 test_MsiEnumComponentsEx();
14635 test_MsiGetFileVersion();
14636 test_MsiGetFileSignatureInformation();
14637 test_MsiConfigureProductEx();
14638 test_MsiSetFeatureAttributes();
14639 test_MsiGetFeatureInfo();
14640 test_lastusedsource();
14641 test_setpropertyfolder();
14642 test_sourcedir_props();
14643 if (pMsiGetComponentPathExA)
14644 test_concurrentinstall();
14645 test_command_line_parsing();
14646 test_MsiProvideQualifiedComponentEx();
14648 SetCurrentDirectoryA(prev_path);