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 pMsiQueryComponentStateA = (void*)GetProcAddress(hmsi, "MsiQueryComponentStateA");
873 pMsiSourceListGetInfoA = (void*)GetProcAddress(hmsi, "MsiSourceListGetInfoA");
876 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
883 r = MsiRecordGetString(rec, field, buffer, &sz);
884 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
887 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
891 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
892 GetTempFileNameA(".", "xx", 0, tempname);
894 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
896 lstrcpyA(pszTempName, tempname);
897 HeapFree(GetProcessHeap(), 0, tempname);
901 HeapFree(GetProcessHeap(), 0, tempname);
906 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
907 USHORT *pattribs, int *err, void *pv)
909 BY_HANDLE_FILE_INFORMATION finfo;
915 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
916 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
918 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
920 res = GetFileInformationByHandle(handle, &finfo);
921 ok(res, "Expected GetFileInformationByHandle to succeed\n");
923 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
924 FileTimeToDosDateTime(&filetime, pdate, ptime);
926 attrs = GetFileAttributes(pszName);
927 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
929 return (INT_PTR)handle;
932 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
935 char filename[MAX_PATH];
937 lstrcpyA(path, CURR_DIR);
938 lstrcatA(path, "\\");
939 lstrcatA(path, file);
941 lstrcpyA(filename, file);
943 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
944 progress, get_open_info, compress);
947 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
949 ZeroMemory(pCabParams, sizeof(CCAB));
951 pCabParams->cb = max_size;
952 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
953 pCabParams->setID = 0xbeef;
954 pCabParams->iCab = 1;
955 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
956 lstrcatA(pCabParams->szCabPath, "\\");
957 lstrcpyA(pCabParams->szCab, name);
960 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
968 set_cab_parameters(&cabParams, name, max_size);
970 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
971 fci_read, fci_write, fci_close, fci_seek, fci_delete,
972 get_temp_file, &cabParams, NULL);
974 ok(hfci != NULL, "Failed to create an FCI context\n");
979 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
980 ok(res, "Failed to add file: %s\n", ptr);
981 ptr += lstrlen(ptr) + 1;
984 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
985 ok(res, "Failed to flush the cabinet\n");
987 res = FCIDestroy(hfci);
988 ok(res, "Failed to destroy the cabinet\n");
991 static BOOL get_program_files_dir(LPSTR buf)
994 DWORD type = REG_EXPAND_SZ, size;
996 if (RegOpenKey(HKEY_LOCAL_MACHINE,
997 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
1001 if (RegQueryValueEx(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size))
1008 static void create_file(const CHAR *name, DWORD size)
1011 DWORD written, left;
1013 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1014 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1015 WriteFile(file, name, strlen(name), &written, NULL);
1016 WriteFile(file, "\n", strlen("\n"), &written, NULL);
1018 left = size - lstrlen(name) - 1;
1020 SetFilePointer(file, left, NULL, FILE_CURRENT);
1026 static void create_test_files(void)
1028 CreateDirectoryA("msitest", NULL);
1029 create_file("msitest\\one.txt", 100);
1030 CreateDirectoryA("msitest\\first", NULL);
1031 create_file("msitest\\first\\two.txt", 100);
1032 CreateDirectoryA("msitest\\second", NULL);
1033 create_file("msitest\\second\\three.txt", 100);
1035 create_file("four.txt", 100);
1036 create_file("five.txt", 100);
1037 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1039 create_file("msitest\\filename", 100);
1040 create_file("msitest\\service.exe", 100);
1042 DeleteFileA("four.txt");
1043 DeleteFileA("five.txt");
1046 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
1048 CHAR path[MAX_PATH];
1050 lstrcpyA(path, PROG_FILES_DIR);
1051 lstrcatA(path, "\\");
1052 lstrcatA(path, rel_path);
1055 return DeleteFileA(path);
1057 return RemoveDirectoryA(path);
1060 static void delete_test_files(void)
1062 DeleteFileA("msitest.msi");
1063 DeleteFileA("msitest.cab");
1064 DeleteFileA("msitest\\second\\three.txt");
1065 DeleteFileA("msitest\\first\\two.txt");
1066 DeleteFileA("msitest\\one.txt");
1067 DeleteFileA("msitest\\service.exe");
1068 DeleteFileA("msitest\\filename");
1069 RemoveDirectoryA("msitest\\second");
1070 RemoveDirectoryA("msitest\\first");
1071 RemoveDirectoryA("msitest");
1074 static void write_file(const CHAR *filename, const char *data, int data_size)
1078 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1079 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1081 WriteFile(hf, data, data_size, &size, NULL);
1085 static void write_msi_summary_info(MSIHANDLE db)
1090 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1093 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1096 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1097 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1098 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1100 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1103 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1106 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1107 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1109 /* write the summary changes back to the stream */
1110 r = MsiSummaryInfoPersist(summary);
1111 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1113 MsiCloseHandle(summary);
1116 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1122 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1123 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1125 /* import the tables into the database */
1126 for (j = 0; j < num_tables; j++)
1128 const msi_table *table = &tables[j];
1130 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1132 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1133 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1135 DeleteFileA(table->filename);
1138 write_msi_summary_info(db);
1140 r = MsiDatabaseCommit(db);
1141 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1146 static void check_service_is_installed(void)
1148 SC_HANDLE scm, service;
1151 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1152 ok(scm != NULL, "Failed to open the SC Manager\n");
1154 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1155 ok(service != NULL, "Failed to open TestService\n");
1157 res = DeleteService(service);
1158 ok(res, "Failed to delete TestService\n");
1161 static void test_MsiInstallProduct(void)
1164 CHAR path[MAX_PATH];
1167 DWORD num, size, type;
1169 create_test_files();
1170 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1172 r = MsiInstallProductA(msifile, NULL);
1173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1175 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1176 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1177 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1178 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1179 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1180 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1181 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1182 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1183 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1184 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1185 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1186 ok(delete_pf("msitest", FALSE), "File not installed\n");
1188 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1189 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1193 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1194 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1195 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1199 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1200 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1204 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1205 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1206 ok(num == 314, "Expected 314, got %d\n", num);
1210 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1211 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1212 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1214 check_service_is_installed();
1216 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1218 delete_test_files();
1221 static void test_MsiSetComponentState(void)
1223 INSTALLSTATE installed, action;
1225 char path[MAX_PATH];
1228 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1232 lstrcpy(path, CURR_DIR);
1233 lstrcat(path, "\\");
1234 lstrcat(path, msifile);
1236 r = MsiOpenPackage(path, &package);
1237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1239 r = MsiDoAction(package, "CostInitialize");
1240 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1242 r = MsiDoAction(package, "FileCost");
1243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1245 r = MsiDoAction(package, "CostFinalize");
1246 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1248 r = MsiGetComponentState(package, "dangler", &installed, &action);
1249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1250 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1251 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1253 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1256 MsiCloseHandle(package);
1259 DeleteFileA(msifile);
1262 static void test_packagecoltypes(void)
1264 MSIHANDLE hdb, view, rec;
1265 char path[MAX_PATH];
1269 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1273 lstrcpy(path, CURR_DIR);
1274 lstrcat(path, "\\");
1275 lstrcat(path, msifile);
1277 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1278 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1280 query = "SELECT * FROM `Media`";
1281 r = MsiDatabaseOpenView( hdb, query, &view );
1282 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1284 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1285 count = MsiRecordGetFieldCount( rec );
1286 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1287 ok(count == 6, "Expected 6, got %d\n", count);
1288 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1289 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1290 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1291 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1292 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1293 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1294 MsiCloseHandle(rec);
1296 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1297 count = MsiRecordGetFieldCount( rec );
1298 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1299 ok(count == 6, "Expected 6, got %d\n", count);
1300 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1301 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1302 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1303 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1304 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1305 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1307 MsiCloseHandle(rec);
1308 MsiCloseHandle(view);
1309 MsiCloseHandle(hdb);
1310 DeleteFile(msifile);
1313 static void create_cc_test_files(void)
1318 static CHAR cab_context[] = "test%d.cab";
1321 create_file("maximus", 500);
1322 create_file("augustus", 50000);
1323 create_file("caesar", 500);
1325 set_cab_parameters(&cabParams, "test1.cab", 200);
1327 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1328 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1329 get_temp_file, &cabParams, cab_context);
1330 ok(hfci != NULL, "Failed to create an FCI context\n");
1332 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1333 ok(res, "Failed to add file maximus\n");
1335 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1336 ok(res, "Failed to add file augustus\n");
1338 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1339 ok(res, "Failed to flush the cabinet\n");
1341 res = FCIDestroy(hfci);
1342 ok(res, "Failed to destroy the cabinet\n");
1344 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1346 DeleteFile("maximus");
1347 DeleteFile("augustus");
1348 DeleteFile("caesar");
1351 static void delete_cab_files(void)
1353 SHFILEOPSTRUCT shfl;
1354 CHAR path[MAX_PATH+10];
1356 lstrcpyA(path, CURR_DIR);
1357 lstrcatA(path, "\\*.cab");
1358 path[strlen(path) + 1] = '\0';
1361 shfl.wFunc = FO_DELETE;
1364 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1366 SHFileOperation(&shfl);
1369 static void test_continuouscabs(void)
1373 create_cc_test_files();
1374 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1376 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1378 r = MsiInstallProductA(msifile, NULL);
1379 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1383 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1384 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1386 ok(delete_pf("msitest", FALSE), "File not installed\n");
1389 DeleteFile(msifile);
1392 static void test_caborder(void)
1396 create_file("imperator", 100);
1397 create_file("maximus", 500);
1398 create_file("augustus", 50000);
1399 create_file("caesar", 500);
1401 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1403 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1405 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1406 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1407 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1409 r = MsiInstallProductA(msifile, NULL);
1410 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1411 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1412 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1415 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1416 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1421 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1422 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1423 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1425 r = MsiInstallProductA(msifile, NULL);
1426 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1427 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1428 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1429 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1432 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1436 DeleteFile(msifile);
1438 create_cc_test_files();
1439 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1441 r = MsiInstallProductA(msifile, NULL);
1442 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1443 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1444 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1447 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1448 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1452 DeleteFile(msifile);
1454 create_cc_test_files();
1455 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1457 r = MsiInstallProductA(msifile, NULL);
1458 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1459 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1462 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1463 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1464 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1468 DeleteFile("imperator");
1469 DeleteFile("maximus");
1470 DeleteFile("augustus");
1471 DeleteFile("caesar");
1472 DeleteFile(msifile);
1475 static void test_mixedmedia(void)
1479 CreateDirectoryA("msitest", NULL);
1480 create_file("msitest\\maximus", 500);
1481 create_file("msitest\\augustus", 500);
1482 create_file("caesar", 500);
1484 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1486 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1488 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1490 r = MsiInstallProductA(msifile, NULL);
1491 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1492 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1493 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1494 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1495 ok(delete_pf("msitest", FALSE), "File not installed\n");
1497 /* Delete the files in the temp (current) folder */
1498 DeleteFile("msitest\\maximus");
1499 DeleteFile("msitest\\augustus");
1500 RemoveDirectory("msitest");
1501 DeleteFile("caesar");
1502 DeleteFile("test1.cab");
1503 DeleteFile(msifile);
1506 static void test_samesequence(void)
1510 create_cc_test_files();
1511 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1513 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1515 r = MsiInstallProductA(msifile, NULL);
1518 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1519 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1520 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1522 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1523 ok(delete_pf("msitest", FALSE), "File not installed\n");
1526 DeleteFile(msifile);
1529 static void test_uiLevelFlags(void)
1533 create_cc_test_files();
1534 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1536 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1538 r = MsiInstallProductA(msifile, NULL);
1539 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1542 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1543 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1545 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1546 ok(delete_pf("msitest", FALSE), "File not installed\n");
1549 DeleteFile(msifile);
1552 static BOOL file_matches(LPSTR path)
1558 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1559 NULL, OPEN_EXISTING, 0, NULL);
1561 ZeroMemory(buf, MAX_PATH);
1562 ReadFile(file, buf, 15, &size, NULL);
1565 return !lstrcmp(buf, "msitest\\maximus");
1568 static void test_readonlyfile(void)
1573 CHAR path[MAX_PATH];
1575 CreateDirectoryA("msitest", NULL);
1576 create_file("msitest\\maximus", 500);
1577 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1579 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1581 lstrcpy(path, PROG_FILES_DIR);
1582 lstrcat(path, "\\msitest");
1583 CreateDirectory(path, NULL);
1585 lstrcat(path, "\\maximus");
1586 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1587 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1589 WriteFile(file, "readonlyfile", 20, &size, NULL);
1592 r = MsiInstallProductA(msifile, NULL);
1593 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1594 ok(file_matches(path), "Expected file to be overwritten\n");
1595 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1596 ok(delete_pf("msitest", FALSE), "File not installed\n");
1598 /* Delete the files in the temp (current) folder */
1599 DeleteFile("msitest\\maximus");
1600 RemoveDirectory("msitest");
1601 DeleteFile(msifile);
1604 static void test_setdirproperty(void)
1608 CreateDirectoryA("msitest", NULL);
1609 create_file("msitest\\maximus", 500);
1610 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1612 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1614 r = MsiInstallProductA(msifile, NULL);
1615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1616 ok(delete_pf("Common Files\\msitest\\maximus", TRUE), "File not installed\n");
1617 ok(delete_pf("Common Files\\msitest", FALSE), "File not installed\n");
1619 /* Delete the files in the temp (current) folder */
1620 DeleteFile(msifile);
1621 DeleteFile("msitest\\maximus");
1622 RemoveDirectory("msitest");
1625 static void test_cabisextracted(void)
1629 CreateDirectoryA("msitest", NULL);
1630 create_file("msitest\\gaius", 500);
1631 create_file("maximus", 500);
1632 create_file("augustus", 500);
1633 create_file("caesar", 500);
1635 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1636 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1637 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1639 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1641 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1643 r = MsiInstallProductA(msifile, NULL);
1644 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1645 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1646 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1647 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1648 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1649 ok(delete_pf("msitest", FALSE), "File not installed\n");
1651 /* Delete the files in the temp (current) folder */
1653 DeleteFile(msifile);
1654 DeleteFile("maximus");
1655 DeleteFile("augustus");
1656 DeleteFile("caesar");
1657 DeleteFile("msitest\\gaius");
1658 RemoveDirectory("msitest");
1661 static void test_concurrentinstall(void)
1664 CHAR path[MAX_PATH];
1666 CreateDirectoryA("msitest", NULL);
1667 CreateDirectoryA("msitest\\msitest", NULL);
1668 create_file("msitest\\maximus", 500);
1669 create_file("msitest\\msitest\\augustus", 500);
1671 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1673 lstrcpyA(path, CURR_DIR);
1674 lstrcatA(path, "\\msitest\\concurrent.msi");
1675 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1677 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1679 r = MsiInstallProductA(msifile, NULL);
1680 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1681 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1682 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1683 ok(delete_pf("msitest", FALSE), "File not installed\n");
1685 /* Delete the files in the temp (current) folder */
1686 DeleteFile(msifile);
1688 DeleteFile("msitest\\msitest\\augustus");
1689 DeleteFile("msitest\\maximus");
1690 RemoveDirectory("msitest\\msitest");
1691 RemoveDirectory("msitest");
1694 static void test_setpropertyfolder(void)
1698 CreateDirectoryA("msitest", NULL);
1699 create_file("msitest\\maximus", 500);
1701 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1703 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1705 r = MsiInstallProductA(msifile, NULL);
1706 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1707 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1708 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1709 ok(delete_pf("msitest", FALSE), "File not installed\n");
1711 /* Delete the files in the temp (current) folder */
1712 DeleteFile(msifile);
1713 DeleteFile("msitest\\maximus");
1714 RemoveDirectory("msitest");
1717 static BOOL file_exists(LPCSTR file)
1719 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
1722 static BOOL pf_exists(LPCSTR file)
1724 CHAR path[MAX_PATH];
1726 lstrcpyA(path, PROG_FILES_DIR);
1727 lstrcatA(path, "\\");
1728 lstrcatA(path, file);
1730 return file_exists(path);
1733 static void delete_pfmsitest_files(void)
1735 SHFILEOPSTRUCT shfl;
1736 CHAR path[MAX_PATH+10];
1738 lstrcpyA(path, PROG_FILES_DIR);
1739 lstrcatA(path, "\\msitest\\*");
1740 path[strlen(path) + 1] = '\0';
1743 shfl.wFunc = FO_DELETE;
1746 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1748 SHFileOperation(&shfl);
1750 lstrcpyA(path, PROG_FILES_DIR);
1751 lstrcatA(path, "\\msitest");
1752 RemoveDirectoryA(path);
1755 static void test_publish(void)
1759 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
1761 CreateDirectoryA("msitest", NULL);
1762 create_file("msitest\\maximus", 500);
1764 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
1766 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1768 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1769 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1771 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1772 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1774 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1775 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1777 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1778 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1779 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1780 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1782 /* nothing published */
1783 r = MsiInstallProductA(msifile, NULL);
1784 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1785 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1786 ok(pf_exists("msitest"), "File not installed\n");
1788 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1789 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1791 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1792 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1794 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1795 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1797 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1798 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1799 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1800 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1803 r = MsiInstallProductA(msifile, NULL);
1804 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1805 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1806 ok(pf_exists("msitest"), "File not installed\n");
1808 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1809 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1811 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1812 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1814 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1815 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1817 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1818 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1819 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1820 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1822 /* try to uninstall */
1823 r = MsiInstallProductA(msifile, "REMOVE=ALL");
1826 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1828 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1829 ok(pf_exists("msitest"), "File deleted\n");
1831 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1832 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1834 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1835 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1837 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1838 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1840 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1841 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1842 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1843 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1845 /* PublishProduct */
1846 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
1847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1848 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1849 ok(pf_exists("msitest"), "File not installed\n");
1851 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1852 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
1854 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1855 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1857 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1858 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1859 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1860 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1862 /* try to uninstall after PublishProduct */
1863 r = MsiInstallProductA(msifile, "REMOVE=ALL");
1864 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1865 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1866 ok(pf_exists("msitest"), "File deleted\n");
1868 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1869 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1871 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1872 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1874 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1875 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1877 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1878 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1879 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1880 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1882 /* PublishProduct and RegisterProduct */
1883 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
1884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1885 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1886 ok(pf_exists("msitest"), "File not installed\n");
1888 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1889 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1891 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1892 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1894 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1895 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1897 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1898 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1899 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
1900 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1903 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
1904 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1905 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1906 ok(pf_exists("msitest"), "File not installed\n");
1908 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1911 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1914 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1915 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1917 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1918 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1920 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1921 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1924 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1926 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1928 /* uninstall has a problem with this */
1929 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
1932 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1934 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1935 ok(pf_exists("msitest"), "File deleted\n");
1937 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1938 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1940 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1941 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1943 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1944 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1945 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1946 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1948 /* PublishProduct and RegisterProduct and ProcessComponents */
1949 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
1950 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1951 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1952 ok(pf_exists("msitest"), "File not installed\n");
1954 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1955 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
1957 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1958 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1960 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1961 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1963 r = pMsiQueryComponentStateA(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);
1974 ok(pf_exists("msitest\\maximus"), "File deleted\n");
1975 ok(pf_exists("msitest"), "File deleted\n");
1977 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1978 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1980 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1981 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1983 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1984 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1986 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1987 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1988 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1989 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1991 /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
1992 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
1993 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1994 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1995 ok(pf_exists("msitest"), "File not installed\n");
1997 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1998 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2000 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2003 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2006 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2009 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2012 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2013 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2016 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2017 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2020 /* complete uninstall */
2021 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2022 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2025 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2026 ok(!pf_exists("msitest"), "File deleted\n");
2029 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2030 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2032 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");\
2033 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2035 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2036 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2038 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2039 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2040 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2041 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2043 /* complete install */
2044 r = MsiInstallProductA(msifile, "FULL=1");
2045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2046 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2047 ok(pf_exists("msitest"), "File not installed\n");
2049 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2050 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2052 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2055 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2058 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2061 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2064 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2065 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2069 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2072 /* no UnpublishFeatures */
2073 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2077 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2078 ok(!pf_exists("msitest"), "File deleted\n");
2081 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2082 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2084 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2085 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2087 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2088 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2090 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2091 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2092 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2093 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2095 /* complete install */
2096 r = MsiInstallProductA(msifile, "FULL=1");
2097 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2098 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2099 ok(pf_exists("msitest"), "File not installed\n");
2101 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2102 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2104 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2107 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2110 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2113 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2116 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2117 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2120 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2121 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2124 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
2125 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
2126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2127 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2128 ok(pf_exists("msitest"), "File deleted\n");
2130 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2131 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2133 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2136 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2139 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2142 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2145 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2146 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2150 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2153 /* complete install */
2154 r = MsiInstallProductA(msifile, "FULL=1");
2155 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2156 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2157 ok(pf_exists("msitest"), "File not installed\n");
2159 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2160 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2162 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2165 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2168 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2171 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2174 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2175 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2178 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2179 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2182 /* UnpublishFeatures, both features removed */
2183 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
2184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2187 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2188 ok(!pf_exists("msitest"), "File not deleted\n");
2191 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2192 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2194 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2195 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2197 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2198 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2200 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2201 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2202 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2203 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2205 /* complete install */
2206 r = MsiInstallProductA(msifile, "FULL=1");
2207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2208 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2209 ok(pf_exists("msitest"), "File not installed\n");
2211 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2212 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2214 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2217 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2220 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2223 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2226 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2227 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2230 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2231 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2234 /* complete uninstall */
2235 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2239 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2240 ok(!pf_exists("msitest"), "File not deleted\n");
2243 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2244 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2246 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2247 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2249 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2250 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2252 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2253 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2254 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2255 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2257 /* make sure 'Program Files\msitest' is removed */
2258 delete_pfmsitest_files();
2260 DeleteFile(msifile);
2261 DeleteFile("msitest\\maximus");
2262 RemoveDirectory("msitest");
2265 static void test_publishsourcelist(void)
2269 CHAR value[MAX_PATH];
2270 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2272 CreateDirectoryA("msitest", NULL);
2273 create_file("msitest\\maximus", 500);
2275 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2277 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2279 r = MsiInstallProductA(msifile, NULL);
2280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2281 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2282 ok(pf_exists("msitest"), "File not installed\n");
2284 /* nothing published */
2286 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2287 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2288 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2289 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2291 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2292 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2293 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2294 ok(pf_exists("msitest"), "File not installed\n");
2296 /* after RegisterProduct */
2298 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2299 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2300 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2301 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2303 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2304 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2305 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2306 ok(pf_exists("msitest"), "File not installed\n");
2308 /* after ProcessComponents */
2310 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2311 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2312 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2313 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2315 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2317 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2318 ok(pf_exists("msitest"), "File not installed\n");
2320 /* after PublishFeatures */
2322 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2323 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2324 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2325 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2327 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2328 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2329 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2330 ok(pf_exists("msitest"), "File not installed\n");
2332 /* after PublishProduct */
2334 lstrcpyA(value, "aaa");
2335 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2336 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
2337 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2338 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
2339 ok(size == 11, "Expected 11, got %d\n", size);
2341 /* complete uninstall */
2342 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2346 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2347 ok(!pf_exists("msitest"), "File not deleted\n");
2350 /* make sure 'Program Files\msitest' is removed */
2351 delete_pfmsitest_files();
2353 DeleteFile(msifile);
2354 DeleteFile("msitest\\maximus");
2355 RemoveDirectory("msitest");
2358 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
2360 MSIHANDLE hview = 0;
2363 r = MsiDatabaseOpenView(hdb, query, &hview);
2364 if(r != ERROR_SUCCESS)
2367 r = MsiViewExecute(hview, hrec);
2368 if(r == ERROR_SUCCESS)
2369 r = MsiViewClose(hview);
2370 MsiCloseHandle(hview);
2374 static void set_transform_summary_info(void)
2379 /* build summmary info */
2380 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
2383 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
2386 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
2389 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2392 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
2393 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2394 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2395 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
2398 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
2401 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
2404 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2407 r = MsiSummaryInfoPersist(suminfo);
2410 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
2413 r = MsiCloseHandle(suminfo);
2416 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
2420 static void generate_transform(void)
2422 MSIHANDLE hdb1, hdb2;
2426 /* start with two identical databases */
2427 CopyFile(msifile, msifile2, FALSE);
2429 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
2430 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2432 r = MsiDatabaseCommit(hdb1);
2433 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
2435 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
2436 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2438 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2439 r = run_query(hdb1, 0, query);
2440 ok(r == ERROR_SUCCESS, "failed to add property\n");
2442 /* database needs to be committed */
2443 MsiDatabaseCommit(hdb1);
2445 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
2446 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
2448 #if 0 /* not implemented in wine yet */
2449 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
2450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2453 MsiCloseHandle(hdb1);
2454 MsiCloseHandle(hdb2);
2457 /* data for generating a transform */
2459 /* tables transform names - encoded as they would be in an msi database file */
2460 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
2461 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
2462 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
2464 /* data in each table */
2465 static const char data1[] = /* _StringData */
2466 "propval"; /* all the strings squashed together */
2468 static const WCHAR data2[] = { /* _StringPool */
2470 0, 0, /* string 0 '' */
2471 4, 1, /* string 1 'prop' */
2472 3, 1, /* string 2 'val' */
2475 static const WCHAR data3[] = { /* Property */
2476 0x0201, 0x0001, 0x0002,
2479 static const struct {
2483 } table_transform_data[] =
2485 { name1, data1, sizeof data1 - 1 },
2486 { name2, data2, sizeof data2 },
2487 { name3, data3, sizeof data3 },
2490 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
2492 static void generate_transform_manual(void)
2494 IStorage *stg = NULL;
2499 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
2501 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
2503 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
2505 r = StgCreateDocfile(name, mode, 0, &stg);
2506 ok(r == S_OK, "failed to create storage\n");
2510 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
2511 ok(r == S_OK, "failed to set storage type\n");
2513 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
2515 r = IStorage_CreateStream(stg, table_transform_data[i].name,
2516 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
2519 ok(0, "failed to create stream %08x\n", r);
2523 r = IStream_Write(stm, table_transform_data[i].data,
2524 table_transform_data[i].size, &count);
2525 if (FAILED(r) || count != table_transform_data[i].size)
2526 ok(0, "failed to write stream\n");
2527 IStream_Release(stm);
2530 IStorage_Release(stg);
2532 set_transform_summary_info();
2535 static void test_transformprop(void)
2539 CreateDirectoryA("msitest", NULL);
2540 create_file("msitest\\augustus", 500);
2542 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
2544 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2546 r = MsiInstallProductA(msifile, NULL);
2547 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2548 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2549 ok(!delete_pf("msitest", FALSE), "File installed\n");
2552 generate_transform();
2554 generate_transform_manual();
2556 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
2557 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2558 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2559 ok(delete_pf("msitest", FALSE), "File not installed\n");
2561 /* Delete the files in the temp (current) folder */
2562 DeleteFile(msifile);
2563 DeleteFile(msifile2);
2564 DeleteFile(mstfile);
2565 DeleteFile("msitest\\augustus");
2566 RemoveDirectory("msitest");
2569 static void test_currentworkingdir(void)
2572 CHAR path[MAX_PATH];
2575 CreateDirectoryA("msitest", NULL);
2576 create_file("msitest\\augustus", 500);
2578 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
2580 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2582 CreateDirectoryA("diffdir", NULL);
2583 SetCurrentDirectoryA("diffdir");
2585 sprintf(path, "..\\%s", msifile);
2586 r = MsiInstallProductA(path, NULL);
2589 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
2590 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2591 ok(!delete_pf("msitest", FALSE), "File installed\n");
2594 sprintf(path, "%s\\%s", CURR_DIR, msifile);
2595 r = MsiInstallProductA(path, NULL);
2596 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2597 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2598 ok(delete_pf("msitest", FALSE), "File not installed\n");
2600 lstrcpyA(path, CURR_DIR);
2601 if (path[lstrlenA(path) - 1] != '\\')
2602 lstrcatA(path, "\\");
2603 lstrcatA(path, "msitest.msi");
2605 ptr2 = strrchr(path, '\\');
2607 ptr = strrchr(path, '\\');
2611 SetCurrentDirectoryA(path);
2613 r = MsiInstallProductA(ptr, NULL);
2614 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2615 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
2616 ok(delete_pf("msitest", FALSE), "File not installed\n");
2618 SetCurrentDirectoryA(CURR_DIR);
2620 DeleteFile(msifile);
2621 DeleteFile("msitest\\augustus");
2622 RemoveDirectory("msitest");
2623 RemoveDirectory("diffdir");
2626 static void set_admin_summary_info(const CHAR *name)
2628 MSIHANDLE db, summary;
2631 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
2632 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2634 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
2635 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2637 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
2638 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2640 /* write the summary changes back to the stream */
2641 r = MsiSummaryInfoPersist(summary);
2642 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2644 MsiCloseHandle(summary);
2646 r = MsiDatabaseCommit(db);
2647 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2652 static void test_admin(void)
2656 CreateDirectoryA("msitest", NULL);
2657 create_file("msitest\\augustus", 500);
2659 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
2660 set_admin_summary_info(msifile);
2662 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2664 r = MsiInstallProductA(msifile, NULL);
2665 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2666 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
2667 ok(!delete_pf("msitest", FALSE), "File installed\n");
2668 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
2669 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
2671 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
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");
2677 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
2678 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
2681 DeleteFile(msifile);
2682 DeleteFile("msitest\\augustus");
2683 RemoveDirectory("msitest");
2686 static void set_admin_property_stream(LPCSTR file)
2690 WCHAR fileW[MAX_PATH];
2693 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
2695 /* AdminProperties */
2696 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
2697 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
2699 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
2701 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
2702 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2706 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
2707 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2709 hr = IStream_Write(stm, data, sizeof(data) - 1, &count);
2710 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
2712 IStream_Release(stm);
2713 IStorage_Release(stg);
2716 static void test_adminprops(void)
2720 CreateDirectoryA("msitest", NULL);
2721 create_file("msitest\\augustus", 500);
2723 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
2724 set_admin_summary_info(msifile);
2725 set_admin_property_stream(msifile);
2727 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
2729 r = MsiInstallProductA(msifile, NULL);
2730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2731 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
2732 ok(delete_pf("msitest", FALSE), "File installed\n");
2734 DeleteFile(msifile);
2735 DeleteFile("msitest\\augustus");
2736 RemoveDirectory("msitest");
2739 static void create_pf(LPCSTR file, BOOL is_file)
2741 CHAR path[MAX_PATH];
2743 lstrcpyA(path, PROG_FILES_DIR);
2744 lstrcatA(path, "\\");
2745 lstrcatA(path, file);
2748 create_file(path, 500);
2750 CreateDirectoryA(path, NULL);
2753 static void test_removefiles(void)
2757 CreateDirectoryA("msitest", NULL);
2758 create_file("msitest\\hydrogen", 500);
2759 create_file("msitest\\helium", 500);
2760 create_file("msitest\\lithium", 500);
2762 create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
2764 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2766 r = MsiInstallProductA(msifile, NULL);
2767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2768 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
2769 ok(!pf_exists("msitest\\helium"), "File installed\n");
2770 ok(pf_exists("msitest\\lithium"), "File not installed\n");
2771 ok(pf_exists("msitest"), "File not installed\n");
2773 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2774 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2775 ok(!pf_exists("msitest\\helium"), "File not deleted\n");
2776 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
2779 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
2780 ok(delete_pf("msitest", FALSE), "File deleted\n");
2783 create_pf("msitest", FALSE);
2784 create_pf("msitest\\hydrogen", TRUE);
2785 create_pf("msitest\\helium", TRUE);
2786 create_pf("msitest\\lithium", TRUE);
2788 r = MsiInstallProductA(msifile, NULL);
2789 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2790 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
2791 ok(pf_exists("msitest\\helium"), "File not installed\n");
2792 ok(pf_exists("msitest\\lithium"), "File not installed\n");
2793 ok(pf_exists("msitest"), "File not installed\n");
2795 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2797 ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
2798 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
2801 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
2802 ok(delete_pf("msitest", FALSE), "File deleted\n");
2805 create_pf("msitest", FALSE);
2806 create_pf("msitest\\furlong", TRUE);
2807 create_pf("msitest\\firkin", TRUE);
2808 create_pf("msitest\\fortnight", TRUE);
2809 create_pf("msitest\\becquerel", TRUE);
2810 create_pf("msitest\\dioptre", TRUE);
2811 create_pf("msitest\\attoparsec", TRUE);
2812 create_pf("msitest\\storeys", TRUE);
2813 create_pf("msitest\\block", TRUE);
2814 create_pf("msitest\\siriometer", TRUE);
2816 r = MsiInstallProductA(msifile, NULL);
2817 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2818 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
2819 ok(!pf_exists("msitest\\helium"), "File installed\n");
2820 ok(pf_exists("msitest\\lithium"), "File not installed\n");
2821 ok(pf_exists("msitest\\becquerel"), "File not installed\n");
2822 ok(pf_exists("msitest\\dioptre"), "File not installed\n");
2823 ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
2824 ok(pf_exists("msitest"), "File not installed\n");
2827 ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
2828 ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
2829 ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
2830 ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
2831 ok(!pf_exists("msitest\\block"), "File not deleted\n");
2832 ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
2835 create_pf("msitest\\furlong", TRUE);
2836 create_pf("msitest\\firkin", TRUE);
2837 create_pf("msitest\\fortnight", TRUE);
2838 create_pf("msitest\\storeys", TRUE);
2839 create_pf("msitest\\block", TRUE);
2840 create_pf("msitest\\siriometer", TRUE);
2842 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2843 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2844 ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
2845 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
2846 ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
2847 ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
2848 ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
2849 ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
2850 ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
2853 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
2854 ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
2855 ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
2856 ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
2857 ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
2859 ok(delete_pf("msitest", FALSE), "File deleted\n");
2861 DeleteFile(msifile);
2862 DeleteFile("msitest\\hydrogen");
2863 DeleteFile("msitest\\helium");
2864 DeleteFile("msitest\\lithium");
2865 RemoveDirectory("msitest");
2871 char temp_path[MAX_PATH], prev_path[MAX_PATH];
2873 init_functionpointers();
2875 GetCurrentDirectoryA(MAX_PATH, prev_path);
2876 GetTempPath(MAX_PATH, temp_path);
2877 SetCurrentDirectoryA(temp_path);
2879 lstrcpyA(CURR_DIR, temp_path);
2880 len = lstrlenA(CURR_DIR);
2882 if(len && (CURR_DIR[len - 1] == '\\'))
2883 CURR_DIR[len - 1] = 0;
2885 get_program_files_dir(PROG_FILES_DIR);
2887 test_MsiInstallProduct();
2888 test_MsiSetComponentState();
2889 test_packagecoltypes();
2890 test_continuouscabs();
2893 test_samesequence();
2894 test_uiLevelFlags();
2895 test_readonlyfile();
2896 test_setdirproperty();
2897 test_cabisextracted();
2898 test_concurrentinstall();
2899 test_setpropertyfolder();
2901 test_publishsourcelist();
2902 test_transformprop();
2903 test_currentworkingdir();
2908 SetCurrentDirectoryA(prev_path);