msi: Implement MsiSourceListEnumSources.
[wine/winequartzdrv.git] / dlls / msi / tests / install.c
blobbb87cd189f336329be9b263e2beb040d458f32ad
1 /*
2 * Copyright (C) 2006 James Hawkins
4 * A test program for installing MSI products.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define _WIN32_MSI 300
22 #define COBJMACROS
24 #include <stdio.h>
26 #include <windows.h>
27 #include <msiquery.h>
28 #include <msidefs.h>
29 #include <msi.h>
30 #include <fci.h>
31 #include <objidl.h>
33 #include "wine/test.h"
35 static UINT (WINAPI *pMsiQueryComponentStateA)
36 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
37 static UINT (WINAPI *pMsiSourceListGetInfoA)
38 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
40 static const char *msifile = "msitest.msi";
41 static const char *msifile2 = "winetest2.msi";
42 static const char *mstfile = "winetest.mst";
43 static CHAR CURR_DIR[MAX_PATH];
44 static CHAR PROG_FILES_DIR[MAX_PATH];
45 static CHAR COMMON_FILES_DIR[MAX_PATH];
47 /* msi database data */
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
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";
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";
367 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
368 "s38\ts72\n"
369 "FeatureComponents\tFeature_\tComponent_\n"
370 "feature\taugustus";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
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";
589 typedef struct _msi_table
591 const CHAR *filename;
592 const CHAR *data;
593 int size;
594 } msi_table;
596 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
598 static const msi_table tables[] =
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)
613 static const msi_table cc_tables[] =
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),
625 static const msi_table co_tables[] =
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),
637 static const msi_table co2_tables[] =
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),
649 static const msi_table mm_tables[] =
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),
661 static const msi_table ss_tables[] =
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),
673 static const msi_table ui_tables[] =
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),
687 static const msi_table rof_tables[] =
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),
699 static const msi_table sdp_tables[] =
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),
712 static const msi_table cie_tables[] =
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),
724 static const msi_table ci_tables[] =
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),
737 static const msi_table ci2_tables[] =
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),
749 static const msi_table spf_tables[] =
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),
763 static const msi_table pp_tables[] =
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),
775 static const msi_table tp_tables[] =
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),
787 static const msi_table cwd_tables[] =
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),
799 static const msi_table adm_tables[] =
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),
813 static const msi_table amp_tables[] =
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),
825 static const msi_table rem_tables[] =
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),
838 static const msi_table mov_tables[] =
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),
851 static const msi_table mc_tables[] =
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),
864 static const msi_table df_tables[] =
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),
877 static const msi_table wrv_tables[] =
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),
890 static const msi_table sf_tables[] =
892 ADD_TABLE(wrv_component),
893 ADD_TABLE(directory),
894 ADD_TABLE(rof_feature),
895 ADD_TABLE(ci2_feature_comp),
896 ADD_TABLE(ci2_file),
897 ADD_TABLE(install_exec_seq),
898 ADD_TABLE(rof_media),
899 ADD_TABLE(property),
902 /* cabinet definitions */
904 /* make the max size large so there is only one cab file */
905 #define MEDIA_SIZE 0x7FFFFFFF
906 #define FOLDER_THRESHOLD 900000
908 /* the FCI callbacks */
910 static void *mem_alloc(ULONG cb)
912 return HeapAlloc(GetProcessHeap(), 0, cb);
915 static void mem_free(void *memory)
917 HeapFree(GetProcessHeap(), 0, memory);
920 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
922 sprintf(pccab->szCab, pv, pccab->iCab);
923 return TRUE;
926 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
928 return 0;
931 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
932 BOOL fContinuation, void *pv)
934 return 0;
937 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
939 HANDLE handle;
940 DWORD dwAccess = 0;
941 DWORD dwShareMode = 0;
942 DWORD dwCreateDisposition = OPEN_EXISTING;
944 dwAccess = GENERIC_READ | GENERIC_WRITE;
945 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
946 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
948 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
949 dwCreateDisposition = OPEN_EXISTING;
950 else
951 dwCreateDisposition = CREATE_NEW;
953 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
954 dwCreateDisposition, 0, NULL);
956 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
958 return (INT_PTR)handle;
961 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
963 HANDLE handle = (HANDLE)hf;
964 DWORD dwRead;
965 BOOL res;
967 res = ReadFile(handle, memory, cb, &dwRead, NULL);
968 ok(res, "Failed to ReadFile\n");
970 return dwRead;
973 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
975 HANDLE handle = (HANDLE)hf;
976 DWORD dwWritten;
977 BOOL res;
979 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
980 ok(res, "Failed to WriteFile\n");
982 return dwWritten;
985 static int fci_close(INT_PTR hf, int *err, void *pv)
987 HANDLE handle = (HANDLE)hf;
988 ok(CloseHandle(handle), "Failed to CloseHandle\n");
990 return 0;
993 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
995 HANDLE handle = (HANDLE)hf;
996 DWORD ret;
998 ret = SetFilePointer(handle, dist, NULL, seektype);
999 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
1001 return ret;
1004 static int fci_delete(char *pszFile, int *err, void *pv)
1006 BOOL ret = DeleteFileA(pszFile);
1007 ok(ret, "Failed to DeleteFile %s\n", pszFile);
1009 return 0;
1012 static void init_functionpointers(void)
1014 HMODULE hmsi = GetModuleHandleA("msi.dll");
1016 #define GET_PROC(func) \
1017 p ## func = (void*)GetProcAddress(hmsi, #func); \
1018 if(!p ## func) \
1019 trace("GetProcAddress(%s) failed\n", #func);
1021 GET_PROC(MsiQueryComponentStateA);
1022 GET_PROC(MsiSourceListGetInfoA);
1024 #undef GET_PROC
1027 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
1029 CHAR buffer[0x20];
1030 UINT r;
1031 DWORD sz;
1033 sz = sizeof buffer;
1034 r = MsiRecordGetString(rec, field, buffer, &sz);
1035 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
1038 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
1040 LPSTR tempname;
1042 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
1043 GetTempFileNameA(".", "xx", 0, tempname);
1045 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
1047 lstrcpyA(pszTempName, tempname);
1048 HeapFree(GetProcessHeap(), 0, tempname);
1049 return TRUE;
1052 HeapFree(GetProcessHeap(), 0, tempname);
1054 return FALSE;
1057 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
1058 USHORT *pattribs, int *err, void *pv)
1060 BY_HANDLE_FILE_INFORMATION finfo;
1061 FILETIME filetime;
1062 HANDLE handle;
1063 DWORD attrs;
1064 BOOL res;
1066 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
1067 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
1069 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
1071 res = GetFileInformationByHandle(handle, &finfo);
1072 ok(res, "Expected GetFileInformationByHandle to succeed\n");
1074 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
1075 FileTimeToDosDateTime(&filetime, pdate, ptime);
1077 attrs = GetFileAttributes(pszName);
1078 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
1080 return (INT_PTR)handle;
1083 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
1085 char path[MAX_PATH];
1086 char filename[MAX_PATH];
1088 lstrcpyA(path, CURR_DIR);
1089 lstrcatA(path, "\\");
1090 lstrcatA(path, file);
1092 lstrcpyA(filename, file);
1094 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
1095 progress, get_open_info, compress);
1098 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
1100 ZeroMemory(pCabParams, sizeof(CCAB));
1102 pCabParams->cb = max_size;
1103 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
1104 pCabParams->setID = 0xbeef;
1105 pCabParams->iCab = 1;
1106 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
1107 lstrcatA(pCabParams->szCabPath, "\\");
1108 lstrcpyA(pCabParams->szCab, name);
1111 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
1113 CCAB cabParams;
1114 LPCSTR ptr;
1115 HFCI hfci;
1116 ERF erf;
1117 BOOL res;
1119 set_cab_parameters(&cabParams, name, max_size);
1121 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1122 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1123 get_temp_file, &cabParams, NULL);
1125 ok(hfci != NULL, "Failed to create an FCI context\n");
1127 ptr = files;
1128 while (*ptr)
1130 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
1131 ok(res, "Failed to add file: %s\n", ptr);
1132 ptr += lstrlen(ptr) + 1;
1135 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1136 ok(res, "Failed to flush the cabinet\n");
1138 res = FCIDestroy(hfci);
1139 ok(res, "Failed to destroy the cabinet\n");
1142 static BOOL get_program_files_dir(LPSTR buf, LPSTR buf2)
1144 HKEY hkey;
1145 DWORD type, size;
1147 if (RegOpenKey(HKEY_LOCAL_MACHINE,
1148 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
1149 return FALSE;
1151 size = MAX_PATH;
1152 if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size)) {
1153 RegCloseKey(hkey);
1154 return FALSE;
1157 size = MAX_PATH;
1158 if (RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)buf2, &size)) {
1159 RegCloseKey(hkey);
1160 return FALSE;
1163 RegCloseKey(hkey);
1164 return TRUE;
1167 static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
1169 HANDLE file;
1170 DWORD written;
1172 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1173 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1174 WriteFile(file, data, strlen(data), &written, NULL);
1176 if (size)
1178 SetFilePointer(file, size, NULL, FILE_BEGIN);
1179 SetEndOfFile(file);
1182 CloseHandle(file);
1185 #define create_file(name, size) create_file_data(name, name, size)
1187 static void create_test_files(void)
1189 CreateDirectoryA("msitest", NULL);
1190 create_file("msitest\\one.txt", 100);
1191 CreateDirectoryA("msitest\\first", NULL);
1192 create_file("msitest\\first\\two.txt", 100);
1193 CreateDirectoryA("msitest\\second", NULL);
1194 create_file("msitest\\second\\three.txt", 100);
1196 create_file("four.txt", 100);
1197 create_file("five.txt", 100);
1198 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1200 create_file("msitest\\filename", 100);
1201 create_file("msitest\\service.exe", 100);
1203 DeleteFileA("four.txt");
1204 DeleteFileA("five.txt");
1207 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
1209 CHAR path[MAX_PATH];
1211 lstrcpyA(path, PROG_FILES_DIR);
1212 lstrcatA(path, "\\");
1213 lstrcatA(path, rel_path);
1215 if (is_file)
1216 return DeleteFileA(path);
1217 else
1218 return RemoveDirectoryA(path);
1221 static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
1223 CHAR path[MAX_PATH];
1225 lstrcpyA(path, COMMON_FILES_DIR);
1226 lstrcatA(path, "\\");
1227 lstrcatA(path, rel_path);
1229 if (is_file)
1230 return DeleteFileA(path);
1231 else
1232 return RemoveDirectoryA(path);
1235 static void delete_test_files(void)
1237 DeleteFileA("msitest.msi");
1238 DeleteFileA("msitest.cab");
1239 DeleteFileA("msitest\\second\\three.txt");
1240 DeleteFileA("msitest\\first\\two.txt");
1241 DeleteFileA("msitest\\one.txt");
1242 DeleteFileA("msitest\\service.exe");
1243 DeleteFileA("msitest\\filename");
1244 RemoveDirectoryA("msitest\\second");
1245 RemoveDirectoryA("msitest\\first");
1246 RemoveDirectoryA("msitest");
1249 static void write_file(const CHAR *filename, const char *data, int data_size)
1251 DWORD size;
1253 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1254 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1256 WriteFile(hf, data, data_size, &size, NULL);
1257 CloseHandle(hf);
1260 static void write_msi_summary_info(MSIHANDLE db)
1262 MSIHANDLE summary;
1263 UINT r;
1265 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1266 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1268 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1271 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1272 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1273 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1275 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1276 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1278 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1281 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1282 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1284 /* write the summary changes back to the stream */
1285 r = MsiSummaryInfoPersist(summary);
1286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1288 MsiCloseHandle(summary);
1291 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1293 MSIHANDLE db;
1294 UINT r;
1295 int j;
1297 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1298 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1300 /* import the tables into the database */
1301 for (j = 0; j < num_tables; j++)
1303 const msi_table *table = &tables[j];
1305 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1307 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1310 DeleteFileA(table->filename);
1313 write_msi_summary_info(db);
1315 r = MsiDatabaseCommit(db);
1316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1318 MsiCloseHandle(db);
1321 static void check_service_is_installed(void)
1323 SC_HANDLE scm, service;
1324 BOOL res;
1326 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1327 ok(scm != NULL, "Failed to open the SC Manager\n");
1329 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1330 ok(service != NULL, "Failed to open TestService\n");
1332 res = DeleteService(service);
1333 ok(res, "Failed to delete TestService\n");
1335 CloseServiceHandle(service);
1336 CloseServiceHandle(scm);
1339 static void test_MsiInstallProduct(void)
1341 UINT r;
1342 CHAR path[MAX_PATH];
1343 LONG res;
1344 HKEY hkey;
1345 DWORD num, size, type;
1346 SC_HANDLE scm;
1348 scm = OpenSCManager(NULL, NULL, GENERIC_ALL);
1349 if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
1351 skip("Services are not implemented, we are most likely on win9x\n");
1352 return;
1354 CloseServiceHandle(scm);
1356 create_test_files();
1357 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1359 r = MsiInstallProductA(msifile, NULL);
1360 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1362 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1363 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1364 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1365 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1366 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1367 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1368 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1369 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1370 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1371 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1372 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1373 ok(delete_pf("msitest", FALSE), "File not installed\n");
1375 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1376 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1378 size = MAX_PATH;
1379 type = REG_SZ;
1380 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1381 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1382 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1384 size = MAX_PATH;
1385 type = REG_SZ;
1386 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1387 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1389 size = sizeof(num);
1390 type = REG_DWORD;
1391 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1392 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1393 ok(num == 314, "Expected 314, got %d\n", num);
1395 size = MAX_PATH;
1396 type = REG_SZ;
1397 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1398 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1399 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1401 check_service_is_installed();
1403 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1405 delete_test_files();
1408 static void test_MsiSetComponentState(void)
1410 INSTALLSTATE installed, action;
1411 MSIHANDLE package;
1412 char path[MAX_PATH];
1413 UINT r;
1415 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1417 CoInitialize(NULL);
1419 lstrcpy(path, CURR_DIR);
1420 lstrcat(path, "\\");
1421 lstrcat(path, msifile);
1423 r = MsiOpenPackage(path, &package);
1424 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1426 r = MsiDoAction(package, "CostInitialize");
1427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1429 r = MsiDoAction(package, "FileCost");
1430 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1432 r = MsiDoAction(package, "CostFinalize");
1433 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1435 r = MsiGetComponentState(package, "dangler", &installed, &action);
1436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1437 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1438 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1440 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1443 MsiCloseHandle(package);
1444 CoUninitialize();
1446 DeleteFileA(msifile);
1449 static void test_packagecoltypes(void)
1451 MSIHANDLE hdb, view, rec;
1452 char path[MAX_PATH];
1453 LPCSTR query;
1454 UINT r, count;
1456 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1458 CoInitialize(NULL);
1460 lstrcpy(path, CURR_DIR);
1461 lstrcat(path, "\\");
1462 lstrcat(path, msifile);
1464 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1465 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1467 query = "SELECT * FROM `Media`";
1468 r = MsiDatabaseOpenView( hdb, query, &view );
1469 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1471 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1472 count = MsiRecordGetFieldCount( rec );
1473 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1474 ok(count == 6, "Expected 6, got %d\n", count);
1475 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1476 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1477 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1478 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1479 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1480 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1481 MsiCloseHandle(rec);
1483 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1484 count = MsiRecordGetFieldCount( rec );
1485 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1486 ok(count == 6, "Expected 6, got %d\n", count);
1487 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1488 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1489 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1490 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1491 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1492 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1494 MsiCloseHandle(rec);
1495 MsiCloseHandle(view);
1496 MsiCloseHandle(hdb);
1497 DeleteFile(msifile);
1500 static void create_cc_test_files(void)
1502 CCAB cabParams;
1503 HFCI hfci;
1504 ERF erf;
1505 static CHAR cab_context[] = "test%d.cab";
1506 BOOL res;
1508 create_file("maximus", 500);
1509 create_file("augustus", 50000);
1510 create_file("caesar", 500);
1512 set_cab_parameters(&cabParams, "test1.cab", 200);
1514 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1515 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1516 get_temp_file, &cabParams, cab_context);
1517 ok(hfci != NULL, "Failed to create an FCI context\n");
1519 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1520 ok(res, "Failed to add file maximus\n");
1522 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1523 ok(res, "Failed to add file augustus\n");
1525 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1526 ok(res, "Failed to flush the cabinet\n");
1528 res = FCIDestroy(hfci);
1529 ok(res, "Failed to destroy the cabinet\n");
1531 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1533 DeleteFile("maximus");
1534 DeleteFile("augustus");
1535 DeleteFile("caesar");
1538 static void delete_cab_files(void)
1540 SHFILEOPSTRUCT shfl;
1541 CHAR path[MAX_PATH+10];
1543 lstrcpyA(path, CURR_DIR);
1544 lstrcatA(path, "\\*.cab");
1545 path[strlen(path) + 1] = '\0';
1547 shfl.hwnd = NULL;
1548 shfl.wFunc = FO_DELETE;
1549 shfl.pFrom = path;
1550 shfl.pTo = NULL;
1551 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1553 SHFileOperation(&shfl);
1556 static void test_continuouscabs(void)
1558 UINT r;
1560 create_cc_test_files();
1561 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1563 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1565 r = MsiInstallProductA(msifile, NULL);
1566 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1567 todo_wine
1569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1570 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1571 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1573 ok(delete_pf("msitest", FALSE), "File not installed\n");
1575 delete_cab_files();
1576 DeleteFile(msifile);
1579 static void test_caborder(void)
1581 UINT r;
1583 create_file("imperator", 100);
1584 create_file("maximus", 500);
1585 create_file("augustus", 50000);
1586 create_file("caesar", 500);
1588 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1590 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1592 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1593 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1594 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1596 r = MsiInstallProductA(msifile, NULL);
1597 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1598 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1599 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1600 todo_wine
1602 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1603 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1606 delete_cab_files();
1608 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1609 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1610 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1612 r = MsiInstallProductA(msifile, NULL);
1613 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1614 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1615 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1616 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1617 todo_wine
1619 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1622 delete_cab_files();
1623 DeleteFile(msifile);
1625 create_cc_test_files();
1626 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1628 r = MsiInstallProductA(msifile, NULL);
1629 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1630 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1631 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1632 todo_wine
1634 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1635 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1638 delete_cab_files();
1639 DeleteFile(msifile);
1641 create_cc_test_files();
1642 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1644 r = MsiInstallProductA(msifile, NULL);
1645 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1646 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1647 todo_wine
1649 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1650 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1651 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1654 delete_cab_files();
1655 DeleteFile("imperator");
1656 DeleteFile("maximus");
1657 DeleteFile("augustus");
1658 DeleteFile("caesar");
1659 DeleteFile(msifile);
1662 static void test_mixedmedia(void)
1664 UINT r;
1666 CreateDirectoryA("msitest", NULL);
1667 create_file("msitest\\maximus", 500);
1668 create_file("msitest\\augustus", 500);
1669 create_file("caesar", 500);
1671 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1673 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1675 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1677 r = MsiInstallProductA(msifile, NULL);
1678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1679 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1680 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1681 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1682 ok(delete_pf("msitest", FALSE), "File not installed\n");
1684 /* Delete the files in the temp (current) folder */
1685 DeleteFile("msitest\\maximus");
1686 DeleteFile("msitest\\augustus");
1687 RemoveDirectory("msitest");
1688 DeleteFile("caesar");
1689 DeleteFile("test1.cab");
1690 DeleteFile(msifile);
1693 static void test_samesequence(void)
1695 UINT r;
1697 create_cc_test_files();
1698 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1700 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1702 r = MsiInstallProductA(msifile, NULL);
1703 todo_wine
1705 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1706 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1707 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1709 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1710 ok(delete_pf("msitest", FALSE), "File not installed\n");
1712 delete_cab_files();
1713 DeleteFile(msifile);
1716 static void test_uiLevelFlags(void)
1718 UINT r;
1720 create_cc_test_files();
1721 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1723 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1725 r = MsiInstallProductA(msifile, NULL);
1726 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1727 todo_wine
1729 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1730 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1732 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1733 ok(delete_pf("msitest", FALSE), "File not installed\n");
1735 delete_cab_files();
1736 DeleteFile(msifile);
1739 static BOOL file_matches(LPSTR path)
1741 CHAR buf[MAX_PATH];
1742 HANDLE file;
1743 DWORD size;
1745 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1746 NULL, OPEN_EXISTING, 0, NULL);
1748 ZeroMemory(buf, MAX_PATH);
1749 ReadFile(file, buf, 15, &size, NULL);
1750 CloseHandle(file);
1752 return !lstrcmp(buf, "msitest\\maximus");
1755 static void test_readonlyfile(void)
1757 UINT r;
1758 DWORD size;
1759 HANDLE file;
1760 CHAR path[MAX_PATH];
1762 CreateDirectoryA("msitest", NULL);
1763 create_file("msitest\\maximus", 500);
1764 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1766 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1768 lstrcpy(path, PROG_FILES_DIR);
1769 lstrcat(path, "\\msitest");
1770 CreateDirectory(path, NULL);
1772 lstrcat(path, "\\maximus");
1773 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1774 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1776 WriteFile(file, "readonlyfile", 20, &size, NULL);
1777 CloseHandle(file);
1779 r = MsiInstallProductA(msifile, NULL);
1780 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1781 ok(file_matches(path), "Expected file to be overwritten\n");
1782 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1783 ok(delete_pf("msitest", FALSE), "File not installed\n");
1785 /* Delete the files in the temp (current) folder */
1786 DeleteFile("msitest\\maximus");
1787 RemoveDirectory("msitest");
1788 DeleteFile(msifile);
1791 static void test_setdirproperty(void)
1793 UINT r;
1795 CreateDirectoryA("msitest", NULL);
1796 create_file("msitest\\maximus", 500);
1797 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1799 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1801 r = MsiInstallProductA(msifile, NULL);
1802 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1803 ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
1804 ok(delete_cf("msitest", FALSE), "File not installed\n");
1806 /* Delete the files in the temp (current) folder */
1807 DeleteFile(msifile);
1808 DeleteFile("msitest\\maximus");
1809 RemoveDirectory("msitest");
1812 static void test_cabisextracted(void)
1814 UINT r;
1816 CreateDirectoryA("msitest", NULL);
1817 create_file("msitest\\gaius", 500);
1818 create_file("maximus", 500);
1819 create_file("augustus", 500);
1820 create_file("caesar", 500);
1822 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1823 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1824 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1826 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1828 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1830 r = MsiInstallProductA(msifile, NULL);
1831 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1832 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1833 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1834 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1835 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1836 ok(delete_pf("msitest", FALSE), "File not installed\n");
1838 /* Delete the files in the temp (current) folder */
1839 delete_cab_files();
1840 DeleteFile(msifile);
1841 DeleteFile("maximus");
1842 DeleteFile("augustus");
1843 DeleteFile("caesar");
1844 DeleteFile("msitest\\gaius");
1845 RemoveDirectory("msitest");
1848 static void test_concurrentinstall(void)
1850 UINT r;
1851 CHAR path[MAX_PATH];
1853 CreateDirectoryA("msitest", NULL);
1854 CreateDirectoryA("msitest\\msitest", NULL);
1855 create_file("msitest\\maximus", 500);
1856 create_file("msitest\\msitest\\augustus", 500);
1858 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1860 lstrcpyA(path, CURR_DIR);
1861 lstrcatA(path, "\\msitest\\concurrent.msi");
1862 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1864 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1866 r = MsiInstallProductA(msifile, NULL);
1867 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1868 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1869 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1870 ok(delete_pf("msitest", FALSE), "File not installed\n");
1872 DeleteFile(path);
1874 r = MsiInstallProductA(msifile, NULL);
1875 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1876 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1877 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
1878 ok(delete_pf("msitest", FALSE), "File not installed\n");
1880 DeleteFile(msifile);
1881 DeleteFile("msitest\\msitest\\augustus");
1882 DeleteFile("msitest\\maximus");
1883 RemoveDirectory("msitest\\msitest");
1884 RemoveDirectory("msitest");
1887 static void test_setpropertyfolder(void)
1889 UINT r;
1891 CreateDirectoryA("msitest", NULL);
1892 create_file("msitest\\maximus", 500);
1894 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1896 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1898 r = MsiInstallProductA(msifile, NULL);
1899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1900 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1901 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1902 ok(delete_pf("msitest", FALSE), "File not installed\n");
1904 /* Delete the files in the temp (current) folder */
1905 DeleteFile(msifile);
1906 DeleteFile("msitest\\maximus");
1907 RemoveDirectory("msitest");
1910 static BOOL file_exists(LPCSTR file)
1912 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
1915 static BOOL pf_exists(LPCSTR file)
1917 CHAR path[MAX_PATH];
1919 lstrcpyA(path, PROG_FILES_DIR);
1920 lstrcatA(path, "\\");
1921 lstrcatA(path, file);
1923 return file_exists(path);
1926 static void delete_pfmsitest_files(void)
1928 SHFILEOPSTRUCT shfl;
1929 CHAR path[MAX_PATH+11];
1931 lstrcpyA(path, PROG_FILES_DIR);
1932 lstrcatA(path, "\\msitest\\*");
1933 path[strlen(path) + 1] = '\0';
1935 shfl.hwnd = NULL;
1936 shfl.wFunc = FO_DELETE;
1937 shfl.pFrom = path;
1938 shfl.pTo = NULL;
1939 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1941 SHFileOperation(&shfl);
1943 lstrcpyA(path, PROG_FILES_DIR);
1944 lstrcatA(path, "\\msitest");
1945 RemoveDirectoryA(path);
1948 static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
1950 char val[MAX_PATH];
1951 DWORD size, type;
1952 LONG res;
1954 size = MAX_PATH;
1955 val[0] = '\0';
1956 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
1958 if (res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ))
1960 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
1961 return;
1964 if (!expected)
1965 ok_(__FILE__, line)(lstrlenA(val) == 0, "Expected empty string, got %s\n", val);
1966 else
1968 if (bcase)
1969 ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
1970 else
1971 ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
1975 static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD line)
1977 DWORD val, size, type;
1978 LONG res;
1980 size = sizeof(DWORD);
1981 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
1983 if (res != ERROR_SUCCESS || type != REG_DWORD)
1985 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
1986 return;
1989 ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
1992 #define CHECK_REG_STR(prodkey, name, expected) \
1993 check_reg_str(prodkey, name, expected, TRUE, __LINE__);
1995 #define CHECK_REG_ISTR(prodkey, name, expected) \
1996 check_reg_str(prodkey, name, expected, FALSE, __LINE__);
1998 #define CHECK_REG_DWORD(prodkey, name, expected) \
1999 check_reg_dword(prodkey, name, expected, __LINE__);
2001 static void get_date_str(LPSTR date)
2003 SYSTEMTIME systime;
2005 static const char date_fmt[] = "%d%02d%02d";
2006 GetLocalTime(&systime);
2007 sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
2010 static void test_publish(void)
2012 UINT r;
2013 LONG res;
2014 HKEY uninstall, prodkey;
2015 INSTALLSTATE state;
2016 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2017 char date[MAX_PATH];
2018 char temp[MAX_PATH];
2020 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2022 get_date_str(date);
2023 GetTempPath(MAX_PATH, temp);
2025 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2026 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2028 CreateDirectoryA("msitest", NULL);
2029 create_file("msitest\\maximus", 500);
2031 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2033 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2035 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2036 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2038 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2039 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2041 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2042 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2044 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2045 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2046 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2047 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2049 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2050 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2052 /* nothing published */
2053 r = MsiInstallProductA(msifile, NULL);
2054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2055 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2056 ok(pf_exists("msitest"), "File not installed\n");
2058 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2059 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2061 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2062 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2064 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2065 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2067 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2068 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2069 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2070 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2072 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2073 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2075 /* install again */
2076 r = MsiInstallProductA(msifile, NULL);
2077 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2078 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2079 ok(pf_exists("msitest"), "File not installed\n");
2081 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2082 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2084 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2085 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2087 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2088 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2090 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2091 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2092 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2093 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2095 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2096 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2098 /* try to uninstall */
2099 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2100 todo_wine
2102 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2104 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2105 ok(pf_exists("msitest"), "File deleted\n");
2107 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2108 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2110 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2111 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2113 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2114 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2116 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2117 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2118 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2119 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2121 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2122 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2124 /* PublishProduct */
2125 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2127 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2128 ok(pf_exists("msitest"), "File not installed\n");
2130 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2131 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2133 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2134 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2136 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2137 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2138 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2139 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2141 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2142 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2144 /* try to uninstall after PublishProduct */
2145 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2147 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2148 ok(pf_exists("msitest"), "File deleted\n");
2150 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2151 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2153 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2154 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2156 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2157 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2159 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2160 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2161 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2162 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2164 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2165 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2167 /* RegisterProduct */
2168 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2169 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2170 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2171 ok(pf_exists("msitest"), "File not installed\n");
2173 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2174 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2176 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2177 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2179 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2180 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2181 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2182 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2184 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2185 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2187 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2188 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2189 CHECK_REG_STR(prodkey, "InstallDate", date);
2190 CHECK_REG_STR(prodkey, "InstallSource", temp);
2191 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2192 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2193 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2194 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2195 CHECK_REG_STR(prodkey, "Comments", NULL);
2196 CHECK_REG_STR(prodkey, "Contact", NULL);
2197 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2198 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2199 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2200 CHECK_REG_STR(prodkey, "Readme", NULL);
2201 CHECK_REG_STR(prodkey, "Size", NULL);
2202 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2203 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2204 CHECK_REG_DWORD(prodkey, "Language", 1033);
2205 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2206 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2207 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2208 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2209 todo_wine
2211 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2214 RegCloseKey(prodkey);
2216 /* complete uninstall */
2217 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2218 todo_wine
2220 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2222 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2223 ok(pf_exists("msitest"), "File deleted\n");
2225 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2226 todo_wine
2228 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2231 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2232 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2234 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2235 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2237 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2238 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2239 todo_wine
2241 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2243 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2245 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2246 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2248 todo_wine
2250 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2251 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2252 CHECK_REG_STR(prodkey, "InstallDate", date);
2253 CHECK_REG_STR(prodkey, "InstallSource", temp);
2254 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2255 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2256 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2257 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2258 CHECK_REG_STR(prodkey, "Comments", NULL);
2259 CHECK_REG_STR(prodkey, "Contact", NULL);
2260 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2261 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2262 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2263 CHECK_REG_STR(prodkey, "Readme", NULL);
2264 CHECK_REG_STR(prodkey, "Size", NULL);
2265 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2266 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2267 CHECK_REG_DWORD(prodkey, "Language", 1033);
2268 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2269 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2270 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2271 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2272 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2275 RegCloseKey(prodkey);
2277 /* PublishProduct and RegisterProduct */
2278 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2280 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2281 ok(pf_exists("msitest"), "File not installed\n");
2283 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2284 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2286 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2287 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2289 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2290 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2292 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2293 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2294 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2295 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2297 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2298 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2300 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2301 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2302 CHECK_REG_STR(prodkey, "InstallDate", date);
2303 CHECK_REG_STR(prodkey, "InstallSource", temp);
2304 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2305 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2306 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2307 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2308 CHECK_REG_STR(prodkey, "Comments", NULL);
2309 CHECK_REG_STR(prodkey, "Contact", NULL);
2310 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2311 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2312 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2313 CHECK_REG_STR(prodkey, "Readme", NULL);
2314 CHECK_REG_STR(prodkey, "Size", NULL);
2315 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2316 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2317 CHECK_REG_DWORD(prodkey, "Language", 1033);
2318 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2319 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2320 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2321 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2322 todo_wine
2324 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2327 RegCloseKey(prodkey);
2329 /* try it again */
2330 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2332 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2333 ok(pf_exists("msitest"), "File not installed\n");
2335 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2336 todo_wine
2338 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2341 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2342 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2344 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2345 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2347 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2348 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2349 todo_wine
2351 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2353 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2355 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2356 todo_wine
2358 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2361 /* uninstall has a problem with this */
2362 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2363 todo_wine
2365 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2367 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2368 ok(pf_exists("msitest"), "File deleted\n");
2370 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2371 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2373 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2374 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2376 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2377 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2378 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2379 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2381 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2382 todo_wine
2384 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2387 /* PublishProduct and RegisterProduct and ProcessComponents */
2388 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
2389 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2390 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2391 ok(pf_exists("msitest"), "File not installed\n");
2393 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2394 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2396 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2397 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2399 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2400 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2402 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2403 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2404 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2405 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2407 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2408 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2410 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2411 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2412 CHECK_REG_STR(prodkey, "InstallDate", date);
2413 CHECK_REG_STR(prodkey, "InstallSource", temp);
2414 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2415 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2416 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2417 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2418 CHECK_REG_STR(prodkey, "Comments", NULL);
2419 CHECK_REG_STR(prodkey, "Contact", NULL);
2420 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2421 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2422 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2423 CHECK_REG_STR(prodkey, "Readme", NULL);
2424 CHECK_REG_STR(prodkey, "Size", NULL);
2425 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2426 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2427 CHECK_REG_DWORD(prodkey, "Language", 1033);
2428 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2429 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2430 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2431 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2432 todo_wine
2434 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2437 RegCloseKey(prodkey);
2439 /* complete uninstall */
2440 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2442 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2443 ok(pf_exists("msitest"), "File deleted\n");
2445 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2446 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2448 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2449 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2451 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2452 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2454 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2455 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2456 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2457 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2459 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2460 todo_wine
2462 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2465 /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
2466 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
2467 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2468 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2469 ok(pf_exists("msitest"), "File not installed\n");
2471 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2472 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2474 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2475 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2477 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2478 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2480 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2481 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2482 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2483 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2485 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2486 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2488 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2489 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2490 CHECK_REG_STR(prodkey, "InstallDate", date);
2491 CHECK_REG_STR(prodkey, "InstallSource", temp);
2492 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2493 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2494 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2495 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2496 CHECK_REG_STR(prodkey, "Comments", NULL);
2497 CHECK_REG_STR(prodkey, "Contact", NULL);
2498 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2499 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2500 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2501 CHECK_REG_STR(prodkey, "Readme", NULL);
2502 CHECK_REG_STR(prodkey, "Size", NULL);
2503 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2504 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2505 CHECK_REG_DWORD(prodkey, "Language", 1033);
2506 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2507 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2508 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2509 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2510 todo_wine
2512 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2515 RegCloseKey(prodkey);
2517 /* complete uninstall */
2518 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2519 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2520 todo_wine
2522 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2523 ok(!pf_exists("msitest"), "File deleted\n");
2526 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2527 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2529 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2530 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2532 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2533 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2535 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2536 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2537 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2538 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2540 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2541 todo_wine
2543 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2546 /* complete install */
2547 r = MsiInstallProductA(msifile, "FULL=1");
2548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2549 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2550 ok(pf_exists("msitest"), "File not installed\n");
2552 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2553 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2555 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2556 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2558 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2559 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2561 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2562 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2563 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2564 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2566 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2567 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2569 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2570 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2571 CHECK_REG_STR(prodkey, "InstallDate", date);
2572 CHECK_REG_STR(prodkey, "InstallSource", temp);
2573 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2574 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2575 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2576 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2577 CHECK_REG_STR(prodkey, "Comments", NULL);
2578 CHECK_REG_STR(prodkey, "Contact", NULL);
2579 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2580 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2581 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2582 CHECK_REG_STR(prodkey, "Readme", NULL);
2583 CHECK_REG_STR(prodkey, "Size", NULL);
2584 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2585 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2586 CHECK_REG_DWORD(prodkey, "Language", 1033);
2587 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2588 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2589 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2590 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2591 todo_wine
2593 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2596 RegCloseKey(prodkey);
2598 /* no UnpublishFeatures */
2599 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2601 todo_wine
2603 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2604 ok(!pf_exists("msitest"), "File deleted\n");
2607 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2608 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2610 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2611 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2613 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2614 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2616 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2617 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2618 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2619 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2621 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2622 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2624 /* complete install */
2625 r = MsiInstallProductA(msifile, "FULL=1");
2626 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2627 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2628 ok(pf_exists("msitest"), "File not installed\n");
2630 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2631 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2633 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2634 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2636 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2637 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2639 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2640 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2641 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2642 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2644 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2645 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2647 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2648 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2649 CHECK_REG_STR(prodkey, "InstallDate", date);
2650 CHECK_REG_STR(prodkey, "InstallSource", temp);
2651 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2652 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2653 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2654 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2655 CHECK_REG_STR(prodkey, "Comments", NULL);
2656 CHECK_REG_STR(prodkey, "Contact", NULL);
2657 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2658 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2659 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2660 CHECK_REG_STR(prodkey, "Readme", NULL);
2661 CHECK_REG_STR(prodkey, "Size", NULL);
2662 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2663 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2664 CHECK_REG_DWORD(prodkey, "Language", 1033);
2665 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2666 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2667 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2668 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2669 todo_wine
2671 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2674 RegCloseKey(prodkey);
2676 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
2677 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
2678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2679 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2680 ok(pf_exists("msitest"), "File deleted\n");
2682 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2683 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2685 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2686 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2688 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2689 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2691 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2692 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2693 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2694 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2696 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2697 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2699 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2700 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2701 CHECK_REG_STR(prodkey, "InstallDate", date);
2702 CHECK_REG_STR(prodkey, "InstallSource", temp);
2703 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2704 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2705 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2706 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2707 CHECK_REG_STR(prodkey, "Comments", NULL);
2708 CHECK_REG_STR(prodkey, "Contact", NULL);
2709 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2710 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2711 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2712 CHECK_REG_STR(prodkey, "Readme", NULL);
2713 CHECK_REG_STR(prodkey, "Size", NULL);
2714 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2715 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2716 CHECK_REG_DWORD(prodkey, "Language", 1033);
2717 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2718 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2719 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2720 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2721 todo_wine
2723 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2726 RegCloseKey(prodkey);
2728 /* complete install */
2729 r = MsiInstallProductA(msifile, "FULL=1");
2730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2731 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2732 ok(pf_exists("msitest"), "File not installed\n");
2734 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2735 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2737 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2738 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2740 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2741 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2743 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2744 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2745 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2746 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2748 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2749 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2751 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2752 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2753 CHECK_REG_STR(prodkey, "InstallDate", date);
2754 CHECK_REG_STR(prodkey, "InstallSource", temp);
2755 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2756 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2757 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2758 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2759 CHECK_REG_STR(prodkey, "Comments", NULL);
2760 CHECK_REG_STR(prodkey, "Contact", NULL);
2761 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2762 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2763 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2764 CHECK_REG_STR(prodkey, "Readme", NULL);
2765 CHECK_REG_STR(prodkey, "Size", NULL);
2766 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2767 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2768 CHECK_REG_DWORD(prodkey, "Language", 1033);
2769 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2770 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2771 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2772 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2773 todo_wine
2775 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2778 RegCloseKey(prodkey);
2780 /* UnpublishFeatures, both features removed */
2781 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
2782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2783 todo_wine
2785 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2786 ok(!pf_exists("msitest"), "File not deleted\n");
2789 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2790 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2792 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2793 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2795 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2796 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2798 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2799 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2800 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2801 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2803 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2804 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2806 /* complete install */
2807 r = MsiInstallProductA(msifile, "FULL=1");
2808 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2809 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2810 ok(pf_exists("msitest"), "File not installed\n");
2812 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2813 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2815 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2816 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2818 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2819 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2821 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2822 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2824 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2826 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2827 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2829 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2830 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2831 CHECK_REG_STR(prodkey, "InstallDate", date);
2832 CHECK_REG_STR(prodkey, "InstallSource", temp);
2833 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2834 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2835 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2836 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2837 CHECK_REG_STR(prodkey, "Comments", NULL);
2838 CHECK_REG_STR(prodkey, "Contact", NULL);
2839 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2840 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2841 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2842 CHECK_REG_STR(prodkey, "Readme", NULL);
2843 CHECK_REG_STR(prodkey, "Size", NULL);
2844 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2845 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2846 CHECK_REG_DWORD(prodkey, "Language", 1033);
2847 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2848 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2849 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2850 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2851 todo_wine
2853 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2856 RegCloseKey(prodkey);
2858 /* complete uninstall */
2859 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2860 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2861 todo_wine
2863 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2864 ok(!pf_exists("msitest"), "File not deleted\n");
2867 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2868 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2870 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2871 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2873 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2874 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2876 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2877 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2878 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2879 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2881 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2882 todo_wine
2884 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2887 /* make sure 'Program Files\msitest' is removed */
2888 delete_pfmsitest_files();
2890 RegCloseKey(uninstall);
2891 DeleteFile(msifile);
2892 DeleteFile("msitest\\maximus");
2893 RemoveDirectory("msitest");
2896 static void test_publishsourcelist(void)
2898 UINT r;
2899 DWORD size;
2900 CHAR value[MAX_PATH];
2901 CHAR path[MAX_PATH];
2902 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2904 CreateDirectoryA("msitest", NULL);
2905 create_file("msitest\\maximus", 500);
2907 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2909 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2911 r = MsiInstallProductA(msifile, NULL);
2912 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2913 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2914 ok(pf_exists("msitest"), "File not installed\n");
2916 /* nothing published */
2917 size = 0xdeadbeef;
2918 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2919 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2920 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2921 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2923 size = 0xdeadbeef;
2924 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2925 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
2926 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2927 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2929 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2930 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2931 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2932 ok(pf_exists("msitest"), "File not installed\n");
2934 /* after RegisterProduct */
2935 size = 0xdeadbeef;
2936 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2937 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2938 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2939 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2941 size = 0xdeadbeef;
2942 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2943 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
2944 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2945 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2947 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2948 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2949 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2950 ok(pf_exists("msitest"), "File not installed\n");
2952 /* after ProcessComponents */
2953 size = 0xdeadbeef;
2954 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2955 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2956 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2957 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2959 size = 0xdeadbeef;
2960 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2961 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
2962 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2963 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2965 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2966 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2967 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2968 ok(pf_exists("msitest"), "File not installed\n");
2970 /* after PublishFeatures */
2971 size = 0xdeadbeef;
2972 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2973 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2974 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2975 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2977 size = 0xdeadbeef;
2978 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2979 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
2980 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2981 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2983 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2984 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2985 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2986 ok(pf_exists("msitest"), "File not installed\n");
2988 /* after PublishProduct */
2989 size = MAX_PATH;
2990 lstrcpyA(value, "aaa");
2991 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2992 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
2993 todo_wine
2995 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2996 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
2997 ok(size == 11, "Expected 11, got %d\n", size);
3000 size = MAX_PATH;
3001 lstrcpyA(value, "aaa");
3002 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3003 MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH, value, &size);
3004 todo_wine
3006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3007 ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
3008 ok(size == 0, "Expected 0, got %d\n", size);
3011 size = MAX_PATH;
3012 lstrcpyA(value, "aaa");
3013 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3014 MSICODE_PRODUCT, INSTALLPROPERTY_DISKPROMPT, value, &size);
3015 todo_wine
3017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3018 ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
3019 ok(size == 0, "Expected 0, got %d\n", size);
3022 lstrcpyA(path, CURR_DIR);
3023 lstrcatA(path, "\\");
3025 size = MAX_PATH;
3026 lstrcpyA(value, "aaa");
3027 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3028 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
3029 todo_wine
3031 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3032 ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
3033 ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
3036 size = MAX_PATH;
3037 lstrcpyA(value, "aaa");
3038 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3039 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDTYPE, value, &size);
3040 todo_wine
3042 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3043 ok(!lstrcmpA(value, "n"), "Expected \"n\", got \"%s\"\n", value);
3044 ok(size == 1, "Expected 1, got %d\n", size);
3047 size = MAX_PATH;
3048 lstrcpyA(value, "aaa");
3049 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3050 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
3051 todo_wine
3053 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3055 ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
3056 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
3058 size = MAX_PATH;
3059 lstrcpyA(value, "aaa");
3060 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3061 MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 0, value, &size);
3062 todo_wine
3064 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3065 ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
3066 ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
3069 size = MAX_PATH;
3070 lstrcpyA(value, "aaa");
3071 r = MsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3072 MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 1, value, &size);
3073 todo_wine
3075 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3077 ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
3078 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
3080 /* complete uninstall */
3081 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
3082 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3083 todo_wine
3085 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
3086 ok(!pf_exists("msitest"), "File not deleted\n");
3089 /* make sure 'Program Files\msitest' is removed */
3090 delete_pfmsitest_files();
3092 DeleteFile(msifile);
3093 DeleteFile("msitest\\maximus");
3094 RemoveDirectory("msitest");
3097 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
3099 MSIHANDLE hview = 0;
3100 UINT r;
3102 r = MsiDatabaseOpenView(hdb, query, &hview);
3103 if(r != ERROR_SUCCESS)
3104 return r;
3106 r = MsiViewExecute(hview, hrec);
3107 if(r == ERROR_SUCCESS)
3108 r = MsiViewClose(hview);
3109 MsiCloseHandle(hview);
3110 return r;
3113 static void set_transform_summary_info(void)
3115 UINT r;
3116 MSIHANDLE suminfo = 0;
3118 /* build summmary info */
3119 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
3120 todo_wine
3122 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
3125 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
3126 todo_wine
3128 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3131 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
3132 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
3133 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
3134 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
3135 todo_wine
3137 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
3140 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
3141 todo_wine
3143 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3146 r = MsiSummaryInfoPersist(suminfo);
3147 todo_wine
3149 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
3152 r = MsiCloseHandle(suminfo);
3153 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
3156 static void generate_transform(void)
3158 MSIHANDLE hdb1, hdb2;
3159 LPCSTR query;
3160 UINT r;
3162 /* start with two identical databases */
3163 CopyFile(msifile, msifile2, FALSE);
3165 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
3166 ok(r == ERROR_SUCCESS , "Failed to create database\n");
3168 r = MsiDatabaseCommit(hdb1);
3169 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
3171 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
3172 ok(r == ERROR_SUCCESS , "Failed to create database\n");
3174 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
3175 r = run_query(hdb1, 0, query);
3176 ok(r == ERROR_SUCCESS, "failed to add property\n");
3178 /* database needs to be committed */
3179 MsiDatabaseCommit(hdb1);
3181 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
3182 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
3184 #if 0 /* not implemented in wine yet */
3185 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
3186 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3187 #endif
3189 MsiCloseHandle(hdb1);
3190 MsiCloseHandle(hdb2);
3193 /* data for generating a transform */
3195 /* tables transform names - encoded as they would be in an msi database file */
3196 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
3197 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
3198 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
3200 /* data in each table */
3201 static const char data1[] = /* _StringData */
3202 "propval"; /* all the strings squashed together */
3204 static const WCHAR data2[] = { /* _StringPool */
3205 /* len, refs */
3206 0, 0, /* string 0 '' */
3207 4, 1, /* string 1 'prop' */
3208 3, 1, /* string 2 'val' */
3211 static const WCHAR data3[] = { /* Property */
3212 0x0201, 0x0001, 0x0002,
3215 static const struct {
3216 LPCWSTR name;
3217 const void *data;
3218 DWORD size;
3219 } table_transform_data[] =
3221 { name1, data1, sizeof data1 - 1 },
3222 { name2, data2, sizeof data2 },
3223 { name3, data3, sizeof data3 },
3226 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
3228 static void generate_transform_manual(void)
3230 IStorage *stg = NULL;
3231 IStream *stm;
3232 WCHAR name[0x20];
3233 HRESULT r;
3234 DWORD i, count;
3235 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
3237 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
3239 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
3241 r = StgCreateDocfile(name, mode, 0, &stg);
3242 ok(r == S_OK, "failed to create storage\n");
3243 if (!stg)
3244 return;
3246 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
3247 ok(r == S_OK, "failed to set storage type\n");
3249 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
3251 r = IStorage_CreateStream(stg, table_transform_data[i].name,
3252 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3253 if (FAILED(r))
3255 ok(0, "failed to create stream %08x\n", r);
3256 continue;
3259 r = IStream_Write(stm, table_transform_data[i].data,
3260 table_transform_data[i].size, &count);
3261 if (FAILED(r) || count != table_transform_data[i].size)
3262 ok(0, "failed to write stream\n");
3263 IStream_Release(stm);
3266 IStorage_Release(stg);
3268 set_transform_summary_info();
3271 static void test_transformprop(void)
3273 UINT r;
3275 CreateDirectoryA("msitest", NULL);
3276 create_file("msitest\\augustus", 500);
3278 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
3280 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3282 r = MsiInstallProductA(msifile, NULL);
3283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3284 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3285 ok(!delete_pf("msitest", FALSE), "File installed\n");
3287 if (0)
3288 generate_transform();
3289 else
3290 generate_transform_manual();
3292 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
3293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3294 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3295 ok(delete_pf("msitest", FALSE), "File not installed\n");
3297 /* Delete the files in the temp (current) folder */
3298 DeleteFile(msifile);
3299 DeleteFile(msifile2);
3300 DeleteFile(mstfile);
3301 DeleteFile("msitest\\augustus");
3302 RemoveDirectory("msitest");
3305 static void test_currentworkingdir(void)
3307 UINT r;
3308 CHAR path[MAX_PATH];
3309 LPSTR ptr, ptr2;
3311 CreateDirectoryA("msitest", NULL);
3312 create_file("msitest\\augustus", 500);
3314 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
3316 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3318 CreateDirectoryA("diffdir", NULL);
3319 SetCurrentDirectoryA("diffdir");
3321 sprintf(path, "..\\%s", msifile);
3322 r = MsiInstallProductA(path, NULL);
3323 todo_wine
3325 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
3326 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3327 ok(!delete_pf("msitest", FALSE), "File installed\n");
3330 sprintf(path, "%s\\%s", CURR_DIR, msifile);
3331 r = MsiInstallProductA(path, NULL);
3332 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3333 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3334 ok(delete_pf("msitest", FALSE), "File not installed\n");
3336 lstrcpyA(path, CURR_DIR);
3337 if (path[lstrlenA(path) - 1] != '\\')
3338 lstrcatA(path, "\\");
3339 lstrcatA(path, "msitest.msi");
3341 ptr2 = strrchr(path, '\\');
3342 *ptr2 = '\0';
3343 ptr = strrchr(path, '\\');
3344 *ptr2 = '\\';
3345 *(ptr++) = '\0';
3347 SetCurrentDirectoryA(path);
3349 r = MsiInstallProductA(ptr, NULL);
3350 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3351 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3352 ok(delete_pf("msitest", FALSE), "File not installed\n");
3354 SetCurrentDirectoryA(CURR_DIR);
3356 DeleteFile(msifile);
3357 DeleteFile("msitest\\augustus");
3358 RemoveDirectory("msitest");
3359 RemoveDirectory("diffdir");
3362 static void set_admin_summary_info(const CHAR *name)
3364 MSIHANDLE db, summary;
3365 UINT r;
3367 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
3368 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3370 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
3371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3373 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
3374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3376 /* write the summary changes back to the stream */
3377 r = MsiSummaryInfoPersist(summary);
3378 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3380 MsiCloseHandle(summary);
3382 r = MsiDatabaseCommit(db);
3383 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3385 MsiCloseHandle(db);
3388 static void test_admin(void)
3390 UINT r;
3392 CreateDirectoryA("msitest", NULL);
3393 create_file("msitest\\augustus", 500);
3395 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
3396 set_admin_summary_info(msifile);
3398 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3400 r = MsiInstallProductA(msifile, NULL);
3401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3402 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3403 ok(!delete_pf("msitest", FALSE), "File installed\n");
3404 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
3405 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
3407 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
3408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3409 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3410 ok(!delete_pf("msitest", FALSE), "File installed\n");
3411 todo_wine
3413 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
3414 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
3417 DeleteFile(msifile);
3418 DeleteFile("msitest\\augustus");
3419 RemoveDirectory("msitest");
3422 static void set_admin_property_stream(LPCSTR file)
3424 IStorage *stg;
3425 IStream *stm;
3426 WCHAR fileW[MAX_PATH];
3427 HRESULT hr;
3428 DWORD count;
3429 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
3431 /* AdminProperties */
3432 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
3433 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
3435 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
3437 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
3438 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3439 if (!stg)
3440 return;
3442 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3443 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3445 hr = IStream_Write(stm, data, sizeof(data), &count);
3446 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3448 IStream_Release(stm);
3449 IStorage_Release(stg);
3452 static void test_adminprops(void)
3454 UINT r;
3456 CreateDirectoryA("msitest", NULL);
3457 create_file("msitest\\augustus", 500);
3459 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
3460 set_admin_summary_info(msifile);
3461 set_admin_property_stream(msifile);
3463 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3465 r = MsiInstallProductA(msifile, NULL);
3466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3467 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
3468 ok(delete_pf("msitest", FALSE), "File installed\n");
3470 DeleteFile(msifile);
3471 DeleteFile("msitest\\augustus");
3472 RemoveDirectory("msitest");
3475 static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file)
3477 CHAR path[MAX_PATH];
3479 lstrcpyA(path, PROG_FILES_DIR);
3480 lstrcatA(path, "\\");
3481 lstrcatA(path, file);
3483 if (is_file)
3484 create_file_data(path, data, 500);
3485 else
3486 CreateDirectoryA(path, NULL);
3489 #define create_pf(file, is_file) create_pf_data(file, file, is_file)
3491 static void test_removefiles(void)
3493 UINT r;
3495 CreateDirectoryA("msitest", NULL);
3496 create_file("msitest\\hydrogen", 500);
3497 create_file("msitest\\helium", 500);
3498 create_file("msitest\\lithium", 500);
3500 create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
3502 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3504 r = MsiInstallProductA(msifile, NULL);
3505 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3506 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3507 ok(!pf_exists("msitest\\helium"), "File installed\n");
3508 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3509 ok(pf_exists("msitest"), "File not installed\n");
3511 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3512 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3513 ok(!pf_exists("msitest\\helium"), "File not deleted\n");
3514 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3515 todo_wine
3517 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3518 ok(delete_pf("msitest", FALSE), "File deleted\n");
3521 create_pf("msitest", FALSE);
3522 create_pf("msitest\\hydrogen", TRUE);
3523 create_pf("msitest\\helium", TRUE);
3524 create_pf("msitest\\lithium", TRUE);
3526 r = MsiInstallProductA(msifile, NULL);
3527 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3528 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3529 ok(pf_exists("msitest\\helium"), "File not installed\n");
3530 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3531 ok(pf_exists("msitest"), "File not installed\n");
3533 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3534 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3535 ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
3536 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3537 todo_wine
3539 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3540 ok(delete_pf("msitest", FALSE), "File deleted\n");
3543 create_pf("msitest", FALSE);
3544 create_pf("msitest\\furlong", TRUE);
3545 create_pf("msitest\\firkin", TRUE);
3546 create_pf("msitest\\fortnight", TRUE);
3547 create_pf("msitest\\becquerel", TRUE);
3548 create_pf("msitest\\dioptre", TRUE);
3549 create_pf("msitest\\attoparsec", TRUE);
3550 create_pf("msitest\\storeys", TRUE);
3551 create_pf("msitest\\block", TRUE);
3552 create_pf("msitest\\siriometer", TRUE);
3554 r = MsiInstallProductA(msifile, NULL);
3555 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3556 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3557 ok(!pf_exists("msitest\\helium"), "File installed\n");
3558 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3559 ok(pf_exists("msitest\\becquerel"), "File not installed\n");
3560 ok(pf_exists("msitest\\dioptre"), "File not installed\n");
3561 ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
3562 ok(pf_exists("msitest"), "File not installed\n");
3563 todo_wine
3565 ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
3566 ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
3567 ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
3568 ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
3569 ok(!pf_exists("msitest\\block"), "File not deleted\n");
3570 ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
3573 create_pf("msitest\\furlong", TRUE);
3574 create_pf("msitest\\firkin", TRUE);
3575 create_pf("msitest\\fortnight", TRUE);
3576 create_pf("msitest\\storeys", TRUE);
3577 create_pf("msitest\\block", TRUE);
3578 create_pf("msitest\\siriometer", TRUE);
3580 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3581 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3582 ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
3583 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3584 ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
3585 ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
3586 ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
3587 ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
3588 ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
3589 todo_wine
3591 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
3592 ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
3593 ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
3594 ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
3595 ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
3597 ok(delete_pf("msitest", FALSE), "File deleted\n");
3599 DeleteFile(msifile);
3600 DeleteFile("msitest\\hydrogen");
3601 DeleteFile("msitest\\helium");
3602 DeleteFile("msitest\\lithium");
3603 RemoveDirectory("msitest");
3606 static void test_movefiles(void)
3608 UINT r;
3609 char props[MAX_PATH];
3611 CreateDirectoryA("msitest", NULL);
3612 create_file("msitest\\augustus", 100);
3613 create_file("cameroon", 100);
3614 create_file("djibouti", 100);
3615 create_file("egypt", 100);
3616 create_file("finland", 100);
3617 create_file("gambai", 100);
3618 create_file("honduras", 100);
3619 create_file("msitest\\india", 100);
3620 create_file("japan", 100);
3621 create_file("kenya", 100);
3622 CreateDirectoryA("latvia", NULL);
3623 create_file("nauru", 100);
3624 create_file("apple", 100);
3625 create_file("application", 100);
3626 create_file("ape", 100);
3627 create_file("foo", 100);
3628 create_file("fao", 100);
3629 create_file("fbod", 100);
3630 create_file("budding", 100);
3631 create_file("buddy", 100);
3632 create_file("bud", 100);
3633 create_file("bar", 100);
3634 create_file("bur", 100);
3635 create_file("bird", 100);
3637 create_database(msifile, mov_tables, sizeof(mov_tables) / sizeof(msi_table));
3639 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3640 MsiEnableLog(INSTALLLOGMODE_VERBOSE | INSTALLLOGMODE_EXTRADEBUG, "log.txt", 0);
3642 /* if the source or dest property is not a full path,
3643 * windows tries to access it as a network resource
3646 sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
3647 "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
3648 CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);
3650 r = MsiInstallProductA(msifile, props);
3651 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3652 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3653 ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
3654 ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
3655 ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
3656 ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
3657 ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
3658 ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
3659 ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
3660 ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
3661 ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
3662 ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
3663 ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
3664 ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
3665 /* either apple or application will be moved depending on directory order */
3666 if (!delete_pf("msitest\\apple", TRUE))
3667 ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
3668 else
3669 ok(!delete_pf("msitest\\application", TRUE), "File should not exist\n");
3670 ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
3671 ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
3672 ok(delete_pf("msitest\\foo", TRUE), "File not moved\n");
3673 ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
3674 ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
3675 ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
3676 ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
3677 ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
3678 ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
3679 ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
3680 ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
3681 ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
3682 ok(delete_pf("msitest", FALSE), "File not installed\n");
3683 ok(DeleteFileA("cameroon"), "File moved\n");
3684 ok(!DeleteFileA("djibouti"), "File not moved\n");
3685 ok(DeleteFileA("egypt"), "File moved\n");
3686 ok(DeleteFileA("finland"), "File moved\n");
3687 ok(DeleteFileA("gambai"), "File moved\n");
3688 ok(!DeleteFileA("honduras"), "File not moved\n");
3689 ok(DeleteFileA("msitest\\india"), "File moved\n");
3690 ok(DeleteFileA("japan"), "File moved\n");
3691 ok(!DeleteFileA("kenya"), "File not moved\n");
3692 ok(RemoveDirectoryA("latvia"), "Directory moved\n");
3693 ok(!DeleteFileA("nauru"), "File not moved\n");
3694 ok(!DeleteFileA("apple"), "File not moved\n");
3695 ok(!DeleteFileA("application"), "File not moved\n");
3696 ok(DeleteFileA("ape"), "File moved\n");
3697 ok(!DeleteFileA("foo"), "File not moved\n");
3698 ok(!DeleteFileA("fao"), "File not moved\n");
3699 ok(DeleteFileA("fbod"), "File moved\n");
3700 ok(!DeleteFileA("budding"), "File not moved\n");
3701 ok(!DeleteFileA("buddy"), "File not moved\n");
3702 ok(DeleteFileA("bud"), "File moved\n");
3703 ok(!DeleteFileA("bar"), "File not moved\n");
3704 ok(!DeleteFileA("bur"), "File not moved\n");
3705 ok(DeleteFileA("bird"), "File moved\n");
3707 DeleteFile("msitest\\augustus");
3708 RemoveDirectory("msitest");
3709 DeleteFile(msifile);
3712 static void test_missingcab(void)
3714 UINT r;
3716 CreateDirectoryA("msitest", NULL);
3717 create_file("msitest\\augustus", 500);
3718 create_file("maximus", 500);
3720 create_database(msifile, mc_tables, sizeof(mc_tables) / sizeof(msi_table));
3722 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3724 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
3726 create_pf("msitest", FALSE);
3727 create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
3729 r = MsiInstallProductA(msifile, NULL);
3730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3731 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3732 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3733 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3734 ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
3735 ok(delete_pf("msitest", FALSE), "File not installed\n");
3737 create_pf("msitest", FALSE);
3738 create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
3739 create_pf("msitest\\gaius", TRUE);
3741 r = MsiInstallProductA(msifile, "GAIUS=1");
3742 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3743 todo_wine
3745 ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
3746 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3748 ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
3749 ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
3750 ok(delete_pf("msitest", FALSE), "File not installed\n");
3752 DeleteFile("msitest\\augustus");
3753 RemoveDirectory("msitest");
3754 DeleteFile("maximus");
3755 DeleteFile("test1.cab");
3756 DeleteFile(msifile);
3759 static void test_duplicatefiles(void)
3761 UINT r;
3763 CreateDirectoryA("msitest", NULL);
3764 create_file("msitest\\maximus", 500);
3765 create_database(msifile, df_tables, sizeof(df_tables) / sizeof(msi_table));
3767 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3769 /* fails if the destination folder is not a valid property */
3771 r = MsiInstallProductA(msifile, NULL);
3772 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3773 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3774 ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
3775 ok(delete_pf("msitest\\this\\doesnot\\exist\\maximus", TRUE), "File not duplicated\n");
3776 ok(delete_pf("msitest\\this\\doesnot\\exist", FALSE), "File not duplicated\n");
3777 ok(delete_pf("msitest\\this\\doesnot", FALSE), "File not duplicated\n");
3778 ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n");
3779 ok(delete_pf("msitest", FALSE), "File not installed\n");
3781 DeleteFile("msitest\\maximus");
3782 RemoveDirectory("msitest");
3783 DeleteFile(msifile);
3786 static void test_writeregistryvalues(void)
3788 UINT r;
3789 LONG res;
3790 HKEY hkey;
3791 DWORD type, size;
3792 CHAR path[MAX_PATH];
3794 CreateDirectoryA("msitest", NULL);
3795 create_file("msitest\\augustus", 500);
3797 create_database(msifile, wrv_tables, sizeof(wrv_tables) / sizeof(msi_table));
3799 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3801 r = MsiInstallProductA(msifile, NULL);
3802 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3803 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
3804 ok(delete_pf("msitest", FALSE), "File installed\n");
3806 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3807 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3809 size = MAX_PATH;
3810 type = REG_MULTI_SZ;
3811 memset(path, 'a', MAX_PATH);
3812 res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
3813 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3814 ok(!memcmp(path, "one\0two\0three\0\0", size), "Wrong multi-sz data\n");
3815 ok(size == 15, "Expected 15, got %d\n", size);
3816 ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
3818 DeleteFile(msifile);
3819 DeleteFile("msitest\\augustus");
3820 RemoveDirectory("msitest");
3823 static void test_sourcefolder(void)
3825 UINT r;
3827 CreateDirectoryA("msitest", NULL);
3828 create_file("augustus", 500);
3830 create_database(msifile, sf_tables, sizeof(sf_tables) / sizeof(msi_table));
3832 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3834 r = MsiInstallProductA(msifile, NULL);
3835 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3836 todo_wine
3838 ok(r == ERROR_INSTALL_FAILURE,
3839 "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3840 ok(!delete_pf("msitest", FALSE), "File installed\n");
3843 RemoveDirectoryA("msitest");
3845 r = MsiInstallProductA(msifile, NULL);
3846 todo_wine
3848 ok(r == ERROR_INSTALL_FAILURE,
3849 "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3850 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3851 ok(!delete_pf("msitest", FALSE), "File installed\n");
3854 DeleteFile(msifile);
3855 DeleteFile("augustus");
3858 START_TEST(install)
3860 DWORD len;
3861 char temp_path[MAX_PATH], prev_path[MAX_PATH];
3863 init_functionpointers();
3865 GetCurrentDirectoryA(MAX_PATH, prev_path);
3866 GetTempPath(MAX_PATH, temp_path);
3867 SetCurrentDirectoryA(temp_path);
3869 lstrcpyA(CURR_DIR, temp_path);
3870 len = lstrlenA(CURR_DIR);
3872 if(len && (CURR_DIR[len - 1] == '\\'))
3873 CURR_DIR[len - 1] = 0;
3875 get_program_files_dir(PROG_FILES_DIR, COMMON_FILES_DIR);
3877 test_MsiInstallProduct();
3878 test_MsiSetComponentState();
3879 test_packagecoltypes();
3880 test_continuouscabs();
3881 test_caborder();
3882 test_mixedmedia();
3883 test_samesequence();
3884 test_uiLevelFlags();
3885 test_readonlyfile();
3886 test_setdirproperty();
3887 test_cabisextracted();
3888 test_concurrentinstall();
3889 test_setpropertyfolder();
3890 test_publish();
3891 test_publishsourcelist();
3892 test_transformprop();
3893 test_currentworkingdir();
3894 test_admin();
3895 test_adminprops();
3896 test_removefiles();
3897 test_movefiles();
3898 test_missingcab();
3899 test_duplicatefiles();
3900 test_writeregistryvalues();
3901 test_sourcefolder();
3903 SetCurrentDirectoryA(prev_path);