2 * Copyright (C) 2006 James Hawkins
4 * A test program for installing MSI products.
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
33 #include "wine/test.h"
35 static UINT (WINAPI *pMsiQueryComponentStateA)
36 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
37 static UINT (WINAPI *pMsiSourceListGetInfoA)
38 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
40 static const char *msifile = "msitest.msi";
41 static const char *msifile2 = "winetest2.msi";
42 static const char *mstfile = "winetest.mst";
43 CHAR CURR_DIR[MAX_PATH];
44 CHAR PROG_FILES_DIR[MAX_PATH];
46 /* msi database data */
48 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
49 "s72\tS38\ts72\ti2\tS255\tS72\n"
50 "Component\tComponent\n"
51 "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
52 "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
53 "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\t\tone.txt\n"
54 "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
55 "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
56 "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
57 "component\t\tMSITESTDIR\t0\t1\tfile\n"
58 "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
60 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
62 "Directory\tDirectory\n"
63 "CABOUTDIR\tMSITESTDIR\tcabout\n"
64 "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
65 "FIRSTDIR\tMSITESTDIR\tfirst\n"
66 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
67 "NEWDIR\tCABOUTDIR\tnew\n"
68 "ProgramFilesFolder\tTARGETDIR\t.\n"
69 "TARGETDIR\t\tSourceDir";
71 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
72 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
74 "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
75 "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
76 "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
77 "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
78 "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
79 "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
80 "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
82 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
84 "FeatureComponents\tFeature_\tComponent_\n"
90 "feature\tcomponent\n"
91 "service_feature\tservice_comp\n";
93 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
94 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
96 "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
97 "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
98 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
99 "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
100 "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
101 "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
102 "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
104 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
106 "InstallExecuteSequence\tAction\n"
107 "AllocateRegistrySpace\tNOT Installed\t1550\n"
108 "CostFinalize\t\t1000\n"
109 "CostInitialize\t\t800\n"
111 "InstallFiles\t\t4000\n"
112 "InstallServices\t\t5000\n"
113 "InstallFinalize\t\t6600\n"
114 "InstallInitialize\t\t1500\n"
115 "InstallValidate\t\t1400\n"
116 "LaunchConditions\t\t100\n"
117 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
119 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
120 "i2\ti4\tL64\tS255\tS32\tS72\n"
122 "1\t3\t\t\tDISK1\t\n"
123 "2\t5\t\tmsitest.cab\tDISK2\t\n";
125 static const CHAR property_dat[] = "Property\tValue\n"
127 "Property\tProperty\n"
128 "DefaultUIFont\tDlgFont8\n"
131 "InstallMode\tTypical\n"
132 "Manufacturer\tWine\n"
133 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
134 "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
136 "ProductLanguage\t1033\n"
137 "ProductName\tMSITEST\n"
138 "ProductVersion\t1.1.1\n"
139 "PROMPTROLLBACKCOST\tP\n"
141 "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
142 "AdminProperties\tPOSTADMIN\n";
144 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
145 "s72\ti2\tl255\tL255\tL0\ts72\n"
146 "Registry\tRegistry\n"
147 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
148 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
149 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
150 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
152 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
153 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
154 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
155 "ServiceInstall\tServiceInstall\n"
156 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
158 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
159 "s72\tl255\ti2\tL255\tI2\ts72\n"
160 "ServiceControl\tServiceControl\n"
161 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
163 /* tables for test_continuouscabs */
164 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
165 "s72\tS38\ts72\ti2\tS255\tS72\n"
166 "Component\tComponent\n"
167 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
168 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
169 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
171 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
172 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
174 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
176 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
178 "FeatureComponents\tFeature_\tComponent_\n"
180 "feature\taugustus\n"
183 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
184 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
186 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
187 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
188 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
190 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
191 "i2\ti4\tL64\tS255\tS32\tS72\n"
193 "1\t10\t\ttest1.cab\tDISK1\t\n"
194 "2\t2\t\ttest2.cab\tDISK2\t\n"
195 "3\t12\t\ttest3.cab\tDISK3\t\n";
197 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
198 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
200 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
201 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
202 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
204 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
205 "i2\ti4\tL64\tS255\tS32\tS72\n"
207 "1\t10\t\ttest1.cab\tDISK1\t\n"
208 "2\t2\t\ttest2.cab\tDISK2\t\n"
209 "3\t3\t\ttest3.cab\tDISK3\t\n";
211 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
212 "i2\ti4\tL64\tS255\tS32\tS72\n"
214 "1\t10\t\ttest1.cab\tDISK1\t\n"
215 "2\t12\t\ttest3.cab\tDISK3\t\n"
216 "3\t2\t\ttest2.cab\tDISK2\t\n";
218 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
219 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
221 "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
222 "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
223 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
225 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
226 "i2\ti4\tL64\tS255\tS32\tS72\n"
228 "1\t3\t\ttest1.cab\tDISK1\t\n";
230 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
231 "i2\ti4\tL64\tS255\tS32\tS72\n"
233 "1\t2\t\ttest1.cab\tDISK1\t\n"
234 "2\t2\t\ttest2.cab\tDISK2\t\n"
235 "3\t12\t\ttest3.cab\tDISK3\t\n";
237 /* tables for test_uiLevelFlags */
238 static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
239 "s72\tS38\ts72\ti2\tS255\tS72\n"
240 "Component\tComponent\n"
241 "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
242 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
243 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
245 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
247 "InstallUISequence\tAction\n"
248 "SetUIProperty\t\t5\n"
249 "ExecuteAction\t\t1100\n";
251 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
252 "s72\ti2\tS64\tS0\tS255\n"
253 "CustomAction\tAction\n"
254 "SetUIProperty\t51\tHASUIRUN\t1\t\n";
256 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
257 "s72\tS38\ts72\ti2\tS255\tS72\n"
258 "Component\tComponent\n"
259 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
261 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
262 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
264 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
265 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
267 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
269 "FeatureComponents\tFeature_\tComponent_\n"
271 "montecristo\tmaximus";
273 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
274 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
276 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
278 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
279 "i2\ti4\tL64\tS255\tS32\tS72\n"
281 "1\t1\t\t\tDISK1\t\n";
283 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
285 "InstallExecuteSequence\tAction\n"
286 "AllocateRegistrySpace\tNOT Installed\t1550\n"
287 "CostFinalize\t\t1000\n"
288 "CostInitialize\t\t800\n"
290 "InstallFiles\t\t4000\n"
291 "InstallFinalize\t\t6600\n"
292 "InstallInitialize\t\t1500\n"
293 "InstallValidate\t\t1400\n"
294 "LaunchConditions\t\t100\n"
295 "SetDirProperty\t\t950";
297 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
298 "s72\ti2\tS64\tS0\tS255\n"
299 "CustomAction\tAction\n"
300 "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
302 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
303 "s72\tS38\ts72\ti2\tS255\tS72\n"
304 "Component\tComponent\n"
305 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
306 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
307 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
308 "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
310 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
312 "FeatureComponents\tFeature_\tComponent_\n"
314 "feature\taugustus\n"
318 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
319 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
321 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
322 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
323 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
324 "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
326 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
327 "i2\ti4\tL64\tS255\tS32\tS72\n"
329 "1\t1\t\ttest1.cab\tDISK1\t\n"
330 "2\t2\t\ttest2.cab\tDISK2\t\n"
331 "3\t12\t\ttest3.cab\tDISK3\t\n";
333 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
335 "InstallExecuteSequence\tAction\n"
336 "CostFinalize\t\t1000\n"
337 "CostInitialize\t\t800\n"
339 "InstallFiles\t\t4000\n"
340 "InstallServices\t\t5000\n"
341 "InstallFinalize\t\t6600\n"
342 "InstallInitialize\t\t1500\n"
343 "RunInstall\t\t1600\n"
344 "InstallValidate\t\t1400\n"
345 "LaunchConditions\t\t100";
347 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
348 "s72\ti2\tS64\tS0\tS255\n"
349 "CustomAction\tAction\n"
350 "RunInstall\t23\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
352 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
353 "s72\tS38\ts72\ti2\tS255\tS72\n"
354 "Component\tComponent\n"
355 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
357 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
358 "s72\tS38\ts72\ti2\tS255\tS72\n"
359 "Component\tComponent\n"
360 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
362 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
364 "FeatureComponents\tFeature_\tComponent_\n"
367 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
368 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
370 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
372 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
373 "s72\ti2\tS64\tS0\tS255\n"
374 "CustomAction\tAction\n"
375 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
377 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
379 "InstallExecuteSequence\tAction\n"
380 "CostFinalize\t\t1000\n"
381 "CostInitialize\t\t800\n"
383 "SetFolderProp\t\t950\n"
384 "InstallFiles\t\t4000\n"
385 "InstallServices\t\t5000\n"
386 "InstallFinalize\t\t6600\n"
387 "InstallInitialize\t\t1500\n"
388 "InstallValidate\t\t1400\n"
389 "LaunchConditions\t\t100";
391 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
393 "InstallUISequence\tAction\n"
394 "CostInitialize\t\t800\n"
396 "CostFinalize\t\t1000\n"
397 "ExecuteAction\t\t1100\n";
399 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
401 "InstallExecuteSequence\tAction\n"
402 "ValidateProductID\t\t700\n"
403 "CostInitialize\t\t800\n"
405 "CostFinalize\t\t1000\n"
406 "InstallValidate\t\t1400\n"
407 "InstallInitialize\t\t1500\n"
408 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
409 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
410 "RemoveFiles\t\t3500\n"
411 "InstallFiles\t\t4000\n"
412 "RegisterUser\t\t6000\n"
413 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
414 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
415 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
416 "InstallFinalize\t\t6600";
418 static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
419 "s72\tS38\ts72\ti2\tS255\tS72\n"
420 "Component\tComponent\n"
421 "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";
423 static const CHAR cwd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
424 "s72\tS38\ts72\ti2\tS255\tS72\n"
425 "Component\tComponent\n"
426 "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
428 static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
429 "s72\tS38\ts72\ti2\tS255\tS72\n"
430 "Component\tComponent\n"
431 "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";
433 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
434 "s72\ti2\tS64\tS0\tS255\n"
435 "CustomAction\tAction\n"
436 "SetPOSTADMIN\t51\tPOSTADMIN\t1\t";
438 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
440 "AdminExecuteSequence\tAction\n"
441 "CostFinalize\t\t1000\n"
442 "CostInitialize\t\t800\n"
444 "SetPOSTADMIN\t\t950\n"
445 "InstallFiles\t\t4000\n"
446 "InstallFinalize\t\t6600\n"
447 "InstallInitialize\t\t1500\n"
448 "InstallValidate\t\t1400\n"
449 "LaunchConditions\t\t100";
451 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
452 "s72\tS38\ts72\ti2\tS255\tS72\n"
453 "Component\tComponent\n"
454 "augustus\t\tMSITESTDIR\t0\tMYPROP=2718\taugustus\n";
456 static const CHAR rem_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
457 "s72\tS38\ts72\ti2\tS255\tS72\n"
458 "Component\tComponent\n"
459 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t0\t\thydrogen\n"
460 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
461 "lithium\t\tMSITESTDIR\t2\t\tlithium\n";
463 static const CHAR rem_feature_comp_dat[] = "Feature_\tComponent_\n"
465 "FeatureComponents\tFeature_\tComponent_\n"
466 "feature\thydrogen\n"
470 static const CHAR rem_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
471 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
473 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
474 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
475 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
477 static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
479 "InstallExecuteSequence\tAction\n"
480 "ValidateProductID\t\t700\n"
481 "CostInitialize\t\t800\n"
483 "CostFinalize\t\t1000\n"
484 "InstallValidate\t\t1400\n"
485 "InstallInitialize\t\t1500\n"
486 "ProcessComponents\t\t1600\n"
487 "UnpublishFeatures\t\t1800\n"
488 "RemoveFiles\t\t3500\n"
489 "InstallFiles\t\t4000\n"
490 "RegisterUser\t\t6000\n"
491 "RegisterProduct\t\t6100\n"
492 "PublishFeatures\t\t6300\n"
493 "PublishProduct\t\t6400\n"
494 "InstallFinalize\t\t6600";
496 static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
497 "s72\ts72\tS255\ts72\tI2\n"
498 "RemoveFile\tFileKey\n"
499 "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
500 "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
501 "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
502 "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
503 "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
504 "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
505 "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
506 "block\thelium\tblock\tMSITESTDIR\t3\n"
507 "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n";
509 typedef struct _msi_table
511 const CHAR *filename;
516 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
518 static const msi_table tables[] =
520 ADD_TABLE(component),
521 ADD_TABLE(directory),
523 ADD_TABLE(feature_comp),
525 ADD_TABLE(install_exec_seq),
529 ADD_TABLE(service_install),
530 ADD_TABLE(service_control)
533 static const msi_table cc_tables[] =
535 ADD_TABLE(cc_component),
536 ADD_TABLE(directory),
537 ADD_TABLE(cc_feature),
538 ADD_TABLE(cc_feature_comp),
540 ADD_TABLE(install_exec_seq),
545 static const msi_table co_tables[] =
547 ADD_TABLE(cc_component),
548 ADD_TABLE(directory),
549 ADD_TABLE(cc_feature),
550 ADD_TABLE(cc_feature_comp),
552 ADD_TABLE(install_exec_seq),
557 static const msi_table co2_tables[] =
559 ADD_TABLE(cc_component),
560 ADD_TABLE(directory),
561 ADD_TABLE(cc_feature),
562 ADD_TABLE(cc_feature_comp),
564 ADD_TABLE(install_exec_seq),
565 ADD_TABLE(co2_media),
569 static const msi_table mm_tables[] =
571 ADD_TABLE(cc_component),
572 ADD_TABLE(directory),
573 ADD_TABLE(cc_feature),
574 ADD_TABLE(cc_feature_comp),
576 ADD_TABLE(install_exec_seq),
581 static const msi_table ss_tables[] =
583 ADD_TABLE(cc_component),
584 ADD_TABLE(directory),
585 ADD_TABLE(cc_feature),
586 ADD_TABLE(cc_feature_comp),
588 ADD_TABLE(install_exec_seq),
593 static const msi_table ui_tables[] =
595 ADD_TABLE(ui_component),
596 ADD_TABLE(directory),
597 ADD_TABLE(cc_feature),
598 ADD_TABLE(cc_feature_comp),
600 ADD_TABLE(install_exec_seq),
601 ADD_TABLE(ui_install_ui_seq),
602 ADD_TABLE(ui_custom_action),
607 static const msi_table rof_tables[] =
609 ADD_TABLE(rof_component),
610 ADD_TABLE(directory),
611 ADD_TABLE(rof_feature),
612 ADD_TABLE(rof_feature_comp),
614 ADD_TABLE(install_exec_seq),
615 ADD_TABLE(rof_media),
619 static const msi_table sdp_tables[] =
621 ADD_TABLE(rof_component),
622 ADD_TABLE(directory),
623 ADD_TABLE(rof_feature),
624 ADD_TABLE(rof_feature_comp),
626 ADD_TABLE(sdp_install_exec_seq),
627 ADD_TABLE(sdp_custom_action),
628 ADD_TABLE(rof_media),
632 static const msi_table cie_tables[] =
634 ADD_TABLE(cie_component),
635 ADD_TABLE(directory),
636 ADD_TABLE(cc_feature),
637 ADD_TABLE(cie_feature_comp),
639 ADD_TABLE(install_exec_seq),
640 ADD_TABLE(cie_media),
644 static const msi_table ci_tables[] =
646 ADD_TABLE(ci_component),
647 ADD_TABLE(directory),
648 ADD_TABLE(rof_feature),
649 ADD_TABLE(rof_feature_comp),
651 ADD_TABLE(ci_install_exec_seq),
652 ADD_TABLE(rof_media),
654 ADD_TABLE(ci_custom_action),
657 static const msi_table ci2_tables[] =
659 ADD_TABLE(ci2_component),
660 ADD_TABLE(directory),
661 ADD_TABLE(rof_feature),
662 ADD_TABLE(ci2_feature_comp),
664 ADD_TABLE(install_exec_seq),
665 ADD_TABLE(rof_media),
669 static const msi_table spf_tables[] =
671 ADD_TABLE(ci_component),
672 ADD_TABLE(directory),
673 ADD_TABLE(rof_feature),
674 ADD_TABLE(rof_feature_comp),
676 ADD_TABLE(spf_install_exec_seq),
677 ADD_TABLE(rof_media),
679 ADD_TABLE(spf_custom_action),
680 ADD_TABLE(spf_install_ui_seq),
683 static const msi_table pp_tables[] =
685 ADD_TABLE(ci_component),
686 ADD_TABLE(directory),
687 ADD_TABLE(rof_feature),
688 ADD_TABLE(rof_feature_comp),
690 ADD_TABLE(pp_install_exec_seq),
691 ADD_TABLE(rof_media),
695 static const msi_table tp_tables[] =
697 ADD_TABLE(tp_component),
698 ADD_TABLE(directory),
699 ADD_TABLE(rof_feature),
700 ADD_TABLE(ci2_feature_comp),
702 ADD_TABLE(install_exec_seq),
703 ADD_TABLE(rof_media),
707 static const msi_table cwd_tables[] =
709 ADD_TABLE(cwd_component),
710 ADD_TABLE(directory),
711 ADD_TABLE(rof_feature),
712 ADD_TABLE(ci2_feature_comp),
714 ADD_TABLE(install_exec_seq),
715 ADD_TABLE(rof_media),
719 static const msi_table adm_tables[] =
721 ADD_TABLE(adm_component),
722 ADD_TABLE(directory),
723 ADD_TABLE(rof_feature),
724 ADD_TABLE(ci2_feature_comp),
726 ADD_TABLE(install_exec_seq),
727 ADD_TABLE(rof_media),
729 ADD_TABLE(adm_custom_action),
730 ADD_TABLE(adm_admin_exec_seq),
733 static const msi_table amp_tables[] =
735 ADD_TABLE(amp_component),
736 ADD_TABLE(directory),
737 ADD_TABLE(rof_feature),
738 ADD_TABLE(ci2_feature_comp),
740 ADD_TABLE(install_exec_seq),
741 ADD_TABLE(rof_media),
745 static const msi_table rem_tables[] =
747 ADD_TABLE(rem_component),
748 ADD_TABLE(directory),
749 ADD_TABLE(rof_feature),
750 ADD_TABLE(rem_feature_comp),
752 ADD_TABLE(rem_install_exec_seq),
753 ADD_TABLE(rof_media),
755 ADD_TABLE(rem_remove_files),
758 /* cabinet definitions */
760 /* make the max size large so there is only one cab file */
761 #define MEDIA_SIZE 0x7FFFFFFF
762 #define FOLDER_THRESHOLD 900000
764 /* the FCI callbacks */
766 static void *mem_alloc(ULONG cb)
768 return HeapAlloc(GetProcessHeap(), 0, cb);
771 static void mem_free(void *memory)
773 HeapFree(GetProcessHeap(), 0, memory);
776 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
778 sprintf(pccab->szCab, pv, pccab->iCab);
782 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
787 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
788 BOOL fContinuation, void *pv)
793 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
797 DWORD dwShareMode = 0;
798 DWORD dwCreateDisposition = OPEN_EXISTING;
800 dwAccess = GENERIC_READ | GENERIC_WRITE;
801 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
802 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
804 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
805 dwCreateDisposition = OPEN_EXISTING;
807 dwCreateDisposition = CREATE_NEW;
809 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
810 dwCreateDisposition, 0, NULL);
812 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
814 return (INT_PTR)handle;
817 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
819 HANDLE handle = (HANDLE)hf;
823 res = ReadFile(handle, memory, cb, &dwRead, NULL);
824 ok(res, "Failed to ReadFile\n");
829 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
831 HANDLE handle = (HANDLE)hf;
835 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
836 ok(res, "Failed to WriteFile\n");
841 static int fci_close(INT_PTR hf, int *err, void *pv)
843 HANDLE handle = (HANDLE)hf;
844 ok(CloseHandle(handle), "Failed to CloseHandle\n");
849 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
851 HANDLE handle = (HANDLE)hf;
854 ret = SetFilePointer(handle, dist, NULL, seektype);
855 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
860 static int fci_delete(char *pszFile, int *err, void *pv)
862 BOOL ret = DeleteFileA(pszFile);
863 ok(ret, "Failed to DeleteFile %s\n", pszFile);
868 static void init_functionpointers(void)
870 HMODULE hmsi = GetModuleHandleA("msi.dll");
872 #define GET_PROC(func) \
873 p ## func = (void*)GetProcAddress(hmsi, #func); \
875 trace("GetProcAddress(%s) failed\n", #func);
877 GET_PROC(MsiQueryComponentStateA);
878 GET_PROC(MsiSourceListGetInfoA);
883 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
890 r = MsiRecordGetString(rec, field, buffer, &sz);
891 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
894 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
898 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
899 GetTempFileNameA(".", "xx", 0, tempname);
901 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
903 lstrcpyA(pszTempName, tempname);
904 HeapFree(GetProcessHeap(), 0, tempname);
908 HeapFree(GetProcessHeap(), 0, tempname);
913 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
914 USHORT *pattribs, int *err, void *pv)
916 BY_HANDLE_FILE_INFORMATION finfo;
922 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
923 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
925 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
927 res = GetFileInformationByHandle(handle, &finfo);
928 ok(res, "Expected GetFileInformationByHandle to succeed\n");
930 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
931 FileTimeToDosDateTime(&filetime, pdate, ptime);
933 attrs = GetFileAttributes(pszName);
934 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
936 return (INT_PTR)handle;
939 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
942 char filename[MAX_PATH];
944 lstrcpyA(path, CURR_DIR);
945 lstrcatA(path, "\\");
946 lstrcatA(path, file);
948 lstrcpyA(filename, file);
950 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
951 progress, get_open_info, compress);
954 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
956 ZeroMemory(pCabParams, sizeof(CCAB));
958 pCabParams->cb = max_size;
959 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
960 pCabParams->setID = 0xbeef;
961 pCabParams->iCab = 1;
962 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
963 lstrcatA(pCabParams->szCabPath, "\\");
964 lstrcpyA(pCabParams->szCab, name);
967 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
975 set_cab_parameters(&cabParams, name, max_size);
977 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
978 fci_read, fci_write, fci_close, fci_seek, fci_delete,
979 get_temp_file, &cabParams, NULL);
981 ok(hfci != NULL, "Failed to create an FCI context\n");
986 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
987 ok(res, "Failed to add file: %s\n", ptr);
988 ptr += lstrlen(ptr) + 1;
991 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
992 ok(res, "Failed to flush the cabinet\n");
994 res = FCIDestroy(hfci);
995 ok(res, "Failed to destroy the cabinet\n");
998 static BOOL get_program_files_dir(LPSTR buf)
1001 DWORD type = REG_EXPAND_SZ, size;
1003 if (RegOpenKey(HKEY_LOCAL_MACHINE,
1004 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
1008 if (RegQueryValueEx(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size))
1015 static void create_file(const CHAR *name, DWORD size)
1018 DWORD written, left;
1020 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1021 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1022 WriteFile(file, name, strlen(name), &written, NULL);
1023 WriteFile(file, "\n", strlen("\n"), &written, NULL);
1025 left = size - lstrlen(name) - 1;
1027 SetFilePointer(file, left, NULL, FILE_CURRENT);
1033 static void create_test_files(void)
1035 CreateDirectoryA("msitest", NULL);
1036 create_file("msitest\\one.txt", 100);
1037 CreateDirectoryA("msitest\\first", NULL);
1038 create_file("msitest\\first\\two.txt", 100);
1039 CreateDirectoryA("msitest\\second", NULL);
1040 create_file("msitest\\second\\three.txt", 100);
1042 create_file("four.txt", 100);
1043 create_file("five.txt", 100);
1044 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1046 create_file("msitest\\filename", 100);
1047 create_file("msitest\\service.exe", 100);
1049 DeleteFileA("four.txt");
1050 DeleteFileA("five.txt");
1053 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
1055 CHAR path[MAX_PATH];
1057 lstrcpyA(path, PROG_FILES_DIR);
1058 lstrcatA(path, "\\");
1059 lstrcatA(path, rel_path);
1062 return DeleteFileA(path);
1064 return RemoveDirectoryA(path);
1067 static void delete_test_files(void)
1069 DeleteFileA("msitest.msi");
1070 DeleteFileA("msitest.cab");
1071 DeleteFileA("msitest\\second\\three.txt");
1072 DeleteFileA("msitest\\first\\two.txt");
1073 DeleteFileA("msitest\\one.txt");
1074 DeleteFileA("msitest\\service.exe");
1075 DeleteFileA("msitest\\filename");
1076 RemoveDirectoryA("msitest\\second");
1077 RemoveDirectoryA("msitest\\first");
1078 RemoveDirectoryA("msitest");
1081 static void write_file(const CHAR *filename, const char *data, int data_size)
1085 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1086 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1088 WriteFile(hf, data, data_size, &size, NULL);
1092 static void write_msi_summary_info(MSIHANDLE db)
1097 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1098 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1100 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1103 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1104 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1105 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1107 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1110 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1111 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1113 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1114 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1116 /* write the summary changes back to the stream */
1117 r = MsiSummaryInfoPersist(summary);
1118 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1120 MsiCloseHandle(summary);
1123 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1129 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1130 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1132 /* import the tables into the database */
1133 for (j = 0; j < num_tables; j++)
1135 const msi_table *table = &tables[j];
1137 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1139 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1142 DeleteFileA(table->filename);
1145 write_msi_summary_info(db);
1147 r = MsiDatabaseCommit(db);
1148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1153 static void check_service_is_installed(void)
1155 SC_HANDLE scm, service;
1158 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1159 ok(scm != NULL, "Failed to open the SC Manager\n");
1161 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1162 ok(service != NULL, "Failed to open TestService\n");
1164 res = DeleteService(service);
1165 ok(res, "Failed to delete TestService\n");
1168 static void test_MsiInstallProduct(void)
1171 CHAR path[MAX_PATH];
1174 DWORD num, size, type;
1176 create_test_files();
1177 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1179 r = MsiInstallProductA(msifile, NULL);
1180 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1182 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1183 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1184 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1185 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1186 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1187 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1188 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1189 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1190 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1191 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1192 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1193 ok(delete_pf("msitest", FALSE), "File not installed\n");
1195 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1196 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1200 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1201 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1202 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1206 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1207 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1211 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1212 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1213 ok(num == 314, "Expected 314, got %d\n", num);
1217 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1218 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1219 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1221 check_service_is_installed();
1223 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1225 delete_test_files();
1228 static void test_MsiSetComponentState(void)
1230 INSTALLSTATE installed, action;
1232 char path[MAX_PATH];
1235 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1239 lstrcpy(path, CURR_DIR);
1240 lstrcat(path, "\\");
1241 lstrcat(path, msifile);
1243 r = MsiOpenPackage(path, &package);
1244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1246 r = MsiDoAction(package, "CostInitialize");
1247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1249 r = MsiDoAction(package, "FileCost");
1250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1252 r = MsiDoAction(package, "CostFinalize");
1253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1255 r = MsiGetComponentState(package, "dangler", &installed, &action);
1256 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1257 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1258 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1260 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1263 MsiCloseHandle(package);
1266 DeleteFileA(msifile);
1269 static void test_packagecoltypes(void)
1271 MSIHANDLE hdb, view, rec;
1272 char path[MAX_PATH];
1276 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1280 lstrcpy(path, CURR_DIR);
1281 lstrcat(path, "\\");
1282 lstrcat(path, msifile);
1284 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1287 query = "SELECT * FROM `Media`";
1288 r = MsiDatabaseOpenView( hdb, query, &view );
1289 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1291 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1292 count = MsiRecordGetFieldCount( rec );
1293 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1294 ok(count == 6, "Expected 6, got %d\n", count);
1295 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1296 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1297 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1298 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1299 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1300 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1301 MsiCloseHandle(rec);
1303 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1304 count = MsiRecordGetFieldCount( rec );
1305 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1306 ok(count == 6, "Expected 6, got %d\n", count);
1307 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1308 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1309 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1310 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1311 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1312 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1314 MsiCloseHandle(rec);
1315 MsiCloseHandle(view);
1316 MsiCloseHandle(hdb);
1317 DeleteFile(msifile);
1320 static void create_cc_test_files(void)
1325 static CHAR cab_context[] = "test%d.cab";
1328 create_file("maximus", 500);
1329 create_file("augustus", 50000);
1330 create_file("caesar", 500);
1332 set_cab_parameters(&cabParams, "test1.cab", 200);
1334 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1335 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1336 get_temp_file, &cabParams, cab_context);
1337 ok(hfci != NULL, "Failed to create an FCI context\n");
1339 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1340 ok(res, "Failed to add file maximus\n");
1342 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1343 ok(res, "Failed to add file augustus\n");
1345 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1346 ok(res, "Failed to flush the cabinet\n");
1348 res = FCIDestroy(hfci);
1349 ok(res, "Failed to destroy the cabinet\n");
1351 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1353 DeleteFile("maximus");
1354 DeleteFile("augustus");
1355 DeleteFile("caesar");
1358 static void delete_cab_files(void)
1360 SHFILEOPSTRUCT shfl;
1361 CHAR path[MAX_PATH+10];
1363 lstrcpyA(path, CURR_DIR);
1364 lstrcatA(path, "\\*.cab");
1365 path[strlen(path) + 1] = '\0';
1368 shfl.wFunc = FO_DELETE;
1371 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1373 SHFileOperation(&shfl);
1376 static void test_continuouscabs(void)
1380 create_cc_test_files();
1381 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1383 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1385 r = MsiInstallProductA(msifile, NULL);
1386 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1389 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1390 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1391 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1393 ok(delete_pf("msitest", FALSE), "File not installed\n");
1396 DeleteFile(msifile);
1399 static void test_caborder(void)
1403 create_file("imperator", 100);
1404 create_file("maximus", 500);
1405 create_file("augustus", 50000);
1406 create_file("caesar", 500);
1408 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1410 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1412 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1413 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1414 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1416 r = MsiInstallProductA(msifile, NULL);
1417 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1418 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1419 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1422 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1423 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1428 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1429 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1430 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1432 r = MsiInstallProductA(msifile, NULL);
1433 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1434 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1435 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1436 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1439 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1443 DeleteFile(msifile);
1445 create_cc_test_files();
1446 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1448 r = MsiInstallProductA(msifile, NULL);
1449 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1450 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1451 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1454 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1455 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1459 DeleteFile(msifile);
1461 create_cc_test_files();
1462 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1464 r = MsiInstallProductA(msifile, NULL);
1465 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1466 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1469 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1470 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1471 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1475 DeleteFile("imperator");
1476 DeleteFile("maximus");
1477 DeleteFile("augustus");
1478 DeleteFile("caesar");
1479 DeleteFile(msifile);
1482 static void test_mixedmedia(void)
1486 CreateDirectoryA("msitest", NULL);
1487 create_file("msitest\\maximus", 500);
1488 create_file("msitest\\augustus", 500);
1489 create_file("caesar", 500);
1491 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1493 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1495 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1497 r = MsiInstallProductA(msifile, NULL);
1498 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1499 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1500 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1501 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1502 ok(delete_pf("msitest", FALSE), "File not installed\n");
1504 /* Delete the files in the temp (current) folder */
1505 DeleteFile("msitest\\maximus");
1506 DeleteFile("msitest\\augustus");
1507 RemoveDirectory("msitest");
1508 DeleteFile("caesar");
1509 DeleteFile("test1.cab");
1510 DeleteFile(msifile);
1513 static void test_samesequence(void)
1517 create_cc_test_files();
1518 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1520 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1522 r = MsiInstallProductA(msifile, NULL);
1525 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1526 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1527 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1529 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1530 ok(delete_pf("msitest", FALSE), "File not installed\n");
1533 DeleteFile(msifile);
1536 static void test_uiLevelFlags(void)
1540 create_cc_test_files();
1541 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1543 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1545 r = MsiInstallProductA(msifile, NULL);
1546 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1549 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1550 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1552 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1553 ok(delete_pf("msitest", FALSE), "File not installed\n");
1556 DeleteFile(msifile);
1559 static BOOL file_matches(LPSTR path)
1565 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1566 NULL, OPEN_EXISTING, 0, NULL);
1568 ZeroMemory(buf, MAX_PATH);
1569 ReadFile(file, buf, 15, &size, NULL);
1572 return !lstrcmp(buf, "msitest\\maximus");
1575 static void test_readonlyfile(void)
1580 CHAR path[MAX_PATH];
1582 CreateDirectoryA("msitest", NULL);
1583 create_file("msitest\\maximus", 500);
1584 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1586 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1588 lstrcpy(path, PROG_FILES_DIR);
1589 lstrcat(path, "\\msitest");
1590 CreateDirectory(path, NULL);
1592 lstrcat(path, "\\maximus");
1593 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1594 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1596 WriteFile(file, "readonlyfile", 20, &size, NULL);
1599 r = MsiInstallProductA(msifile, NULL);
1600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1601 ok(file_matches(path), "Expected file to be overwritten\n");
1602 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1603 ok(delete_pf("msitest", FALSE), "File not installed\n");
1605 /* Delete the files in the temp (current) folder */
1606 DeleteFile("msitest\\maximus");
1607 RemoveDirectory("msitest");
1608 DeleteFile(msifile);
1611 static void test_setdirproperty(void)
1615 CreateDirectoryA("msitest", NULL);
1616 create_file("msitest\\maximus", 500);
1617 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1619 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1621 r = MsiInstallProductA(msifile, NULL);
1622 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1623 ok(delete_pf("Common Files\\msitest\\maximus", TRUE), "File not installed\n");
1624 ok(delete_pf("Common Files\\msitest", FALSE), "File not installed\n");
1626 /* Delete the files in the temp (current) folder */
1627 DeleteFile(msifile);
1628 DeleteFile("msitest\\maximus");
1629 RemoveDirectory("msitest");
1632 static void test_cabisextracted(void)
1636 CreateDirectoryA("msitest", NULL);
1637 create_file("msitest\\gaius", 500);
1638 create_file("maximus", 500);
1639 create_file("augustus", 500);
1640 create_file("caesar", 500);
1642 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1643 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1644 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1646 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1648 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1650 r = MsiInstallProductA(msifile, NULL);
1651 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1652 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1653 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1654 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1655 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1656 ok(delete_pf("msitest", FALSE), "File not installed\n");
1658 /* Delete the files in the temp (current) folder */
1660 DeleteFile(msifile);
1661 DeleteFile("maximus");
1662 DeleteFile("augustus");
1663 DeleteFile("caesar");
1664 DeleteFile("msitest\\gaius");
1665 RemoveDirectory("msitest");
1668 static void test_concurrentinstall(void)
1671 CHAR path[MAX_PATH];
1673 CreateDirectoryA("msitest", NULL);
1674 CreateDirectoryA("msitest\\msitest", NULL);
1675 create_file("msitest\\maximus", 500);
1676 create_file("msitest\\msitest\\augustus", 500);
1678 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1680 lstrcpyA(path, CURR_DIR);
1681 lstrcatA(path, "\\msitest\\concurrent.msi");
1682 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1684 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1686 r = MsiInstallProductA(msifile, NULL);
1687 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1688 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1689 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1690 ok(delete_pf("msitest", FALSE), "File not installed\n");
1692 /* Delete the files in the temp (current) folder */
1693 DeleteFile(msifile);
1695 DeleteFile("msitest\\msitest\\augustus");
1696 DeleteFile("msitest\\maximus");
1697 RemoveDirectory("msitest\\msitest");
1698 RemoveDirectory("msitest");
1701 static void test_setpropertyfolder(void)
1705 CreateDirectoryA("msitest", NULL);
1706 create_file("msitest\\maximus", 500);
1708 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1710 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1712 r = MsiInstallProductA(msifile, NULL);
1713 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1714 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1715 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1716 ok(delete_pf("msitest", FALSE), "File not installed\n");
1718 /* Delete the files in the temp (current) folder */
1719 DeleteFile(msifile);
1720 DeleteFile("msitest\\maximus");
1721 RemoveDirectory("msitest");
1724 static BOOL file_exists(LPCSTR file)
1726 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
1729 static BOOL pf_exists(LPCSTR file)
1731 CHAR path[MAX_PATH];
1733 lstrcpyA(path, PROG_FILES_DIR);
1734 lstrcatA(path, "\\");
1735 lstrcatA(path, file);
1737 return file_exists(path);
1740 static void delete_pfmsitest_files(void)
1742 SHFILEOPSTRUCT shfl;
1743 CHAR path[MAX_PATH+11];
1745 lstrcpyA(path, PROG_FILES_DIR);
1746 lstrcatA(path, "\\msitest\\*");
1747 path[strlen(path) + 1] = '\0';
1750 shfl.wFunc = FO_DELETE;
1753 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1755 SHFileOperation(&shfl);
1757 lstrcpyA(path, PROG_FILES_DIR);
1758 lstrcatA(path, "\\msitest");
1759 RemoveDirectoryA(path);
1762 static void test_publish(void)
1766 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
1768 CreateDirectoryA("msitest", NULL);
1769 create_file("msitest\\maximus", 500);
1771 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
1773 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1775 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1776 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1778 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1779 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1781 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1782 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1784 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1785 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1786 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1787 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1789 /* nothing published */
1790 r = MsiInstallProductA(msifile, NULL);
1791 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1792 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1793 ok(pf_exists("msitest"), "File not installed\n");
1795 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1796 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1798 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1799 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1801 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1802 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1804 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1805 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1806 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1807 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1810 r = MsiInstallProductA(msifile, NULL);
1811 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1812 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1813 ok(pf_exists("msitest"), "File not installed\n");
1815 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1816 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1818 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1819 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1821 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1822 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1824 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1825 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1826 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1827 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1829 /* try to uninstall */
1830 r = MsiInstallProductA(msifile, "REMOVE=ALL");
1833 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1835 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1836 ok(pf_exists("msitest"), "File deleted\n");
1838 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1839 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1841 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1842 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1844 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1845 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1847 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1848 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1849 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1850 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1852 /* PublishProduct */
1853 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
1854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1855 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1856 ok(pf_exists("msitest"), "File not installed\n");
1858 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1859 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1861 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1862 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1864 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1865 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1866 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1867 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1869 /* try to uninstall after PublishProduct */
1870 r = MsiInstallProductA(msifile, "REMOVE=ALL");
1871 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1872 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1873 ok(pf_exists("msitest"), "File deleted\n");
1875 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1876 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1878 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1879 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1881 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1882 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1884 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1885 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1886 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1887 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1889 /* PublishProduct and RegisterProduct */
1890 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
1891 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1892 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1893 ok(pf_exists("msitest"), "File not installed\n");
1895 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1896 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1898 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1899 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1901 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1902 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1904 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1905 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1906 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1907 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1910 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
1911 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1912 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1913 ok(pf_exists("msitest"), "File not installed\n");
1915 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1918 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1921 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1922 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1924 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1925 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1927 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1928 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1931 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1933 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1935 /* uninstall has a problem with this */
1936 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
1939 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1941 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1942 ok(pf_exists("msitest"), "File deleted\n");
1944 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1945 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1947 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1948 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1950 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1951 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1952 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1953 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1955 /* PublishProduct and RegisterProduct and ProcessComponents */
1956 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
1957 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1958 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1959 ok(pf_exists("msitest"), "File not installed\n");
1961 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1962 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1964 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1965 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1967 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1968 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1970 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1971 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1974 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1975 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1978 /* complete uninstall */
1979 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
1980 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1981 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1982 ok(pf_exists("msitest"), "File deleted\n");
1984 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1985 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1987 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1988 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1990 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1991 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1993 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1994 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1995 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1996 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1998 /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
1999 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
2000 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2001 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2002 ok(pf_exists("msitest"), "File not installed\n");
2004 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2005 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2007 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2010 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2013 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2016 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2019 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2020 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2023 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2024 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2027 /* complete uninstall */
2028 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2032 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2033 ok(!pf_exists("msitest"), "File deleted\n");
2036 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2037 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2039 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");\
2040 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2042 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2043 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2045 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2046 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2047 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2048 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2050 /* complete install */
2051 r = MsiInstallProductA(msifile, "FULL=1");
2052 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2053 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2054 ok(pf_exists("msitest"), "File not installed\n");
2056 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2057 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2059 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2062 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2065 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2068 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2071 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2072 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2075 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2076 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2079 /* no UnpublishFeatures */
2080 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2084 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2085 ok(!pf_exists("msitest"), "File deleted\n");
2088 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2089 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2091 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2092 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2094 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2095 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2097 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2098 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2099 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2100 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2102 /* complete install */
2103 r = MsiInstallProductA(msifile, "FULL=1");
2104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2105 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2106 ok(pf_exists("msitest"), "File not installed\n");
2108 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2109 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2111 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2114 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2117 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2120 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2123 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2124 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2127 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2128 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2131 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
2132 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
2133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2134 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2135 ok(pf_exists("msitest"), "File deleted\n");
2137 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2138 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2140 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2143 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2146 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2149 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2152 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2153 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2156 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2157 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2160 /* complete install */
2161 r = MsiInstallProductA(msifile, "FULL=1");
2162 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2163 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2164 ok(pf_exists("msitest"), "File not installed\n");
2166 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2167 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2169 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2172 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2175 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2178 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2181 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2182 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2186 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2189 /* UnpublishFeatures, both features removed */
2190 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
2191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2194 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2195 ok(!pf_exists("msitest"), "File not deleted\n");
2198 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2199 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2201 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2202 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2204 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2205 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2207 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2208 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2209 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2210 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2212 /* complete install */
2213 r = MsiInstallProductA(msifile, "FULL=1");
2214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2215 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2216 ok(pf_exists("msitest"), "File not installed\n");
2218 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2219 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2221 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2224 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2227 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2230 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2233 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2234 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2238 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2241 /* complete uninstall */
2242 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2246 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2247 ok(!pf_exists("msitest"), "File not deleted\n");
2250 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2251 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2253 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2254 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2256 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2257 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2259 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2260 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2261 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2262 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2264 /* make sure 'Program Files\msitest' is removed */
2265 delete_pfmsitest_files();
2267 DeleteFile(msifile);
2268 DeleteFile("msitest\\maximus");
2269 RemoveDirectory("msitest");
2272 static void test_publishsourcelist(void)
2276 CHAR value[MAX_PATH];
2277 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2279 CreateDirectoryA("msitest", NULL);
2280 create_file("msitest\\maximus", 500);
2282 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2284 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2286 r = MsiInstallProductA(msifile, NULL);
2287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2288 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2289 ok(pf_exists("msitest"), "File not installed\n");
2291 /* nothing published */
2293 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2294 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2295 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2296 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2298 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2300 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2301 ok(pf_exists("msitest"), "File not installed\n");
2303 /* after RegisterProduct */
2305 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2306 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2307 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2308 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2310 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2312 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2313 ok(pf_exists("msitest"), "File not installed\n");
2315 /* after ProcessComponents */
2317 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2318 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2319 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2320 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2322 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2324 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2325 ok(pf_exists("msitest"), "File not installed\n");
2327 /* after PublishFeatures */
2329 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2330 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2331 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2332 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2334 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2336 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2337 ok(pf_exists("msitest"), "File not installed\n");
2339 /* after PublishProduct */
2341 lstrcpyA(value, "aaa");
2342 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2343 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
2344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2345 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
2346 ok(size == 11, "Expected 11, got %d\n", size);
2348 /* complete uninstall */
2349 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2350 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2353 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2354 ok(!pf_exists("msitest"), "File not deleted\n");
2357 /* make sure 'Program Files\msitest' is removed */
2358 delete_pfmsitest_files();
2360 DeleteFile(msifile);
2361 DeleteFile("msitest\\maximus");
2362 RemoveDirectory("msitest");
2365 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
2367 MSIHANDLE hview = 0;
2370 r = MsiDatabaseOpenView(hdb, query, &hview);
2371 if(r != ERROR_SUCCESS)
2374 r = MsiViewExecute(hview, hrec);
2375 if(r == ERROR_SUCCESS)
2376 r = MsiViewClose(hview);
2377 MsiCloseHandle(hview);
2381 static void set_transform_summary_info(void)
2386 /* build summmary info */
2387 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
2390 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
2393 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
2396 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2399 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
2400 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2401 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2402 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
2405 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
2408 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
2411 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2414 r = MsiSummaryInfoPersist(suminfo);
2417 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
2420 r = MsiCloseHandle(suminfo);
2423 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
2427 static void generate_transform(void)
2429 MSIHANDLE hdb1, hdb2;
2433 /* start with two identical databases */
2434 CopyFile(msifile, msifile2, FALSE);
2436 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
2437 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2439 r = MsiDatabaseCommit(hdb1);
2440 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
2442 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
2443 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2445 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2446 r = run_query(hdb1, 0, query);
2447 ok(r == ERROR_SUCCESS, "failed to add property\n");
2449 /* database needs to be committed */
2450 MsiDatabaseCommit(hdb1);
2452 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
2453 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
2455 #if 0 /* not implemented in wine yet */
2456 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
2457 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2460 MsiCloseHandle(hdb1);
2461 MsiCloseHandle(hdb2);
2464 /* data for generating a transform */
2466 /* tables transform names - encoded as they would be in an msi database file */
2467 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
2468 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
2469 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
2471 /* data in each table */
2472 static const char data1[] = /* _StringData */
2473 "propval"; /* all the strings squashed together */
2475 static const WCHAR data2[] = { /* _StringPool */
2477 0, 0, /* string 0 '' */
2478 4, 1, /* string 1 'prop' */
2479 3, 1, /* string 2 'val' */
2482 static const WCHAR data3[] = { /* Property */
2483 0x0201, 0x0001, 0x0002,
2486 static const struct {
2490 } table_transform_data[] =
2492 { name1, data1, sizeof data1 - 1 },
2493 { name2, data2, sizeof data2 },
2494 { name3, data3, sizeof data3 },
2497 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
2499 static void generate_transform_manual(void)
2501 IStorage *stg = NULL;
2506 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
2508 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
2510 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
2512 r = StgCreateDocfile(name, mode, 0, &stg);
2513 ok(r == S_OK, "failed to create storage\n");
2517 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
2518 ok(r == S_OK, "failed to set storage type\n");
2520 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
2522 r = IStorage_CreateStream(stg, table_transform_data[i].name,
2523 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
2526 ok(0, "failed to create stream %08x\n", r);
2530 r = IStream_Write(stm, table_transform_data[i].data,
2531 table_transform_data[i].size, &count);
2532 if (FAILED(r) || count != table_transform_data[i].size)
2533 ok(0, "failed to write stream\n");
2534 IStream_Release(stm);
2537 IStorage_Release(stg);
2539 set_transform_summary_info();
2542 static void test_transformprop(void)
2546 CreateDirectoryA("msitest", NULL);
2547 create_file("msitest\\augustus", 500);
2549 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
2551 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2553 r = MsiInstallProductA(msifile, NULL);
2554 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2555 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2556 ok(!delete_pf("msitest", FALSE), "File installed\n");
2559 generate_transform();
2561 generate_transform_manual();
2563 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
2564 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2565 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2566 ok(delete_pf("msitest", FALSE), "File not installed\n");
2568 /* Delete the files in the temp (current) folder */
2569 DeleteFile(msifile);
2570 DeleteFile(msifile2);
2571 DeleteFile(mstfile);
2572 DeleteFile("msitest\\augustus");
2573 RemoveDirectory("msitest");
2576 static void test_currentworkingdir(void)
2579 CHAR path[MAX_PATH];
2582 CreateDirectoryA("msitest", NULL);
2583 create_file("msitest\\augustus", 500);
2585 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
2587 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2589 CreateDirectoryA("diffdir", NULL);
2590 SetCurrentDirectoryA("diffdir");
2592 sprintf(path, "..\\%s", msifile);
2593 r = MsiInstallProductA(path, NULL);
2596 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
2597 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2598 ok(!delete_pf("msitest", FALSE), "File installed\n");
2601 sprintf(path, "%s\\%s", CURR_DIR, msifile);
2602 r = MsiInstallProductA(path, NULL);
2603 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2604 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2605 ok(delete_pf("msitest", FALSE), "File not installed\n");
2607 lstrcpyA(path, CURR_DIR);
2608 if (path[lstrlenA(path) - 1] != '\\')
2609 lstrcatA(path, "\\");
2610 lstrcatA(path, "msitest.msi");
2612 ptr2 = strrchr(path, '\\');
2614 ptr = strrchr(path, '\\');
2618 SetCurrentDirectoryA(path);
2620 r = MsiInstallProductA(ptr, NULL);
2621 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2622 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2623 ok(delete_pf("msitest", FALSE), "File not installed\n");
2625 SetCurrentDirectoryA(CURR_DIR);
2627 DeleteFile(msifile);
2628 DeleteFile("msitest\\augustus");
2629 RemoveDirectory("msitest");
2630 RemoveDirectory("diffdir");
2633 static void set_admin_summary_info(const CHAR *name)
2635 MSIHANDLE db, summary;
2638 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
2639 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2641 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
2642 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2644 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
2645 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2647 /* write the summary changes back to the stream */
2648 r = MsiSummaryInfoPersist(summary);
2649 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2651 MsiCloseHandle(summary);
2653 r = MsiDatabaseCommit(db);
2654 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2659 static void test_admin(void)
2663 CreateDirectoryA("msitest", NULL);
2664 create_file("msitest\\augustus", 500);
2666 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
2667 set_admin_summary_info(msifile);
2669 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2671 r = MsiInstallProductA(msifile, NULL);
2672 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2673 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2674 ok(!delete_pf("msitest", FALSE), "File installed\n");
2675 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
2676 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
2678 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
2679 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2680 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2681 ok(!delete_pf("msitest", FALSE), "File installed\n");
2684 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
2685 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
2688 DeleteFile(msifile);
2689 DeleteFile("msitest\\augustus");
2690 RemoveDirectory("msitest");
2693 static void set_admin_property_stream(LPCSTR file)
2697 WCHAR fileW[MAX_PATH];
2700 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
2702 /* AdminProperties */
2703 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
2704 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
2706 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
2708 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
2709 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2713 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
2714 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2716 hr = IStream_Write(stm, data, sizeof(data) - 1, &count);
2717 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2719 IStream_Release(stm);
2720 IStorage_Release(stg);
2723 static void test_adminprops(void)
2727 CreateDirectoryA("msitest", NULL);
2728 create_file("msitest\\augustus", 500);
2730 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
2731 set_admin_summary_info(msifile);
2732 set_admin_property_stream(msifile);
2734 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2736 r = MsiInstallProductA(msifile, NULL);
2737 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2738 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
2739 ok(delete_pf("msitest", FALSE), "File installed\n");
2741 DeleteFile(msifile);
2742 DeleteFile("msitest\\augustus");
2743 RemoveDirectory("msitest");
2746 static void create_pf(LPCSTR file, BOOL is_file)
2748 CHAR path[MAX_PATH];
2750 lstrcpyA(path, PROG_FILES_DIR);
2751 lstrcatA(path, "\\");
2752 lstrcatA(path, file);
2755 create_file(path, 500);
2757 CreateDirectoryA(path, NULL);
2760 static void test_removefiles(void)
2764 CreateDirectoryA("msitest", NULL);
2765 create_file("msitest\\hydrogen", 500);
2766 create_file("msitest\\helium", 500);
2767 create_file("msitest\\lithium", 500);
2769 create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
2771 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2773 r = MsiInstallProductA(msifile, NULL);
2774 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2775 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
2776 ok(!pf_exists("msitest\\helium"), "File installed\n");
2777 ok(pf_exists("msitest\\lithium"), "File not installed\n");
2778 ok(pf_exists("msitest"), "File not installed\n");
2780 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2782 ok(!pf_exists("msitest\\helium"), "File not deleted\n");
2783 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
2786 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
2787 ok(delete_pf("msitest", FALSE), "File deleted\n");
2790 create_pf("msitest", FALSE);
2791 create_pf("msitest\\hydrogen", TRUE);
2792 create_pf("msitest\\helium", TRUE);
2793 create_pf("msitest\\lithium", TRUE);
2795 r = MsiInstallProductA(msifile, NULL);
2796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2797 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
2798 ok(pf_exists("msitest\\helium"), "File not installed\n");
2799 ok(pf_exists("msitest\\lithium"), "File not installed\n");
2800 ok(pf_exists("msitest"), "File not installed\n");
2802 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2803 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2804 ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
2805 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
2808 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
2809 ok(delete_pf("msitest", FALSE), "File deleted\n");
2812 create_pf("msitest", FALSE);
2813 create_pf("msitest\\furlong", TRUE);
2814 create_pf("msitest\\firkin", TRUE);
2815 create_pf("msitest\\fortnight", TRUE);
2816 create_pf("msitest\\becquerel", TRUE);
2817 create_pf("msitest\\dioptre", TRUE);
2818 create_pf("msitest\\attoparsec", TRUE);
2819 create_pf("msitest\\storeys", TRUE);
2820 create_pf("msitest\\block", TRUE);
2821 create_pf("msitest\\siriometer", TRUE);
2823 r = MsiInstallProductA(msifile, NULL);
2824 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2825 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
2826 ok(!pf_exists("msitest\\helium"), "File installed\n");
2827 ok(pf_exists("msitest\\lithium"), "File not installed\n");
2828 ok(pf_exists("msitest\\becquerel"), "File not installed\n");
2829 ok(pf_exists("msitest\\dioptre"), "File not installed\n");
2830 ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
2831 ok(pf_exists("msitest"), "File not installed\n");
2834 ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
2835 ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
2836 ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
2837 ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
2838 ok(!pf_exists("msitest\\block"), "File not deleted\n");
2839 ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
2842 create_pf("msitest\\furlong", TRUE);
2843 create_pf("msitest\\firkin", TRUE);
2844 create_pf("msitest\\fortnight", TRUE);
2845 create_pf("msitest\\storeys", TRUE);
2846 create_pf("msitest\\block", TRUE);
2847 create_pf("msitest\\siriometer", TRUE);
2849 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2851 ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
2852 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
2853 ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
2854 ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
2855 ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
2856 ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
2857 ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
2860 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
2861 ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
2862 ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
2863 ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
2864 ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
2866 ok(delete_pf("msitest", FALSE), "File deleted\n");
2868 DeleteFile(msifile);
2869 DeleteFile("msitest\\hydrogen");
2870 DeleteFile("msitest\\helium");
2871 DeleteFile("msitest\\lithium");
2872 RemoveDirectory("msitest");
2878 char temp_path[MAX_PATH], prev_path[MAX_PATH];
2880 init_functionpointers();
2882 GetCurrentDirectoryA(MAX_PATH, prev_path);
2883 GetTempPath(MAX_PATH, temp_path);
2884 SetCurrentDirectoryA(temp_path);
2886 lstrcpyA(CURR_DIR, temp_path);
2887 len = lstrlenA(CURR_DIR);
2889 if(len && (CURR_DIR[len - 1] == '\\'))
2890 CURR_DIR[len - 1] = 0;
2892 get_program_files_dir(PROG_FILES_DIR);
2894 test_MsiInstallProduct();
2895 test_MsiSetComponentState();
2896 test_packagecoltypes();
2897 test_continuouscabs();
2900 test_samesequence();
2901 test_uiLevelFlags();
2902 test_readonlyfile();
2903 test_setdirproperty();
2904 test_cabisextracted();
2905 test_concurrentinstall();
2906 test_setpropertyfolder();
2908 test_publishsourcelist();
2909 test_transformprop();
2910 test_currentworkingdir();
2915 SetCurrentDirectoryA(prev_path);