push 97f44e0adb27fff75ba63d8fb97c65db9edfbe82
[wine/hacks.git] / dlls / msi / tests / install.c
blobb8817d9ab34ab349a0cd089a0effa946046e8128
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 "InstallServices\t\t5000\n"
116 "InstallFinalize\t\t6600\n"
117 "InstallInitialize\t\t1500\n"
118 "InstallValidate\t\t1400\n"
119 "LaunchConditions\t\t100\n"
120 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
122 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
123 "i2\ti4\tL64\tS255\tS32\tS72\n"
124 "Media\tDiskId\n"
125 "1\t3\t\t\tDISK1\t\n"
126 "2\t5\t\tmsitest.cab\tDISK2\t\n";
128 static const CHAR property_dat[] = "Property\tValue\n"
129 "s72\tl0\n"
130 "Property\tProperty\n"
131 "DefaultUIFont\tDlgFont8\n"
132 "HASUIRUN\t0\n"
133 "INSTALLLEVEL\t3\n"
134 "InstallMode\tTypical\n"
135 "Manufacturer\tWine\n"
136 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
137 "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
138 "ProductID\tnone\n"
139 "ProductLanguage\t1033\n"
140 "ProductName\tMSITEST\n"
141 "ProductVersion\t1.1.1\n"
142 "PROMPTROLLBACKCOST\tP\n"
143 "Setup\tSetup\n"
144 "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
145 "AdminProperties\tPOSTADMIN\n"
146 "ROOTDRIVE\tC:\\\n";
148 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
149 "s72\ti2\tl255\tL255\tL0\ts72\n"
150 "Registry\tRegistry\n"
151 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
152 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
153 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
154 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
156 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
157 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
158 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
159 "ServiceInstall\tServiceInstall\n"
160 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
162 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
163 "s72\tl255\ti2\tL255\tI2\ts72\n"
164 "ServiceControl\tServiceControl\n"
165 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
167 /* tables for test_continuouscabs */
168 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
169 "s72\tS38\ts72\ti2\tS255\tS72\n"
170 "Component\tComponent\n"
171 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
172 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
173 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
175 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
176 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
177 "Feature\tFeature\n"
178 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
180 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
181 "s38\ts72\n"
182 "FeatureComponents\tFeature_\tComponent_\n"
183 "feature\tmaximus\n"
184 "feature\taugustus\n"
185 "feature\tcaesar";
187 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
188 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
189 "File\tFile\n"
190 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
191 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
192 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
194 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
195 "i2\ti4\tL64\tS255\tS32\tS72\n"
196 "Media\tDiskId\n"
197 "1\t10\t\ttest1.cab\tDISK1\t\n"
198 "2\t2\t\ttest2.cab\tDISK2\t\n"
199 "3\t12\t\ttest3.cab\tDISK3\t\n";
201 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
202 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
203 "File\tFile\n"
204 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
205 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
206 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
208 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
209 "i2\ti4\tL64\tS255\tS32\tS72\n"
210 "Media\tDiskId\n"
211 "1\t10\t\ttest1.cab\tDISK1\t\n"
212 "2\t2\t\ttest2.cab\tDISK2\t\n"
213 "3\t3\t\ttest3.cab\tDISK3\t\n";
215 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
216 "i2\ti4\tL64\tS255\tS32\tS72\n"
217 "Media\tDiskId\n"
218 "1\t10\t\ttest1.cab\tDISK1\t\n"
219 "2\t12\t\ttest3.cab\tDISK3\t\n"
220 "3\t2\t\ttest2.cab\tDISK2\t\n";
222 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
223 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
224 "File\tFile\n"
225 "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
226 "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
227 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
229 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
230 "i2\ti4\tL64\tS255\tS32\tS72\n"
231 "Media\tDiskId\n"
232 "1\t3\t\ttest1.cab\tDISK1\t\n";
234 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
235 "i2\ti4\tL64\tS255\tS32\tS72\n"
236 "Media\tDiskId\n"
237 "1\t2\t\ttest1.cab\tDISK1\t\n"
238 "2\t2\t\ttest2.cab\tDISK2\t\n"
239 "3\t12\t\ttest3.cab\tDISK3\t\n";
241 /* tables for test_uiLevelFlags */
242 static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
243 "s72\tS38\ts72\ti2\tS255\tS72\n"
244 "Component\tComponent\n"
245 "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
246 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
247 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
249 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
250 "s72\tS255\tI2\n"
251 "InstallUISequence\tAction\n"
252 "SetUIProperty\t\t5\n"
253 "ExecuteAction\t\t1100\n";
255 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
256 "s72\ti2\tS64\tS0\tS255\n"
257 "CustomAction\tAction\n"
258 "SetUIProperty\t51\tHASUIRUN\t1\t\n";
260 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
261 "s72\tS38\ts72\ti2\tS255\tS72\n"
262 "Component\tComponent\n"
263 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
265 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
266 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
267 "Feature\tFeature\n"
268 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
269 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
271 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
272 "s38\ts72\n"
273 "FeatureComponents\tFeature_\tComponent_\n"
274 "feature\tmaximus\n"
275 "montecristo\tmaximus";
277 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
278 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
279 "File\tFile\n"
280 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
282 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
283 "i2\ti4\tL64\tS255\tS32\tS72\n"
284 "Media\tDiskId\n"
285 "1\t1\t\t\tDISK1\t\n";
287 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
288 "s72\tS255\tI2\n"
289 "InstallExecuteSequence\tAction\n"
290 "AllocateRegistrySpace\tNOT Installed\t1550\n"
291 "CostFinalize\t\t1000\n"
292 "CostInitialize\t\t800\n"
293 "FileCost\t\t900\n"
294 "InstallFiles\t\t4000\n"
295 "InstallFinalize\t\t6600\n"
296 "InstallInitialize\t\t1500\n"
297 "InstallValidate\t\t1400\n"
298 "LaunchConditions\t\t100\n"
299 "SetDirProperty\t\t950";
301 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
302 "s72\ti2\tS64\tS0\tS255\n"
303 "CustomAction\tAction\n"
304 "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
306 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
307 "s72\tS38\ts72\ti2\tS255\tS72\n"
308 "Component\tComponent\n"
309 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
310 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
311 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
312 "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
314 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
315 "s38\ts72\n"
316 "FeatureComponents\tFeature_\tComponent_\n"
317 "feature\tmaximus\n"
318 "feature\taugustus\n"
319 "feature\tcaesar\n"
320 "feature\tgaius";
322 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
323 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
324 "File\tFile\n"
325 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
326 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
327 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
328 "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
330 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
331 "i2\ti4\tL64\tS255\tS32\tS72\n"
332 "Media\tDiskId\n"
333 "1\t1\t\ttest1.cab\tDISK1\t\n"
334 "2\t2\t\ttest2.cab\tDISK2\t\n"
335 "3\t12\t\ttest3.cab\tDISK3\t\n";
337 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
338 "s72\tS255\tI2\n"
339 "InstallExecuteSequence\tAction\n"
340 "CostFinalize\t\t1000\n"
341 "CostInitialize\t\t800\n"
342 "FileCost\t\t900\n"
343 "InstallFiles\t\t4000\n"
344 "InstallServices\t\t5000\n"
345 "InstallFinalize\t\t6600\n"
346 "InstallInitialize\t\t1500\n"
347 "RunInstall\t\t1600\n"
348 "InstallValidate\t\t1400\n"
349 "LaunchConditions\t\t100";
351 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
352 "s72\ti2\tS64\tS0\tS255\n"
353 "CustomAction\tAction\n"
354 "RunInstall\t23\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
356 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
357 "s72\tS38\ts72\ti2\tS255\tS72\n"
358 "Component\tComponent\n"
359 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
361 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
362 "s72\tS38\ts72\ti2\tS255\tS72\n"
363 "Component\tComponent\n"
364 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
366 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
367 "s38\ts72\n"
368 "FeatureComponents\tFeature_\tComponent_\n"
369 "feature\taugustus";
371 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
372 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
373 "File\tFile\n"
374 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
376 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
377 "s72\ti2\tS64\tS0\tS255\n"
378 "CustomAction\tAction\n"
379 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
381 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
382 "s72\tS255\tI2\n"
383 "InstallExecuteSequence\tAction\n"
384 "CostFinalize\t\t1000\n"
385 "CostInitialize\t\t800\n"
386 "FileCost\t\t900\n"
387 "SetFolderProp\t\t950\n"
388 "InstallFiles\t\t4000\n"
389 "InstallServices\t\t5000\n"
390 "InstallFinalize\t\t6600\n"
391 "InstallInitialize\t\t1500\n"
392 "InstallValidate\t\t1400\n"
393 "LaunchConditions\t\t100";
395 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
396 "s72\tS255\tI2\n"
397 "InstallUISequence\tAction\n"
398 "CostInitialize\t\t800\n"
399 "FileCost\t\t900\n"
400 "CostFinalize\t\t1000\n"
401 "ExecuteAction\t\t1100\n";
403 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
404 "s72\tS255\tI2\n"
405 "InstallExecuteSequence\tAction\n"
406 "ValidateProductID\t\t700\n"
407 "CostInitialize\t\t800\n"
408 "FileCost\t\t900\n"
409 "CostFinalize\t\t1000\n"
410 "InstallValidate\t\t1400\n"
411 "InstallInitialize\t\t1500\n"
412 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
413 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
414 "RemoveFiles\t\t3500\n"
415 "InstallFiles\t\t4000\n"
416 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
417 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
418 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
419 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
420 "InstallFinalize\t\t6600";
422 static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
423 "s72\tS38\ts72\ti2\tS255\tS72\n"
424 "Component\tComponent\n"
425 "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";
427 static const CHAR cwd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
428 "s72\tS38\ts72\ti2\tS255\tS72\n"
429 "Component\tComponent\n"
430 "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
432 static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
433 "s72\tS38\ts72\ti2\tS255\tS72\n"
434 "Component\tComponent\n"
435 "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";
437 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
438 "s72\ti2\tS64\tS0\tS255\n"
439 "CustomAction\tAction\n"
440 "SetPOSTADMIN\t51\tPOSTADMIN\t1\t\n";
442 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
443 "s72\tS255\tI2\n"
444 "AdminExecuteSequence\tAction\n"
445 "CostFinalize\t\t1000\n"
446 "CostInitialize\t\t800\n"
447 "FileCost\t\t900\n"
448 "SetPOSTADMIN\t\t950\n"
449 "InstallFiles\t\t4000\n"
450 "InstallFinalize\t\t6600\n"
451 "InstallInitialize\t\t1500\n"
452 "InstallValidate\t\t1400\n"
453 "LaunchConditions\t\t100";
455 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
456 "s72\tS38\ts72\ti2\tS255\tS72\n"
457 "Component\tComponent\n"
458 "augustus\t\tMSITESTDIR\t0\tMYPROP=2718\taugustus\n";
460 static const CHAR rem_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
461 "s72\tS38\ts72\ti2\tS255\tS72\n"
462 "Component\tComponent\n"
463 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t0\t\thydrogen\n"
464 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
465 "lithium\t\tMSITESTDIR\t2\t\tlithium\n";
467 static const CHAR rem_feature_comp_dat[] = "Feature_\tComponent_\n"
468 "s38\ts72\n"
469 "FeatureComponents\tFeature_\tComponent_\n"
470 "feature\thydrogen\n"
471 "feature\thelium\n"
472 "feature\tlithium";
474 static const CHAR rem_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
475 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
476 "File\tFile\n"
477 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
478 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
479 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
481 static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
482 "s72\tS255\tI2\n"
483 "InstallExecuteSequence\tAction\n"
484 "ValidateProductID\t\t700\n"
485 "CostInitialize\t\t800\n"
486 "FileCost\t\t900\n"
487 "CostFinalize\t\t1000\n"
488 "InstallValidate\t\t1400\n"
489 "InstallInitialize\t\t1500\n"
490 "ProcessComponents\t\t1600\n"
491 "UnpublishFeatures\t\t1800\n"
492 "RemoveFiles\t\t3500\n"
493 "InstallFiles\t\t4000\n"
494 "RegisterProduct\t\t6100\n"
495 "PublishFeatures\t\t6300\n"
496 "PublishProduct\t\t6400\n"
497 "InstallFinalize\t\t6600";
499 static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
500 "s72\ts72\tS255\ts72\tI2\n"
501 "RemoveFile\tFileKey\n"
502 "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
503 "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
504 "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
505 "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
506 "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
507 "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
508 "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
509 "block\thelium\tblock\tMSITESTDIR\t3\n"
510 "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n";
512 static const CHAR mov_move_file_dat[] = "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
513 "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
514 "MoveFile\tFileKey\n"
515 "abkhazia\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t0\n"
516 "bahamas\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t1\n"
517 "cambodia\taugustus\tcameroon\tcanada\tSourceDir\tMSITESTDIR\t0\n"
518 "denmark\taugustus\tdjibouti\tdominica\tSourceDir\tMSITESTDIR\t1\n"
519 "ecuador\taugustus\tegypt\telsalvador\tNotAProp\tMSITESTDIR\t1\n"
520 "fiji\taugustus\tfinland\tfrance\tSourceDir\tNotAProp\t1\n"
521 "gabon\taugustus\tgambia\tgeorgia\tSOURCEFULL\tMSITESTDIR\t1\n"
522 "haiti\taugustus\thonduras\thungary\tSourceDir\tDESTFULL\t1\n"
523 "iceland\taugustus\tindia\tindonesia\tMSITESTDIR\tMSITESTDIR\t1\n"
524 "jamaica\taugustus\tjapan\tjordan\tFILEPATHBAD\tMSITESTDIR\t1\n"
525 "kazakhstan\taugustus\t\tkiribati\tFILEPATHGOOD\tMSITESTDIR\t1\n"
526 "laos\taugustus\tlatvia\tlebanon\tSourceDir\tMSITESTDIR\t1\n"
527 "namibia\taugustus\tnauru\tkiribati\tSourceDir\tMSITESTDIR\t1\n"
528 "wildcard\taugustus\tapp*\twildcard\tSourceDir\tMSITESTDIR\t1\n"
529 "single\taugustus\tf?o\tsingle\tSourceDir\tMSITESTDIR\t1\n"
530 "wildcardnodest\taugustus\tbudd*\t\tSourceDir\tMSITESTDIR\t1\n"
531 "singlenodest\taugustus\tb?r\t\tSourceDir\tMSITESTDIR\t1\n";
533 static const CHAR mc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
534 "s72\tS38\ts72\ti2\tS255\tS72\n"
535 "Component\tComponent\n"
536 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
537 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
538 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
539 "gaius\t\tMSITESTDIR\t0\tGAIUS=1\tgaius\n";
541 static const CHAR mc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
542 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
543 "File\tFile\n"
544 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
545 "augustus\taugustus\taugustus\t500\t\t\t0\t2\n"
546 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3\n"
547 "gaius\tgaius\tgaius\t500\t\t\t16384\t4";
549 static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
550 "i2\ti4\tL64\tS255\tS32\tS72\n"
551 "Media\tDiskId\n"
552 "1\t1\t\ttest1.cab\tDISK1\t\n"
553 "2\t2\t\ttest2.cab\tDISK2\t\n"
554 "3\t3\t\ttest3.cab\tDISK3\t\n"
555 "4\t4\t\ttest3.cab\tDISK3\t\n";
557 static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n"
558 "s72\ti2\ti4\ti4\ti4\ti4\n"
559 "MsiFileHash\tFile_\n"
560 "caesar\t0\t1477005400\t-2141257985\t284379198\t21485139";
562 typedef struct _msi_table
564 const CHAR *filename;
565 const CHAR *data;
566 int size;
567 } msi_table;
569 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
571 static const msi_table tables[] =
573 ADD_TABLE(component),
574 ADD_TABLE(directory),
575 ADD_TABLE(feature),
576 ADD_TABLE(feature_comp),
577 ADD_TABLE(file),
578 ADD_TABLE(install_exec_seq),
579 ADD_TABLE(media),
580 ADD_TABLE(property),
581 ADD_TABLE(registry),
582 ADD_TABLE(service_install),
583 ADD_TABLE(service_control)
586 static const msi_table cc_tables[] =
588 ADD_TABLE(cc_component),
589 ADD_TABLE(directory),
590 ADD_TABLE(cc_feature),
591 ADD_TABLE(cc_feature_comp),
592 ADD_TABLE(cc_file),
593 ADD_TABLE(install_exec_seq),
594 ADD_TABLE(cc_media),
595 ADD_TABLE(property),
598 static const msi_table co_tables[] =
600 ADD_TABLE(cc_component),
601 ADD_TABLE(directory),
602 ADD_TABLE(cc_feature),
603 ADD_TABLE(cc_feature_comp),
604 ADD_TABLE(co_file),
605 ADD_TABLE(install_exec_seq),
606 ADD_TABLE(co_media),
607 ADD_TABLE(property),
610 static const msi_table co2_tables[] =
612 ADD_TABLE(cc_component),
613 ADD_TABLE(directory),
614 ADD_TABLE(cc_feature),
615 ADD_TABLE(cc_feature_comp),
616 ADD_TABLE(cc_file),
617 ADD_TABLE(install_exec_seq),
618 ADD_TABLE(co2_media),
619 ADD_TABLE(property),
622 static const msi_table mm_tables[] =
624 ADD_TABLE(cc_component),
625 ADD_TABLE(directory),
626 ADD_TABLE(cc_feature),
627 ADD_TABLE(cc_feature_comp),
628 ADD_TABLE(mm_file),
629 ADD_TABLE(install_exec_seq),
630 ADD_TABLE(mm_media),
631 ADD_TABLE(property),
634 static const msi_table ss_tables[] =
636 ADD_TABLE(cc_component),
637 ADD_TABLE(directory),
638 ADD_TABLE(cc_feature),
639 ADD_TABLE(cc_feature_comp),
640 ADD_TABLE(cc_file),
641 ADD_TABLE(install_exec_seq),
642 ADD_TABLE(ss_media),
643 ADD_TABLE(property),
646 static const msi_table ui_tables[] =
648 ADD_TABLE(ui_component),
649 ADD_TABLE(directory),
650 ADD_TABLE(cc_feature),
651 ADD_TABLE(cc_feature_comp),
652 ADD_TABLE(cc_file),
653 ADD_TABLE(install_exec_seq),
654 ADD_TABLE(ui_install_ui_seq),
655 ADD_TABLE(ui_custom_action),
656 ADD_TABLE(cc_media),
657 ADD_TABLE(property),
660 static const msi_table rof_tables[] =
662 ADD_TABLE(rof_component),
663 ADD_TABLE(directory),
664 ADD_TABLE(rof_feature),
665 ADD_TABLE(rof_feature_comp),
666 ADD_TABLE(rof_file),
667 ADD_TABLE(install_exec_seq),
668 ADD_TABLE(rof_media),
669 ADD_TABLE(property),
672 static const msi_table sdp_tables[] =
674 ADD_TABLE(rof_component),
675 ADD_TABLE(directory),
676 ADD_TABLE(rof_feature),
677 ADD_TABLE(rof_feature_comp),
678 ADD_TABLE(rof_file),
679 ADD_TABLE(sdp_install_exec_seq),
680 ADD_TABLE(sdp_custom_action),
681 ADD_TABLE(rof_media),
682 ADD_TABLE(property),
685 static const msi_table cie_tables[] =
687 ADD_TABLE(cie_component),
688 ADD_TABLE(directory),
689 ADD_TABLE(cc_feature),
690 ADD_TABLE(cie_feature_comp),
691 ADD_TABLE(cie_file),
692 ADD_TABLE(install_exec_seq),
693 ADD_TABLE(cie_media),
694 ADD_TABLE(property),
697 static const msi_table ci_tables[] =
699 ADD_TABLE(ci_component),
700 ADD_TABLE(directory),
701 ADD_TABLE(rof_feature),
702 ADD_TABLE(rof_feature_comp),
703 ADD_TABLE(rof_file),
704 ADD_TABLE(ci_install_exec_seq),
705 ADD_TABLE(rof_media),
706 ADD_TABLE(property),
707 ADD_TABLE(ci_custom_action),
710 static const msi_table ci2_tables[] =
712 ADD_TABLE(ci2_component),
713 ADD_TABLE(directory),
714 ADD_TABLE(rof_feature),
715 ADD_TABLE(ci2_feature_comp),
716 ADD_TABLE(ci2_file),
717 ADD_TABLE(install_exec_seq),
718 ADD_TABLE(rof_media),
719 ADD_TABLE(property),
722 static const msi_table spf_tables[] =
724 ADD_TABLE(ci_component),
725 ADD_TABLE(directory),
726 ADD_TABLE(rof_feature),
727 ADD_TABLE(rof_feature_comp),
728 ADD_TABLE(rof_file),
729 ADD_TABLE(spf_install_exec_seq),
730 ADD_TABLE(rof_media),
731 ADD_TABLE(property),
732 ADD_TABLE(spf_custom_action),
733 ADD_TABLE(spf_install_ui_seq),
736 static const msi_table pp_tables[] =
738 ADD_TABLE(ci_component),
739 ADD_TABLE(directory),
740 ADD_TABLE(rof_feature),
741 ADD_TABLE(rof_feature_comp),
742 ADD_TABLE(rof_file),
743 ADD_TABLE(pp_install_exec_seq),
744 ADD_TABLE(rof_media),
745 ADD_TABLE(property),
748 static const msi_table tp_tables[] =
750 ADD_TABLE(tp_component),
751 ADD_TABLE(directory),
752 ADD_TABLE(rof_feature),
753 ADD_TABLE(ci2_feature_comp),
754 ADD_TABLE(ci2_file),
755 ADD_TABLE(install_exec_seq),
756 ADD_TABLE(rof_media),
757 ADD_TABLE(property),
760 static const msi_table cwd_tables[] =
762 ADD_TABLE(cwd_component),
763 ADD_TABLE(directory),
764 ADD_TABLE(rof_feature),
765 ADD_TABLE(ci2_feature_comp),
766 ADD_TABLE(ci2_file),
767 ADD_TABLE(install_exec_seq),
768 ADD_TABLE(rof_media),
769 ADD_TABLE(property),
772 static const msi_table adm_tables[] =
774 ADD_TABLE(adm_component),
775 ADD_TABLE(directory),
776 ADD_TABLE(rof_feature),
777 ADD_TABLE(ci2_feature_comp),
778 ADD_TABLE(ci2_file),
779 ADD_TABLE(install_exec_seq),
780 ADD_TABLE(rof_media),
781 ADD_TABLE(property),
782 ADD_TABLE(adm_custom_action),
783 ADD_TABLE(adm_admin_exec_seq),
786 static const msi_table amp_tables[] =
788 ADD_TABLE(amp_component),
789 ADD_TABLE(directory),
790 ADD_TABLE(rof_feature),
791 ADD_TABLE(ci2_feature_comp),
792 ADD_TABLE(ci2_file),
793 ADD_TABLE(install_exec_seq),
794 ADD_TABLE(rof_media),
795 ADD_TABLE(property),
798 static const msi_table rem_tables[] =
800 ADD_TABLE(rem_component),
801 ADD_TABLE(directory),
802 ADD_TABLE(rof_feature),
803 ADD_TABLE(rem_feature_comp),
804 ADD_TABLE(rem_file),
805 ADD_TABLE(rem_install_exec_seq),
806 ADD_TABLE(rof_media),
807 ADD_TABLE(property),
808 ADD_TABLE(rem_remove_files),
811 static const msi_table mov_tables[] =
813 ADD_TABLE(cwd_component),
814 ADD_TABLE(directory),
815 ADD_TABLE(rof_feature),
816 ADD_TABLE(ci2_feature_comp),
817 ADD_TABLE(ci2_file),
818 ADD_TABLE(install_exec_seq),
819 ADD_TABLE(rof_media),
820 ADD_TABLE(property),
821 ADD_TABLE(mov_move_file),
822 ADD_TABLE(registry),
825 static const msi_table mc_tables[] =
827 ADD_TABLE(mc_component),
828 ADD_TABLE(directory),
829 ADD_TABLE(cc_feature),
830 ADD_TABLE(cie_feature_comp),
831 ADD_TABLE(mc_file),
832 ADD_TABLE(install_exec_seq),
833 ADD_TABLE(mc_media),
834 ADD_TABLE(property),
835 ADD_TABLE(mc_file_hash),
838 /* cabinet definitions */
840 /* make the max size large so there is only one cab file */
841 #define MEDIA_SIZE 0x7FFFFFFF
842 #define FOLDER_THRESHOLD 900000
844 /* the FCI callbacks */
846 static void *mem_alloc(ULONG cb)
848 return HeapAlloc(GetProcessHeap(), 0, cb);
851 static void mem_free(void *memory)
853 HeapFree(GetProcessHeap(), 0, memory);
856 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
858 sprintf(pccab->szCab, pv, pccab->iCab);
859 return TRUE;
862 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
864 return 0;
867 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
868 BOOL fContinuation, void *pv)
870 return 0;
873 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
875 HANDLE handle;
876 DWORD dwAccess = 0;
877 DWORD dwShareMode = 0;
878 DWORD dwCreateDisposition = OPEN_EXISTING;
880 dwAccess = GENERIC_READ | GENERIC_WRITE;
881 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
882 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
884 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
885 dwCreateDisposition = OPEN_EXISTING;
886 else
887 dwCreateDisposition = CREATE_NEW;
889 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
890 dwCreateDisposition, 0, NULL);
892 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
894 return (INT_PTR)handle;
897 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
899 HANDLE handle = (HANDLE)hf;
900 DWORD dwRead;
901 BOOL res;
903 res = ReadFile(handle, memory, cb, &dwRead, NULL);
904 ok(res, "Failed to ReadFile\n");
906 return dwRead;
909 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
911 HANDLE handle = (HANDLE)hf;
912 DWORD dwWritten;
913 BOOL res;
915 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
916 ok(res, "Failed to WriteFile\n");
918 return dwWritten;
921 static int fci_close(INT_PTR hf, int *err, void *pv)
923 HANDLE handle = (HANDLE)hf;
924 ok(CloseHandle(handle), "Failed to CloseHandle\n");
926 return 0;
929 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
931 HANDLE handle = (HANDLE)hf;
932 DWORD ret;
934 ret = SetFilePointer(handle, dist, NULL, seektype);
935 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
937 return ret;
940 static int fci_delete(char *pszFile, int *err, void *pv)
942 BOOL ret = DeleteFileA(pszFile);
943 ok(ret, "Failed to DeleteFile %s\n", pszFile);
945 return 0;
948 static void init_functionpointers(void)
950 HMODULE hmsi = GetModuleHandleA("msi.dll");
952 #define GET_PROC(func) \
953 p ## func = (void*)GetProcAddress(hmsi, #func); \
954 if(!p ## func) \
955 trace("GetProcAddress(%s) failed\n", #func);
957 GET_PROC(MsiQueryComponentStateA);
958 GET_PROC(MsiSourceListGetInfoA);
960 #undef GET_PROC
963 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
965 CHAR buffer[0x20];
966 UINT r;
967 DWORD sz;
969 sz = sizeof buffer;
970 r = MsiRecordGetString(rec, field, buffer, &sz);
971 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
974 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
976 LPSTR tempname;
978 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
979 GetTempFileNameA(".", "xx", 0, tempname);
981 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
983 lstrcpyA(pszTempName, tempname);
984 HeapFree(GetProcessHeap(), 0, tempname);
985 return TRUE;
988 HeapFree(GetProcessHeap(), 0, tempname);
990 return FALSE;
993 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
994 USHORT *pattribs, int *err, void *pv)
996 BY_HANDLE_FILE_INFORMATION finfo;
997 FILETIME filetime;
998 HANDLE handle;
999 DWORD attrs;
1000 BOOL res;
1002 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
1003 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
1005 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
1007 res = GetFileInformationByHandle(handle, &finfo);
1008 ok(res, "Expected GetFileInformationByHandle to succeed\n");
1010 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
1011 FileTimeToDosDateTime(&filetime, pdate, ptime);
1013 attrs = GetFileAttributes(pszName);
1014 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
1016 return (INT_PTR)handle;
1019 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
1021 char path[MAX_PATH];
1022 char filename[MAX_PATH];
1024 lstrcpyA(path, CURR_DIR);
1025 lstrcatA(path, "\\");
1026 lstrcatA(path, file);
1028 lstrcpyA(filename, file);
1030 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
1031 progress, get_open_info, compress);
1034 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
1036 ZeroMemory(pCabParams, sizeof(CCAB));
1038 pCabParams->cb = max_size;
1039 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
1040 pCabParams->setID = 0xbeef;
1041 pCabParams->iCab = 1;
1042 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
1043 lstrcatA(pCabParams->szCabPath, "\\");
1044 lstrcpyA(pCabParams->szCab, name);
1047 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
1049 CCAB cabParams;
1050 LPCSTR ptr;
1051 HFCI hfci;
1052 ERF erf;
1053 BOOL res;
1055 set_cab_parameters(&cabParams, name, max_size);
1057 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1058 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1059 get_temp_file, &cabParams, NULL);
1061 ok(hfci != NULL, "Failed to create an FCI context\n");
1063 ptr = files;
1064 while (*ptr)
1066 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
1067 ok(res, "Failed to add file: %s\n", ptr);
1068 ptr += lstrlen(ptr) + 1;
1071 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1072 ok(res, "Failed to flush the cabinet\n");
1074 res = FCIDestroy(hfci);
1075 ok(res, "Failed to destroy the cabinet\n");
1078 static BOOL get_program_files_dir(LPSTR buf, LPSTR buf2)
1080 HKEY hkey;
1081 DWORD type, size;
1083 if (RegOpenKey(HKEY_LOCAL_MACHINE,
1084 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
1085 return FALSE;
1087 size = MAX_PATH;
1088 if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size)) {
1089 RegCloseKey(hkey);
1090 return FALSE;
1093 size = MAX_PATH;
1094 if (RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)buf2, &size)) {
1095 RegCloseKey(hkey);
1096 return FALSE;
1099 RegCloseKey(hkey);
1100 return TRUE;
1103 static void create_file(const CHAR *name, DWORD size)
1105 HANDLE file;
1106 DWORD written, left;
1108 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1109 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1110 WriteFile(file, name, strlen(name), &written, NULL);
1111 WriteFile(file, "\n", strlen("\n"), &written, NULL);
1113 left = size - lstrlen(name) - 1;
1115 SetFilePointer(file, left, NULL, FILE_CURRENT);
1116 SetEndOfFile(file);
1118 CloseHandle(file);
1121 static void create_test_files(void)
1123 CreateDirectoryA("msitest", NULL);
1124 create_file("msitest\\one.txt", 100);
1125 CreateDirectoryA("msitest\\first", NULL);
1126 create_file("msitest\\first\\two.txt", 100);
1127 CreateDirectoryA("msitest\\second", NULL);
1128 create_file("msitest\\second\\three.txt", 100);
1130 create_file("four.txt", 100);
1131 create_file("five.txt", 100);
1132 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1134 create_file("msitest\\filename", 100);
1135 create_file("msitest\\service.exe", 100);
1137 DeleteFileA("four.txt");
1138 DeleteFileA("five.txt");
1141 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
1143 CHAR path[MAX_PATH];
1145 lstrcpyA(path, PROG_FILES_DIR);
1146 lstrcatA(path, "\\");
1147 lstrcatA(path, rel_path);
1149 if (is_file)
1150 return DeleteFileA(path);
1151 else
1152 return RemoveDirectoryA(path);
1155 static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
1157 CHAR path[MAX_PATH];
1159 lstrcpyA(path, COMMON_FILES_DIR);
1160 lstrcatA(path, "\\");
1161 lstrcatA(path, rel_path);
1163 if (is_file)
1164 return DeleteFileA(path);
1165 else
1166 return RemoveDirectoryA(path);
1169 static void delete_test_files(void)
1171 DeleteFileA("msitest.msi");
1172 DeleteFileA("msitest.cab");
1173 DeleteFileA("msitest\\second\\three.txt");
1174 DeleteFileA("msitest\\first\\two.txt");
1175 DeleteFileA("msitest\\one.txt");
1176 DeleteFileA("msitest\\service.exe");
1177 DeleteFileA("msitest\\filename");
1178 RemoveDirectoryA("msitest\\second");
1179 RemoveDirectoryA("msitest\\first");
1180 RemoveDirectoryA("msitest");
1183 static void write_file(const CHAR *filename, const char *data, int data_size)
1185 DWORD size;
1187 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1188 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1190 WriteFile(hf, data, data_size, &size, NULL);
1191 CloseHandle(hf);
1194 static void write_msi_summary_info(MSIHANDLE db)
1196 MSIHANDLE summary;
1197 UINT r;
1199 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1200 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1202 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1205 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1206 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1209 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1210 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1212 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1213 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1215 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1216 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1218 /* write the summary changes back to the stream */
1219 r = MsiSummaryInfoPersist(summary);
1220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1222 MsiCloseHandle(summary);
1225 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1227 MSIHANDLE db;
1228 UINT r;
1229 int j;
1231 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1234 /* import the tables into the database */
1235 for (j = 0; j < num_tables; j++)
1237 const msi_table *table = &tables[j];
1239 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1241 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1244 DeleteFileA(table->filename);
1247 write_msi_summary_info(db);
1249 r = MsiDatabaseCommit(db);
1250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1252 MsiCloseHandle(db);
1255 static void check_service_is_installed(void)
1257 SC_HANDLE scm, service;
1258 BOOL res;
1260 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1261 ok(scm != NULL, "Failed to open the SC Manager\n");
1263 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1264 ok(service != NULL, "Failed to open TestService\n");
1266 res = DeleteService(service);
1267 ok(res, "Failed to delete TestService\n");
1269 CloseServiceHandle(service);
1270 CloseServiceHandle(scm);
1273 static void test_MsiInstallProduct(void)
1275 UINT r;
1276 CHAR path[MAX_PATH];
1277 LONG res;
1278 HKEY hkey;
1279 DWORD num, size, type;
1281 create_test_files();
1282 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1284 r = MsiInstallProductA(msifile, NULL);
1285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1287 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1288 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1289 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1290 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1291 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1292 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1293 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1294 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1295 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1296 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1297 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1298 ok(delete_pf("msitest", FALSE), "File not installed\n");
1300 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1301 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1303 size = MAX_PATH;
1304 type = REG_SZ;
1305 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1306 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1307 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1309 size = MAX_PATH;
1310 type = REG_SZ;
1311 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1312 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1314 size = sizeof(num);
1315 type = REG_DWORD;
1316 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1317 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1318 ok(num == 314, "Expected 314, got %d\n", num);
1320 size = MAX_PATH;
1321 type = REG_SZ;
1322 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1323 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1324 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1326 check_service_is_installed();
1328 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1330 delete_test_files();
1333 static void test_MsiSetComponentState(void)
1335 INSTALLSTATE installed, action;
1336 MSIHANDLE package;
1337 char path[MAX_PATH];
1338 UINT r;
1340 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1342 CoInitialize(NULL);
1344 lstrcpy(path, CURR_DIR);
1345 lstrcat(path, "\\");
1346 lstrcat(path, msifile);
1348 r = MsiOpenPackage(path, &package);
1349 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1351 r = MsiDoAction(package, "CostInitialize");
1352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1354 r = MsiDoAction(package, "FileCost");
1355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1357 r = MsiDoAction(package, "CostFinalize");
1358 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1360 r = MsiGetComponentState(package, "dangler", &installed, &action);
1361 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1362 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1363 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1365 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1366 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1368 MsiCloseHandle(package);
1369 CoUninitialize();
1371 DeleteFileA(msifile);
1374 static void test_packagecoltypes(void)
1376 MSIHANDLE hdb, view, rec;
1377 char path[MAX_PATH];
1378 LPCSTR query;
1379 UINT r, count;
1381 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1383 CoInitialize(NULL);
1385 lstrcpy(path, CURR_DIR);
1386 lstrcat(path, "\\");
1387 lstrcat(path, msifile);
1389 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1390 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1392 query = "SELECT * FROM `Media`";
1393 r = MsiDatabaseOpenView( hdb, query, &view );
1394 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1396 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1397 count = MsiRecordGetFieldCount( rec );
1398 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1399 ok(count == 6, "Expected 6, got %d\n", count);
1400 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1401 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1402 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1403 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1404 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1405 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1406 MsiCloseHandle(rec);
1408 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1409 count = MsiRecordGetFieldCount( rec );
1410 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1411 ok(count == 6, "Expected 6, got %d\n", count);
1412 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1413 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1414 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1415 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1416 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1417 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1419 MsiCloseHandle(rec);
1420 MsiCloseHandle(view);
1421 MsiCloseHandle(hdb);
1422 DeleteFile(msifile);
1425 static void create_cc_test_files(void)
1427 CCAB cabParams;
1428 HFCI hfci;
1429 ERF erf;
1430 static CHAR cab_context[] = "test%d.cab";
1431 BOOL res;
1433 create_file("maximus", 500);
1434 create_file("augustus", 50000);
1435 create_file("caesar", 500);
1437 set_cab_parameters(&cabParams, "test1.cab", 200);
1439 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1440 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1441 get_temp_file, &cabParams, cab_context);
1442 ok(hfci != NULL, "Failed to create an FCI context\n");
1444 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1445 ok(res, "Failed to add file maximus\n");
1447 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1448 ok(res, "Failed to add file augustus\n");
1450 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1451 ok(res, "Failed to flush the cabinet\n");
1453 res = FCIDestroy(hfci);
1454 ok(res, "Failed to destroy the cabinet\n");
1456 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1458 DeleteFile("maximus");
1459 DeleteFile("augustus");
1460 DeleteFile("caesar");
1463 static void delete_cab_files(void)
1465 SHFILEOPSTRUCT shfl;
1466 CHAR path[MAX_PATH+10];
1468 lstrcpyA(path, CURR_DIR);
1469 lstrcatA(path, "\\*.cab");
1470 path[strlen(path) + 1] = '\0';
1472 shfl.hwnd = NULL;
1473 shfl.wFunc = FO_DELETE;
1474 shfl.pFrom = path;
1475 shfl.pTo = NULL;
1476 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1478 SHFileOperation(&shfl);
1481 static void test_continuouscabs(void)
1483 UINT r;
1485 create_cc_test_files();
1486 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1488 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1490 r = MsiInstallProductA(msifile, NULL);
1491 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1492 todo_wine
1494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1495 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1496 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1498 ok(delete_pf("msitest", FALSE), "File not installed\n");
1500 delete_cab_files();
1501 DeleteFile(msifile);
1504 static void test_caborder(void)
1506 UINT r;
1508 create_file("imperator", 100);
1509 create_file("maximus", 500);
1510 create_file("augustus", 50000);
1511 create_file("caesar", 500);
1513 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1515 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1517 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1518 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1519 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1521 r = MsiInstallProductA(msifile, NULL);
1522 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1523 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1524 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1525 todo_wine
1527 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1528 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1531 delete_cab_files();
1533 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1534 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1535 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1537 r = MsiInstallProductA(msifile, NULL);
1538 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1539 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1540 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1541 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1542 todo_wine
1544 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1547 delete_cab_files();
1548 DeleteFile(msifile);
1550 create_cc_test_files();
1551 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1553 r = MsiInstallProductA(msifile, NULL);
1554 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1555 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1556 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1557 todo_wine
1559 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1560 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1563 delete_cab_files();
1564 DeleteFile(msifile);
1566 create_cc_test_files();
1567 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1569 r = MsiInstallProductA(msifile, NULL);
1570 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1571 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1572 todo_wine
1574 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1575 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1576 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1579 delete_cab_files();
1580 DeleteFile("imperator");
1581 DeleteFile("maximus");
1582 DeleteFile("augustus");
1583 DeleteFile("caesar");
1584 DeleteFile(msifile);
1587 static void test_mixedmedia(void)
1589 UINT r;
1591 CreateDirectoryA("msitest", NULL);
1592 create_file("msitest\\maximus", 500);
1593 create_file("msitest\\augustus", 500);
1594 create_file("caesar", 500);
1596 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1598 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1600 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1602 r = MsiInstallProductA(msifile, NULL);
1603 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1604 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1605 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1606 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1607 ok(delete_pf("msitest", FALSE), "File not installed\n");
1609 /* Delete the files in the temp (current) folder */
1610 DeleteFile("msitest\\maximus");
1611 DeleteFile("msitest\\augustus");
1612 RemoveDirectory("msitest");
1613 DeleteFile("caesar");
1614 DeleteFile("test1.cab");
1615 DeleteFile(msifile);
1618 static void test_samesequence(void)
1620 UINT r;
1622 create_cc_test_files();
1623 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1625 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1627 r = MsiInstallProductA(msifile, NULL);
1628 todo_wine
1630 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1631 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1632 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1634 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1635 ok(delete_pf("msitest", FALSE), "File not installed\n");
1637 delete_cab_files();
1638 DeleteFile(msifile);
1641 static void test_uiLevelFlags(void)
1643 UINT r;
1645 create_cc_test_files();
1646 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1648 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1650 r = MsiInstallProductA(msifile, NULL);
1651 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1652 todo_wine
1654 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1655 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1657 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1658 ok(delete_pf("msitest", FALSE), "File not installed\n");
1660 delete_cab_files();
1661 DeleteFile(msifile);
1664 static BOOL file_matches(LPSTR path)
1666 CHAR buf[MAX_PATH];
1667 HANDLE file;
1668 DWORD size;
1670 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1671 NULL, OPEN_EXISTING, 0, NULL);
1673 ZeroMemory(buf, MAX_PATH);
1674 ReadFile(file, buf, 15, &size, NULL);
1675 CloseHandle(file);
1677 return !lstrcmp(buf, "msitest\\maximus");
1680 static void test_readonlyfile(void)
1682 UINT r;
1683 DWORD size;
1684 HANDLE file;
1685 CHAR path[MAX_PATH];
1687 CreateDirectoryA("msitest", NULL);
1688 create_file("msitest\\maximus", 500);
1689 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1691 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1693 lstrcpy(path, PROG_FILES_DIR);
1694 lstrcat(path, "\\msitest");
1695 CreateDirectory(path, NULL);
1697 lstrcat(path, "\\maximus");
1698 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1699 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1701 WriteFile(file, "readonlyfile", 20, &size, NULL);
1702 CloseHandle(file);
1704 r = MsiInstallProductA(msifile, NULL);
1705 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1706 ok(file_matches(path), "Expected file to be overwritten\n");
1707 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1708 ok(delete_pf("msitest", FALSE), "File not installed\n");
1710 /* Delete the files in the temp (current) folder */
1711 DeleteFile("msitest\\maximus");
1712 RemoveDirectory("msitest");
1713 DeleteFile(msifile);
1716 static void test_setdirproperty(void)
1718 UINT r;
1720 CreateDirectoryA("msitest", NULL);
1721 create_file("msitest\\maximus", 500);
1722 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1724 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1726 r = MsiInstallProductA(msifile, NULL);
1727 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1728 ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
1729 ok(delete_cf("msitest", FALSE), "File not installed\n");
1731 /* Delete the files in the temp (current) folder */
1732 DeleteFile(msifile);
1733 DeleteFile("msitest\\maximus");
1734 RemoveDirectory("msitest");
1737 static void test_cabisextracted(void)
1739 UINT r;
1741 CreateDirectoryA("msitest", NULL);
1742 create_file("msitest\\gaius", 500);
1743 create_file("maximus", 500);
1744 create_file("augustus", 500);
1745 create_file("caesar", 500);
1747 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1748 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1749 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1751 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1753 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1755 r = MsiInstallProductA(msifile, NULL);
1756 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1757 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1758 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1759 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1760 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1761 ok(delete_pf("msitest", FALSE), "File not installed\n");
1763 /* Delete the files in the temp (current) folder */
1764 delete_cab_files();
1765 DeleteFile(msifile);
1766 DeleteFile("maximus");
1767 DeleteFile("augustus");
1768 DeleteFile("caesar");
1769 DeleteFile("msitest\\gaius");
1770 RemoveDirectory("msitest");
1773 static void test_concurrentinstall(void)
1775 UINT r;
1776 CHAR path[MAX_PATH];
1778 CreateDirectoryA("msitest", NULL);
1779 CreateDirectoryA("msitest\\msitest", NULL);
1780 create_file("msitest\\maximus", 500);
1781 create_file("msitest\\msitest\\augustus", 500);
1783 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1785 lstrcpyA(path, CURR_DIR);
1786 lstrcatA(path, "\\msitest\\concurrent.msi");
1787 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1789 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1791 r = MsiInstallProductA(msifile, NULL);
1792 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1793 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1794 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1795 ok(delete_pf("msitest", FALSE), "File not installed\n");
1797 /* Delete the files in the temp (current) folder */
1798 DeleteFile(msifile);
1799 DeleteFile(path);
1800 DeleteFile("msitest\\msitest\\augustus");
1801 DeleteFile("msitest\\maximus");
1802 RemoveDirectory("msitest\\msitest");
1803 RemoveDirectory("msitest");
1806 static void test_setpropertyfolder(void)
1808 UINT r;
1810 CreateDirectoryA("msitest", NULL);
1811 create_file("msitest\\maximus", 500);
1813 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1815 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1817 r = MsiInstallProductA(msifile, NULL);
1818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1819 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1820 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1821 ok(delete_pf("msitest", FALSE), "File not installed\n");
1823 /* Delete the files in the temp (current) folder */
1824 DeleteFile(msifile);
1825 DeleteFile("msitest\\maximus");
1826 RemoveDirectory("msitest");
1829 static BOOL file_exists(LPCSTR file)
1831 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
1834 static BOOL pf_exists(LPCSTR file)
1836 CHAR path[MAX_PATH];
1838 lstrcpyA(path, PROG_FILES_DIR);
1839 lstrcatA(path, "\\");
1840 lstrcatA(path, file);
1842 return file_exists(path);
1845 static void delete_pfmsitest_files(void)
1847 SHFILEOPSTRUCT shfl;
1848 CHAR path[MAX_PATH+11];
1850 lstrcpyA(path, PROG_FILES_DIR);
1851 lstrcatA(path, "\\msitest\\*");
1852 path[strlen(path) + 1] = '\0';
1854 shfl.hwnd = NULL;
1855 shfl.wFunc = FO_DELETE;
1856 shfl.pFrom = path;
1857 shfl.pTo = NULL;
1858 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1860 SHFileOperation(&shfl);
1862 lstrcpyA(path, PROG_FILES_DIR);
1863 lstrcatA(path, "\\msitest");
1864 RemoveDirectoryA(path);
1867 static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
1869 char val[MAX_PATH];
1870 DWORD size, type;
1871 LONG res;
1873 size = MAX_PATH;
1874 val[0] = '\0';
1875 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
1877 if (res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ))
1879 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
1880 return;
1883 if (!expected)
1884 ok_(__FILE__, line)(lstrlenA(val) == 0, "Expected empty string, got %s\n", val);
1885 else
1887 if (bcase)
1888 ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
1889 else
1890 ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
1894 static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD line)
1896 DWORD val, size, type;
1897 LONG res;
1899 size = sizeof(DWORD);
1900 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
1902 if (res != ERROR_SUCCESS || type != REG_DWORD)
1904 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
1905 return;
1908 ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
1911 #define CHECK_REG_STR(prodkey, name, expected) \
1912 check_reg_str(prodkey, name, expected, TRUE, __LINE__);
1914 #define CHECK_REG_ISTR(prodkey, name, expected) \
1915 check_reg_str(prodkey, name, expected, FALSE, __LINE__);
1917 #define CHECK_REG_DWORD(prodkey, name, expected) \
1918 check_reg_dword(prodkey, name, expected, __LINE__);
1920 static void get_date_str(LPSTR date)
1922 SYSTEMTIME systime;
1924 static const char date_fmt[] = "%d%d%d";
1925 GetLocalTime(&systime);
1926 sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
1929 static void test_publish(void)
1931 UINT r;
1932 LONG res;
1933 HKEY uninstall, prodkey;
1934 INSTALLSTATE state;
1935 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
1936 char date[MAX_PATH];
1937 char temp[MAX_PATH];
1939 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
1941 get_date_str(date);
1942 GetTempPath(MAX_PATH, temp);
1944 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
1945 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1947 CreateDirectoryA("msitest", NULL);
1948 create_file("msitest\\maximus", 500);
1950 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
1952 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1954 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1955 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1957 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1958 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1960 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1961 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1963 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1964 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1965 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1966 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1968 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
1969 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1971 /* nothing published */
1972 r = MsiInstallProductA(msifile, NULL);
1973 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1974 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1975 ok(pf_exists("msitest"), "File not installed\n");
1977 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
1978 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1980 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
1981 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1983 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
1984 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1986 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
1987 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
1988 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
1989 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
1991 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
1992 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1994 /* install again */
1995 r = MsiInstallProductA(msifile, NULL);
1996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1997 ok(pf_exists("msitest\\maximus"), "File not installed\n");
1998 ok(pf_exists("msitest"), "File not installed\n");
2000 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2001 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2003 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2004 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2006 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2007 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2009 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2010 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2011 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2012 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2014 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2015 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2017 /* try to uninstall */
2018 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2019 todo_wine
2021 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2023 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2024 ok(pf_exists("msitest"), "File deleted\n");
2026 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2027 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2029 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2030 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2032 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2033 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2035 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2036 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2037 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2038 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2040 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2041 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2043 /* PublishProduct */
2044 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2046 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2047 ok(pf_exists("msitest"), "File not installed\n");
2049 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2050 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2052 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2053 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2055 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2056 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2057 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2058 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2060 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2061 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2063 /* try to uninstall after PublishProduct */
2064 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2066 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2067 ok(pf_exists("msitest"), "File deleted\n");
2069 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2070 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2072 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2073 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2075 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2076 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2078 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2079 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2080 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2081 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2083 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2084 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2086 /* RegisterProduct */
2087 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2088 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2089 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2090 ok(pf_exists("msitest"), "File not installed\n");
2092 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2093 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2095 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2096 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2098 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2099 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2100 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2101 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2103 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2104 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2106 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2107 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2108 CHECK_REG_STR(prodkey, "InstallDate", date);
2109 CHECK_REG_STR(prodkey, "InstallSource", temp);
2110 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2111 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2112 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2113 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2114 CHECK_REG_STR(prodkey, "Comments", NULL);
2115 CHECK_REG_STR(prodkey, "Contact", NULL);
2116 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2117 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2118 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2119 CHECK_REG_STR(prodkey, "Readme", NULL);
2120 CHECK_REG_STR(prodkey, "Size", NULL);
2121 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2122 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2123 CHECK_REG_DWORD(prodkey, "Language", 1033);
2124 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2125 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2126 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2127 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2128 todo_wine
2130 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2133 RegCloseKey(prodkey);
2135 /* complete uninstall */
2136 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2137 todo_wine
2139 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2141 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2142 ok(pf_exists("msitest"), "File deleted\n");
2144 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2145 todo_wine
2147 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2150 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2151 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2153 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2154 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2156 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2157 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2158 todo_wine
2160 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, 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_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2167 todo_wine
2169 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2170 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2171 CHECK_REG_STR(prodkey, "InstallDate", date);
2172 CHECK_REG_STR(prodkey, "InstallSource", temp);
2173 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2174 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2175 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2176 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2177 CHECK_REG_STR(prodkey, "Comments", NULL);
2178 CHECK_REG_STR(prodkey, "Contact", NULL);
2179 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2180 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2181 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2182 CHECK_REG_STR(prodkey, "Readme", NULL);
2183 CHECK_REG_STR(prodkey, "Size", NULL);
2184 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2185 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2186 CHECK_REG_DWORD(prodkey, "Language", 1033);
2187 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2188 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2189 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2190 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2191 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2194 RegCloseKey(prodkey);
2196 /* PublishProduct and RegisterProduct */
2197 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2198 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2199 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2200 ok(pf_exists("msitest"), "File not installed\n");
2202 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2203 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2205 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2206 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2208 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2209 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2211 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2212 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2213 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2214 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2216 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2217 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2219 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2220 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2221 CHECK_REG_STR(prodkey, "InstallDate", date);
2222 CHECK_REG_STR(prodkey, "InstallSource", temp);
2223 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2224 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2225 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2226 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2227 CHECK_REG_STR(prodkey, "Comments", NULL);
2228 CHECK_REG_STR(prodkey, "Contact", NULL);
2229 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2230 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2231 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2232 CHECK_REG_STR(prodkey, "Readme", NULL);
2233 CHECK_REG_STR(prodkey, "Size", NULL);
2234 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2235 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2236 CHECK_REG_DWORD(prodkey, "Language", 1033);
2237 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2238 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2239 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2240 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2241 todo_wine
2243 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2246 RegCloseKey(prodkey);
2248 /* try it again */
2249 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2251 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2252 ok(pf_exists("msitest"), "File not installed\n");
2254 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2255 todo_wine
2257 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2260 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2261 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2263 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2264 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2266 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2267 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2268 todo_wine
2270 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2272 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2274 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2275 todo_wine
2277 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2280 /* uninstall has a problem with this */
2281 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2282 todo_wine
2284 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2286 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2287 ok(pf_exists("msitest"), "File deleted\n");
2289 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2290 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2292 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2293 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2295 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2296 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2297 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2298 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2300 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2301 todo_wine
2303 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2306 /* PublishProduct and RegisterProduct and ProcessComponents */
2307 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
2308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2309 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2310 ok(pf_exists("msitest"), "File not installed\n");
2312 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2313 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2315 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2316 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2318 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2319 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2321 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2322 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2324 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2326 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2327 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2329 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2330 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2331 CHECK_REG_STR(prodkey, "InstallDate", date);
2332 CHECK_REG_STR(prodkey, "InstallSource", temp);
2333 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2334 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2335 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2336 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2337 CHECK_REG_STR(prodkey, "Comments", NULL);
2338 CHECK_REG_STR(prodkey, "Contact", NULL);
2339 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2340 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2341 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2342 CHECK_REG_STR(prodkey, "Readme", NULL);
2343 CHECK_REG_STR(prodkey, "Size", NULL);
2344 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2345 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2346 CHECK_REG_DWORD(prodkey, "Language", 1033);
2347 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2348 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2349 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2350 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2351 todo_wine
2353 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2356 RegCloseKey(prodkey);
2358 /* complete uninstall */
2359 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2360 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2361 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2362 ok(pf_exists("msitest"), "File deleted\n");
2364 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2365 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2367 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2368 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2370 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2371 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2373 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2374 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2375 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2376 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2378 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2379 todo_wine
2381 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2384 /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
2385 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
2386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2387 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2388 ok(pf_exists("msitest"), "File not installed\n");
2390 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2391 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2393 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2394 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2396 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2397 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2399 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2400 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2402 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2404 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2405 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2407 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2408 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2409 CHECK_REG_STR(prodkey, "InstallDate", date);
2410 CHECK_REG_STR(prodkey, "InstallSource", temp);
2411 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2412 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2413 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2414 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2415 CHECK_REG_STR(prodkey, "Comments", NULL);
2416 CHECK_REG_STR(prodkey, "Contact", NULL);
2417 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2418 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2419 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2420 CHECK_REG_STR(prodkey, "Readme", NULL);
2421 CHECK_REG_STR(prodkey, "Size", NULL);
2422 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2423 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2424 CHECK_REG_DWORD(prodkey, "Language", 1033);
2425 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2426 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2427 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2428 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2429 todo_wine
2431 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2434 RegCloseKey(prodkey);
2436 /* complete uninstall */
2437 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2438 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2439 todo_wine
2441 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
2442 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 /* complete install */
2466 r = MsiInstallProductA(msifile, "FULL=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 /* no UnpublishFeatures */
2518 r = MsiInstallProductA(msifile, "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 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2543 /* complete install */
2544 r = MsiInstallProductA(msifile, "FULL=1");
2545 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2546 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2547 ok(pf_exists("msitest"), "File not installed\n");
2549 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2550 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2552 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2553 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2555 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2556 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2558 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2559 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2561 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2563 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2564 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2566 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2567 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2568 CHECK_REG_STR(prodkey, "InstallDate", date);
2569 CHECK_REG_STR(prodkey, "InstallSource", temp);
2570 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2571 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2572 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2573 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2574 CHECK_REG_STR(prodkey, "Comments", NULL);
2575 CHECK_REG_STR(prodkey, "Contact", NULL);
2576 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2577 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2578 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2579 CHECK_REG_STR(prodkey, "Readme", NULL);
2580 CHECK_REG_STR(prodkey, "Size", NULL);
2581 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2582 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2583 CHECK_REG_DWORD(prodkey, "Language", 1033);
2584 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2585 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2586 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2587 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2588 todo_wine
2590 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2593 RegCloseKey(prodkey);
2595 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
2596 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
2597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2598 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2599 ok(pf_exists("msitest"), "File deleted\n");
2601 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2602 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2604 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2605 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2607 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2608 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2610 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2611 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2612 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2613 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2615 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2616 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2618 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2619 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2620 CHECK_REG_STR(prodkey, "InstallDate", date);
2621 CHECK_REG_STR(prodkey, "InstallSource", temp);
2622 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2623 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2624 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2625 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2626 CHECK_REG_STR(prodkey, "Comments", NULL);
2627 CHECK_REG_STR(prodkey, "Contact", NULL);
2628 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2629 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2630 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2631 CHECK_REG_STR(prodkey, "Readme", NULL);
2632 CHECK_REG_STR(prodkey, "Size", NULL);
2633 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2634 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2635 CHECK_REG_DWORD(prodkey, "Language", 1033);
2636 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2637 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2638 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2639 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2640 todo_wine
2642 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2645 RegCloseKey(prodkey);
2647 /* complete install */
2648 r = MsiInstallProductA(msifile, "FULL=1");
2649 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2650 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2651 ok(pf_exists("msitest"), "File not installed\n");
2653 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2654 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2656 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2657 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2659 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2660 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2662 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2663 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2664 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2665 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2667 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2668 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2670 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2671 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2672 CHECK_REG_STR(prodkey, "InstallDate", date);
2673 CHECK_REG_STR(prodkey, "InstallSource", temp);
2674 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2675 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2676 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2677 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2678 CHECK_REG_STR(prodkey, "Comments", NULL);
2679 CHECK_REG_STR(prodkey, "Contact", NULL);
2680 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2681 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2682 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2683 CHECK_REG_STR(prodkey, "Readme", NULL);
2684 CHECK_REG_STR(prodkey, "Size", NULL);
2685 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2686 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2687 CHECK_REG_DWORD(prodkey, "Language", 1033);
2688 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2689 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2690 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2691 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2692 todo_wine
2694 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2697 RegCloseKey(prodkey);
2699 /* UnpublishFeatures, both features removed */
2700 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
2701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2702 todo_wine
2704 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2705 ok(!pf_exists("msitest"), "File not deleted\n");
2708 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2709 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2711 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2712 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2714 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2715 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2717 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2718 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2719 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2720 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2722 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2723 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2725 /* complete install */
2726 r = MsiInstallProductA(msifile, "FULL=1");
2727 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2728 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2729 ok(pf_exists("msitest"), "File not installed\n");
2731 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2732 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2734 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2735 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2737 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2738 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2740 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2741 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2742 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2743 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2745 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2746 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2748 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2749 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2750 CHECK_REG_STR(prodkey, "InstallDate", date);
2751 CHECK_REG_STR(prodkey, "InstallSource", temp);
2752 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2753 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2754 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2755 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2756 CHECK_REG_STR(prodkey, "Comments", NULL);
2757 CHECK_REG_STR(prodkey, "Contact", NULL);
2758 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2759 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2760 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2761 CHECK_REG_STR(prodkey, "Readme", NULL);
2762 CHECK_REG_STR(prodkey, "Size", NULL);
2763 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2764 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2765 CHECK_REG_DWORD(prodkey, "Language", 1033);
2766 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2767 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2768 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2769 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2770 todo_wine
2772 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2775 RegCloseKey(prodkey);
2777 /* complete uninstall */
2778 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2780 todo_wine
2782 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2783 ok(!pf_exists("msitest"), "File not deleted\n");
2786 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2787 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2789 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2790 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2792 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2793 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2795 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2796 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2797 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2798 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2800 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2801 todo_wine
2803 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2806 /* make sure 'Program Files\msitest' is removed */
2807 delete_pfmsitest_files();
2809 RegCloseKey(uninstall);
2810 DeleteFile(msifile);
2811 DeleteFile("msitest\\maximus");
2812 RemoveDirectory("msitest");
2815 static void test_publishsourcelist(void)
2817 UINT r;
2818 DWORD size;
2819 CHAR value[MAX_PATH];
2820 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2822 CreateDirectoryA("msitest", NULL);
2823 create_file("msitest\\maximus", 500);
2825 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2827 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2829 r = MsiInstallProductA(msifile, NULL);
2830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2831 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2832 ok(pf_exists("msitest"), "File not installed\n");
2834 /* nothing published */
2835 size = 0xdeadbeef;
2836 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2837 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2838 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2839 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2841 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2842 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2843 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2844 ok(pf_exists("msitest"), "File not installed\n");
2846 /* after RegisterProduct */
2847 size = 0xdeadbeef;
2848 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2849 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2850 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2851 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2853 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2855 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2856 ok(pf_exists("msitest"), "File not installed\n");
2858 /* after ProcessComponents */
2859 size = 0xdeadbeef;
2860 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2861 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2862 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2863 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2865 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2867 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2868 ok(pf_exists("msitest"), "File not installed\n");
2870 /* after PublishFeatures */
2871 size = 0xdeadbeef;
2872 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2873 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
2874 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2875 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
2877 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2879 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2880 ok(pf_exists("msitest"), "File not installed\n");
2882 /* after PublishProduct */
2883 size = MAX_PATH;
2884 lstrcpyA(value, "aaa");
2885 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2886 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
2887 todo_wine
2889 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2890 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
2891 ok(size == 11, "Expected 11, got %d\n", size);
2894 /* complete uninstall */
2895 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2897 todo_wine
2899 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
2900 ok(!pf_exists("msitest"), "File not deleted\n");
2903 /* make sure 'Program Files\msitest' is removed */
2904 delete_pfmsitest_files();
2906 DeleteFile(msifile);
2907 DeleteFile("msitest\\maximus");
2908 RemoveDirectory("msitest");
2911 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
2913 MSIHANDLE hview = 0;
2914 UINT r;
2916 r = MsiDatabaseOpenView(hdb, query, &hview);
2917 if(r != ERROR_SUCCESS)
2918 return r;
2920 r = MsiViewExecute(hview, hrec);
2921 if(r == ERROR_SUCCESS)
2922 r = MsiViewClose(hview);
2923 MsiCloseHandle(hview);
2924 return r;
2927 static void set_transform_summary_info(void)
2929 UINT r;
2930 MSIHANDLE suminfo = 0;
2932 /* build summmary info */
2933 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
2934 todo_wine
2936 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
2939 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
2940 todo_wine
2942 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2945 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
2946 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2947 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
2948 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
2949 todo_wine
2951 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
2954 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
2955 todo_wine
2957 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
2960 r = MsiSummaryInfoPersist(suminfo);
2961 todo_wine
2963 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
2966 r = MsiCloseHandle(suminfo);
2967 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
2970 static void generate_transform(void)
2972 MSIHANDLE hdb1, hdb2;
2973 LPCSTR query;
2974 UINT r;
2976 /* start with two identical databases */
2977 CopyFile(msifile, msifile2, FALSE);
2979 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
2980 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2982 r = MsiDatabaseCommit(hdb1);
2983 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
2985 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
2986 ok(r == ERROR_SUCCESS , "Failed to create database\n");
2988 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2989 r = run_query(hdb1, 0, query);
2990 ok(r == ERROR_SUCCESS, "failed to add property\n");
2992 /* database needs to be committed */
2993 MsiDatabaseCommit(hdb1);
2995 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
2996 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
2998 #if 0 /* not implemented in wine yet */
2999 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
3000 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3001 #endif
3003 MsiCloseHandle(hdb1);
3004 MsiCloseHandle(hdb2);
3007 /* data for generating a transform */
3009 /* tables transform names - encoded as they would be in an msi database file */
3010 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
3011 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
3012 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
3014 /* data in each table */
3015 static const char data1[] = /* _StringData */
3016 "propval"; /* all the strings squashed together */
3018 static const WCHAR data2[] = { /* _StringPool */
3019 /* len, refs */
3020 0, 0, /* string 0 '' */
3021 4, 1, /* string 1 'prop' */
3022 3, 1, /* string 2 'val' */
3025 static const WCHAR data3[] = { /* Property */
3026 0x0201, 0x0001, 0x0002,
3029 static const struct {
3030 LPCWSTR name;
3031 const void *data;
3032 DWORD size;
3033 } table_transform_data[] =
3035 { name1, data1, sizeof data1 - 1 },
3036 { name2, data2, sizeof data2 },
3037 { name3, data3, sizeof data3 },
3040 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
3042 static void generate_transform_manual(void)
3044 IStorage *stg = NULL;
3045 IStream *stm;
3046 WCHAR name[0x20];
3047 HRESULT r;
3048 DWORD i, count;
3049 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
3051 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
3053 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
3055 r = StgCreateDocfile(name, mode, 0, &stg);
3056 ok(r == S_OK, "failed to create storage\n");
3057 if (!stg)
3058 return;
3060 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
3061 ok(r == S_OK, "failed to set storage type\n");
3063 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
3065 r = IStorage_CreateStream(stg, table_transform_data[i].name,
3066 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3067 if (FAILED(r))
3069 ok(0, "failed to create stream %08x\n", r);
3070 continue;
3073 r = IStream_Write(stm, table_transform_data[i].data,
3074 table_transform_data[i].size, &count);
3075 if (FAILED(r) || count != table_transform_data[i].size)
3076 ok(0, "failed to write stream\n");
3077 IStream_Release(stm);
3080 IStorage_Release(stg);
3082 set_transform_summary_info();
3085 static void test_transformprop(void)
3087 UINT r;
3089 CreateDirectoryA("msitest", NULL);
3090 create_file("msitest\\augustus", 500);
3092 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
3094 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3096 r = MsiInstallProductA(msifile, NULL);
3097 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3098 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3099 ok(!delete_pf("msitest", FALSE), "File installed\n");
3101 if (0)
3102 generate_transform();
3103 else
3104 generate_transform_manual();
3106 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
3107 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3108 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3109 ok(delete_pf("msitest", FALSE), "File not installed\n");
3111 /* Delete the files in the temp (current) folder */
3112 DeleteFile(msifile);
3113 DeleteFile(msifile2);
3114 DeleteFile(mstfile);
3115 DeleteFile("msitest\\augustus");
3116 RemoveDirectory("msitest");
3119 static void test_currentworkingdir(void)
3121 UINT r;
3122 CHAR path[MAX_PATH];
3123 LPSTR ptr, ptr2;
3125 CreateDirectoryA("msitest", NULL);
3126 create_file("msitest\\augustus", 500);
3128 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
3130 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3132 CreateDirectoryA("diffdir", NULL);
3133 SetCurrentDirectoryA("diffdir");
3135 sprintf(path, "..\\%s", msifile);
3136 r = MsiInstallProductA(path, NULL);
3137 todo_wine
3139 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
3140 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3141 ok(!delete_pf("msitest", FALSE), "File installed\n");
3144 sprintf(path, "%s\\%s", CURR_DIR, msifile);
3145 r = MsiInstallProductA(path, NULL);
3146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3147 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3148 ok(delete_pf("msitest", FALSE), "File not installed\n");
3150 lstrcpyA(path, CURR_DIR);
3151 if (path[lstrlenA(path) - 1] != '\\')
3152 lstrcatA(path, "\\");
3153 lstrcatA(path, "msitest.msi");
3155 ptr2 = strrchr(path, '\\');
3156 *ptr2 = '\0';
3157 ptr = strrchr(path, '\\');
3158 *ptr2 = '\\';
3159 *(ptr++) = '\0';
3161 SetCurrentDirectoryA(path);
3163 r = MsiInstallProductA(ptr, NULL);
3164 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3165 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3166 ok(delete_pf("msitest", FALSE), "File not installed\n");
3168 SetCurrentDirectoryA(CURR_DIR);
3170 DeleteFile(msifile);
3171 DeleteFile("msitest\\augustus");
3172 RemoveDirectory("msitest");
3173 RemoveDirectory("diffdir");
3176 static void set_admin_summary_info(const CHAR *name)
3178 MSIHANDLE db, summary;
3179 UINT r;
3181 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
3182 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3184 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
3185 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3187 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
3188 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3190 /* write the summary changes back to the stream */
3191 r = MsiSummaryInfoPersist(summary);
3192 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3194 MsiCloseHandle(summary);
3196 r = MsiDatabaseCommit(db);
3197 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3199 MsiCloseHandle(db);
3202 static void test_admin(void)
3204 UINT r;
3206 CreateDirectoryA("msitest", NULL);
3207 create_file("msitest\\augustus", 500);
3209 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
3210 set_admin_summary_info(msifile);
3212 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3214 r = MsiInstallProductA(msifile, NULL);
3215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3216 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3217 ok(!delete_pf("msitest", FALSE), "File installed\n");
3218 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
3219 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
3221 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
3222 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3223 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3224 ok(!delete_pf("msitest", FALSE), "File installed\n");
3225 todo_wine
3227 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
3228 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
3231 DeleteFile(msifile);
3232 DeleteFile("msitest\\augustus");
3233 RemoveDirectory("msitest");
3236 static void set_admin_property_stream(LPCSTR file)
3238 IStorage *stg;
3239 IStream *stm;
3240 WCHAR fileW[MAX_PATH];
3241 HRESULT hr;
3242 DWORD count;
3243 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
3245 /* AdminProperties */
3246 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
3247 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
3249 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
3251 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
3252 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3253 if (!stg)
3254 return;
3256 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3257 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3259 hr = IStream_Write(stm, data, sizeof(data), &count);
3260 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3262 IStream_Release(stm);
3263 IStorage_Release(stg);
3266 static void test_adminprops(void)
3268 UINT r;
3270 CreateDirectoryA("msitest", NULL);
3271 create_file("msitest\\augustus", 500);
3273 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
3274 set_admin_summary_info(msifile);
3275 set_admin_property_stream(msifile);
3277 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3279 r = MsiInstallProductA(msifile, NULL);
3280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3281 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
3282 ok(delete_pf("msitest", FALSE), "File installed\n");
3284 DeleteFile(msifile);
3285 DeleteFile("msitest\\augustus");
3286 RemoveDirectory("msitest");
3289 static void create_pf(LPCSTR file, BOOL is_file)
3291 CHAR path[MAX_PATH];
3293 lstrcpyA(path, PROG_FILES_DIR);
3294 lstrcatA(path, "\\");
3295 lstrcatA(path, file);
3297 if (is_file)
3298 create_file(path, 500);
3299 else
3300 CreateDirectoryA(path, NULL);
3303 static void test_removefiles(void)
3305 UINT r;
3307 CreateDirectoryA("msitest", NULL);
3308 create_file("msitest\\hydrogen", 500);
3309 create_file("msitest\\helium", 500);
3310 create_file("msitest\\lithium", 500);
3312 create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
3314 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3316 r = MsiInstallProductA(msifile, NULL);
3317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3318 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3319 ok(!pf_exists("msitest\\helium"), "File installed\n");
3320 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3321 ok(pf_exists("msitest"), "File not installed\n");
3323 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3324 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3325 ok(!pf_exists("msitest\\helium"), "File not deleted\n");
3326 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3327 todo_wine
3329 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3330 ok(delete_pf("msitest", FALSE), "File deleted\n");
3333 create_pf("msitest", FALSE);
3334 create_pf("msitest\\hydrogen", TRUE);
3335 create_pf("msitest\\helium", TRUE);
3336 create_pf("msitest\\lithium", TRUE);
3338 r = MsiInstallProductA(msifile, NULL);
3339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3340 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3341 ok(pf_exists("msitest\\helium"), "File not installed\n");
3342 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3343 ok(pf_exists("msitest"), "File not installed\n");
3345 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3347 ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
3348 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3349 todo_wine
3351 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3352 ok(delete_pf("msitest", FALSE), "File deleted\n");
3355 create_pf("msitest", FALSE);
3356 create_pf("msitest\\furlong", TRUE);
3357 create_pf("msitest\\firkin", TRUE);
3358 create_pf("msitest\\fortnight", TRUE);
3359 create_pf("msitest\\becquerel", TRUE);
3360 create_pf("msitest\\dioptre", TRUE);
3361 create_pf("msitest\\attoparsec", TRUE);
3362 create_pf("msitest\\storeys", TRUE);
3363 create_pf("msitest\\block", TRUE);
3364 create_pf("msitest\\siriometer", TRUE);
3366 r = MsiInstallProductA(msifile, NULL);
3367 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3368 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3369 ok(!pf_exists("msitest\\helium"), "File installed\n");
3370 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3371 ok(pf_exists("msitest\\becquerel"), "File not installed\n");
3372 ok(pf_exists("msitest\\dioptre"), "File not installed\n");
3373 ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
3374 ok(pf_exists("msitest"), "File not installed\n");
3375 todo_wine
3377 ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
3378 ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
3379 ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
3380 ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
3381 ok(!pf_exists("msitest\\block"), "File not deleted\n");
3382 ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
3385 create_pf("msitest\\furlong", TRUE);
3386 create_pf("msitest\\firkin", TRUE);
3387 create_pf("msitest\\fortnight", TRUE);
3388 create_pf("msitest\\storeys", TRUE);
3389 create_pf("msitest\\block", TRUE);
3390 create_pf("msitest\\siriometer", TRUE);
3392 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3394 ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
3395 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3396 ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
3397 ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
3398 ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
3399 ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
3400 ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
3401 todo_wine
3403 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
3404 ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
3405 ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
3406 ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
3407 ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
3409 ok(delete_pf("msitest", FALSE), "File deleted\n");
3411 DeleteFile(msifile);
3412 DeleteFile("msitest\\hydrogen");
3413 DeleteFile("msitest\\helium");
3414 DeleteFile("msitest\\lithium");
3415 RemoveDirectory("msitest");
3418 static void test_movefiles(void)
3420 UINT r;
3421 char props[MAX_PATH];
3423 CreateDirectoryA("msitest", NULL);
3424 create_file("msitest\\augustus", 100);
3425 create_file("cameroon", 100);
3426 create_file("djibouti", 100);
3427 create_file("egypt", 100);
3428 create_file("finland", 100);
3429 create_file("gambai", 100);
3430 create_file("honduras", 100);
3431 create_file("msitest\\india", 100);
3432 create_file("japan", 100);
3433 create_file("kenya", 100);
3434 CreateDirectoryA("latvia", NULL);
3435 create_file("nauru", 100);
3436 create_file("apple", 100);
3437 create_file("application", 100);
3438 create_file("ape", 100);
3439 create_file("foo", 100);
3440 create_file("fao", 100);
3441 create_file("fbod", 100);
3442 create_file("budding", 100);
3443 create_file("buddy", 100);
3444 create_file("bud", 100);
3445 create_file("bar", 100);
3446 create_file("bur", 100);
3447 create_file("bird", 100);
3449 create_database(msifile, mov_tables, sizeof(mov_tables) / sizeof(msi_table));
3451 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3452 MsiEnableLog(INSTALLLOGMODE_VERBOSE | INSTALLLOGMODE_EXTRADEBUG, "log.txt", 0);
3454 /* if the source or dest property is not a full path,
3455 * windows tries to access it as a network resource
3458 sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
3459 "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
3460 CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);
3462 r = MsiInstallProductA(msifile, props);
3463 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3464 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3465 ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
3466 ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
3467 ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
3468 ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
3469 ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
3470 ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
3471 ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
3472 ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
3473 ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
3474 ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
3475 ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
3476 ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
3477 ok(!delete_pf("msitest\\apple", TRUE), "File should not exist\n");
3478 ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
3479 ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
3480 ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
3481 ok(delete_pf("msitest\\foo", TRUE), "File not moved\n");
3482 ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
3483 ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
3484 ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
3485 ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
3486 ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
3487 ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
3488 ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
3489 ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
3490 ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
3491 ok(delete_pf("msitest", FALSE), "File not installed\n");
3492 ok(DeleteFileA("cameroon"), "File moved\n");
3493 ok(!DeleteFileA("djibouti"), "File not moved\n");
3494 ok(DeleteFileA("egypt"), "File moved\n");
3495 ok(DeleteFileA("finland"), "File moved\n");
3496 ok(DeleteFileA("gambai"), "File moved\n");
3497 ok(!DeleteFileA("honduras"), "File not moved\n");
3498 ok(DeleteFileA("msitest\\india"), "File moved\n");
3499 ok(DeleteFileA("japan"), "File moved\n");
3500 ok(!DeleteFileA("kenya"), "File not moved\n");
3501 ok(RemoveDirectoryA("latvia"), "Directory moved\n");
3502 ok(!DeleteFileA("nauru"), "File not moved\n");
3503 ok(!DeleteFileA("apple"), "File not moved\n");
3504 ok(!DeleteFileA("application"), "File not moved\n");
3505 ok(DeleteFileA("ape"), "File moved\n");
3506 ok(!DeleteFileA("foo"), "File not moved\n");
3507 ok(!DeleteFileA("fao"), "File not moved\n");
3508 ok(DeleteFileA("fbod"), "File moved\n");
3509 ok(!DeleteFileA("budding"), "File not moved\n");
3510 ok(!DeleteFileA("buddy"), "File not moved\n");
3511 ok(DeleteFileA("bud"), "File moved\n");
3512 ok(!DeleteFileA("bar"), "File not moved\n");
3513 ok(!DeleteFileA("bur"), "File not moved\n");
3514 ok(DeleteFileA("bird"), "File moved\n");
3516 DeleteFile("msitest\\augustus");
3517 RemoveDirectory("msitest");
3518 DeleteFile(msifile);
3521 static void test_missingcab(void)
3523 UINT r;
3525 CreateDirectoryA("msitest", NULL);
3526 create_file("msitest\\augustus", 500);
3527 create_file("maximus", 500);
3529 create_database(msifile, mc_tables, sizeof(mc_tables) / sizeof(msi_table));
3531 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3533 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
3535 create_pf("msitest", FALSE);
3536 create_pf("msitest\\caesar", TRUE);
3538 r = MsiInstallProductA(msifile, NULL);
3539 todo_wine
3541 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3543 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3544 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3545 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3546 ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
3547 ok(delete_pf("msitest", FALSE), "File not installed\n");
3549 create_pf("msitest", FALSE);
3550 create_pf("msitest\\caesar", TRUE);
3551 create_pf("msitest\\gaius", TRUE);
3553 r = MsiInstallProductA(msifile, "GAIUS=1");
3554 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3555 todo_wine
3557 ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
3558 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3560 ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
3561 ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
3562 ok(delete_pf("msitest", FALSE), "File not installed\n");
3564 DeleteFile("msitest\\augustus");
3565 RemoveDirectory("msitest");
3566 DeleteFile("maximus");
3567 DeleteFile("test1.cab");
3568 DeleteFile(msifile);
3571 START_TEST(install)
3573 DWORD len;
3574 char temp_path[MAX_PATH], prev_path[MAX_PATH];
3576 init_functionpointers();
3578 GetCurrentDirectoryA(MAX_PATH, prev_path);
3579 GetTempPath(MAX_PATH, temp_path);
3580 SetCurrentDirectoryA(temp_path);
3582 lstrcpyA(CURR_DIR, temp_path);
3583 len = lstrlenA(CURR_DIR);
3585 if(len && (CURR_DIR[len - 1] == '\\'))
3586 CURR_DIR[len - 1] = 0;
3588 get_program_files_dir(PROG_FILES_DIR, COMMON_FILES_DIR);
3590 test_MsiInstallProduct();
3591 test_MsiSetComponentState();
3592 test_packagecoltypes();
3593 test_continuouscabs();
3594 test_caborder();
3595 test_mixedmedia();
3596 test_samesequence();
3597 test_uiLevelFlags();
3598 test_readonlyfile();
3599 test_setdirproperty();
3600 test_cabisextracted();
3601 test_concurrentinstall();
3602 test_setpropertyfolder();
3603 test_publish();
3604 test_publishsourcelist();
3605 test_transformprop();
3606 test_currentworkingdir();
3607 test_admin();
3608 test_adminprops();
3609 test_removefiles();
3610 test_movefiles();
3611 test_missingcab();
3613 SetCurrentDirectoryA(prev_path);