b5892c0880e7c0409078fa9e39c37fcb5988f305
[reactos.git] / rostests / winetests / msi / install.c
1 /*
2 * Copyright (C) 2006 James Hawkins
3 *
4 * A test program for installing MSI products.
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #define _WIN32_MSI 300
22 #define COBJMACROS
23
24 #include <stdio.h>
25
26 #include <windows.h>
27 #include <msiquery.h>
28 #include <msidefs.h>
29 #include <msi.h>
30 #include <fci.h>
31 #include <objidl.h>
32
33 #include "wine/test.h"
34
35 static UINT (WINAPI *pMsiQueryComponentStateA)
36 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
37 static UINT (WINAPI *pMsiSourceListGetInfoA)
38 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
39
40 static const char *msifile = "msitest.msi";
41 static const char *msifile2 = "winetest2.msi";
42 static const char *mstfile = "winetest.mst";
43 static CHAR CURR_DIR[MAX_PATH];
44 static CHAR PROG_FILES_DIR[MAX_PATH];
45 static CHAR COMMON_FILES_DIR[MAX_PATH];
46
47 /* msi database data */
48
49 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
50 "s72\tS38\ts72\ti2\tS255\tS72\n"
51 "Component\tComponent\n"
52 "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
53 "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
54 "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\t\tone.txt\n"
55 "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
56 "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
57 "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
58 "component\t\tMSITESTDIR\t0\t1\tfile\n"
59 "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
60
61 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
62 "s72\tS72\tl255\n"
63 "Directory\tDirectory\n"
64 "CABOUTDIR\tMSITESTDIR\tcabout\n"
65 "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
66 "FIRSTDIR\tMSITESTDIR\tfirst\n"
67 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
68 "NEWDIR\tCABOUTDIR\tnew\n"
69 "ProgramFilesFolder\tTARGETDIR\t.\n"
70 "TARGETDIR\t\tSourceDir";
71
72 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
73 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
74 "Feature\tFeature\n"
75 "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
76 "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
77 "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
78 "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
79 "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
80 "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
81 "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
82
83 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
84 "s38\ts72\n"
85 "FeatureComponents\tFeature_\tComponent_\n"
86 "Five\tFive\n"
87 "Four\tFour\n"
88 "One\tOne\n"
89 "Three\tThree\n"
90 "Two\tTwo\n"
91 "feature\tcomponent\n"
92 "service_feature\tservice_comp\n";
93
94 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
95 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
96 "File\tFile\n"
97 "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
98 "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
99 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
100 "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
101 "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
102 "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
103 "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
104
105 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
106 "s72\tS255\tI2\n"
107 "InstallExecuteSequence\tAction\n"
108 "AllocateRegistrySpace\tNOT Installed\t1550\n"
109 "CostFinalize\t\t1000\n"
110 "CostInitialize\t\t800\n"
111 "FileCost\t\t900\n"
112 "ResolveSource\t\t950\n"
113 "MoveFiles\t\t1700\n"
114 "InstallFiles\t\t4000\n"
115 "DuplicateFiles\t\t4500\n"
116 "InstallServices\t\t5000\n"
117 "InstallFinalize\t\t6600\n"
118 "InstallInitialize\t\t1500\n"
119 "InstallValidate\t\t1400\n"
120 "LaunchConditions\t\t100\n"
121 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
122
123 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
124 "i2\ti4\tL64\tS255\tS32\tS72\n"
125 "Media\tDiskId\n"
126 "1\t3\t\t\tDISK1\t\n"
127 "2\t5\t\tmsitest.cab\tDISK2\t\n";
128
129 static const CHAR property_dat[] = "Property\tValue\n"
130 "s72\tl0\n"
131 "Property\tProperty\n"
132 "DefaultUIFont\tDlgFont8\n"
133 "HASUIRUN\t0\n"
134 "INSTALLLEVEL\t3\n"
135 "InstallMode\tTypical\n"
136 "Manufacturer\tWine\n"
137 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
138 "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
139 "ProductID\tnone\n"
140 "ProductLanguage\t1033\n"
141 "ProductName\tMSITEST\n"
142 "ProductVersion\t1.1.1\n"
143 "PROMPTROLLBACKCOST\tP\n"
144 "Setup\tSetup\n"
145 "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
146 "AdminProperties\tPOSTADMIN\n"
147 "ROOTDRIVE\tC:\\\n";
148
149 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
150 "s72\ti2\tl255\tL255\tL0\ts72\n"
151 "Registry\tRegistry\n"
152 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
153 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
154 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
155 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
156
157 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
158 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
159 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
160 "ServiceInstall\tServiceInstall\n"
161 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
162
163 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
164 "s72\tl255\ti2\tL255\tI2\ts72\n"
165 "ServiceControl\tServiceControl\n"
166 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
167
168 /* tables for test_continuouscabs */
169 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
170 "s72\tS38\ts72\ti2\tS255\tS72\n"
171 "Component\tComponent\n"
172 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
173 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
174 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
175
176 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
177 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
178 "Feature\tFeature\n"
179 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
180
181 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
182 "s38\ts72\n"
183 "FeatureComponents\tFeature_\tComponent_\n"
184 "feature\tmaximus\n"
185 "feature\taugustus\n"
186 "feature\tcaesar";
187
188 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
189 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
190 "File\tFile\n"
191 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
192 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
193 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
194
195 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
196 "i2\ti4\tL64\tS255\tS32\tS72\n"
197 "Media\tDiskId\n"
198 "1\t10\t\ttest1.cab\tDISK1\t\n"
199 "2\t2\t\ttest2.cab\tDISK2\t\n"
200 "3\t12\t\ttest3.cab\tDISK3\t\n";
201
202 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
203 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
204 "File\tFile\n"
205 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
206 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
207 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
208
209 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
210 "i2\ti4\tL64\tS255\tS32\tS72\n"
211 "Media\tDiskId\n"
212 "1\t10\t\ttest1.cab\tDISK1\t\n"
213 "2\t2\t\ttest2.cab\tDISK2\t\n"
214 "3\t3\t\ttest3.cab\tDISK3\t\n";
215
216 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
217 "i2\ti4\tL64\tS255\tS32\tS72\n"
218 "Media\tDiskId\n"
219 "1\t10\t\ttest1.cab\tDISK1\t\n"
220 "2\t12\t\ttest3.cab\tDISK3\t\n"
221 "3\t2\t\ttest2.cab\tDISK2\t\n";
222
223 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
224 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
225 "File\tFile\n"
226 "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
227 "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
228 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
229
230 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
231 "i2\ti4\tL64\tS255\tS32\tS72\n"
232 "Media\tDiskId\n"
233 "1\t3\t\ttest1.cab\tDISK1\t\n";
234
235 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
236 "i2\ti4\tL64\tS255\tS32\tS72\n"
237 "Media\tDiskId\n"
238 "1\t2\t\ttest1.cab\tDISK1\t\n"
239 "2\t2\t\ttest2.cab\tDISK2\t\n"
240 "3\t12\t\ttest3.cab\tDISK3\t\n";
241
242 /* tables for test_uiLevelFlags */
243 static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
244 "s72\tS38\ts72\ti2\tS255\tS72\n"
245 "Component\tComponent\n"
246 "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
247 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
248 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
249
250 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
251 "s72\tS255\tI2\n"
252 "InstallUISequence\tAction\n"
253 "SetUIProperty\t\t5\n"
254 "ExecuteAction\t\t1100\n";
255
256 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
257 "s72\ti2\tS64\tS0\tS255\n"
258 "CustomAction\tAction\n"
259 "SetUIProperty\t51\tHASUIRUN\t1\t\n";
260
261 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
262 "s72\tS38\ts72\ti2\tS255\tS72\n"
263 "Component\tComponent\n"
264 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
265
266 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
267 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
268 "Feature\tFeature\n"
269 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
270 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
271
272 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
273 "s38\ts72\n"
274 "FeatureComponents\tFeature_\tComponent_\n"
275 "feature\tmaximus\n"
276 "montecristo\tmaximus";
277
278 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
279 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
280 "File\tFile\n"
281 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
282
283 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
284 "i2\ti4\tL64\tS255\tS32\tS72\n"
285 "Media\tDiskId\n"
286 "1\t1\t\t\tDISK1\t\n";
287
288 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
289 "s72\tS255\tI2\n"
290 "InstallExecuteSequence\tAction\n"
291 "AllocateRegistrySpace\tNOT Installed\t1550\n"
292 "CostFinalize\t\t1000\n"
293 "CostInitialize\t\t800\n"
294 "FileCost\t\t900\n"
295 "InstallFiles\t\t4000\n"
296 "InstallFinalize\t\t6600\n"
297 "InstallInitialize\t\t1500\n"
298 "InstallValidate\t\t1400\n"
299 "LaunchConditions\t\t100\n"
300 "SetDirProperty\t\t950";
301
302 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
303 "s72\ti2\tS64\tS0\tS255\n"
304 "CustomAction\tAction\n"
305 "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
306
307 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
308 "s72\tS38\ts72\ti2\tS255\tS72\n"
309 "Component\tComponent\n"
310 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
311 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
312 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
313 "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
314
315 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
316 "s38\ts72\n"
317 "FeatureComponents\tFeature_\tComponent_\n"
318 "feature\tmaximus\n"
319 "feature\taugustus\n"
320 "feature\tcaesar\n"
321 "feature\tgaius";
322
323 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
324 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
325 "File\tFile\n"
326 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
327 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
328 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
329 "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
330
331 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
332 "i2\ti4\tL64\tS255\tS32\tS72\n"
333 "Media\tDiskId\n"
334 "1\t1\t\ttest1.cab\tDISK1\t\n"
335 "2\t2\t\ttest2.cab\tDISK2\t\n"
336 "3\t12\t\ttest3.cab\tDISK3\t\n";
337
338 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
339 "s72\tS255\tI2\n"
340 "InstallExecuteSequence\tAction\n"
341 "CostFinalize\t\t1000\n"
342 "CostInitialize\t\t800\n"
343 "FileCost\t\t900\n"
344 "InstallFiles\t\t4000\n"
345 "InstallServices\t\t5000\n"
346 "InstallFinalize\t\t6600\n"
347 "InstallInitialize\t\t1500\n"
348 "RunInstall\t\t1600\n"
349 "InstallValidate\t\t1400\n"
350 "LaunchConditions\t\t100";
351
352 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
353 "s72\ti2\tS64\tS0\tS255\n"
354 "CustomAction\tAction\n"
355 "RunInstall\t23\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
356
357 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
358 "s72\tS38\ts72\ti2\tS255\tS72\n"
359 "Component\tComponent\n"
360 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
361
362 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
363 "s72\tS38\ts72\ti2\tS255\tS72\n"
364 "Component\tComponent\n"
365 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
366
367 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
368 "s38\ts72\n"
369 "FeatureComponents\tFeature_\tComponent_\n"
370 "feature\taugustus";
371
372 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
373 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
374 "File\tFile\n"
375 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
376
377 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
378 "s72\ti2\tS64\tS0\tS255\n"
379 "CustomAction\tAction\n"
380 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
381
382 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
383 "s72\tS255\tI2\n"
384 "InstallExecuteSequence\tAction\n"
385 "CostFinalize\t\t1000\n"
386 "CostInitialize\t\t800\n"
387 "FileCost\t\t900\n"
388 "SetFolderProp\t\t950\n"
389 "InstallFiles\t\t4000\n"
390 "InstallServices\t\t5000\n"
391 "InstallFinalize\t\t6600\n"
392 "InstallInitialize\t\t1500\n"
393 "InstallValidate\t\t1400\n"
394 "LaunchConditions\t\t100";
395
396 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
397 "s72\tS255\tI2\n"
398 "InstallUISequence\tAction\n"
399 "CostInitialize\t\t800\n"
400 "FileCost\t\t900\n"
401 "CostFinalize\t\t1000\n"
402 "ExecuteAction\t\t1100\n";
403
404 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
405 "s72\tS255\tI2\n"
406 "InstallExecuteSequence\tAction\n"
407 "ValidateProductID\t\t700\n"
408 "CostInitialize\t\t800\n"
409 "FileCost\t\t900\n"
410 "CostFinalize\t\t1000\n"
411 "InstallValidate\t\t1400\n"
412 "InstallInitialize\t\t1500\n"
413 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
414 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
415 "RemoveFiles\t\t3500\n"
416 "InstallFiles\t\t4000\n"
417 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
418 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
419 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
420 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
421 "InstallFinalize\t\t6600";
422
423 static const CHAR tp_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\tprop=\"val\"\taugustus\n";
427
428 static const CHAR cwd_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\t\taugustus\n";
432
433 static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
434 "s72\tS38\ts72\ti2\tS255\tS72\n"
435 "Component\tComponent\n"
436 "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";
437
438 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
439 "s72\ti2\tS64\tS0\tS255\n"
440 "CustomAction\tAction\n"
441 "SetPOSTADMIN\t51\tPOSTADMIN\t1\t\n";
442
443 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
444 "s72\tS255\tI2\n"
445 "AdminExecuteSequence\tAction\n"
446 "CostFinalize\t\t1000\n"
447 "CostInitialize\t\t800\n"
448 "FileCost\t\t900\n"
449 "SetPOSTADMIN\t\t950\n"
450 "InstallFiles\t\t4000\n"
451 "InstallFinalize\t\t6600\n"
452 "InstallInitialize\t\t1500\n"
453 "InstallValidate\t\t1400\n"
454 "LaunchConditions\t\t100";
455
456 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
457 "s72\tS38\ts72\ti2\tS255\tS72\n"
458 "Component\tComponent\n"
459 "augustus\t\tMSITESTDIR\t0\tMYPROP=2718\taugustus\n";
460
461 static const CHAR rem_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
462 "s72\tS38\ts72\ti2\tS255\tS72\n"
463 "Component\tComponent\n"
464 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t0\t\thydrogen\n"
465 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
466 "lithium\t\tMSITESTDIR\t2\t\tlithium\n";
467
468 static const CHAR rem_feature_comp_dat[] = "Feature_\tComponent_\n"
469 "s38\ts72\n"
470 "FeatureComponents\tFeature_\tComponent_\n"
471 "feature\thydrogen\n"
472 "feature\thelium\n"
473 "feature\tlithium";
474
475 static const CHAR rem_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
476 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
477 "File\tFile\n"
478 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
479 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
480 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
481
482 static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
483 "s72\tS255\tI2\n"
484 "InstallExecuteSequence\tAction\n"
485 "ValidateProductID\t\t700\n"
486 "CostInitialize\t\t800\n"
487 "FileCost\t\t900\n"
488 "CostFinalize\t\t1000\n"
489 "InstallValidate\t\t1400\n"
490 "InstallInitialize\t\t1500\n"
491 "ProcessComponents\t\t1600\n"
492 "UnpublishFeatures\t\t1800\n"
493 "RemoveFiles\t\t3500\n"
494 "InstallFiles\t\t4000\n"
495 "RegisterProduct\t\t6100\n"
496 "PublishFeatures\t\t6300\n"
497 "PublishProduct\t\t6400\n"
498 "InstallFinalize\t\t6600";
499
500 static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
501 "s72\ts72\tS255\ts72\tI2\n"
502 "RemoveFile\tFileKey\n"
503 "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
504 "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
505 "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
506 "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
507 "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
508 "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
509 "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
510 "block\thelium\tblock\tMSITESTDIR\t3\n"
511 "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n";
512
513 static const CHAR mov_move_file_dat[] = "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
514 "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
515 "MoveFile\tFileKey\n"
516 "abkhazia\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t0\n"
517 "bahamas\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t1\n"
518 "cambodia\taugustus\tcameroon\tcanada\tSourceDir\tMSITESTDIR\t0\n"
519 "denmark\taugustus\tdjibouti\tdominica\tSourceDir\tMSITESTDIR\t1\n"
520 "ecuador\taugustus\tegypt\telsalvador\tNotAProp\tMSITESTDIR\t1\n"
521 "fiji\taugustus\tfinland\tfrance\tSourceDir\tNotAProp\t1\n"
522 "gabon\taugustus\tgambia\tgeorgia\tSOURCEFULL\tMSITESTDIR\t1\n"
523 "haiti\taugustus\thonduras\thungary\tSourceDir\tDESTFULL\t1\n"
524 "iceland\taugustus\tindia\tindonesia\tMSITESTDIR\tMSITESTDIR\t1\n"
525 "jamaica\taugustus\tjapan\tjordan\tFILEPATHBAD\tMSITESTDIR\t1\n"
526 "kazakhstan\taugustus\t\tkiribati\tFILEPATHGOOD\tMSITESTDIR\t1\n"
527 "laos\taugustus\tlatvia\tlebanon\tSourceDir\tMSITESTDIR\t1\n"
528 "namibia\taugustus\tnauru\tkiribati\tSourceDir\tMSITESTDIR\t1\n"
529 "wildcard\taugustus\tapp*\twildcard\tSourceDir\tMSITESTDIR\t1\n"
530 "single\taugustus\tf?o\tsingle\tSourceDir\tMSITESTDIR\t1\n"
531 "wildcardnodest\taugustus\tbudd*\t\tSourceDir\tMSITESTDIR\t1\n"
532 "singlenodest\taugustus\tb?r\t\tSourceDir\tMSITESTDIR\t1\n";
533
534 static const CHAR mc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
535 "s72\tS38\ts72\ti2\tS255\tS72\n"
536 "Component\tComponent\n"
537 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
538 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
539 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
540 "gaius\t\tMSITESTDIR\t0\tGAIUS=1\tgaius\n";
541
542 static const CHAR mc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
543 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
544 "File\tFile\n"
545 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
546 "augustus\taugustus\taugustus\t500\t\t\t0\t2\n"
547 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3\n"
548 "gaius\tgaius\tgaius\t500\t\t\t16384\t4";
549
550 static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
551 "i2\ti4\tL64\tS255\tS32\tS72\n"
552 "Media\tDiskId\n"
553 "1\t1\t\ttest1.cab\tDISK1\t\n"
554 "2\t2\t\ttest2.cab\tDISK2\t\n"
555 "3\t3\t\ttest3.cab\tDISK3\t\n"
556 "4\t4\t\ttest3.cab\tDISK3\t\n";
557
558 static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n"
559 "s72\ti2\ti4\ti4\ti4\ti4\n"
560 "MsiFileHash\tFile_\n"
561 "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824";
562
563 static const CHAR df_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
564 "s72\tS72\tl255\n"
565 "Directory\tDirectory\n"
566 "THIS\tMSITESTDIR\tthis\n"
567 "DOESNOT\tTHIS\tdoesnot\n"
568 "NONEXISTENT\tDOESNOT\texist\n"
569 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
570 "ProgramFilesFolder\tTARGETDIR\t.\n"
571 "TARGETDIR\t\tSourceDir";
572
573 static const CHAR df_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
574 "s72\ts72\ts72\tS255\tS72\n"
575 "DuplicateFile\tFileKey\n"
576 "maximus\tmaximus\tmaximus\taugustus\t\n"
577 "caesar\tmaximus\tmaximus\t\tNONEXISTENT\n";
578
579 static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
580 "s72\tS38\ts72\ti2\tS255\tS72\n"
581 "Component\tComponent\n"
582 "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
583
584 static const CHAR wrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
585 "s72\ti2\tl255\tL255\tL0\ts72\n"
586 "Registry\tRegistry\n"
587 "regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus";
588
589 typedef struct _msi_table
590 {
591 const CHAR *filename;
592 const CHAR *data;
593 int size;
594 } msi_table;
595
596 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
597
598 static const msi_table tables[] =
599 {
600 ADD_TABLE(component),
601 ADD_TABLE(directory),
602 ADD_TABLE(feature),
603 ADD_TABLE(feature_comp),
604 ADD_TABLE(file),
605 ADD_TABLE(install_exec_seq),
606 ADD_TABLE(media),
607 ADD_TABLE(property),
608 ADD_TABLE(registry),
609 ADD_TABLE(service_install),
610 ADD_TABLE(service_control)
611 };
612
613 static const msi_table cc_tables[] =
614 {
615 ADD_TABLE(cc_component),
616 ADD_TABLE(directory),
617 ADD_TABLE(cc_feature),
618 ADD_TABLE(cc_feature_comp),
619 ADD_TABLE(cc_file),
620 ADD_TABLE(install_exec_seq),
621 ADD_TABLE(cc_media),
622 ADD_TABLE(property),
623 };
624
625 static const msi_table co_tables[] =
626 {
627 ADD_TABLE(cc_component),
628 ADD_TABLE(directory),
629 ADD_TABLE(cc_feature),
630 ADD_TABLE(cc_feature_comp),
631 ADD_TABLE(co_file),
632 ADD_TABLE(install_exec_seq),
633 ADD_TABLE(co_media),
634 ADD_TABLE(property),
635 };
636
637 static const msi_table co2_tables[] =
638 {
639 ADD_TABLE(cc_component),
640 ADD_TABLE(directory),
641 ADD_TABLE(cc_feature),
642 ADD_TABLE(cc_feature_comp),
643 ADD_TABLE(cc_file),
644 ADD_TABLE(install_exec_seq),
645 ADD_TABLE(co2_media),
646 ADD_TABLE(property),
647 };
648
649 static const msi_table mm_tables[] =
650 {
651 ADD_TABLE(cc_component),
652 ADD_TABLE(directory),
653 ADD_TABLE(cc_feature),
654 ADD_TABLE(cc_feature_comp),
655 ADD_TABLE(mm_file),
656 ADD_TABLE(install_exec_seq),
657 ADD_TABLE(mm_media),
658 ADD_TABLE(property),
659 };
660
661 static const msi_table ss_tables[] =
662 {
663 ADD_TABLE(cc_component),
664 ADD_TABLE(directory),
665 ADD_TABLE(cc_feature),
666 ADD_TABLE(cc_feature_comp),
667 ADD_TABLE(cc_file),
668 ADD_TABLE(install_exec_seq),
669 ADD_TABLE(ss_media),
670 ADD_TABLE(property),
671 };
672
673 static const msi_table ui_tables[] =
674 {
675 ADD_TABLE(ui_component),
676 ADD_TABLE(directory),
677 ADD_TABLE(cc_feature),
678 ADD_TABLE(cc_feature_comp),
679 ADD_TABLE(cc_file),
680 ADD_TABLE(install_exec_seq),
681 ADD_TABLE(ui_install_ui_seq),
682 ADD_TABLE(ui_custom_action),
683 ADD_TABLE(cc_media),
684 ADD_TABLE(property),
685 };
686
687 static const msi_table rof_tables[] =
688 {
689 ADD_TABLE(rof_component),
690 ADD_TABLE(directory),
691 ADD_TABLE(rof_feature),
692 ADD_TABLE(rof_feature_comp),
693 ADD_TABLE(rof_file),
694 ADD_TABLE(install_exec_seq),
695 ADD_TABLE(rof_media),
696 ADD_TABLE(property),
697 };
698
699 static const msi_table sdp_tables[] =
700 {
701 ADD_TABLE(rof_component),
702 ADD_TABLE(directory),
703 ADD_TABLE(rof_feature),
704 ADD_TABLE(rof_feature_comp),
705 ADD_TABLE(rof_file),
706 ADD_TABLE(sdp_install_exec_seq),
707 ADD_TABLE(sdp_custom_action),
708 ADD_TABLE(rof_media),
709 ADD_TABLE(property),
710 };
711
712 static const msi_table cie_tables[] =
713 {
714 ADD_TABLE(cie_component),
715 ADD_TABLE(directory),
716 ADD_TABLE(cc_feature),
717 ADD_TABLE(cie_feature_comp),
718 ADD_TABLE(cie_file),
719 ADD_TABLE(install_exec_seq),
720 ADD_TABLE(cie_media),
721 ADD_TABLE(property),
722 };
723
724 static const msi_table ci_tables[] =
725 {
726 ADD_TABLE(ci_component),
727 ADD_TABLE(directory),
728 ADD_TABLE(rof_feature),
729 ADD_TABLE(rof_feature_comp),
730 ADD_TABLE(rof_file),
731 ADD_TABLE(ci_install_exec_seq),
732 ADD_TABLE(rof_media),
733 ADD_TABLE(property),
734 ADD_TABLE(ci_custom_action),
735 };
736
737 static const msi_table ci2_tables[] =
738 {
739 ADD_TABLE(ci2_component),
740 ADD_TABLE(directory),
741 ADD_TABLE(rof_feature),
742 ADD_TABLE(ci2_feature_comp),
743 ADD_TABLE(ci2_file),
744 ADD_TABLE(install_exec_seq),
745 ADD_TABLE(rof_media),
746 ADD_TABLE(property),
747 };
748
749 static const msi_table spf_tables[] =
750 {
751 ADD_TABLE(ci_component),
752 ADD_TABLE(directory),
753 ADD_TABLE(rof_feature),
754 ADD_TABLE(rof_feature_comp),
755 ADD_TABLE(rof_file),
756 ADD_TABLE(spf_install_exec_seq),
757 ADD_TABLE(rof_media),
758 ADD_TABLE(property),
759 ADD_TABLE(spf_custom_action),
760 ADD_TABLE(spf_install_ui_seq),
761 };
762
763 static const msi_table pp_tables[] =
764 {
765 ADD_TABLE(ci_component),
766 ADD_TABLE(directory),
767 ADD_TABLE(rof_feature),
768 ADD_TABLE(rof_feature_comp),
769 ADD_TABLE(rof_file),
770 ADD_TABLE(pp_install_exec_seq),
771 ADD_TABLE(rof_media),
772 ADD_TABLE(property),
773 };
774
775 static const msi_table tp_tables[] =
776 {
777 ADD_TABLE(tp_component),
778 ADD_TABLE(directory),
779 ADD_TABLE(rof_feature),
780 ADD_TABLE(ci2_feature_comp),
781 ADD_TABLE(ci2_file),
782 ADD_TABLE(install_exec_seq),
783 ADD_TABLE(rof_media),
784 ADD_TABLE(property),
785 };
786
787 static const msi_table cwd_tables[] =
788 {
789 ADD_TABLE(cwd_component),
790 ADD_TABLE(directory),
791 ADD_TABLE(rof_feature),
792 ADD_TABLE(ci2_feature_comp),
793 ADD_TABLE(ci2_file),
794 ADD_TABLE(install_exec_seq),
795 ADD_TABLE(rof_media),
796 ADD_TABLE(property),
797 };
798
799 static const msi_table adm_tables[] =
800 {
801 ADD_TABLE(adm_component),
802 ADD_TABLE(directory),
803 ADD_TABLE(rof_feature),
804 ADD_TABLE(ci2_feature_comp),
805 ADD_TABLE(ci2_file),
806 ADD_TABLE(install_exec_seq),
807 ADD_TABLE(rof_media),
808 ADD_TABLE(property),
809 ADD_TABLE(adm_custom_action),
810 ADD_TABLE(adm_admin_exec_seq),
811 };
812
813 static const msi_table amp_tables[] =
814 {
815 ADD_TABLE(amp_component),
816 ADD_TABLE(directory),
817 ADD_TABLE(rof_feature),
818 ADD_TABLE(ci2_feature_comp),
819 ADD_TABLE(ci2_file),
820 ADD_TABLE(install_exec_seq),
821 ADD_TABLE(rof_media),
822 ADD_TABLE(property),
823 };
824
825 static const msi_table rem_tables[] =
826 {
827 ADD_TABLE(rem_component),
828 ADD_TABLE(directory),
829 ADD_TABLE(rof_feature),
830 ADD_TABLE(rem_feature_comp),
831 ADD_TABLE(rem_file),
832 ADD_TABLE(rem_install_exec_seq),
833 ADD_TABLE(rof_media),
834 ADD_TABLE(property),
835 ADD_TABLE(rem_remove_files),
836 };
837
838 static const msi_table mov_tables[] =
839 {
840 ADD_TABLE(cwd_component),
841 ADD_TABLE(directory),
842 ADD_TABLE(rof_feature),
843 ADD_TABLE(ci2_feature_comp),
844 ADD_TABLE(ci2_file),
845 ADD_TABLE(install_exec_seq),
846 ADD_TABLE(rof_media),
847 ADD_TABLE(property),
848 ADD_TABLE(mov_move_file),
849 };
850
851 static const msi_table mc_tables[] =
852 {
853 ADD_TABLE(mc_component),
854 ADD_TABLE(directory),
855 ADD_TABLE(cc_feature),
856 ADD_TABLE(cie_feature_comp),
857 ADD_TABLE(mc_file),
858 ADD_TABLE(install_exec_seq),
859 ADD_TABLE(mc_media),
860 ADD_TABLE(property),
861 ADD_TABLE(mc_file_hash),
862 };
863
864 static const msi_table df_tables[] =
865 {
866 ADD_TABLE(rof_component),
867 ADD_TABLE(df_directory),
868 ADD_TABLE(rof_feature),
869 ADD_TABLE(rof_feature_comp),
870 ADD_TABLE(rof_file),
871 ADD_TABLE(install_exec_seq),
872 ADD_TABLE(rof_media),
873 ADD_TABLE(property),
874 ADD_TABLE(df_duplicate_file),
875 };
876
877 static const msi_table wrv_tables[] =
878 {
879 ADD_TABLE(wrv_component),
880 ADD_TABLE(directory),
881 ADD_TABLE(rof_feature),
882 ADD_TABLE(ci2_feature_comp),
883 ADD_TABLE(ci2_file),
884 ADD_TABLE(install_exec_seq),
885 ADD_TABLE(rof_media),
886 ADD_TABLE(property),
887 ADD_TABLE(wrv_registry),
888 };
889
890 /* cabinet definitions */
891
892 /* make the max size large so there is only one cab file */
893 #define MEDIA_SIZE 0x7FFFFFFF
894 #define FOLDER_THRESHOLD 900000
895
896 /* the FCI callbacks */
897
898 static void *mem_alloc(ULONG cb)
899 {
900 return HeapAlloc(GetProcessHeap(), 0, cb);
901 }
902
903 static void mem_free(void *memory)
904 {
905 HeapFree(GetProcessHeap(), 0, memory);
906 }
907
908 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
909 {
910 sprintf(pccab->szCab, pv, pccab->iCab);
911 return TRUE;
912 }
913
914 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
915 {
916 return 0;
917 }
918
919 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
920 BOOL fContinuation, void *pv)
921 {
922 return 0;
923 }
924
925 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
926 {
927 HANDLE handle;
928 DWORD dwAccess = 0;
929 DWORD dwShareMode = 0;
930 DWORD dwCreateDisposition = OPEN_EXISTING;
931
932 dwAccess = GENERIC_READ | GENERIC_WRITE;
933 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
934 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
935
936 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
937 dwCreateDisposition = OPEN_EXISTING;
938 else
939 dwCreateDisposition = CREATE_NEW;
940
941 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
942 dwCreateDisposition, 0, NULL);
943
944 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
945
946 return (INT_PTR)handle;
947 }
948
949 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
950 {
951 HANDLE handle = (HANDLE)hf;
952 DWORD dwRead;
953 BOOL res;
954
955 res = ReadFile(handle, memory, cb, &dwRead, NULL);
956 ok(res, "Failed to ReadFile\n");
957
958 return dwRead;
959 }
960
961 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
962 {
963 HANDLE handle = (HANDLE)hf;
964 DWORD dwWritten;
965 BOOL res;
966
967 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
968 ok(res, "Failed to WriteFile\n");
969
970 return dwWritten;
971 }
972
973 static int fci_close(INT_PTR hf, int *err, void *pv)
974 {
975 HANDLE handle = (HANDLE)hf;
976 ok(CloseHandle(handle), "Failed to CloseHandle\n");
977
978 return 0;
979 }
980
981 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
982 {
983 HANDLE handle = (HANDLE)hf;
984 DWORD ret;
985
986 ret = SetFilePointer(handle, dist, NULL, seektype);
987 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
988
989 return ret;
990 }
991
992 static int fci_delete(char *pszFile, int *err, void *pv)
993 {
994 BOOL ret = DeleteFileA(pszFile);
995 ok(ret, "Failed to DeleteFile %s\n", pszFile);
996
997 return 0;
998 }
999
1000 static void init_functionpointers(void)
1001 {
1002 HMODULE hmsi = GetModuleHandleA("msi.dll");
1003
1004 #define GET_PROC(func) \
1005 p ## func = (void*)GetProcAddress(hmsi, #func); \
1006 if(!p ## func) \
1007 trace("GetProcAddress(%s) failed\n", #func);
1008
1009 GET_PROC(MsiQueryComponentStateA);
1010 GET_PROC(MsiSourceListGetInfoA);
1011
1012 #undef GET_PROC
1013 }
1014
1015 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
1016 {
1017 CHAR buffer[0x20];
1018 UINT r;
1019 DWORD sz;
1020
1021 sz = sizeof buffer;
1022 r = MsiRecordGetString(rec, field, buffer, &sz);
1023 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
1024 }
1025
1026 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
1027 {
1028 LPSTR tempname;
1029
1030 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
1031 GetTempFileNameA(".", "xx", 0, tempname);
1032
1033 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
1034 {
1035 lstrcpyA(pszTempName, tempname);
1036 HeapFree(GetProcessHeap(), 0, tempname);
1037 return TRUE;
1038 }
1039
1040 HeapFree(GetProcessHeap(), 0, tempname);
1041
1042 return FALSE;
1043 }
1044
1045 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
1046 USHORT *pattribs, int *err, void *pv)
1047 {
1048 BY_HANDLE_FILE_INFORMATION finfo;
1049 FILETIME filetime;
1050 HANDLE handle;
1051 DWORD attrs;
1052 BOOL res;
1053
1054 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
1055 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
1056
1057 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
1058
1059 res = GetFileInformationByHandle(handle, &finfo);
1060 ok(res, "Expected GetFileInformationByHandle to succeed\n");
1061
1062 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
1063 FileTimeToDosDateTime(&filetime, pdate, ptime);
1064
1065 attrs = GetFileAttributes(pszName);
1066 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
1067
1068 return (INT_PTR)handle;
1069 }
1070
1071 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
1072 {
1073 char path[MAX_PATH];
1074 char filename[MAX_PATH];
1075
1076 lstrcpyA(path, CURR_DIR);
1077 lstrcatA(path, "\\");
1078 lstrcatA(path, file);
1079
1080 lstrcpyA(filename, file);
1081
1082 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
1083 progress, get_open_info, compress);
1084 }
1085
1086 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
1087 {
1088 ZeroMemory(pCabParams, sizeof(CCAB));
1089
1090 pCabParams->cb = max_size;
1091 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
1092 pCabParams->setID = 0xbeef;
1093 pCabParams->iCab = 1;
1094 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
1095 lstrcatA(pCabParams->szCabPath, "\\");
1096 lstrcpyA(pCabParams->szCab, name);
1097 }
1098
1099 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
1100 {
1101 CCAB cabParams;
1102 LPCSTR ptr;
1103 HFCI hfci;
1104 ERF erf;
1105 BOOL res;
1106
1107 set_cab_parameters(&cabParams, name, max_size);
1108
1109 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1110 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1111 get_temp_file, &cabParams, NULL);
1112
1113 ok(hfci != NULL, "Failed to create an FCI context\n");
1114
1115 ptr = files;
1116 while (*ptr)
1117 {
1118 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
1119 ok(res, "Failed to add file: %s\n", ptr);
1120 ptr += lstrlen(ptr) + 1;
1121 }
1122
1123 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1124 ok(res, "Failed to flush the cabinet\n");
1125
1126 res = FCIDestroy(hfci);
1127 ok(res, "Failed to destroy the cabinet\n");
1128 }
1129
1130 static BOOL get_program_files_dir(LPSTR buf, LPSTR buf2)
1131 {
1132 HKEY hkey;
1133 DWORD type, size;
1134
1135 if (RegOpenKey(HKEY_LOCAL_MACHINE,
1136 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
1137 return FALSE;
1138
1139 size = MAX_PATH;
1140 if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size)) {
1141 RegCloseKey(hkey);
1142 return FALSE;
1143 }
1144
1145 size = MAX_PATH;
1146 if (RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)buf2, &size)) {
1147 RegCloseKey(hkey);
1148 return FALSE;
1149 }
1150
1151 RegCloseKey(hkey);
1152 return TRUE;
1153 }
1154
1155 static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
1156 {
1157 HANDLE file;
1158 DWORD written;
1159
1160 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1161 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1162 WriteFile(file, data, strlen(data), &written, NULL);
1163
1164 if (size)
1165 {
1166 SetFilePointer(file, size, NULL, FILE_BEGIN);
1167 SetEndOfFile(file);
1168 }
1169
1170 CloseHandle(file);
1171 }
1172
1173 #define create_file(name, size) create_file_data(name, name, size)
1174
1175 static void create_test_files(void)
1176 {
1177 CreateDirectoryA("msitest", NULL);
1178 create_file("msitest\\one.txt", 100);
1179 CreateDirectoryA("msitest\\first", NULL);
1180 create_file("msitest\\first\\two.txt", 100);
1181 CreateDirectoryA("msitest\\second", NULL);
1182 create_file("msitest\\second\\three.txt", 100);
1183
1184 create_file("four.txt", 100);
1185 create_file("five.txt", 100);
1186 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1187
1188 create_file("msitest\\filename", 100);
1189 create_file("msitest\\service.exe", 100);
1190
1191 DeleteFileA("four.txt");
1192 DeleteFileA("five.txt");
1193 }
1194
1195 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
1196 {
1197 CHAR path[MAX_PATH];
1198
1199 lstrcpyA(path, PROG_FILES_DIR);
1200 lstrcatA(path, "\\");
1201 lstrcatA(path, rel_path);
1202
1203 if (is_file)
1204 return DeleteFileA(path);
1205 else
1206 return RemoveDirectoryA(path);
1207 }
1208
1209 static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
1210 {
1211 CHAR path[MAX_PATH];
1212
1213 lstrcpyA(path, COMMON_FILES_DIR);
1214 lstrcatA(path, "\\");
1215 lstrcatA(path, rel_path);
1216
1217 if (is_file)
1218 return DeleteFileA(path);
1219 else
1220 return RemoveDirectoryA(path);
1221 }
1222
1223 static void delete_test_files(void)
1224 {
1225 DeleteFileA("msitest.msi");
1226 DeleteFileA("msitest.cab");
1227 DeleteFileA("msitest\\second\\three.txt");
1228 DeleteFileA("msitest\\first\\two.txt");
1229 DeleteFileA("msitest\\one.txt");
1230 DeleteFileA("msitest\\service.exe");
1231 DeleteFileA("msitest\\filename");
1232 RemoveDirectoryA("msitest\\second");
1233 RemoveDirectoryA("msitest\\first");
1234 RemoveDirectoryA("msitest");
1235 }
1236
1237 static void write_file(const CHAR *filename, const char *data, int data_size)
1238 {
1239 DWORD size;
1240
1241 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1242 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1243
1244 WriteFile(hf, data, data_size, &size, NULL);
1245 CloseHandle(hf);
1246 }
1247
1248 static void write_msi_summary_info(MSIHANDLE db)
1249 {
1250 MSIHANDLE summary;
1251 UINT r;
1252
1253 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1255
1256 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1257 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1258
1259 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1260 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1261 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1262
1263 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1264 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1265
1266 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1268
1269 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1270 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1271
1272 /* write the summary changes back to the stream */
1273 r = MsiSummaryInfoPersist(summary);
1274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1275
1276 MsiCloseHandle(summary);
1277 }
1278
1279 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1280 {
1281 MSIHANDLE db;
1282 UINT r;
1283 int j;
1284
1285 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1287
1288 /* import the tables into the database */
1289 for (j = 0; j < num_tables; j++)
1290 {
1291 const msi_table *table = &tables[j];
1292
1293 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1294
1295 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1297
1298 DeleteFileA(table->filename);
1299 }
1300
1301 write_msi_summary_info(db);
1302
1303 r = MsiDatabaseCommit(db);
1304 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1305
1306 MsiCloseHandle(db);
1307 }
1308
1309 static void check_service_is_installed(void)
1310 {
1311 SC_HANDLE scm, service;
1312 BOOL res;
1313
1314 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1315 ok(scm != NULL, "Failed to open the SC Manager\n");
1316
1317 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1318 ok(service != NULL, "Failed to open TestService\n");
1319
1320 res = DeleteService(service);
1321 ok(res, "Failed to delete TestService\n");
1322
1323 CloseServiceHandle(service);
1324 CloseServiceHandle(scm);
1325 }
1326
1327 static void test_MsiInstallProduct(void)
1328 {
1329 UINT r;
1330 CHAR path[MAX_PATH];
1331 LONG res;
1332 HKEY hkey;
1333 DWORD num, size, type;
1334
1335 create_test_files();
1336 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1337
1338 r = MsiInstallProductA(msifile, NULL);
1339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1340
1341 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1342 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1343 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1344 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1345 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1346 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1347 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1348 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1349 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1350 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1351 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1352 ok(delete_pf("msitest", FALSE), "File not installed\n");
1353
1354 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1355 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1356
1357 size = MAX_PATH;
1358 type = REG_SZ;
1359 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1360 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1361 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1362
1363 size = MAX_PATH;
1364 type = REG_SZ;
1365 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1366 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1367
1368 size = sizeof(num);
1369 type = REG_DWORD;
1370 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1371 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1372 ok(num == 314, "Expected 314, got %d\n", num);
1373
1374 size = MAX_PATH;
1375 type = REG_SZ;
1376 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1377 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1378 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1379
1380 check_service_is_installed();
1381
1382 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1383
1384 delete_test_files();
1385 }
1386
1387 static void test_MsiSetComponentState(void)
1388 {
1389 INSTALLSTATE installed, action;
1390 MSIHANDLE package;
1391 char path[MAX_PATH];
1392 UINT r;
1393
1394 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1395
1396 CoInitialize(NULL);
1397
1398 lstrcpy(path, CURR_DIR);
1399 lstrcat(path, "\\");
1400 lstrcat(path, msifile);
1401
1402 r = MsiOpenPackage(path, &package);
1403 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1404
1405 r = MsiDoAction(package, "CostInitialize");
1406 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1407
1408 r = MsiDoAction(package, "FileCost");
1409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1410
1411 r = MsiDoAction(package, "CostFinalize");
1412 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1413
1414 r = MsiGetComponentState(package, "dangler", &installed, &action);
1415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1416 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1417 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1418
1419 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1420 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1421
1422 MsiCloseHandle(package);
1423 CoUninitialize();
1424
1425 DeleteFileA(msifile);
1426 }
1427
1428 static void test_packagecoltypes(void)
1429 {
1430 MSIHANDLE hdb, view, rec;
1431 char path[MAX_PATH];
1432 LPCSTR query;
1433 UINT r, count;
1434
1435 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1436
1437 CoInitialize(NULL);
1438
1439 lstrcpy(path, CURR_DIR);
1440 lstrcat(path, "\\");
1441 lstrcat(path, msifile);
1442
1443 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1444 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1445
1446 query = "SELECT * FROM `Media`";
1447 r = MsiDatabaseOpenView( hdb, query, &view );
1448 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1449
1450 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1451 count = MsiRecordGetFieldCount( rec );
1452 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1453 ok(count == 6, "Expected 6, got %d\n", count);
1454 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1455 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1456 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1457 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1458 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1459 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1460 MsiCloseHandle(rec);
1461
1462 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1463 count = MsiRecordGetFieldCount( rec );
1464 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1465 ok(count == 6, "Expected 6, got %d\n", count);
1466 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1467 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1468 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1469 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1470 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1471 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1472
1473 MsiCloseHandle(rec);
1474 MsiCloseHandle(view);
1475 MsiCloseHandle(hdb);
1476 DeleteFile(msifile);
1477 }
1478
1479 static void create_cc_test_files(void)
1480 {
1481 CCAB cabParams;
1482 HFCI hfci;
1483 ERF erf;
1484 static CHAR cab_context[] = "test%d.cab";
1485 BOOL res;
1486
1487 create_file("maximus", 500);
1488 create_file("augustus", 50000);
1489 create_file("caesar", 500);
1490
1491 set_cab_parameters(&cabParams, "test1.cab", 200);
1492
1493 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1494 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1495 get_temp_file, &cabParams, cab_context);
1496 ok(hfci != NULL, "Failed to create an FCI context\n");
1497
1498 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1499 ok(res, "Failed to add file maximus\n");
1500
1501 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1502 ok(res, "Failed to add file augustus\n");
1503
1504 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1505 ok(res, "Failed to flush the cabinet\n");
1506
1507 res = FCIDestroy(hfci);
1508 ok(res, "Failed to destroy the cabinet\n");
1509
1510 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1511
1512 DeleteFile("maximus");
1513 DeleteFile("augustus");
1514 DeleteFile("caesar");
1515 }
1516
1517 static void delete_cab_files(void)
1518 {
1519 SHFILEOPSTRUCT shfl;
1520 CHAR path[MAX_PATH+10];
1521
1522 lstrcpyA(path, CURR_DIR);
1523 lstrcatA(path, "\\*.cab");
1524 path[strlen(path) + 1] = '\0';
1525
1526 shfl.hwnd = NULL;
1527 shfl.wFunc = FO_DELETE;
1528 shfl.pFrom = path;
1529 shfl.pTo = NULL;
1530 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1531
1532 SHFileOperation(&shfl);
1533 }
1534
1535 static void test_continuouscabs(void)
1536 {
1537 UINT r;
1538
1539 create_cc_test_files();
1540 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1541
1542 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1543
1544 r = MsiInstallProductA(msifile, NULL);
1545 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1546 todo_wine
1547 {
1548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1549 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1550 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1551 }
1552 ok(delete_pf("msitest", FALSE), "File not installed\n");
1553
1554 delete_cab_files();
1555 DeleteFile(msifile);
1556 }
1557
1558 static void test_caborder(void)
1559 {
1560 UINT r;
1561
1562 create_file("imperator", 100);
1563 create_file("maximus", 500);
1564 create_file("augustus", 50000);
1565 create_file("caesar", 500);
1566
1567 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1568
1569 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1570
1571 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1572 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1573 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1574
1575 r = MsiInstallProductA(msifile, NULL);
1576 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1577 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1578 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1579 todo_wine
1580 {
1581 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1582 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1583 }
1584
1585 delete_cab_files();
1586
1587 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1588 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1589 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1590
1591 r = MsiInstallProductA(msifile, NULL);
1592 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1593 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1594 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1595 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1596 todo_wine
1597 {
1598 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1599 }
1600
1601 delete_cab_files();
1602 DeleteFile(msifile);
1603
1604 create_cc_test_files();
1605 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1606
1607 r = MsiInstallProductA(msifile, NULL);
1608 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1609 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1610 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1611 todo_wine
1612 {
1613 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1614 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1615 }
1616
1617 delete_cab_files();
1618 DeleteFile(msifile);
1619
1620 create_cc_test_files();
1621 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1622
1623 r = MsiInstallProductA(msifile, NULL);
1624 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1625 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1626 todo_wine
1627 {
1628 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1629 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1630 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1631 }
1632
1633 delete_cab_files();
1634 DeleteFile("imperator");
1635 DeleteFile("maximus");
1636 DeleteFile("augustus");
1637 DeleteFile("caesar");
1638 DeleteFile(msifile);
1639 }
1640
1641 static void test_mixedmedia(void)
1642 {
1643 UINT r;
1644
1645 CreateDirectoryA("msitest", NULL);
1646 create_file("msitest\\maximus", 500);
1647 create_file("msitest\\augustus", 500);
1648 create_file("caesar", 500);
1649
1650 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1651
1652 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1653
1654 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1655
1656 r = MsiInstallProductA(msifile, NULL);
1657 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1658 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1659 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1660 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1661 ok(delete_pf("msitest", FALSE), "File not installed\n");
1662
1663 /* Delete the files in the temp (current) folder */
1664 DeleteFile("msitest\\maximus");
1665 DeleteFile("msitest\\augustus");
1666 RemoveDirectory("msitest");
1667 DeleteFile("caesar");
1668 DeleteFile("test1.cab");
1669 DeleteFile(msifile);
1670 }
1671
1672 static void test_samesequence(void)
1673 {
1674 UINT r;
1675
1676 create_cc_test_files();
1677 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1678
1679 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1680
1681 r = MsiInstallProductA(msifile, NULL);
1682 todo_wine
1683 {
1684 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1685 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1686 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1687 }
1688 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1689 ok(delete_pf("msitest", FALSE), "File not installed\n");
1690
1691 delete_cab_files();
1692 DeleteFile(msifile);
1693 }
1694
1695 static void test_uiLevelFlags(void)
1696 {
1697 UINT r;
1698
1699 create_cc_test_files();
1700 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1701
1702 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1703
1704 r = MsiInstallProductA(msifile, NULL);
1705 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1706 todo_wine
1707 {
1708 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1709 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1710 }
1711 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1712 ok(delete_pf("msitest", FALSE), "File not installed\n");
1713
1714 delete_cab_files();
1715 DeleteFile(msifile);
1716 }
1717
1718 static BOOL file_matches(LPSTR path)
1719 {
1720 CHAR buf[MAX_PATH];
1721 HANDLE file;
1722 DWORD size;
1723
1724 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1725 NULL, OPEN_EXISTING, 0, NULL);
1726
1727 ZeroMemory(buf, MAX_PATH);
1728 ReadFile(file, buf, 15, &size, NULL);
1729 CloseHandle(file);
1730
1731 return !lstrcmp(buf, "msitest\\maximus");
1732 }
1733
1734 static void test_readonlyfile(void)
1735 {
1736 UINT r;
1737 DWORD size;
1738 HANDLE file;
1739 CHAR path[MAX_PATH];
1740
1741 CreateDirectoryA("msitest", NULL);
1742 create_file("msitest\\maximus", 500);
1743 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1744
1745 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1746
1747 lstrcpy(path, PROG_FILES_DIR);
1748 lstrcat(path, "\\msitest");
1749 CreateDirectory(path, NULL);
1750
1751 lstrcat(path, "\\maximus");
1752 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1753 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1754
1755 WriteFile(file, "readonlyfile", 20, &size, NULL);
1756 CloseHandle(file);
1757
1758 r = MsiInstallProductA(msifile, NULL);
1759 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1760 ok(file_matches(path), "Expected file to be overwritten\n");
1761 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1762 ok(delete_pf("msitest", FALSE), "File not installed\n");
1763
1764 /* Delete the files in the temp (current) folder */
1765 DeleteFile("msitest\\maximus");
1766 RemoveDirectory("msitest");
1767 DeleteFile(msifile);
1768 }
1769
1770 static void test_setdirproperty(void)
1771 {
1772 UINT r;
1773
1774 CreateDirectoryA("msitest", NULL);
1775 create_file("msitest\\maximus", 500);
1776 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1777
1778 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1779
1780 r = MsiInstallProductA(msifile, NULL);
1781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1782 ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
1783 ok(delete_cf("msitest", FALSE), "File not installed\n");
1784
1785 /* Delete the files in the temp (current) folder */
1786 DeleteFile(msifile);
1787 DeleteFile("msitest\\maximus");
1788 RemoveDirectory("msitest");
1789 }
1790
1791 static void test_cabisextracted(void)
1792 {
1793 UINT r;
1794
1795 CreateDirectoryA("msitest", NULL);
1796 create_file("msitest\\gaius", 500);
1797 create_file("maximus", 500);
1798 create_file("augustus", 500);
1799 create_file("caesar", 500);
1800
1801 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1802 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1803 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1804
1805 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1806
1807 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1808
1809 r = MsiInstallProductA(msifile, NULL);
1810 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1811 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1812 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1813 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1814 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1815 ok(delete_pf("msitest", FALSE), "File not installed\n");
1816
1817 /* Delete the files in the temp (current) folder */
1818 delete_cab_files();
1819 DeleteFile(msifile);
1820 DeleteFile("maximus");
1821 DeleteFile("augustus");
1822 DeleteFile("caesar");
1823 DeleteFile("msitest\\gaius");
1824 RemoveDirectory("msitest");
1825 }
1826
1827 static void test_concurrentinstall(void)
1828 {
1829 UINT r;
1830 CHAR path[MAX_PATH];
1831
1832 CreateDirectoryA("msitest", NULL);
1833 CreateDirectoryA("msitest\\msitest", NULL);
1834 create_file("msitest\\maximus", 500);
1835 create_file("msitest\\msitest\\augustus", 500);
1836
1837 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1838
1839 lstrcpyA(path, CURR_DIR);
1840 lstrcatA(path, "\\msitest\\concurrent.msi");
1841 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1842
1843 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1844
1845 r = MsiInstallProductA(msifile, NULL);
1846 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1847 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1848 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1849 ok(delete_pf("msitest", FALSE), "File not installed\n");
1850
1851 /* Delete the files in the temp (current) folder */
1852 DeleteFile(msifile);
1853 DeleteFile(path);
1854 DeleteFile("msitest\\msitest\\augustus");
1855 DeleteFile("msitest\\maximus");
1856 RemoveDirectory("msitest\\msitest");
1857 RemoveDirectory("msitest");
1858 }
1859
1860 static void test_setpropertyfolder(void)
1861 {
1862 UINT r;
1863
1864 CreateDirectoryA("msitest", NULL);
1865 create_file("msitest\\maximus", 500);
1866
1867 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1868
1869 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1870
1871 r = MsiInstallProductA(msifile, NULL);
1872 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1873 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1874 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1875 ok(delete_pf("msitest", FALSE), "File not installed\n");
1876
1877 /* Delete the files in the temp (current) folder */
1878 DeleteFile(msifile);
1879 DeleteFile("msitest\\maximus");
1880 RemoveDirectory("msitest");
1881 }
1882
1883 static BOOL file_exists(LPCSTR file)
1884 {
1885 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
1886 }
1887
1888 static BOOL pf_exists(LPCSTR file)
1889 {
1890 CHAR path[MAX_PATH];
1891
1892 lstrcpyA(path, PROG_FILES_DIR);
1893 lstrcatA(path, "\\");
1894 lstrcatA(path, file);
1895
1896 return file_exists(path);
1897 }
1898
1899 static void delete_pfmsitest_files(void)
1900 {
1901 SHFILEOPSTRUCT shfl;
1902 CHAR path[MAX_PATH+11];
1903
1904 lstrcpyA(path, PROG_FILES_DIR);
1905 lstrcatA(path, "\\msitest\\*");
1906 path[strlen(path) + 1] = '\0';
1907
1908 shfl.hwnd = NULL;
1909 shfl.wFunc = FO_DELETE;
1910 shfl.pFrom = path;
1911 shfl.pTo = NULL;
1912 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1913
1914 SHFileOperation(&shfl);
1915
1916 lstrcpyA(path, PROG_FILES_DIR);
1917 lstrcatA(path, "\\msitest");
1918 RemoveDirectoryA(path);
1919 }
1920
1921 static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
1922 {
1923 char val[MAX_PATH];
1924 DWORD size, type;
1925 LONG res;
1926
1927 size = MAX_PATH;
1928 val[0] = '\0';
1929 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
1930
1931 if (res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ))
1932 {
1933 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
1934 return;
1935 }
1936
1937 if (!expected)
1938 ok_(__FILE__, line)(lstrlenA(val) == 0, "Expected empty string, got %s\n", val);
1939 else
1940 {
1941 if (bcase)
1942 ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
1943 else
1944 ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
1945 }
1946 }
1947
1948 static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD line)
1949 {
1950 DWORD val, size, type;
1951 LONG res;
1952
1953 size = sizeof(DWORD);
1954 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
1955
1956 if (res != ERROR_SUCCESS || type != REG_DWORD)
1957 {
1958 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
1959 return;
1960 }
1961
1962 ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
1963 }
1964
1965 #define CHECK_REG_STR(prodkey, name, expected) \
1966 check_reg_str(prodkey, name, expected, TRUE, __LINE__);
1967
1968 #define CHECK_REG_ISTR(prodkey, name, expected) \
1969 check_reg_str(prodkey, name, expected, FALSE, __LINE__);
1970
1971 #define CHECK_REG_DWORD(prodkey, name, expected) \
1972 check_reg_dword(prodkey, name, expected, __LINE__);
1973
1974 static void get_date_str(LPSTR date)
1975 {
1976 SYSTEMTIME systime;
1977
1978 static const char date_fmt[] = "%d%02d%02d";
1979 GetLocalTime(&systime);
1980 sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
1981 }
1982
1983 static void test_publish(void)
1984 {
1985 UINT r;
1986 LONG res;
1987 HKEY uninstall, prodkey;
1988 INSTALLSTATE state;
1989 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
1990 char date[MAX_PATH];
1991 char temp[MAX_PATH];
1992
1993 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
1994
1995 get_date_str(date);
1996 GetTempPath(MAX_PATH, temp);
1997
1998 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
1999 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2000
2001 CreateDirectoryA("msitest", NULL);
2002 create_file("msitest\\maximus", 500);
2003
2004 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2005
2006 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2007
2008 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2009 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2010
2011 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2012 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2013
2014 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2015 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2016
2017 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2018 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2019 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2020 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2021
2022 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2023 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2024
2025 /* nothing published */
2026 r = MsiInstallProductA(msifile, NULL);
2027 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2028 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2029 ok(pf_exists("msitest"), "File not installed\n");
2030
2031 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2032 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2033
2034 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2035 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2036
2037 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2038 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2039
2040 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2041 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2042 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2043 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2044
2045 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2046 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2047
2048 /* install again */
2049 r = MsiInstallProductA(msifile, NULL);
2050 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2051 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2052 ok(pf_exists("msitest"), "File not installed\n");
2053
2054 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2055 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2056
2057 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2058 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2059
2060 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2061 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2062
2063 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2064 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2065 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2066 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2067
2068 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2069 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2070
2071 /* try to uninstall */
2072 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2073 todo_wine
2074 {
2075 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2076 }
2077 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2078 ok(pf_exists("msitest"), "File deleted\n");
2079
2080 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2081 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2082
2083 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2084 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2085
2086 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2087 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2088
2089 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2090 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2091 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2092 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2093
2094 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2095 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2096
2097 /* PublishProduct */
2098 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2099 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2100 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2101 ok(pf_exists("msitest"), "File not installed\n");
2102
2103 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2104 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2105
2106 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2107 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2108
2109 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2110 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2111 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2112 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2113
2114 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2115 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2116
2117 /* try to uninstall after PublishProduct */
2118 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2120 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2121 ok(pf_exists("msitest"), "File deleted\n");
2122
2123 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2124 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2125
2126 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2127 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2128
2129 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2130 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2131
2132 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2133 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2134 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2135 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2136
2137 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2138 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2139
2140 /* RegisterProduct */
2141 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2142 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2143 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2144 ok(pf_exists("msitest"), "File not installed\n");
2145
2146 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2147 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2148
2149 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2150 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2151
2152 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2153 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2154 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2155 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2156
2157 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2158 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2159
2160 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2161 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2162 CHECK_REG_STR(prodkey, "InstallDate", date);
2163 CHECK_REG_STR(prodkey, "InstallSource", temp);
2164 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2165 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2166 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2167 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2168 CHECK_REG_STR(prodkey, "Comments", NULL);
2169 CHECK_REG_STR(prodkey, "Contact", NULL);
2170 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2171 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2172 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2173 CHECK_REG_STR(prodkey, "Readme", NULL);
2174 CHECK_REG_STR(prodkey, "Size", NULL);
2175 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2176 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2177 CHECK_REG_DWORD(prodkey, "Language", 1033);
2178 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2179 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2180 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2181 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2182 todo_wine
2183 {
2184 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2185 }
2186
2187 RegCloseKey(prodkey);
2188
2189 /* complete uninstall */
2190 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2191 todo_wine
2192 {
2193 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2194 }
2195 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2196 ok(pf_exists("msitest"), "File deleted\n");
2197
2198 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2199 todo_wine
2200 {
2201 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2202 }
2203
2204 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2205 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2206
2207 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2208 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2209
2210 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2211 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2212 todo_wine
2213 {
2214 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2215 }
2216 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2217
2218 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2219 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2220
2221 todo_wine
2222 {
2223 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2224 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2225 CHECK_REG_STR(prodkey, "InstallDate", date);
2226 CHECK_REG_STR(prodkey, "InstallSource", temp);
2227 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2228 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2229 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2230 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2231 CHECK_REG_STR(prodkey, "Comments", NULL);
2232 CHECK_REG_STR(prodkey, "Contact", NULL);
2233 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2234 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2235 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2236 CHECK_REG_STR(prodkey, "Readme", NULL);
2237 CHECK_REG_STR(prodkey, "Size", NULL);
2238 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2239 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2240 CHECK_REG_DWORD(prodkey, "Language", 1033);
2241 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2242 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2243 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2244 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2245 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2246 }
2247
2248 RegCloseKey(prodkey);
2249
2250 /* PublishProduct and RegisterProduct */
2251 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2252 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2253 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2254 ok(pf_exists("msitest"), "File not installed\n");
2255
2256 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2257 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2258
2259 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2260 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2261
2262 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2263 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2264
2265 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2266 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2267 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2268 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2269
2270 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2271 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2272
2273 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2274 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2275 CHECK_REG_STR(prodkey, "InstallDate", date);
2276 CHECK_REG_STR(prodkey, "InstallSource", temp);
2277 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2278 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2279 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2280 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2281 CHECK_REG_STR(prodkey, "Comments", NULL);
2282 CHECK_REG_STR(prodkey, "Contact", NULL);
2283 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2284 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2285 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2286 CHECK_REG_STR(prodkey, "Readme", NULL);
2287 CHECK_REG_STR(prodkey, "Size", NULL);
2288 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2289 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2290 CHECK_REG_DWORD(prodkey, "Language", 1033);
2291 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2292 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2293 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2294 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2295 todo_wine
2296 {
2297 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2298 }
2299
2300 RegCloseKey(prodkey);
2301
2302 /* try it again */
2303 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2304 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2305 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2306 ok(pf_exists("msitest"), "File not installed\n");
2307
2308 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2309 todo_wine
2310 {
2311 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2312 }
2313
2314 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2315 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2316
2317 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2318 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2319
2320 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2321 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2322 todo_wine
2323 {
2324 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2325 }
2326 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2327
2328 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2329 todo_wine
2330 {
2331 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2332 }
2333
2334 /* uninstall has a problem with this */
2335 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2336 todo_wine
2337 {
2338 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2339 }
2340 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2341 ok(pf_exists("msitest"), "File deleted\n");
2342
2343 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2344 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2345
2346 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2347 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2348
2349 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2350 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2351 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2352 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2353
2354 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2355 todo_wine
2356 {
2357 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2358 }
2359
2360 /* PublishProduct and RegisterProduct and ProcessComponents */
2361 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
2362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2363 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2364 ok(pf_exists("msitest"), "File not installed\n");
2365
2366 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2367 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2368
2369 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2370 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2371
2372 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2373 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2374
2375 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2376 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2378 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2379
2380 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2381 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2382
2383 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2384 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2385 CHECK_REG_STR(prodkey, "InstallDate", date);
2386 CHECK_REG_STR(prodkey, "InstallSource", temp);
2387 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2388 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2389 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2390 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2391 CHECK_REG_STR(prodkey, "Comments", NULL);
2392 CHECK_REG_STR(prodkey, "Contact", NULL);
2393 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2394 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2395 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2396 CHECK_REG_STR(prodkey, "Readme", NULL);
2397 CHECK_REG_STR(prodkey, "Size", NULL);
2398 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2399 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2400 CHECK_REG_DWORD(prodkey, "Language", 1033);
2401 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2402 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2403 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2404 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2405 todo_wine
2406 {
2407 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2408 }
2409
2410 RegCloseKey(prodkey);
2411
2412 /* complete uninstall */
2413 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2414 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2415 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2416 ok(pf_exists("msitest"), "File deleted\n");
2417
2418 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2419 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2420
2421 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2422 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2423
2424 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2425 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2426
2427 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2428 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2429 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2430 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2431
2432 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2433 todo_wine
2434 {
2435 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2436 }
2437
2438 /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
2439 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
2440 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2441 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2442 ok(pf_exists("msitest"), "File not installed\n");
2443
2444 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2445 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2446
2447 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2448 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2449
2450 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2451 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2452
2453 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2454 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2455 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2456 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2457
2458 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2459 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2460
2461 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2462 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2463 CHECK_REG_STR(prodkey, "InstallDate", date);
2464 CHECK_REG_STR(prodkey, "InstallSource", temp);
2465 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2466 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2467 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2468 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2469 CHECK_REG_STR(prodkey, "Comments", NULL);
2470 CHECK_REG_STR(prodkey, "Contact", NULL);
2471 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2472 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2473 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2474 CHECK_REG_STR(prodkey, "Readme", NULL);
2475 CHECK_REG_STR(prodkey, "Size", NULL);
2476 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2477 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2478 CHECK_REG_DWORD(prodkey, "Language", 1033);
2479 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2480 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2481 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2482 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2483 todo_wine
2484 {
2485 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2486 }
2487
2488 RegCloseKey(prodkey);
2489
2490 /* complete uninstall */
2491 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2492 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2493 todo_wine
2494 {
2495 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2496 ok(!pf_exists("msitest"), "File deleted\n");
2497 }
2498
2499 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2500 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2501
2502 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2503 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2504
2505 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2506 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2507
2508 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2509 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2510 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2511 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2512
2513 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2514 todo_wine
2515 {
2516 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2517 }
2518
2519 /* complete install */
2520 r = MsiInstallProductA(msifile, "FULL=1");
2521 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2522 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2523 ok(pf_exists("msitest"), "File not installed\n");
2524
2525 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2526 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2527
2528 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2529 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2530
2531 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2532 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2533
2534 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2535 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2536 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2537 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2538
2539 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2541
2542 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2543 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2544 CHECK_REG_STR(prodkey, "InstallDate", date);
2545 CHECK_REG_STR(prodkey, "InstallSource", temp);
2546 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2547 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2548 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2549 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2550 CHECK_REG_STR(prodkey, "Comments", NULL);
2551 CHECK_REG_STR(prodkey, "Contact", NULL);
2552 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2553 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2554 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2555 CHECK_REG_STR(prodkey, "Readme", NULL);
2556 CHECK_REG_STR(prodkey, "Size", NULL);
2557 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2558 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2559 CHECK_REG_DWORD(prodkey, "Language", 1033);
2560 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2561 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2562 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2563 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2564 todo_wine
2565 {
2566 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2567 }
2568
2569 RegCloseKey(prodkey);
2570
2571 /* no UnpublishFeatures */
2572 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2573 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2574 todo_wine
2575 {
2576 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2577 ok(!pf_exists("msitest"), "File deleted\n");
2578 }
2579
2580 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2581 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2582
2583 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2584 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2585
2586 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2587 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2588
2589 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2590 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2591 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2592 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2593
2594 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2595 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2596
2597 /* complete install */
2598 r = MsiInstallProductA(msifile, "FULL=1");
2599 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2600 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2601 ok(pf_exists("msitest"), "File not installed\n");
2602
2603 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2604 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2605
2606 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2607 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2608
2609 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2610 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2611
2612 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2613 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2614 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2615 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2616
2617 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2618 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2619
2620 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2621 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2622 CHECK_REG_STR(prodkey, "InstallDate", date);
2623 CHECK_REG_STR(prodkey, "InstallSource", temp);
2624 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2625 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2626 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2627 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2628 CHECK_REG_STR(prodkey, "Comments", NULL);
2629 CHECK_REG_STR(prodkey, "Contact", NULL);
2630 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2631 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2632 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2633 CHECK_REG_STR(prodkey, "Readme", NULL);
2634 CHECK_REG_STR(prodkey, "Size", NULL);
2635 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2636 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2637 CHECK_REG_DWORD(prodkey, "Language", 1033);
2638 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2639 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2640 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2641 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2642 todo_wine
2643 {
2644 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2645 }
2646
2647 RegCloseKey(prodkey);
2648
2649 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
2650 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
2651 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2652 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2653 ok(pf_exists("msitest"), "File deleted\n");
2654
2655 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2656 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2657
2658 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2659 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2660
2661 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2662 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2663
2664 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2665 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2666 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2667 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2668
2669 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2670 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2671
2672 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2673 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2674 CHECK_REG_STR(prodkey, "InstallDate", date);
2675 CHECK_REG_STR(prodkey, "InstallSource", temp);
2676 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2677 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2678 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2679 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2680 CHECK_REG_STR(prodkey, "Comments", NULL);
2681 CHECK_REG_STR(prodkey, "Contact", NULL);
2682 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2683 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2684 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2685 CHECK_REG_STR(prodkey, "Readme", NULL);
2686 CHECK_REG_STR(prodkey, "Size", NULL);
2687 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2688 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2689 CHECK_REG_DWORD(prodkey, "Language", 1033);
2690 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2691 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2692 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2693 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2694 todo_wine
2695 {
2696 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2697 }
2698
2699 RegCloseKey(prodkey);
2700
2701 /* complete install */
2702 r = MsiInstallProductA(msifile, "FULL=1");
2703 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2704 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2705 ok(pf_exists("msitest"), "File not installed\n");
2706
2707 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2708 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2709
2710 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2711 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2712
2713 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2714 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2715
2716 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2717 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2718 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2719 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2720
2721 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2722 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2723
2724 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2725 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2726 CHECK_REG_STR(prodkey, "InstallDate", date);
2727 CHECK_REG_STR(prodkey, "InstallSource", temp);
2728 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2729 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2730 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2731 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2732 CHECK_REG_STR(prodkey, "Comments", NULL);
2733 CHECK_REG_STR(prodkey, "Contact", NULL);
2734 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2735 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2736 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2737 CHECK_REG_STR(prodkey, "Readme", NULL);
2738 CHECK_REG_STR(prodkey, "Size", NULL);
2739 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2740 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2741 CHECK_REG_DWORD(prodkey, "Language", 1033);
2742 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2743 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2744 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2745 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2746 todo_wine
2747 {
2748 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2749 }
2750
2751 RegCloseKey(prodkey);
2752
2753 /* UnpublishFeatures, both features removed */
2754 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
2755 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2756 todo_wine
2757 {
2758 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2759 ok(!pf_exists("msitest"), "File not deleted\n");
2760 }
2761
2762 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2763 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2764
2765 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2766 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2767
2768 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2769 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2770
2771 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2772 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2773 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2774 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2775
2776 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2777 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2778
2779 /* complete install */
2780 r = MsiInstallProductA(msifile, "FULL=1");
2781 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2782 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2783 ok(pf_exists("msitest"), "File not installed\n");
2784
2785 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2786 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2787
2788 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2789 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2790
2791 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2792 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2793
2794 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2795 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2796 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2797 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2798
2799 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2800 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2801
2802 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2803 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2804 CHECK_REG_STR(prodkey, "InstallDate", date);
2805 CHECK_REG_STR(prodkey, "InstallSource", temp);
2806 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2807 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2808 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2809 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2810 CHECK_REG_STR(prodkey, "Comments", NULL);
2811 CHECK_REG_STR(prodkey, "Contact", NULL);
2812 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2813 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2814 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2815 CHECK_REG_STR(prodkey, "Readme", NULL);
2816 CHECK_REG_STR(prodkey, "Size", NULL);
2817 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2818 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2819 CHECK_REG_DWORD(prodkey, "Language", 1033);
2820 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2821 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2822 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2823 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2824 todo_wine
2825 {
2826 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2827 }
2828
2829 RegCloseKey(prodkey);
2830
2831 /* complete uninstall */
2832 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2833 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2834 todo_wine
2835 {
2836 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2837 ok(!pf_exists("msitest"), "File not deleted\n");
2838 }
2839
2840 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2841 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2842
2843 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2844 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2845
2846 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2847 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2848
2849 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2850 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2851 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2852 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2853
2854 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2855 todo_wine
2856 {
2857 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2858 }
2859
2860 /* make sure 'Program Files\msitest' is removed */
2861 delete_pfmsitest_files();
2862
2863 RegCloseKey(uninstall);
2864 DeleteFile(msifile);
2865 DeleteFile("msitest\\maximus");
2866 RemoveDirectory("msitest");
2867 }
2868
2869 static void test_publishsourcelist(void)
2870 {
2871 UINT r;
2872 DWORD size;
2873 CHAR value[MAX_PATH];
2874 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2875
2876 CreateDirectoryA("msitest", NULL);
2877 create_file("msitest\\maximus", 500);
2878
2879 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2880
2881 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2882
2883 r = MsiInstallProductA(msifile, NULL);
2884 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2885 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2886 ok(pf_exists("msitest"), "File not installed\n");
2887
2888 /* nothing published */
2889 size = 0xdeadbeef;
2890 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2891 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2892 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2893 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2894
2895 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2897 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2898 ok(pf_exists("msitest"), "File not installed\n");
2899
2900 /* after RegisterProduct */
2901 size = 0xdeadbeef;
2902 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2903 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2904 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2905 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2906
2907 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2909 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2910 ok(pf_exists("msitest"), "File not installed\n");
2911
2912 /* after ProcessComponents */
2913 size = 0xdeadbeef;
2914 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2915 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2916 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2917 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2918
2919 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2921 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2922 ok(pf_exists("msitest"), "File not installed\n");
2923
2924 /* after PublishFeatures */
2925 size = 0xdeadbeef;
2926 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2927 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2928 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2929 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2930
2931 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2932 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2933 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2934 ok(pf_exists("msitest"), "File not installed\n");
2935
2936 /* after PublishProduct */
2937 size = MAX_PATH;
2938 lstrcpyA(value, "aaa");
2939 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2940 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
2941 todo_wine
2942 {
2943 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2944 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
2945 ok(size == 11, "Expected 11, got %d\n", size);
2946 }
2947
2948 /* complete uninstall */
2949 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2950 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2951 todo_wine
2952 {
2953 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2954 ok(!pf_exists("msitest"), "File not deleted\n");
2955 }
2956
2957 /* make sure 'Program Files\msitest' is removed */
2958 delete_pfmsitest_files();
2959
2960 DeleteFile(msifile);
2961 DeleteFile("msitest\\maximus");
2962 RemoveDirectory("msitest");
2963 }
2964
2965 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
2966 {
2967 MSIHANDLE hview = 0;
2968 UINT r;
2969
2970 r = MsiDatabaseOpenView(hdb, query, &hview);
2971 if(r != ERROR_SUCCESS)
2972 return r;
2973
2974 r = MsiViewExecute(hview, hrec);
2975 if(r == ERROR_SUCCESS)
2976 r = MsiViewClose(hview);
2977 MsiCloseHandle(hview);
2978 return r;
2979 }
2980
2981 static void set_transform_summary_info(void)
2982 {
2983 UINT r;
2984 MSIHANDLE suminfo = 0;
2985
2986 /* build summmary info */
2987 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
2988 todo_wine
2989 {
2990 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
2991 }
2992
2993 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
2994 todo_wine
2995 {
2996 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2997 }
2998
2999 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
3000 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
3001 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
3002 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
3003 todo_wine
3004 {
3005 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
3006 }
3007
3008 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
3009 todo_wine
3010 {
3011 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3012 }
3013
3014 r = MsiSummaryInfoPersist(suminfo);
3015 todo_wine
3016 {
3017 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
3018 }
3019
3020 r = MsiCloseHandle(suminfo);
3021 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
3022 }
3023
3024 static void generate_transform(void)
3025 {
3026 MSIHANDLE hdb1, hdb2;
3027 LPCSTR query;
3028 UINT r;
3029
3030 /* start with two identical databases */
3031 CopyFile(msifile, msifile2, FALSE);
3032
3033 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
3034 ok(r == ERROR_SUCCESS , "Failed to create database\n");
3035
3036 r = MsiDatabaseCommit(hdb1);
3037 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
3038
3039 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
3040 ok(r == ERROR_SUCCESS , "Failed to create database\n");
3041
3042 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
3043 r = run_query(hdb1, 0, query);
3044 ok(r == ERROR_SUCCESS, "failed to add property\n");
3045
3046 /* database needs to be committed */
3047 MsiDatabaseCommit(hdb1);
3048
3049 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
3050 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
3051
3052 #if 0 /* not implemented in wine yet */
3053 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
3054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3055 #endif
3056
3057 MsiCloseHandle(hdb1);
3058 MsiCloseHandle(hdb2);
3059 }
3060
3061 /* data for generating a transform */
3062
3063 /* tables transform names - encoded as they would be in an msi database file */
3064 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
3065 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
3066 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
3067
3068 /* data in each table */
3069 static const char data1[] = /* _StringData */
3070 "propval"; /* all the strings squashed together */
3071
3072 static const WCHAR data2[] = { /* _StringPool */
3073 /* len, refs */
3074 0, 0, /* string 0 '' */
3075 4, 1, /* string 1 'prop' */
3076 3, 1, /* string 2 'val' */
3077 };
3078
3079 static const WCHAR data3[] = { /* Property */
3080 0x0201, 0x0001, 0x0002,
3081 };
3082
3083 static const struct {
3084 LPCWSTR name;
3085 const void *data;
3086 DWORD size;
3087 } table_transform_data[] =
3088 {
3089 { name1, data1, sizeof data1 - 1 },
3090 { name2, data2, sizeof data2 },
3091 { name3, data3, sizeof data3 },
3092 };
3093
3094 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
3095
3096 static void generate_transform_manual(void)
3097 {
3098 IStorage *stg = NULL;
3099 IStream *stm;
3100 WCHAR name[0x20];
3101 HRESULT r;
3102 DWORD i, count;
3103 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
3104
3105 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
3106
3107 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
3108
3109 r = StgCreateDocfile(name, mode, 0, &stg);
3110 ok(r == S_OK, "failed to create storage\n");
3111 if (!stg)
3112 return;
3113
3114 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
3115 ok(r == S_OK, "failed to set storage type\n");
3116
3117 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
3118 {
3119 r = IStorage_CreateStream(stg, table_transform_data[i].name,
3120 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3121 if (FAILED(r))
3122 {
3123 ok(0, "failed to create stream %08x\n", r);
3124 continue;
3125 }
3126
3127 r = IStream_Write(stm, table_transform_data[i].data,
3128 table_transform_data[i].size, &count);
3129 if (FAILED(r) || count != table_transform_data[i].size)
3130 ok(0, "failed to write stream\n");
3131 IStream_Release(stm);
3132 }
3133
3134 IStorage_Release(stg);
3135
3136 set_transform_summary_info();
3137 }
3138
3139 static void test_transformprop(void)
3140 {
3141 UINT r;
3142
3143 CreateDirectoryA("msitest", NULL);
3144 create_file("msitest\\augustus", 500);
3145
3146 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
3147
3148 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3149
3150 r = MsiInstallProductA(msifile, NULL);
3151 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3152 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3153 ok(!delete_pf("msitest", FALSE), "File installed\n");
3154
3155 if (0)
3156 generate_transform();
3157 else
3158 generate_transform_manual();
3159
3160 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
3161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3162 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3163 ok(delete_pf("msitest", FALSE), "File not installed\n");
3164
3165 /* Delete the files in the temp (current) folder */
3166 DeleteFile(msifile);
3167 DeleteFile(msifile2);
3168 DeleteFile(mstfile);
3169 DeleteFile("msitest\\augustus");
3170 RemoveDirectory("msitest");
3171 }
3172
3173 static void test_currentworkingdir(void)
3174 {
3175 UINT r;
3176 CHAR path[MAX_PATH];
3177 LPSTR ptr, ptr2;
3178
3179 CreateDirectoryA("msitest", NULL);
3180 create_file("msitest\\augustus", 500);
3181
3182 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
3183
3184 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3185
3186 CreateDirectoryA("diffdir", NULL);
3187 SetCurrentDirectoryA("diffdir");
3188
3189 sprintf(path, "..\\%s", msifile);
3190 r = MsiInstallProductA(path, NULL);
3191 todo_wine
3192 {
3193 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
3194 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3195 ok(!delete_pf("msitest", FALSE), "File installed\n");
3196 }
3197
3198 sprintf(path, "%s\\%s", CURR_DIR, msifile);
3199 r = MsiInstallProductA(path, NULL);
3200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3201 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3202 ok(delete_pf("msitest", FALSE), "File not installed\n");
3203
3204 lstrcpyA(path, CURR_DIR);
3205 if (path[lstrlenA(path) - 1] != '\\')
3206 lstrcatA(path, "\\");
3207 lstrcatA(path, "msitest.msi");
3208
3209 ptr2 = strrchr(path, '\\');
3210 *ptr2 = '\0';
3211 ptr = strrchr(path, '\\');
3212 *ptr2 = '\\';
3213 *(ptr++) = '\0';
3214
3215 SetCurrentDirectoryA(path);
3216
3217 r = MsiInstallProductA(ptr, NULL);
3218 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3219 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3220 ok(delete_pf("msitest", FALSE), "File not installed\n");
3221
3222 SetCurrentDirectoryA(CURR_DIR);
3223
3224 DeleteFile(msifile);
3225 DeleteFile("msitest\\augustus");
3226 RemoveDirectory("msitest");
3227 RemoveDirectory("diffdir");
3228 }
3229
3230 static void set_admin_summary_info(const CHAR *name)
3231 {
3232 MSIHANDLE db, summary;
3233 UINT r;
3234
3235 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
3236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3237
3238 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
3239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3240
3241 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
3242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3243
3244 /* write the summary changes back to the stream */
3245 r = MsiSummaryInfoPersist(summary);
3246 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3247
3248 MsiCloseHandle(summary);
3249
3250 r = MsiDatabaseCommit(db);
3251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3252
3253 MsiCloseHandle(db);
3254 }
3255
3256 static void test_admin(void)
3257 {
3258 UINT r;
3259
3260 CreateDirectoryA("msitest", NULL);
3261 create_file("msitest\\augustus", 500);
3262
3263 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
3264 set_admin_summary_info(msifile);
3265
3266 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3267
3268 r = MsiInstallProductA(msifile, NULL);
3269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3270 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3271 ok(!delete_pf("msitest", FALSE), "File installed\n");
3272 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
3273 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
3274
3275 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
3276 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3277 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3278 ok(!delete_pf("msitest", FALSE), "File installed\n");
3279 todo_wine
3280 {
3281 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
3282 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
3283 }
3284
3285 DeleteFile(msifile);
3286 DeleteFile("msitest\\augustus");
3287 RemoveDirectory("msitest");
3288 }
3289
3290 static void set_admin_property_stream(LPCSTR file)
3291 {
3292 IStorage *stg;
3293 IStream *stm;
3294 WCHAR fileW[MAX_PATH];
3295 HRESULT hr;
3296 DWORD count;
3297 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
3298
3299 /* AdminProperties */
3300 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
3301 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
3302
3303 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
3304
3305 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
3306 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3307 if (!stg)
3308 return;
3309
3310 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3311 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3312
3313 hr = IStream_Write(stm, data, sizeof(data), &count);
3314 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3315
3316 IStream_Release(stm);
3317 IStorage_Release(stg);
3318 }
3319
3320 static void test_adminprops(void)
3321 {
3322 UINT r;
3323
3324 CreateDirectoryA("msitest", NULL);
3325 create_file("msitest\\augustus", 500);
3326
3327 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
3328 set_admin_summary_info(msifile);
3329 set_admin_property_stream(msifile);
3330
3331 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3332
3333 r = MsiInstallProductA(msifile, NULL);
3334 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3335 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
3336 ok(delete_pf("msitest", FALSE), "File installed\n");
3337
3338 DeleteFile(msifile);
3339 DeleteFile("msitest\\augustus");
3340 RemoveDirectory("msitest");
3341 }
3342
3343 static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file)
3344 {
3345 CHAR path[MAX_PATH];
3346
3347 lstrcpyA(path, PROG_FILES_DIR);
3348 lstrcatA(path, "\\");
3349 lstrcatA(path, file);
3350
3351 if (is_file)
3352 create_file_data(path, data, 500);
3353 else
3354 CreateDirectoryA(path, NULL);
3355 }
3356
3357 #define create_pf(file, is_file) create_pf_data(file, file, is_file)
3358
3359 static void test_removefiles(void)
3360 {
3361 UINT r;
3362
3363 CreateDirectoryA("msitest", NULL);
3364 create_file("msitest\\hydrogen", 500);
3365 create_file("msitest\\helium", 500);
3366 create_file("msitest\\lithium", 500);
3367
3368 create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
3369
3370 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3371
3372 r = MsiInstallProductA(msifile, NULL);
3373 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3374 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3375 ok(!pf_exists("msitest\\helium"), "File installed\n");
3376 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3377 ok(pf_exists("msitest"), "File not installed\n");
3378
3379 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3380 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3381 ok(!pf_exists("msitest\\helium"), "File not deleted\n");
3382 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3383 todo_wine
3384 {
3385 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3386 ok(delete_pf("msitest", FALSE), "File deleted\n");
3387 }
3388
3389 create_pf("msitest", FALSE);
3390 create_pf("msitest\\hydrogen", TRUE);
3391 create_pf("msitest\\helium", TRUE);
3392 create_pf("msitest\\lithium", TRUE);
3393
3394 r = MsiInstallProductA(msifile, NULL);
3395 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3396 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3397 ok(pf_exists("msitest\\helium"), "File not installed\n");
3398 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3399 ok(pf_exists("msitest"), "File not installed\n");
3400
3401 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3402 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3403 ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
3404 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3405 todo_wine
3406 {
3407 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3408 ok(delete_pf("msitest", FALSE), "File deleted\n");
3409 }
3410
3411 create_pf("msitest", FALSE);
3412 create_pf("msitest\\furlong", TRUE);
3413 create_pf("msitest\\firkin", TRUE);
3414 create_pf("msitest\\fortnight", TRUE);
3415 create_pf("msitest\\becquerel", TRUE);
3416 create_pf("msitest\\dioptre", TRUE);
3417 create_pf("msitest\\attoparsec", TRUE);
3418 create_pf("msitest\\storeys", TRUE);
3419 create_pf("msitest\\block", TRUE);
3420 create_pf("msitest\\siriometer", TRUE);
3421
3422 r = MsiInstallProductA(msifile, NULL);
3423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3424 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3425 ok(!pf_exists("msitest\\helium"), "File installed\n");
3426 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3427 ok(pf_exists("msitest\\becquerel"), "File not installed\n");
3428 ok(pf_exists("msitest\\dioptre"), "File not installed\n");
3429 ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
3430 ok(pf_exists("msitest"), "File not installed\n");
3431 todo_wine
3432 {
3433 ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
3434 ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
3435 ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
3436 ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
3437 ok(!pf_exists("msitest\\block"), "File not deleted\n");
3438 ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
3439 }
3440
3441 create_pf("msitest\\furlong", TRUE);
3442 create_pf("msitest\\firkin", TRUE);
3443 create_pf("msitest\\fortnight", TRUE);
3444 create_pf("msitest\\storeys", TRUE);
3445 create_pf("msitest\\block", TRUE);
3446 create_pf("msitest\\siriometer", TRUE);
3447
3448 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3449 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3450 ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
3451 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3452 ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
3453 ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
3454 ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
3455 ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
3456 ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
3457 todo_wine
3458 {
3459 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
3460 ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
3461 ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
3462 ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
3463 ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
3464 }
3465 ok(delete_pf("msitest", FALSE), "File deleted\n");
3466
3467 DeleteFile(msifile);
3468 DeleteFile("msitest\\hydrogen");
3469 DeleteFile("msitest\\helium");
3470 DeleteFile("msitest\\lithium");
3471 RemoveDirectory("msitest");
3472 }
3473
3474 static void test_movefiles(void)
3475 {
3476 UINT r;
3477 char props[MAX_PATH];
3478
3479 CreateDirectoryA("msitest", NULL);
3480 create_file("msitest\\augustus", 100);
3481 create_file("cameroon", 100);
3482 create_file("djibouti", 100);
3483 create_file("egypt", 100);
3484 create_file("finland", 100);
3485 create_file("gambai", 100);
3486 create_file("honduras", 100);
3487 create_file("msitest\\india", 100);
3488 create_file("japan", 100);
3489 create_file("kenya", 100);
3490 CreateDirectoryA("latvia", NULL);
3491 create_file("nauru", 100);
3492 create_file("apple", 100);
3493 create_file("application", 100);
3494 create_file("ape", 100);
3495 create_file("foo", 100);
3496 create_file("fao", 100);
3497 create_file("fbod", 100);
3498 create_file("budding", 100);
3499 create_file("buddy", 100);
3500 create_file("bud", 100);
3501 create_file("bar", 100);
3502 create_file("bur", 100);
3503 create_file("bird", 100);
3504
3505 create_database(msifile, mov_tables, sizeof(mov_tables) / sizeof(msi_table));
3506
3507 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3508 MsiEnableLog(INSTALLLOGMODE_VERBOSE | INSTALLLOGMODE_EXTRADEBUG, "log.txt", 0);
3509
3510 /* if the source or dest property is not a full path,
3511 * windows tries to access it as a network resource
3512 */
3513
3514 sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
3515 "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
3516 CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);
3517
3518 r = MsiInstallProductA(msifile, props);
3519 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3520 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3521 ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
3522 ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
3523 ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
3524 ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
3525 ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
3526 ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
3527 ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
3528 ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
3529 ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
3530 ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
3531 ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
3532 ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
3533 ok(!delete_pf("msitest\\apple", TRUE), "File should not exist\n");
3534 ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
3535 ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
3536 ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
3537 ok(delete_pf("msitest\\foo", TRUE), "File not moved\n");
3538 ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
3539 ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
3540 ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
3541 ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
3542 ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
3543 ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
3544 ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
3545 ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
3546 ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
3547 ok(delete_pf("msitest", FALSE), "File not installed\n");
3548 ok(DeleteFileA("cameroon"), "File moved\n");
3549 ok(!DeleteFileA("djibouti"), "File not moved\n");
3550 ok(DeleteFileA("egypt"), "File moved\n");
3551 ok(DeleteFileA("finland"), "File moved\n");
3552 ok(DeleteFileA("gambai"), "File moved\n");
3553 ok(!DeleteFileA("honduras"), "File not moved\n");
3554 ok(DeleteFileA("msitest\\india"), "File moved\n");
3555 ok(DeleteFileA("japan"), "File moved\n");
3556 ok(!DeleteFileA("kenya"), "File not moved\n");
3557 ok(RemoveDirectoryA("latvia"), "Directory moved\n");
3558 ok(!DeleteFileA("nauru"), "File not moved\n");
3559 ok(!DeleteFileA("apple"), "File not moved\n");
3560 ok(!DeleteFileA("application"), "File not moved\n");
3561 ok(DeleteFileA("ape"), "File moved\n");
3562 ok(!DeleteFileA("foo"), "File not moved\n");
3563 ok(!DeleteFileA("fao"), "File not moved\n");
3564 ok(DeleteFileA("fbod"), "File moved\n");
3565 ok(!DeleteFileA("budding"), "File not moved\n");
3566 ok(!DeleteFileA("buddy"), "File not moved\n");
3567 ok(DeleteFileA("bud"), "File moved\n");
3568 ok(!DeleteFileA("bar"), "File not moved\n");
3569 ok(!DeleteFileA("bur"), "File not moved\n");
3570 ok(DeleteFileA("bird"), "File moved\n");
3571
3572 DeleteFile("msitest\\augustus");
3573 RemoveDirectory("msitest");
3574 DeleteFile(msifile);
3575 }
3576
3577 static void test_missingcab(void)
3578 {
3579 UINT r;
3580
3581 CreateDirectoryA("msitest", NULL);
3582 create_file("msitest\\augustus", 500);
3583 create_file("maximus", 500);
3584
3585 create_database(msifile, mc_tables, sizeof(mc_tables) / sizeof(msi_table));
3586
3587 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3588
3589 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
3590
3591 create_pf("msitest", FALSE);
3592 create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
3593
3594 r = MsiInstallProductA(msifile, NULL);
3595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3596 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3597 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3598 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3599 ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
3600 ok(delete_pf("msitest", FALSE), "File not installed\n");
3601
3602 create_pf("msitest", FALSE);
3603 create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
3604 create_pf("msitest\\gaius", TRUE);
3605
3606 r = MsiInstallProductA(msifile, "GAIUS=1");
3607 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3608 todo_wine
3609 {
3610 ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
3611 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3612 }
3613 ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
3614 ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
3615 ok(delete_pf("msitest", FALSE), "File not installed\n");
3616
3617 DeleteFile("msitest\\augustus");
3618 RemoveDirectory("msitest");
3619 DeleteFile("maximus");
3620 DeleteFile("test1.cab");
3621 DeleteFile(msifile);
3622 }
3623
3624 static void test_duplicatefiles(void)
3625 {
3626 UINT r;
3627
3628 CreateDirectoryA("msitest", NULL);
3629 create_file("msitest\\maximus", 500);
3630 create_database(msifile, df_tables, sizeof(df_tables) / sizeof(msi_table));
3631
3632 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3633
3634 /* fails if the destination folder is not a valid property */
3635
3636 r = MsiInstallProductA(msifile, NULL);
3637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3638 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3639 ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
3640 ok(delete_pf("msitest\\this\\doesnot\\exist\\maximus", TRUE), "File not duplicated\n");
3641 ok(delete_pf("msitest\\this\\doesnot\\exist", FALSE), "File not duplicated\n");
3642 ok(delete_pf("msitest\\this\\doesnot", FALSE), "File not duplicated\n");
3643 ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n");
3644 ok(delete_pf("msitest", FALSE), "File not installed\n");
3645
3646 DeleteFile("msitest\\maximus");
3647 RemoveDirectory("msitest");
3648 DeleteFile(msifile);
3649 }
3650
3651 static void test_writeregistryvalues(void)
3652 {
3653 UINT r;
3654 LONG res;
3655 HKEY hkey;
3656 DWORD type, size;
3657 CHAR path[MAX_PATH];
3658
3659 CreateDirectoryA("msitest", NULL);
3660 create_file("msitest\\augustus", 500);
3661
3662 create_database(msifile, wrv_tables, sizeof(wrv_tables) / sizeof(msi_table));
3663
3664 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3665
3666 r = MsiInstallProductA(msifile, NULL);
3667 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3668 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
3669 ok(delete_pf("msitest", FALSE), "File installed\n");
3670
3671 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3672 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3673
3674 size = MAX_PATH;
3675 type = REG_MULTI_SZ;
3676 memset(path, 'a', MAX_PATH);
3677 res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
3678 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3679 ok(!memcmp(path, "one\0two\0three\0\0", size), "Wrong multi-sz data\n");
3680 ok(size == 15, "Expected 15, got %d\n", size);
3681 ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
3682
3683 DeleteFile(msifile);
3684 DeleteFile("msitest\\augustus");
3685 RemoveDirectory("msitest");
3686 }
3687
3688 START_TEST(install)
3689 {
3690 DWORD len;
3691 char temp_path[MAX_PATH], prev_path[MAX_PATH];
3692
3693 init_functionpointers();
3694
3695 GetCurrentDirectoryA(MAX_PATH, prev_path);
3696 GetTempPath(MAX_PATH, temp_path);
3697 SetCurrentDirectoryA(temp_path);
3698
3699 lstrcpyA(CURR_DIR, temp_path);
3700 len = lstrlenA(CURR_DIR);
3701
3702 if(len && (CURR_DIR[len - 1] == '\\'))
3703 CURR_DIR[len - 1] = 0;
3704
3705 get_program_files_dir(PROG_FILES_DIR, COMMON_FILES_DIR);
3706
3707 test_MsiInstallProduct();
3708 test_MsiSetComponentState();
3709 test_packagecoltypes();
3710 test_continuouscabs();
3711 test_caborder();
3712 test_mixedmedia();
3713 test_samesequence();
3714 test_uiLevelFlags();
3715 test_readonlyfile();
3716 test_setdirproperty();
3717 test_cabisextracted();
3718 test_concurrentinstall();
3719 test_setpropertyfolder();
3720 test_publish();
3721 test_publishsourcelist();
3722 test_transformprop();
3723 test_currentworkingdir();
3724 test_admin();
3725 test_adminprops();
3726 test_removefiles();
3727 test_movefiles();
3728 test_missingcab();
3729 test_duplicatefiles();
3730 test_writeregistryvalues();
3731
3732 SetCurrentDirectoryA(prev_path);
3733 }