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 const char *msifile = "msitest.msi";
36 static const char *msifile2 = "winetest2.msi";
37 static const char *mstfile = "winetest.mst";
38 CHAR CURR_DIR[MAX_PATH];
39 CHAR PROG_FILES_DIR[MAX_PATH];
41 /* msi database data */
43 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
44 "s72\tS38\ts72\ti2\tS255\tS72\n"
45 "Component\tComponent\n"
46 "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
47 "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
48 "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\t\tone.txt\n"
49 "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
50 "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
51 "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
52 "component\t\tMSITESTDIR\t0\t1\tfile\n"
53 "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
55 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
57 "Directory\tDirectory\n"
58 "CABOUTDIR\tMSITESTDIR\tcabout\n"
59 "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
60 "FIRSTDIR\tMSITESTDIR\tfirst\n"
61 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
62 "NEWDIR\tCABOUTDIR\tnew\n"
63 "ProgramFilesFolder\tTARGETDIR\t.\n"
64 "TARGETDIR\t\tSourceDir";
66 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
67 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
69 "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
70 "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
71 "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
72 "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
73 "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
74 "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
75 "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
77 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
79 "FeatureComponents\tFeature_\tComponent_\n"
85 "feature\tcomponent\n"
86 "service_feature\tservice_comp\n";
88 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
89 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
91 "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
92 "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
93 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
94 "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
95 "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
96 "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
97 "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
99 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
101 "InstallExecuteSequence\tAction\n"
102 "AllocateRegistrySpace\tNOT Installed\t1550\n"
103 "CostFinalize\t\t1000\n"
104 "CostInitialize\t\t800\n"
106 "InstallFiles\t\t4000\n"
107 "InstallServices\t\t5000\n"
108 "InstallFinalize\t\t6600\n"
109 "InstallInitialize\t\t1500\n"
110 "InstallValidate\t\t1400\n"
111 "LaunchConditions\t\t100\n"
112 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
114 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
115 "i2\ti4\tL64\tS255\tS32\tS72\n"
117 "1\t3\t\t\tDISK1\t\n"
118 "2\t5\t\tmsitest.cab\tDISK2\t\n";
120 static const CHAR property_dat[] = "Property\tValue\n"
122 "Property\tProperty\n"
123 "DefaultUIFont\tDlgFont8\n"
126 "InstallMode\tTypical\n"
127 "Manufacturer\tWine\n"
128 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
129 "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
131 "ProductLanguage\t1033\n"
132 "ProductName\tMSITEST\n"
133 "ProductVersion\t1.1.1\n"
134 "PROMPTROLLBACKCOST\tP\n"
136 "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
137 "AdminProperties\tPOSTADMIN\n";
139 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
140 "s72\ti2\tl255\tL255\tL0\ts72\n"
141 "Registry\tRegistry\n"
142 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
143 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
144 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
145 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
147 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
148 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
149 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
150 "ServiceInstall\tServiceInstall\n"
151 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
153 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
154 "s72\tl255\ti2\tL255\tI2\ts72\n"
155 "ServiceControl\tServiceControl\n"
156 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
158 /* tables for test_continuouscabs */
159 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
160 "s72\tS38\ts72\ti2\tS255\tS72\n"
161 "Component\tComponent\n"
162 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
163 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
164 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
166 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
167 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
169 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
171 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
173 "FeatureComponents\tFeature_\tComponent_\n"
175 "feature\taugustus\n"
178 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
179 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
181 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
182 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
183 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
185 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
186 "i2\ti4\tL64\tS255\tS32\tS72\n"
188 "1\t10\t\ttest1.cab\tDISK1\t\n"
189 "2\t2\t\ttest2.cab\tDISK2\t\n"
190 "3\t12\t\ttest3.cab\tDISK3\t\n";
192 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
193 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
195 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
196 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
197 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
199 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
200 "i2\ti4\tL64\tS255\tS32\tS72\n"
202 "1\t10\t\ttest1.cab\tDISK1\t\n"
203 "2\t2\t\ttest2.cab\tDISK2\t\n"
204 "3\t3\t\ttest3.cab\tDISK3\t\n";
206 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
207 "i2\ti4\tL64\tS255\tS32\tS72\n"
209 "1\t10\t\ttest1.cab\tDISK1\t\n"
210 "2\t12\t\ttest3.cab\tDISK3\t\n"
211 "3\t2\t\ttest2.cab\tDISK2\t\n";
213 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
214 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
216 "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
217 "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
218 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
220 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
221 "i2\ti4\tL64\tS255\tS32\tS72\n"
223 "1\t3\t\ttest1.cab\tDISK1\t\n";
225 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
226 "i2\ti4\tL64\tS255\tS32\tS72\n"
228 "1\t2\t\ttest1.cab\tDISK1\t\n"
229 "2\t2\t\ttest2.cab\tDISK2\t\n"
230 "3\t12\t\ttest3.cab\tDISK3\t\n";
232 /* tables for test_uiLevelFlags */
233 static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
234 "s72\tS38\ts72\ti2\tS255\tS72\n"
235 "Component\tComponent\n"
236 "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
237 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
238 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
240 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
242 "InstallUISequence\tAction\n"
243 "SetUIProperty\t\t5\n"
244 "ExecuteAction\t\t1100\n";
246 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
247 "s72\ti2\tS64\tS0\tS255\n"
248 "CustomAction\tAction\n"
249 "SetUIProperty\t51\tHASUIRUN\t1\t\n";
251 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
252 "s72\tS38\ts72\ti2\tS255\tS72\n"
253 "Component\tComponent\n"
254 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
256 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
257 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
259 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
260 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
262 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
264 "FeatureComponents\tFeature_\tComponent_\n"
266 "montecristo\tmaximus";
268 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
269 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
271 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
273 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
274 "i2\ti4\tL64\tS255\tS32\tS72\n"
276 "1\t1\t\t\tDISK1\t\n";
278 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
280 "InstallExecuteSequence\tAction\n"
281 "AllocateRegistrySpace\tNOT Installed\t1550\n"
282 "CostFinalize\t\t1000\n"
283 "CostInitialize\t\t800\n"
285 "InstallFiles\t\t4000\n"
286 "InstallFinalize\t\t6600\n"
287 "InstallInitialize\t\t1500\n"
288 "InstallValidate\t\t1400\n"
289 "LaunchConditions\t\t100\n"
290 "SetDirProperty\t\t950";
292 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
293 "s72\ti2\tS64\tS0\tS255\n"
294 "CustomAction\tAction\n"
295 "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
297 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
298 "s72\tS38\ts72\ti2\tS255\tS72\n"
299 "Component\tComponent\n"
300 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
301 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
302 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
303 "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
305 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
307 "FeatureComponents\tFeature_\tComponent_\n"
309 "feature\taugustus\n"
313 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
314 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
316 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
317 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
318 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
319 "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
321 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
322 "i2\ti4\tL64\tS255\tS32\tS72\n"
324 "1\t1\t\ttest1.cab\tDISK1\t\n"
325 "2\t2\t\ttest2.cab\tDISK2\t\n"
326 "3\t12\t\ttest3.cab\tDISK3\t\n";
328 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
330 "InstallExecuteSequence\tAction\n"
331 "CostFinalize\t\t1000\n"
332 "CostInitialize\t\t800\n"
334 "InstallFiles\t\t4000\n"
335 "InstallServices\t\t5000\n"
336 "InstallFinalize\t\t6600\n"
337 "InstallInitialize\t\t1500\n"
338 "RunInstall\t\t1600\n"
339 "InstallValidate\t\t1400\n"
340 "LaunchConditions\t\t100";
342 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
343 "s72\ti2\tS64\tS0\tS255\n"
344 "CustomAction\tAction\n"
345 "RunInstall\t23\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
347 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
348 "s72\tS38\ts72\ti2\tS255\tS72\n"
349 "Component\tComponent\n"
350 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
352 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
353 "s72\tS38\ts72\ti2\tS255\tS72\n"
354 "Component\tComponent\n"
355 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
357 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
359 "FeatureComponents\tFeature_\tComponent_\n"
362 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
363 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
365 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
367 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
368 "s72\ti2\tS64\tS0\tS255\n"
369 "CustomAction\tAction\n"
370 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
372 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
374 "InstallExecuteSequence\tAction\n"
375 "CostFinalize\t\t1000\n"
376 "CostInitialize\t\t800\n"
378 "SetFolderProp\t\t950\n"
379 "InstallFiles\t\t4000\n"
380 "InstallServices\t\t5000\n"
381 "InstallFinalize\t\t6600\n"
382 "InstallInitialize\t\t1500\n"
383 "InstallValidate\t\t1400\n"
384 "LaunchConditions\t\t100";
386 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
388 "InstallUISequence\tAction\n"
389 "CostInitialize\t\t800\n"
391 "CostFinalize\t\t1000\n"
392 "ExecuteAction\t\t1100\n";
394 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
396 "InstallExecuteSequence\tAction\n"
397 "ValidateProductID\t\t700\n"
398 "CostInitialize\t\t800\n"
400 "CostFinalize\t\t1000\n"
401 "InstallValidate\t\t1400\n"
402 "InstallInitialize\t\t1500\n"
403 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
404 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
405 "RemoveFiles\t\t3500\n"
406 "InstallFiles\t\t4000\n"
407 "RegisterUser\t\t6000\n"
408 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
409 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
410 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
411 "InstallFinalize\t\t6600";
413 static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
414 "s72\tS38\ts72\ti2\tS255\tS72\n"
415 "Component\tComponent\n"
416 "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";
418 static const CHAR cwd_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\t\taugustus\n";
423 static const CHAR adm_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\tPOSTADMIN=1\taugustus";
428 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
429 "s72\ti2\tS64\tS0\tS255\n"
430 "CustomAction\tAction\n"
431 "SetPOSTADMIN\t51\tPOSTADMIN\t1\t";
433 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
435 "AdminExecuteSequence\tAction\n"
436 "CostFinalize\t\t1000\n"
437 "CostInitialize\t\t800\n"
439 "SetPOSTADMIN\t\t950\n"
440 "InstallFiles\t\t4000\n"
441 "InstallFinalize\t\t6600\n"
442 "InstallInitialize\t\t1500\n"
443 "InstallValidate\t\t1400\n"
444 "LaunchConditions\t\t100";
446 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
447 "s72\tS38\ts72\ti2\tS255\tS72\n"
448 "Component\tComponent\n"
449 "augustus\t\tMSITESTDIR\t0\tMYPROP=2718\taugustus\n";
451 typedef struct _msi_table
453 const CHAR *filename;
458 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
460 static const msi_table tables[] =
462 ADD_TABLE(component),
463 ADD_TABLE(directory),
465 ADD_TABLE(feature_comp),
467 ADD_TABLE(install_exec_seq),
471 ADD_TABLE(service_install),
472 ADD_TABLE(service_control)
475 static const msi_table cc_tables[] =
477 ADD_TABLE(cc_component),
478 ADD_TABLE(directory),
479 ADD_TABLE(cc_feature),
480 ADD_TABLE(cc_feature_comp),
482 ADD_TABLE(install_exec_seq),
487 static const msi_table co_tables[] =
489 ADD_TABLE(cc_component),
490 ADD_TABLE(directory),
491 ADD_TABLE(cc_feature),
492 ADD_TABLE(cc_feature_comp),
494 ADD_TABLE(install_exec_seq),
499 static const msi_table co2_tables[] =
501 ADD_TABLE(cc_component),
502 ADD_TABLE(directory),
503 ADD_TABLE(cc_feature),
504 ADD_TABLE(cc_feature_comp),
506 ADD_TABLE(install_exec_seq),
507 ADD_TABLE(co2_media),
511 static const msi_table mm_tables[] =
513 ADD_TABLE(cc_component),
514 ADD_TABLE(directory),
515 ADD_TABLE(cc_feature),
516 ADD_TABLE(cc_feature_comp),
518 ADD_TABLE(install_exec_seq),
523 static const msi_table ss_tables[] =
525 ADD_TABLE(cc_component),
526 ADD_TABLE(directory),
527 ADD_TABLE(cc_feature),
528 ADD_TABLE(cc_feature_comp),
530 ADD_TABLE(install_exec_seq),
535 static const msi_table ui_tables[] =
537 ADD_TABLE(ui_component),
538 ADD_TABLE(directory),
539 ADD_TABLE(cc_feature),
540 ADD_TABLE(cc_feature_comp),
542 ADD_TABLE(install_exec_seq),
543 ADD_TABLE(ui_install_ui_seq),
544 ADD_TABLE(ui_custom_action),
549 static const msi_table rof_tables[] =
551 ADD_TABLE(rof_component),
552 ADD_TABLE(directory),
553 ADD_TABLE(rof_feature),
554 ADD_TABLE(rof_feature_comp),
556 ADD_TABLE(install_exec_seq),
557 ADD_TABLE(rof_media),
561 static const msi_table sdp_tables[] =
563 ADD_TABLE(rof_component),
564 ADD_TABLE(directory),
565 ADD_TABLE(rof_feature),
566 ADD_TABLE(rof_feature_comp),
568 ADD_TABLE(sdp_install_exec_seq),
569 ADD_TABLE(sdp_custom_action),
570 ADD_TABLE(rof_media),
574 static const msi_table cie_tables[] =
576 ADD_TABLE(cie_component),
577 ADD_TABLE(directory),
578 ADD_TABLE(cc_feature),
579 ADD_TABLE(cie_feature_comp),
581 ADD_TABLE(install_exec_seq),
582 ADD_TABLE(cie_media),
586 static const msi_table ci_tables[] =
588 ADD_TABLE(ci_component),
589 ADD_TABLE(directory),
590 ADD_TABLE(rof_feature),
591 ADD_TABLE(rof_feature_comp),
593 ADD_TABLE(ci_install_exec_seq),
594 ADD_TABLE(rof_media),
596 ADD_TABLE(ci_custom_action),
599 static const msi_table ci2_tables[] =
601 ADD_TABLE(ci2_component),
602 ADD_TABLE(directory),
603 ADD_TABLE(rof_feature),
604 ADD_TABLE(ci2_feature_comp),
606 ADD_TABLE(install_exec_seq),
607 ADD_TABLE(rof_media),
611 static const msi_table spf_tables[] =
613 ADD_TABLE(ci_component),
614 ADD_TABLE(directory),
615 ADD_TABLE(rof_feature),
616 ADD_TABLE(rof_feature_comp),
618 ADD_TABLE(spf_install_exec_seq),
619 ADD_TABLE(rof_media),
621 ADD_TABLE(spf_custom_action),
622 ADD_TABLE(spf_install_ui_seq),
625 static const msi_table pp_tables[] =
627 ADD_TABLE(ci_component),
628 ADD_TABLE(directory),
629 ADD_TABLE(rof_feature),
630 ADD_TABLE(rof_feature_comp),
632 ADD_TABLE(pp_install_exec_seq),
633 ADD_TABLE(rof_media),
637 static const msi_table tp_tables[] =
639 ADD_TABLE(tp_component),
640 ADD_TABLE(directory),
641 ADD_TABLE(rof_feature),
642 ADD_TABLE(ci2_feature_comp),
644 ADD_TABLE(install_exec_seq),
645 ADD_TABLE(rof_media),
649 static const msi_table cwd_tables[] =
651 ADD_TABLE(cwd_component),
652 ADD_TABLE(directory),
653 ADD_TABLE(rof_feature),
654 ADD_TABLE(ci2_feature_comp),
656 ADD_TABLE(install_exec_seq),
657 ADD_TABLE(rof_media),
661 static const msi_table adm_tables[] =
663 ADD_TABLE(adm_component),
664 ADD_TABLE(directory),
665 ADD_TABLE(rof_feature),
666 ADD_TABLE(ci2_feature_comp),
668 ADD_TABLE(install_exec_seq),
669 ADD_TABLE(rof_media),
671 ADD_TABLE(adm_custom_action),
672 ADD_TABLE(adm_admin_exec_seq),
675 static const msi_table amp_tables[] =
677 ADD_TABLE(amp_component),
678 ADD_TABLE(directory),
679 ADD_TABLE(rof_feature),
680 ADD_TABLE(ci2_feature_comp),
682 ADD_TABLE(install_exec_seq),
683 ADD_TABLE(rof_media),
687 /* cabinet definitions */
689 /* make the max size large so there is only one cab file */
690 #define MEDIA_SIZE 0x7FFFFFFF
691 #define FOLDER_THRESHOLD 900000
693 /* the FCI callbacks */
695 static void *mem_alloc(ULONG cb)
697 return HeapAlloc(GetProcessHeap(), 0, cb);
700 static void mem_free(void *memory)
702 HeapFree(GetProcessHeap(), 0, memory);
705 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
707 sprintf(pccab->szCab, pv, pccab->iCab);
711 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
716 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
717 BOOL fContinuation, void *pv)
722 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
726 DWORD dwShareMode = 0;
727 DWORD dwCreateDisposition = OPEN_EXISTING;
729 dwAccess = GENERIC_READ | GENERIC_WRITE;
730 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
731 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
733 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
734 dwCreateDisposition = OPEN_EXISTING;
736 dwCreateDisposition = CREATE_NEW;
738 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
739 dwCreateDisposition, 0, NULL);
741 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
743 return (INT_PTR)handle;
746 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
748 HANDLE handle = (HANDLE)hf;
752 res = ReadFile(handle, memory, cb, &dwRead, NULL);
753 ok(res, "Failed to ReadFile\n");
758 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
760 HANDLE handle = (HANDLE)hf;
764 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
765 ok(res, "Failed to WriteFile\n");
770 static int fci_close(INT_PTR hf, int *err, void *pv)
772 HANDLE handle = (HANDLE)hf;
773 ok(CloseHandle(handle), "Failed to CloseHandle\n");
778 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
780 HANDLE handle = (HANDLE)hf;
783 ret = SetFilePointer(handle, dist, NULL, seektype);
784 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
789 static int fci_delete(char *pszFile, int *err, void *pv)
791 BOOL ret = DeleteFileA(pszFile);
792 ok(ret, "Failed to DeleteFile %s\n", pszFile);
797 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
804 r = MsiRecordGetString(rec, field, buffer, &sz);
805 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
808 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
812 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
813 GetTempFileNameA(".", "xx", 0, tempname);
815 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
817 lstrcpyA(pszTempName, tempname);
818 HeapFree(GetProcessHeap(), 0, tempname);
822 HeapFree(GetProcessHeap(), 0, tempname);
827 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
828 USHORT *pattribs, int *err, void *pv)
830 BY_HANDLE_FILE_INFORMATION finfo;
836 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
837 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
839 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
841 res = GetFileInformationByHandle(handle, &finfo);
842 ok(res, "Expected GetFileInformationByHandle to succeed\n");
844 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
845 FileTimeToDosDateTime(&filetime, pdate, ptime);
847 attrs = GetFileAttributes(pszName);
848 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
850 return (INT_PTR)handle;
853 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
856 char filename[MAX_PATH];
858 lstrcpyA(path, CURR_DIR);
859 lstrcatA(path, "\\");
860 lstrcatA(path, file);
862 lstrcpyA(filename, file);
864 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
865 progress, get_open_info, compress);
868 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
870 ZeroMemory(pCabParams, sizeof(CCAB));
872 pCabParams->cb = max_size;
873 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
874 pCabParams->setID = 0xbeef;
875 pCabParams->iCab = 1;
876 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
877 lstrcatA(pCabParams->szCabPath, "\\");
878 lstrcpyA(pCabParams->szCab, name);
881 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
889 set_cab_parameters(&cabParams, name, max_size);
891 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
892 fci_read, fci_write, fci_close, fci_seek, fci_delete,
893 get_temp_file, &cabParams, NULL);
895 ok(hfci != NULL, "Failed to create an FCI context\n");
900 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
901 ok(res, "Failed to add file: %s\n", ptr);
902 ptr += lstrlen(ptr) + 1;
905 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
906 ok(res, "Failed to flush the cabinet\n");
908 res = FCIDestroy(hfci);
909 ok(res, "Failed to destroy the cabinet\n");
912 static BOOL get_program_files_dir(LPSTR buf)
915 DWORD type = REG_EXPAND_SZ, size;
917 if (RegOpenKey(HKEY_LOCAL_MACHINE,
918 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
922 if (RegQueryValueEx(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size))
929 static void create_file(const CHAR *name, DWORD size)
934 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
935 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
936 WriteFile(file, name, strlen(name), &written, NULL);
937 WriteFile(file, "\n", strlen("\n"), &written, NULL);
939 left = size - lstrlen(name) - 1;
941 SetFilePointer(file, left, NULL, FILE_CURRENT);
947 static void create_test_files(void)
949 CreateDirectoryA("msitest", NULL);
950 create_file("msitest\\one.txt", 100);
951 CreateDirectoryA("msitest\\first", NULL);
952 create_file("msitest\\first\\two.txt", 100);
953 CreateDirectoryA("msitest\\second", NULL);
954 create_file("msitest\\second\\three.txt", 100);
956 create_file("four.txt", 100);
957 create_file("five.txt", 100);
958 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
960 create_file("msitest\\filename", 100);
961 create_file("msitest\\service.exe", 100);
963 DeleteFileA("four.txt");
964 DeleteFileA("five.txt");
967 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
971 lstrcpyA(path, PROG_FILES_DIR);
972 lstrcatA(path, "\\");
973 lstrcatA(path, rel_path);
976 return DeleteFileA(path);
978 return RemoveDirectoryA(path);
981 static void delete_test_files(void)
983 DeleteFileA("msitest.msi");
984 DeleteFileA("msitest.cab");
985 DeleteFileA("msitest\\second\\three.txt");
986 DeleteFileA("msitest\\first\\two.txt");
987 DeleteFileA("msitest\\one.txt");
988 DeleteFileA("msitest\\service.exe");
989 DeleteFileA("msitest\\filename");
990 RemoveDirectoryA("msitest\\second");
991 RemoveDirectoryA("msitest\\first");
992 RemoveDirectoryA("msitest");
995 static void write_file(const CHAR *filename, const char *data, int data_size)
999 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1000 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1002 WriteFile(hf, data, data_size, &size, NULL);
1006 static void write_msi_summary_info(MSIHANDLE db)
1011 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1012 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1014 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1015 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1017 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1018 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1019 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1021 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1022 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1024 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1025 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1027 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1028 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1030 /* write the summary changes back to the stream */
1031 r = MsiSummaryInfoPersist(summary);
1032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1034 MsiCloseHandle(summary);
1037 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1043 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1044 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1046 /* import the tables into the database */
1047 for (j = 0; j < num_tables; j++)
1049 const msi_table *table = &tables[j];
1051 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1053 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1056 DeleteFileA(table->filename);
1059 write_msi_summary_info(db);
1061 r = MsiDatabaseCommit(db);
1062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1067 static void check_service_is_installed(void)
1069 SC_HANDLE scm, service;
1072 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1073 ok(scm != NULL, "Failed to open the SC Manager\n");
1075 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1076 ok(service != NULL, "Failed to open TestService\n");
1078 res = DeleteService(service);
1079 ok(res, "Failed to delete TestService\n");
1082 static void test_MsiInstallProduct(void)
1085 CHAR path[MAX_PATH];
1088 DWORD num, size, type;
1090 create_test_files();
1091 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1093 r = MsiInstallProductA(msifile, NULL);
1094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1096 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1097 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1098 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1099 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1100 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1101 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1102 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1103 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1104 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1105 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1106 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1107 ok(delete_pf("msitest", FALSE), "File not installed\n");
1109 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1114 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1115 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1116 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1120 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1121 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1125 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1126 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1127 ok(num == 314, "Expected 314, got %d\n", num);
1131 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1132 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1133 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1135 check_service_is_installed();
1137 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1139 delete_test_files();
1142 static void test_MsiSetComponentState(void)
1144 INSTALLSTATE installed, action;
1146 char path[MAX_PATH];
1149 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1153 lstrcpy(path, CURR_DIR);
1154 lstrcat(path, "\\");
1155 lstrcat(path, msifile);
1157 r = MsiOpenPackage(path, &package);
1158 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1160 r = MsiDoAction(package, "CostInitialize");
1161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1163 r = MsiDoAction(package, "FileCost");
1164 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1166 r = MsiDoAction(package, "CostFinalize");
1167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1169 r = MsiGetComponentState(package, "dangler", &installed, &action);
1170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1171 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1172 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1174 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1177 MsiCloseHandle(package);
1180 DeleteFileA(msifile);
1183 static void test_packagecoltypes(void)
1185 MSIHANDLE hdb, view, rec;
1186 char path[MAX_PATH];
1190 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1194 lstrcpy(path, CURR_DIR);
1195 lstrcat(path, "\\");
1196 lstrcat(path, msifile);
1198 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1201 query = "SELECT * FROM `Media`";
1202 r = MsiDatabaseOpenView( hdb, query, &view );
1203 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1205 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1206 count = MsiRecordGetFieldCount( rec );
1207 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1208 ok(count == 6, "Expected 6, got %d\n", count);
1209 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1210 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1211 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1212 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1213 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1214 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1215 MsiCloseHandle(rec);
1217 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1218 count = MsiRecordGetFieldCount( rec );
1219 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1220 ok(count == 6, "Expected 6, got %d\n", count);
1221 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1222 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1223 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1224 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1225 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1226 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1228 MsiCloseHandle(rec);
1229 MsiCloseHandle(view);
1230 MsiCloseHandle(hdb);
1231 DeleteFile(msifile);
1234 static void create_cc_test_files(void)
1239 static CHAR cab_context[] = "test%d.cab";
1242 create_file("maximus", 500);
1243 create_file("augustus", 50000);
1244 create_file("caesar", 500);
1246 set_cab_parameters(&cabParams, "test1.cab", 200);
1248 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1249 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1250 get_temp_file, &cabParams, cab_context);
1251 ok(hfci != NULL, "Failed to create an FCI context\n");
1253 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1254 ok(res, "Failed to add file maximus\n");
1256 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1257 ok(res, "Failed to add file augustus\n");
1259 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1260 ok(res, "Failed to flush the cabinet\n");
1262 res = FCIDestroy(hfci);
1263 ok(res, "Failed to destroy the cabinet\n");
1265 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1267 DeleteFile("maximus");
1268 DeleteFile("augustus");
1269 DeleteFile("caesar");
1272 static void delete_cab_files(void)
1274 SHFILEOPSTRUCT shfl;
1275 CHAR path[MAX_PATH+10];
1277 lstrcpyA(path, CURR_DIR);
1278 lstrcatA(path, "\\*.cab");
1279 path[strlen(path) + 1] = '\0';
1282 shfl.wFunc = FO_DELETE;
1285 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1287 SHFileOperation(&shfl);
1290 static void test_continuouscabs(void)
1294 create_cc_test_files();
1295 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1297 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1299 r = MsiInstallProductA(msifile, NULL);
1300 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1304 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1305 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1307 ok(delete_pf("msitest", FALSE), "File not installed\n");
1310 DeleteFile(msifile);
1313 static void test_caborder(void)
1317 create_file("imperator", 100);
1318 create_file("maximus", 500);
1319 create_file("augustus", 50000);
1320 create_file("caesar", 500);
1322 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1324 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1326 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1327 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1328 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1330 r = MsiInstallProductA(msifile, NULL);
1331 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1332 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1333 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1336 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1337 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1342 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1343 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1344 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1346 r = MsiInstallProductA(msifile, NULL);
1347 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1348 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1349 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1350 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1353 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1357 DeleteFile(msifile);
1359 create_cc_test_files();
1360 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1362 r = MsiInstallProductA(msifile, NULL);
1363 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1364 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1365 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1368 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1369 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1373 DeleteFile(msifile);
1375 create_cc_test_files();
1376 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1378 r = MsiInstallProductA(msifile, NULL);
1379 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1380 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1383 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1384 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1385 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1389 DeleteFile("imperator");
1390 DeleteFile("maximus");
1391 DeleteFile("augustus");
1392 DeleteFile("caesar");
1393 DeleteFile(msifile);
1396 static void test_mixedmedia(void)
1400 CreateDirectoryA("msitest", NULL);
1401 create_file("msitest\\maximus", 500);
1402 create_file("msitest\\augustus", 500);
1403 create_file("caesar", 500);
1405 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1407 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1409 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1411 r = MsiInstallProductA(msifile, NULL);
1412 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1413 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1414 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1415 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1416 ok(delete_pf("msitest", FALSE), "File not installed\n");
1418 /* Delete the files in the temp (current) folder */
1419 DeleteFile("msitest\\maximus");
1420 DeleteFile("msitest\\augustus");
1421 RemoveDirectory("msitest");
1422 DeleteFile("caesar");
1423 DeleteFile("test1.cab");
1424 DeleteFile(msifile);
1427 static void test_samesequence(void)
1431 create_cc_test_files();
1432 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1434 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1436 r = MsiInstallProductA(msifile, NULL);
1439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1440 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1441 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1443 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1444 ok(delete_pf("msitest", FALSE), "File not installed\n");
1447 DeleteFile(msifile);
1450 static void test_uiLevelFlags(void)
1454 create_cc_test_files();
1455 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1457 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1459 r = MsiInstallProductA(msifile, NULL);
1460 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1463 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1464 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1466 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1467 ok(delete_pf("msitest", FALSE), "File not installed\n");
1470 DeleteFile(msifile);
1473 static BOOL file_matches(LPSTR path)
1479 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1480 NULL, OPEN_EXISTING, 0, NULL);
1482 ZeroMemory(buf, MAX_PATH);
1483 ReadFile(file, buf, 15, &size, NULL);
1486 return !lstrcmp(buf, "msitest\\maximus");
1489 static void test_readonlyfile(void)
1494 CHAR path[MAX_PATH];
1496 CreateDirectoryA("msitest", NULL);
1497 create_file("msitest\\maximus", 500);
1498 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1500 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1502 lstrcpy(path, PROG_FILES_DIR);
1503 lstrcat(path, "\\msitest");
1504 CreateDirectory(path, NULL);
1506 lstrcat(path, "\\maximus");
1507 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1508 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1510 WriteFile(file, "readonlyfile", 20, &size, NULL);
1513 r = MsiInstallProductA(msifile, NULL);
1514 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1515 ok(file_matches(path), "Expected file to be overwritten\n");
1516 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1517 ok(delete_pf("msitest", FALSE), "File not installed\n");
1519 /* Delete the files in the temp (current) folder */
1520 DeleteFile("msitest\\maximus");
1521 RemoveDirectory("msitest");
1522 DeleteFile(msifile);
1525 static void test_setdirproperty(void)
1529 CreateDirectoryA("msitest", NULL);
1530 create_file("msitest\\maximus", 500);
1531 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1533 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1535 r = MsiInstallProductA(msifile, NULL);
1536 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1537 ok(delete_pf("Common Files\\msitest\\maximus", TRUE), "File not installed\n");
1538 ok(delete_pf("Common Files\\msitest", FALSE), "File not installed\n");
1540 /* Delete the files in the temp (current) folder */
1541 DeleteFile(msifile);
1542 DeleteFile("msitest\\maximus");
1543 RemoveDirectory("msitest");
1546 static void test_cabisextracted(void)
1550 CreateDirectoryA("msitest", NULL);
1551 create_file("msitest\\gaius", 500);
1552 create_file("maximus", 500);
1553 create_file("augustus", 500);
1554 create_file("caesar", 500);
1556 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1557 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1558 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1560 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1562 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1564 r = MsiInstallProductA(msifile, NULL);
1565 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1566 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1567 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1568 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1569 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1570 ok(delete_pf("msitest", FALSE), "File not installed\n");
1572 /* Delete the files in the temp (current) folder */
1574 DeleteFile(msifile);
1575 DeleteFile("maximus");
1576 DeleteFile("augustus");
1577 DeleteFile("caesar");
1578 DeleteFile("msitest\\gaius");
1579 RemoveDirectory("msitest");
1582 static void test_concurrentinstall(void)
1585 CHAR path[MAX_PATH];
1587 CreateDirectoryA("msitest", NULL);
1588 CreateDirectoryA("msitest\\msitest", NULL);
1589 create_file("msitest\\maximus", 500);
1590 create_file("msitest\\msitest\\augustus", 500);
1592 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1594 lstrcpyA(path, CURR_DIR);
1595 lstrcatA(path, "\\msitest\\concurrent.msi");
1596 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1598 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1600 r = MsiInstallProductA(msifile, NULL);
1601 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1602 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1603 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1604 ok(delete_pf("msitest", FALSE), "File not installed\n");
1606 /* Delete the files in the temp (current) folder */
1607 DeleteFile(msifile);
1609 DeleteFile("msitest\\msitest\\augustus");
1610 DeleteFile("msitest\\maximus");
1611 RemoveDirectory("msitest\\msitest");
1612 RemoveDirectory("msitest");
1615 static void test_setpropertyfolder(void)
1619 CreateDirectoryA("msitest", NULL);
1620 create_file("msitest\\maximus", 500);
1622 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1624 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1626 r = MsiInstallProductA(msifile, NULL);
1627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1628 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1629 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1630 ok(delete_pf("msitest", FALSE), "File not installed\n");
1632 /* Delete the files in the temp (current) folder */
1633 DeleteFile(msifile);
1634 DeleteFile("msitest\\maximus");
1635 RemoveDirectory("msitest");
1638 static BOOL file_exists(LPCSTR file)
1640 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
1643 static BOOL pf_exists(LPCSTR file)
1645 CHAR path[MAX_PATH];
1647 lstrcpyA(path, PROG_FILES_DIR);
1648 lstrcatA(path, "\\");
1649 lstrcatA(path, file);
1651 return file_exists(path);
1654 static void delete_pfmsitest_files(void)
1656 SHFILEOPSTRUCT shfl;
1657 CHAR path[MAX_PATH+10];
1659 lstrcpyA(path, PROG_FILES_DIR);
1660 lstrcatA(path, "\\msitest\\*");
1661 path[strlen(path) + 1] = '\0';
1664 shfl.wFunc = FO_DELETE;
1667 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1669 SHFileOperation(&shfl);
1671 lstrcpyA(path, PROG_FILES_DIR);
1672 lstrcatA(path, "\\msitest");
1673 RemoveDirectoryA(path);
1676 static void test_publish(void)
1680 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
1682 CreateDirectoryA("msitest", NULL);
1683 create_file("msitest\\maximus", 500);
1685 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
1687 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1689 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1690 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1692 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1693 if (state != INSTALLSTATE_UNKNOWN)
1695 skip("Install database not in a clean state\n");
1699 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1701 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1702 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1704 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1705 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1706 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1707 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1709 /* nothing published */
1710 r = MsiInstallProductA(msifile, NULL);
1711 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1712 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1713 ok(pf_exists("msitest"), "File not installed\n");
1715 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1716 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1718 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1719 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1721 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1722 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1724 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1725 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1726 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1727 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1730 r = MsiInstallProductA(msifile, NULL);
1731 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1732 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1733 ok(pf_exists("msitest"), "File not installed\n");
1735 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1736 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1738 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1739 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1741 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1742 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1744 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1745 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1746 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1747 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1749 /* try to uninstall */
1750 r = MsiInstallProductA(msifile, "REMOVE=ALL");
1753 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1755 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1756 ok(pf_exists("msitest"), "File deleted\n");
1758 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1759 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1761 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1762 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1764 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1765 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1767 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1768 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1769 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1770 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1772 /* PublishProduct */
1773 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
1774 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1775 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1776 ok(pf_exists("msitest"), "File not installed\n");
1778 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1779 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1781 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1782 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1784 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1785 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1788 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1790 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1792 /* try to uninstall after PublishProduct */
1793 r = MsiInstallProductA(msifile, "REMOVE=ALL");
1794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1795 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1796 ok(pf_exists("msitest"), "File deleted\n");
1798 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1799 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1801 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1802 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1804 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1805 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1807 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1808 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1809 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1810 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1812 /* PublishProduct and RegisterProduct */
1813 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
1814 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1815 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1816 ok(pf_exists("msitest"), "File not installed\n");
1818 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1819 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1821 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1822 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1824 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1825 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1827 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1828 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1831 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1833 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1836 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
1837 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1838 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1839 ok(pf_exists("msitest"), "File not installed\n");
1841 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1844 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1847 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1848 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1850 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1851 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1853 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1854 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1855 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1856 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1858 /* uninstall has a problem with this */
1859 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
1862 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1864 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1865 ok(pf_exists("msitest"), "File deleted\n");
1867 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1868 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1870 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1873 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1876 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1877 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1878 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1881 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1884 /* PublishProduct and RegisterProduct and ProcessComponents */
1885 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
1886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1887 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1888 ok(pf_exists("msitest"), "File not installed\n");
1890 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1891 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1893 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1896 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1899 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1902 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1905 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1906 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1909 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1910 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1913 /* complete uninstall */
1914 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
1915 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1916 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1917 ok(pf_exists("msitest"), "File deleted\n");
1919 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1920 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1922 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1925 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1928 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1931 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1934 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1935 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1936 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1939 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1942 /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
1943 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
1944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1945 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1946 ok(pf_exists("msitest"), "File not installed\n");
1948 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1949 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1951 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1954 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1957 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1960 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1963 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1964 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1967 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1968 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
1971 /* complete uninstall */
1972 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
1973 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1976 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
1977 ok(!pf_exists("msitest"), "File deleted\n");
1980 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1981 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1983 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");\
1986 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1989 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1992 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1995 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1996 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1997 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2000 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2003 /* complete install */
2004 r = MsiInstallProductA(msifile, "FULL=1");
2005 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2006 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2007 ok(pf_exists("msitest"), "File not installed\n");
2009 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2010 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2012 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2015 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2018 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2021 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2024 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2025 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2028 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2029 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2032 /* no UnpublishFeatures */
2033 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2034 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2037 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2038 ok(!pf_exists("msitest"), "File deleted\n");
2041 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2042 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2044 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2047 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2050 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2053 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2056 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2057 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2058 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2061 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2064 /* complete install */
2065 r = MsiInstallProductA(msifile, "FULL=1");
2066 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2067 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2068 ok(pf_exists("msitest"), "File not installed\n");
2070 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2071 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2073 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2076 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2079 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2082 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2085 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2086 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2089 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2090 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2093 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
2094 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
2095 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2096 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2097 ok(pf_exists("msitest"), "File deleted\n");
2099 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2100 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2102 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2105 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2108 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2111 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2114 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2115 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2118 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2119 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2122 /* complete install */
2123 r = MsiInstallProductA(msifile, "FULL=1");
2124 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2125 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2126 ok(pf_exists("msitest"), "File not installed\n");
2128 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2129 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2131 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2134 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2137 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2140 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2143 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2144 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2147 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2148 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2151 /* UnpublishFeatures, both features removed */
2152 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
2153 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2156 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2157 ok(!pf_exists("msitest"), "File not deleted\n");
2160 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2161 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2163 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2166 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2169 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2172 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2175 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2176 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2177 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2180 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2183 /* complete install */
2184 r = MsiInstallProductA(msifile, "FULL=1");
2185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2186 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2187 ok(pf_exists("msitest"), "File not installed\n");
2189 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2190 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2192 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2195 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2198 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2201 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2204 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2205 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2209 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2212 /* complete uninstall */
2213 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2217 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2218 ok(!pf_exists("msitest"), "File not deleted\n");
2221 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2222 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2224 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2227 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2230 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2233 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2236 r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2237 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2238 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2241 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2244 /* make sure 'Program Files\msitest' is removed */
2245 delete_pfmsitest_files();
2247 DeleteFile(msifile);
2248 DeleteFile("msitest\\maximus");
2249 RemoveDirectory("msitest");
2252 static void test_publishsourcelist(void)
2256 CHAR value[MAX_PATH];
2257 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2259 CreateDirectoryA("msitest", NULL);
2260 create_file("msitest\\maximus", 500);
2262 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2264 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2266 r = MsiInstallProductA(msifile, NULL);
2267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2268 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2269 ok(pf_exists("msitest"), "File not installed\n");
2271 /* nothing published */
2273 r = MsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2274 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2275 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2276 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2278 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2280 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2281 ok(pf_exists("msitest"), "File not installed\n");
2283 /* after RegisterProduct */
2285 r = MsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2286 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2287 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2288 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2290 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2291 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2292 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2293 ok(pf_exists("msitest"), "File not installed\n");
2295 /* after ProcessComponents */
2297 r = MsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2298 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2299 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2300 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2302 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2304 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2305 ok(pf_exists("msitest"), "File not installed\n");
2307 /* after PublishFeatures */
2309 r = MsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2310 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2311 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2312 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2314 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2315 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2316 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2317 ok(pf_exists("msitest"), "File not installed\n");
2319 /* after PublishProduct */
2321 lstrcpyA(value, "aaa");
2322 r = MsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2323 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
2324 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2325 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
2326 ok(size == 11, "Expected 11, got %d\n", size);
2328 /* complete uninstall */
2329 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2330 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2333 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2334 ok(!pf_exists("msitest"), "File not deleted\n");
2337 /* make sure 'Program Files\msitest' is removed */
2338 delete_pfmsitest_files();
2340 DeleteFile(msifile);
2341 DeleteFile("msitest\\maximus");
2342 RemoveDirectory("msitest");
2345 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
2347 MSIHANDLE hview = 0;
2350 r = MsiDatabaseOpenView(hdb, query, &hview);
2351 if(r != ERROR_SUCCESS)
2354 r = MsiViewExecute(hview, hrec);
2355 if(r == ERROR_SUCCESS)
2356 r = MsiViewClose(hview);
2357 MsiCloseHandle(hview);
2361 static void set_transform_summary_info(void)
2366 /* build summmary info */
2367 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
2370 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
2373 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
2376 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2379 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
2380 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2381 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2382 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
2385 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
2388 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
2391 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2394 r = MsiSummaryInfoPersist(suminfo);
2397 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
2400 r = MsiCloseHandle(suminfo);
2403 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
2407 static void generate_transform(void)
2409 MSIHANDLE hdb1, hdb2;
2413 /* start with two identical databases */
2414 CopyFile(msifile, msifile2, FALSE);
2416 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
2417 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2419 r = MsiDatabaseCommit(hdb1);
2420 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
2422 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
2423 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2425 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2426 r = run_query(hdb1, 0, query);
2427 ok(r == ERROR_SUCCESS, "failed to add property\n");
2429 /* database needs to be committed */
2430 MsiDatabaseCommit(hdb1);
2432 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
2433 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
2435 #if 0 /* not implemented in wine yet */
2436 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
2437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2440 MsiCloseHandle(hdb1);
2441 MsiCloseHandle(hdb2);
2444 /* data for generating a transform */
2446 /* tables transform names - encoded as they would be in an msi database file */
2447 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
2448 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
2449 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
2451 /* data in each table */
2452 static const char data1[] = /* _StringData */
2453 "propval"; /* all the strings squashed together */
2455 static const WCHAR data2[] = { /* _StringPool */
2457 0, 0, /* string 0 '' */
2458 4, 1, /* string 1 'prop' */
2459 3, 1, /* string 2 'val' */
2462 static const WCHAR data3[] = { /* Property */
2463 0x0201, 0x0001, 0x0002,
2466 static const struct {
2470 } table_transform_data[] =
2472 { name1, data1, sizeof data1 - 1 },
2473 { name2, data2, sizeof data2 },
2474 { name3, data3, sizeof data3 },
2477 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
2479 static void generate_transform_manual(void)
2481 IStorage *stg = NULL;
2486 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
2488 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
2490 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
2492 r = StgCreateDocfile(name, mode, 0, &stg);
2493 ok(r == S_OK, "failed to create storage\n");
2497 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
2498 ok(r == S_OK, "failed to set storage type\n");
2500 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
2502 r = IStorage_CreateStream(stg, table_transform_data[i].name,
2503 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
2506 ok(0, "failed to create stream %08x\n", r);
2510 r = IStream_Write(stm, table_transform_data[i].data,
2511 table_transform_data[i].size, &count);
2512 if (FAILED(r) || count != table_transform_data[i].size)
2513 ok(0, "failed to write stream\n");
2514 IStream_Release(stm);
2517 IStorage_Release(stg);
2519 set_transform_summary_info();
2522 static void test_transformprop(void)
2526 CreateDirectoryA("msitest", NULL);
2527 create_file("msitest\\augustus", 500);
2529 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
2531 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2533 r = MsiInstallProductA(msifile, NULL);
2534 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2535 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2536 ok(!delete_pf("msitest", FALSE), "File installed\n");
2539 generate_transform();
2541 generate_transform_manual();
2543 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
2544 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2545 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2546 ok(delete_pf("msitest", FALSE), "File not installed\n");
2548 /* Delete the files in the temp (current) folder */
2549 DeleteFile(msifile);
2550 DeleteFile(msifile2);
2551 DeleteFile(mstfile);
2552 DeleteFile("msitest\\augustus");
2553 RemoveDirectory("msitest");
2556 static void test_currentworkingdir(void)
2559 CHAR path[MAX_PATH];
2562 CreateDirectoryA("msitest", NULL);
2563 create_file("msitest\\augustus", 500);
2565 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
2567 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2569 CreateDirectoryA("diffdir", NULL);
2570 SetCurrentDirectoryA("diffdir");
2572 sprintf(path, "..\\%s", msifile);
2573 r = MsiInstallProductA(path, NULL);
2576 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
2577 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2578 ok(!delete_pf("msitest", FALSE), "File installed\n");
2581 sprintf(path, "%s\\%s", CURR_DIR, msifile);
2582 r = MsiInstallProductA(path, NULL);
2583 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2584 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2585 ok(delete_pf("msitest", FALSE), "File not installed\n");
2587 lstrcpyA(path, CURR_DIR);
2588 if (path[lstrlenA(path) - 1] != '\\')
2589 lstrcatA(path, "\\");
2590 lstrcatA(path, "msitest.msi");
2592 ptr2 = strrchr(path, '\\');
2594 ptr = strrchr(path, '\\');
2598 SetCurrentDirectoryA(path);
2600 r = MsiInstallProductA(ptr, NULL);
2601 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2602 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2603 ok(delete_pf("msitest", FALSE), "File not installed\n");
2605 SetCurrentDirectoryA(CURR_DIR);
2607 DeleteFile(msifile);
2608 DeleteFile("msitest\\augustus");
2609 RemoveDirectory("msitest");
2610 RemoveDirectory("diffdir");
2613 static void set_admin_summary_info(const CHAR *name)
2615 MSIHANDLE db, summary;
2618 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
2619 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2621 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
2622 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2624 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
2625 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2627 /* write the summary changes back to the stream */
2628 r = MsiSummaryInfoPersist(summary);
2629 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2631 MsiCloseHandle(summary);
2633 r = MsiDatabaseCommit(db);
2634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2639 static void test_admin(void)
2643 CreateDirectoryA("msitest", NULL);
2644 create_file("msitest\\augustus", 500);
2646 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
2647 set_admin_summary_info(msifile);
2649 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2651 r = MsiInstallProductA(msifile, NULL);
2652 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2653 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2654 ok(!delete_pf("msitest", FALSE), "File installed\n");
2655 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
2656 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
2658 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
2659 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2660 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2661 ok(!delete_pf("msitest", FALSE), "File installed\n");
2664 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
2665 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
2668 DeleteFile(msifile);
2669 DeleteFile("msitest\\augustus");
2670 RemoveDirectory("msitest");
2673 static void set_admin_property_stream(LPCSTR file)
2677 WCHAR fileW[MAX_PATH];
2680 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
2682 /* AdminProperties */
2683 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
2684 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
2686 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
2688 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
2689 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2693 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
2694 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2696 hr = IStream_Write(stm, data, sizeof(data) - 1, &count);
2697 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2699 IStream_Release(stm);
2700 IStorage_Release(stg);
2703 static void test_adminprops(void)
2707 CreateDirectoryA("msitest", NULL);
2708 create_file("msitest\\augustus", 500);
2710 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
2711 set_admin_summary_info(msifile);
2712 set_admin_property_stream(msifile);
2714 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2716 r = MsiInstallProductA(msifile, NULL);
2717 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2718 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
2719 ok(delete_pf("msitest", FALSE), "File installed\n");
2721 DeleteFile(msifile);
2722 DeleteFile("msitest\\augustus");
2723 RemoveDirectory("msitest");
2729 char temp_path[MAX_PATH], prev_path[MAX_PATH];
2731 GetCurrentDirectoryA(MAX_PATH, prev_path);
2732 GetTempPath(MAX_PATH, temp_path);
2733 SetCurrentDirectoryA(temp_path);
2735 lstrcpyA(CURR_DIR, temp_path);
2736 len = lstrlenA(CURR_DIR);
2738 if(len && (CURR_DIR[len - 1] == '\\'))
2739 CURR_DIR[len - 1] = 0;
2741 get_program_files_dir(PROG_FILES_DIR);
2743 test_MsiInstallProduct();
2744 test_MsiSetComponentState();
2745 test_packagecoltypes();
2746 test_continuouscabs();
2749 test_samesequence();
2750 test_uiLevelFlags();
2751 test_readonlyfile();
2752 test_setdirproperty();
2753 test_cabisextracted();
2754 test_concurrentinstall();
2755 test_setpropertyfolder();
2757 test_publishsourcelist();
2758 test_transformprop();
2759 test_currentworkingdir();
2763 SetCurrentDirectoryA(prev_path);