msi: Fix handling of published installer properties.
[wine.git] / dlls / msi / tests / install.c
blob03458dca1109b5e8c8e108dea0711decad62042d
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 *pMsiSourceListEnumSourcesA)
38 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPSTR, LPDWORD);
39 static UINT (WINAPI *pMsiSourceListGetInfoA)
40 (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
42 static const char *msifile = "msitest.msi";
43 static const char *msifile2 = "winetest2.msi";
44 static const char *mstfile = "winetest.mst";
45 static CHAR CURR_DIR[MAX_PATH];
46 static CHAR PROG_FILES_DIR[MAX_PATH];
47 static CHAR COMMON_FILES_DIR[MAX_PATH];
49 /* msi database data */
51 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
52 "s72\tS38\ts72\ti2\tS255\tS72\n"
53 "Component\tComponent\n"
54 "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
55 "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
56 "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\t\tone.txt\n"
57 "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
58 "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
59 "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
60 "component\t\tMSITESTDIR\t0\t1\tfile\n"
61 "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
63 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
64 "s72\tS72\tl255\n"
65 "Directory\tDirectory\n"
66 "CABOUTDIR\tMSITESTDIR\tcabout\n"
67 "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
68 "FIRSTDIR\tMSITESTDIR\tfirst\n"
69 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
70 "NEWDIR\tCABOUTDIR\tnew\n"
71 "ProgramFilesFolder\tTARGETDIR\t.\n"
72 "TARGETDIR\t\tSourceDir";
74 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
75 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
76 "Feature\tFeature\n"
77 "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
78 "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
79 "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
80 "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
81 "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
82 "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
83 "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
85 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
86 "s38\ts72\n"
87 "FeatureComponents\tFeature_\tComponent_\n"
88 "Five\tFive\n"
89 "Four\tFour\n"
90 "One\tOne\n"
91 "Three\tThree\n"
92 "Two\tTwo\n"
93 "feature\tcomponent\n"
94 "service_feature\tservice_comp\n";
96 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
97 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
98 "File\tFile\n"
99 "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
100 "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
101 "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
102 "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
103 "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
104 "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
105 "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
107 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
108 "s72\tS255\tI2\n"
109 "InstallExecuteSequence\tAction\n"
110 "AllocateRegistrySpace\tNOT Installed\t1550\n"
111 "CostFinalize\t\t1000\n"
112 "CostInitialize\t\t800\n"
113 "FileCost\t\t900\n"
114 "ResolveSource\t\t950\n"
115 "MoveFiles\t\t1700\n"
116 "InstallFiles\t\t4000\n"
117 "DuplicateFiles\t\t4500\n"
118 "InstallServices\t\t5000\n"
119 "InstallFinalize\t\t6600\n"
120 "InstallInitialize\t\t1500\n"
121 "InstallValidate\t\t1400\n"
122 "LaunchConditions\t\t100\n"
123 "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
125 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
126 "i2\ti4\tL64\tS255\tS32\tS72\n"
127 "Media\tDiskId\n"
128 "1\t3\t\t\tDISK1\t\n"
129 "2\t5\t\tmsitest.cab\tDISK2\t\n";
131 static const CHAR property_dat[] = "Property\tValue\n"
132 "s72\tl0\n"
133 "Property\tProperty\n"
134 "DefaultUIFont\tDlgFont8\n"
135 "HASUIRUN\t0\n"
136 "INSTALLLEVEL\t3\n"
137 "InstallMode\tTypical\n"
138 "Manufacturer\tWine\n"
139 "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
140 "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
141 "ProductID\tnone\n"
142 "ProductLanguage\t1033\n"
143 "ProductName\tMSITEST\n"
144 "ProductVersion\t1.1.1\n"
145 "PROMPTROLLBACKCOST\tP\n"
146 "Setup\tSetup\n"
147 "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
148 "AdminProperties\tPOSTADMIN\n"
149 "ROOTDRIVE\tC:\\\n";
151 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
152 "s72\ti2\tl255\tL255\tL0\ts72\n"
153 "Registry\tRegistry\n"
154 "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
155 "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
156 "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
157 "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
159 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
160 "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
161 "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
162 "ServiceInstall\tServiceInstall\n"
163 "TestService\tTestService\tTestService\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
165 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
166 "s72\tl255\ti2\tL255\tI2\ts72\n"
167 "ServiceControl\tServiceControl\n"
168 "ServiceControl\tTestService\t8\t\t0\tservice_comp";
170 /* tables for test_continuouscabs */
171 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
172 "s72\tS38\ts72\ti2\tS255\tS72\n"
173 "Component\tComponent\n"
174 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
175 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
176 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
178 static const CHAR cc2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
179 "s72\tS38\ts72\ti2\tS255\tS72\n"
180 "Component\tComponent\n"
181 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
182 "augustus\t\tMSITESTDIR\t0\t0\taugustus\n"
183 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
185 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
186 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
187 "Feature\tFeature\n"
188 "feature\t\t\t\t2\t1\tTARGETDIR\t0";
190 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
191 "s38\ts72\n"
192 "FeatureComponents\tFeature_\tComponent_\n"
193 "feature\tmaximus\n"
194 "feature\taugustus\n"
195 "feature\tcaesar";
197 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
198 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
199 "File\tFile\n"
200 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
201 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
202 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
204 static const CHAR cc2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
205 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
206 "File\tFile\n"
207 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
208 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
209 "tiberius\tmaximus\ttiberius\t500\t\t\t16384\t3\n"
210 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
212 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
213 "i2\ti4\tL64\tS255\tS32\tS72\n"
214 "Media\tDiskId\n"
215 "1\t10\t\ttest1.cab\tDISK1\t\n"
216 "2\t2\t\ttest2.cab\tDISK2\t\n"
217 "3\t12\t\ttest3.cab\tDISK3\t\n";
219 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
220 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
221 "File\tFile\n"
222 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
223 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
224 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
226 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
227 "i2\ti4\tL64\tS255\tS32\tS72\n"
228 "Media\tDiskId\n"
229 "1\t10\t\ttest1.cab\tDISK1\t\n"
230 "2\t2\t\ttest2.cab\tDISK2\t\n"
231 "3\t3\t\ttest3.cab\tDISK3\t\n";
233 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
234 "i2\ti4\tL64\tS255\tS32\tS72\n"
235 "Media\tDiskId\n"
236 "1\t10\t\ttest1.cab\tDISK1\t\n"
237 "2\t12\t\ttest3.cab\tDISK3\t\n"
238 "3\t2\t\ttest2.cab\tDISK2\t\n";
240 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
241 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
242 "File\tFile\n"
243 "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
244 "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
245 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
247 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
248 "i2\ti4\tL64\tS255\tS32\tS72\n"
249 "Media\tDiskId\n"
250 "1\t3\t\ttest1.cab\tDISK1\t\n";
252 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
253 "i2\ti4\tL64\tS255\tS32\tS72\n"
254 "Media\tDiskId\n"
255 "1\t2\t\ttest1.cab\tDISK1\t\n"
256 "2\t2\t\ttest2.cab\tDISK2\t\n"
257 "3\t12\t\ttest3.cab\tDISK3\t\n";
259 /* tables for test_uiLevelFlags */
260 static const CHAR ui_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\tHASUIRUN=1\tmaximus\n"
264 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
265 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
267 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
268 "s72\tS255\tI2\n"
269 "InstallUISequence\tAction\n"
270 "SetUIProperty\t\t5\n"
271 "ExecuteAction\t\t1100\n";
273 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
274 "s72\ti2\tS64\tS0\tS255\n"
275 "CustomAction\tAction\n"
276 "SetUIProperty\t51\tHASUIRUN\t1\t\n";
278 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
279 "s72\tS38\ts72\ti2\tS255\tS72\n"
280 "Component\tComponent\n"
281 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
283 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
284 "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
285 "Feature\tFeature\n"
286 "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
287 "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
289 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
290 "s38\ts72\n"
291 "FeatureComponents\tFeature_\tComponent_\n"
292 "feature\tmaximus\n"
293 "montecristo\tmaximus";
295 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
296 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
297 "File\tFile\n"
298 "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
300 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
301 "i2\ti4\tL64\tS255\tS32\tS72\n"
302 "Media\tDiskId\n"
303 "1\t1\t\t\tDISK1\t\n";
305 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
306 "s72\tS255\tI2\n"
307 "InstallExecuteSequence\tAction\n"
308 "AllocateRegistrySpace\tNOT Installed\t1550\n"
309 "CostFinalize\t\t1000\n"
310 "CostInitialize\t\t800\n"
311 "FileCost\t\t900\n"
312 "InstallFiles\t\t4000\n"
313 "InstallFinalize\t\t6600\n"
314 "InstallInitialize\t\t1500\n"
315 "InstallValidate\t\t1400\n"
316 "LaunchConditions\t\t100\n"
317 "SetDirProperty\t\t950";
319 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
320 "s72\ti2\tS64\tS0\tS255\n"
321 "CustomAction\tAction\n"
322 "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
324 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
325 "s72\tS38\ts72\ti2\tS255\tS72\n"
326 "Component\tComponent\n"
327 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
328 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
329 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
330 "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
332 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
333 "s38\ts72\n"
334 "FeatureComponents\tFeature_\tComponent_\n"
335 "feature\tmaximus\n"
336 "feature\taugustus\n"
337 "feature\tcaesar\n"
338 "feature\tgaius";
340 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
341 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
342 "File\tFile\n"
343 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
344 "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
345 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
346 "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
348 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
349 "i2\ti4\tL64\tS255\tS32\tS72\n"
350 "Media\tDiskId\n"
351 "1\t1\t\ttest1.cab\tDISK1\t\n"
352 "2\t2\t\ttest2.cab\tDISK2\t\n"
353 "3\t12\t\ttest3.cab\tDISK3\t\n";
355 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
356 "s72\tS255\tI2\n"
357 "InstallExecuteSequence\tAction\n"
358 "CostFinalize\t\t1000\n"
359 "CostInitialize\t\t800\n"
360 "FileCost\t\t900\n"
361 "InstallFiles\t\t4000\n"
362 "InstallServices\t\t5000\n"
363 "InstallFinalize\t\t6600\n"
364 "InstallInitialize\t\t1500\n"
365 "RunInstall\t\t1600\n"
366 "InstallValidate\t\t1400\n"
367 "LaunchConditions\t\t100";
369 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
370 "s72\ti2\tS64\tS0\tS255\n"
371 "CustomAction\tAction\n"
372 "RunInstall\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
374 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
375 "s72\tS38\ts72\ti2\tS255\tS72\n"
376 "Component\tComponent\n"
377 "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
379 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
380 "s72\tS38\ts72\ti2\tS255\tS72\n"
381 "Component\tComponent\n"
382 "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
384 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
385 "s38\ts72\n"
386 "FeatureComponents\tFeature_\tComponent_\n"
387 "feature\taugustus";
389 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
390 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
391 "File\tFile\n"
392 "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
394 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
395 "s72\ti2\tS64\tS0\tS255\n"
396 "CustomAction\tAction\n"
397 "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
399 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
400 "s72\tS255\tI2\n"
401 "InstallExecuteSequence\tAction\n"
402 "CostFinalize\t\t1000\n"
403 "CostInitialize\t\t800\n"
404 "FileCost\t\t900\n"
405 "SetFolderProp\t\t950\n"
406 "InstallFiles\t\t4000\n"
407 "InstallServices\t\t5000\n"
408 "InstallFinalize\t\t6600\n"
409 "InstallInitialize\t\t1500\n"
410 "InstallValidate\t\t1400\n"
411 "LaunchConditions\t\t100";
413 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
414 "s72\tS255\tI2\n"
415 "InstallUISequence\tAction\n"
416 "CostInitialize\t\t800\n"
417 "FileCost\t\t900\n"
418 "CostFinalize\t\t1000\n"
419 "ExecuteAction\t\t1100\n";
421 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
422 "s72\tS255\tI2\n"
423 "InstallExecuteSequence\tAction\n"
424 "ValidateProductID\t\t700\n"
425 "CostInitialize\t\t800\n"
426 "FileCost\t\t900\n"
427 "CostFinalize\t\t1000\n"
428 "InstallValidate\t\t1400\n"
429 "InstallInitialize\t\t1500\n"
430 "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
431 "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
432 "RemoveFiles\t\t3500\n"
433 "InstallFiles\t\t4000\n"
434 "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
435 "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
436 "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
437 "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
438 "InstallFinalize\t\t6600";
440 static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
441 "s72\tS38\ts72\ti2\tS255\tS72\n"
442 "Component\tComponent\n"
443 "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";
445 static const CHAR cwd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
446 "s72\tS38\ts72\ti2\tS255\tS72\n"
447 "Component\tComponent\n"
448 "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
450 static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
451 "s72\tS38\ts72\ti2\tS255\tS72\n"
452 "Component\tComponent\n"
453 "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";
455 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
456 "s72\ti2\tS64\tS0\tS255\n"
457 "CustomAction\tAction\n"
458 "SetPOSTADMIN\t51\tPOSTADMIN\t1\t\n";
460 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
461 "s72\tS255\tI2\n"
462 "AdminExecuteSequence\tAction\n"
463 "CostFinalize\t\t1000\n"
464 "CostInitialize\t\t800\n"
465 "FileCost\t\t900\n"
466 "SetPOSTADMIN\t\t950\n"
467 "InstallFiles\t\t4000\n"
468 "InstallFinalize\t\t6600\n"
469 "InstallInitialize\t\t1500\n"
470 "InstallValidate\t\t1400\n"
471 "LaunchConditions\t\t100";
473 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
474 "s72\tS38\ts72\ti2\tS255\tS72\n"
475 "Component\tComponent\n"
476 "augustus\t\tMSITESTDIR\t0\tMYPROP=2718\taugustus\n";
478 static const CHAR rem_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
479 "s72\tS38\ts72\ti2\tS255\tS72\n"
480 "Component\tComponent\n"
481 "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t0\t\thydrogen\n"
482 "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
483 "lithium\t\tMSITESTDIR\t2\t\tlithium\n";
485 static const CHAR rem_feature_comp_dat[] = "Feature_\tComponent_\n"
486 "s38\ts72\n"
487 "FeatureComponents\tFeature_\tComponent_\n"
488 "feature\thydrogen\n"
489 "feature\thelium\n"
490 "feature\tlithium";
492 static const CHAR rem_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
493 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
494 "File\tFile\n"
495 "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
496 "helium\thelium\thelium\t0\t\t\t8192\t1\n"
497 "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
499 static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
500 "s72\tS255\tI2\n"
501 "InstallExecuteSequence\tAction\n"
502 "ValidateProductID\t\t700\n"
503 "CostInitialize\t\t800\n"
504 "FileCost\t\t900\n"
505 "CostFinalize\t\t1000\n"
506 "InstallValidate\t\t1400\n"
507 "InstallInitialize\t\t1500\n"
508 "ProcessComponents\t\t1600\n"
509 "UnpublishFeatures\t\t1800\n"
510 "RemoveFiles\t\t3500\n"
511 "InstallFiles\t\t4000\n"
512 "RegisterProduct\t\t6100\n"
513 "PublishFeatures\t\t6300\n"
514 "PublishProduct\t\t6400\n"
515 "InstallFinalize\t\t6600";
517 static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
518 "s72\ts72\tS255\ts72\tI2\n"
519 "RemoveFile\tFileKey\n"
520 "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
521 "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
522 "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
523 "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
524 "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
525 "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
526 "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
527 "block\thelium\tblock\tMSITESTDIR\t3\n"
528 "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n";
530 static const CHAR mov_move_file_dat[] = "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
531 "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
532 "MoveFile\tFileKey\n"
533 "abkhazia\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t0\n"
534 "bahamas\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t1\n"
535 "cambodia\taugustus\tcameroon\tcanada\tSourceDir\tMSITESTDIR\t0\n"
536 "denmark\taugustus\tdjibouti\tdominica\tSourceDir\tMSITESTDIR\t1\n"
537 "ecuador\taugustus\tegypt\telsalvador\tNotAProp\tMSITESTDIR\t1\n"
538 "fiji\taugustus\tfinland\tfrance\tSourceDir\tNotAProp\t1\n"
539 "gabon\taugustus\tgambia\tgeorgia\tSOURCEFULL\tMSITESTDIR\t1\n"
540 "haiti\taugustus\thonduras\thungary\tSourceDir\tDESTFULL\t1\n"
541 "iceland\taugustus\tindia\tindonesia\tMSITESTDIR\tMSITESTDIR\t1\n"
542 "jamaica\taugustus\tjapan\tjordan\tFILEPATHBAD\tMSITESTDIR\t1\n"
543 "kazakhstan\taugustus\t\tkiribati\tFILEPATHGOOD\tMSITESTDIR\t1\n"
544 "laos\taugustus\tlatvia\tlebanon\tSourceDir\tMSITESTDIR\t1\n"
545 "namibia\taugustus\tnauru\tkiribati\tSourceDir\tMSITESTDIR\t1\n"
546 "wildcard\taugustus\tapp*\twildcard\tSourceDir\tMSITESTDIR\t1\n"
547 "single\taugustus\tf?o\tsingle\tSourceDir\tMSITESTDIR\t1\n"
548 "wildcardnodest\taugustus\tbudd*\t\tSourceDir\tMSITESTDIR\t1\n"
549 "singlenodest\taugustus\tb?r\t\tSourceDir\tMSITESTDIR\t1\n";
551 static const CHAR mc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
552 "s72\tS38\ts72\ti2\tS255\tS72\n"
553 "Component\tComponent\n"
554 "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
555 "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
556 "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
557 "gaius\t\tMSITESTDIR\t0\tGAIUS=1\tgaius\n";
559 static const CHAR mc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
560 "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
561 "File\tFile\n"
562 "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
563 "augustus\taugustus\taugustus\t500\t\t\t0\t2\n"
564 "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3\n"
565 "gaius\tgaius\tgaius\t500\t\t\t16384\t4";
567 static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
568 "i2\ti4\tL64\tS255\tS32\tS72\n"
569 "Media\tDiskId\n"
570 "1\t1\t\ttest1.cab\tDISK1\t\n"
571 "2\t2\t\ttest2.cab\tDISK2\t\n"
572 "3\t3\t\ttest3.cab\tDISK3\t\n"
573 "4\t4\t\ttest3.cab\tDISK3\t\n";
575 static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n"
576 "s72\ti2\ti4\ti4\ti4\ti4\n"
577 "MsiFileHash\tFile_\n"
578 "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824";
580 static const CHAR df_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
581 "s72\tS72\tl255\n"
582 "Directory\tDirectory\n"
583 "THIS\tMSITESTDIR\tthis\n"
584 "DOESNOT\tTHIS\tdoesnot\n"
585 "NONEXISTENT\tDOESNOT\texist\n"
586 "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
587 "ProgramFilesFolder\tTARGETDIR\t.\n"
588 "TARGETDIR\t\tSourceDir";
590 static const CHAR df_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
591 "s72\ts72\ts72\tS255\tS72\n"
592 "DuplicateFile\tFileKey\n"
593 "maximus\tmaximus\tmaximus\taugustus\t\n"
594 "caesar\tmaximus\tmaximus\t\tNONEXISTENT\n";
596 static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
597 "s72\tS38\ts72\ti2\tS255\tS72\n"
598 "Component\tComponent\n"
599 "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
601 static const CHAR wrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
602 "s72\ti2\tl255\tL255\tL0\ts72\n"
603 "Registry\tRegistry\n"
604 "regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus";
606 typedef struct _msi_table
608 const CHAR *filename;
609 const CHAR *data;
610 int size;
611 } msi_table;
613 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
615 static const msi_table tables[] =
617 ADD_TABLE(component),
618 ADD_TABLE(directory),
619 ADD_TABLE(feature),
620 ADD_TABLE(feature_comp),
621 ADD_TABLE(file),
622 ADD_TABLE(install_exec_seq),
623 ADD_TABLE(media),
624 ADD_TABLE(property),
625 ADD_TABLE(registry),
626 ADD_TABLE(service_install),
627 ADD_TABLE(service_control)
630 static const msi_table cc_tables[] =
632 ADD_TABLE(cc_component),
633 ADD_TABLE(directory),
634 ADD_TABLE(cc_feature),
635 ADD_TABLE(cc_feature_comp),
636 ADD_TABLE(cc_file),
637 ADD_TABLE(install_exec_seq),
638 ADD_TABLE(cc_media),
639 ADD_TABLE(property),
642 static const msi_table cc2_tables[] =
644 ADD_TABLE(cc2_component),
645 ADD_TABLE(directory),
646 ADD_TABLE(cc_feature),
647 ADD_TABLE(cc_feature_comp),
648 ADD_TABLE(cc2_file),
649 ADD_TABLE(install_exec_seq),
650 ADD_TABLE(cc_media),
651 ADD_TABLE(property),
654 static const msi_table co_tables[] =
656 ADD_TABLE(cc_component),
657 ADD_TABLE(directory),
658 ADD_TABLE(cc_feature),
659 ADD_TABLE(cc_feature_comp),
660 ADD_TABLE(co_file),
661 ADD_TABLE(install_exec_seq),
662 ADD_TABLE(co_media),
663 ADD_TABLE(property),
666 static const msi_table co2_tables[] =
668 ADD_TABLE(cc_component),
669 ADD_TABLE(directory),
670 ADD_TABLE(cc_feature),
671 ADD_TABLE(cc_feature_comp),
672 ADD_TABLE(cc_file),
673 ADD_TABLE(install_exec_seq),
674 ADD_TABLE(co2_media),
675 ADD_TABLE(property),
678 static const msi_table mm_tables[] =
680 ADD_TABLE(cc_component),
681 ADD_TABLE(directory),
682 ADD_TABLE(cc_feature),
683 ADD_TABLE(cc_feature_comp),
684 ADD_TABLE(mm_file),
685 ADD_TABLE(install_exec_seq),
686 ADD_TABLE(mm_media),
687 ADD_TABLE(property),
690 static const msi_table ss_tables[] =
692 ADD_TABLE(cc_component),
693 ADD_TABLE(directory),
694 ADD_TABLE(cc_feature),
695 ADD_TABLE(cc_feature_comp),
696 ADD_TABLE(cc_file),
697 ADD_TABLE(install_exec_seq),
698 ADD_TABLE(ss_media),
699 ADD_TABLE(property),
702 static const msi_table ui_tables[] =
704 ADD_TABLE(ui_component),
705 ADD_TABLE(directory),
706 ADD_TABLE(cc_feature),
707 ADD_TABLE(cc_feature_comp),
708 ADD_TABLE(cc_file),
709 ADD_TABLE(install_exec_seq),
710 ADD_TABLE(ui_install_ui_seq),
711 ADD_TABLE(ui_custom_action),
712 ADD_TABLE(cc_media),
713 ADD_TABLE(property),
716 static const msi_table rof_tables[] =
718 ADD_TABLE(rof_component),
719 ADD_TABLE(directory),
720 ADD_TABLE(rof_feature),
721 ADD_TABLE(rof_feature_comp),
722 ADD_TABLE(rof_file),
723 ADD_TABLE(install_exec_seq),
724 ADD_TABLE(rof_media),
725 ADD_TABLE(property),
728 static const msi_table sdp_tables[] =
730 ADD_TABLE(rof_component),
731 ADD_TABLE(directory),
732 ADD_TABLE(rof_feature),
733 ADD_TABLE(rof_feature_comp),
734 ADD_TABLE(rof_file),
735 ADD_TABLE(sdp_install_exec_seq),
736 ADD_TABLE(sdp_custom_action),
737 ADD_TABLE(rof_media),
738 ADD_TABLE(property),
741 static const msi_table cie_tables[] =
743 ADD_TABLE(cie_component),
744 ADD_TABLE(directory),
745 ADD_TABLE(cc_feature),
746 ADD_TABLE(cie_feature_comp),
747 ADD_TABLE(cie_file),
748 ADD_TABLE(install_exec_seq),
749 ADD_TABLE(cie_media),
750 ADD_TABLE(property),
753 static const msi_table ci_tables[] =
755 ADD_TABLE(ci_component),
756 ADD_TABLE(directory),
757 ADD_TABLE(rof_feature),
758 ADD_TABLE(rof_feature_comp),
759 ADD_TABLE(rof_file),
760 ADD_TABLE(ci_install_exec_seq),
761 ADD_TABLE(rof_media),
762 ADD_TABLE(property),
763 ADD_TABLE(ci_custom_action),
766 static const msi_table ci2_tables[] =
768 ADD_TABLE(ci2_component),
769 ADD_TABLE(directory),
770 ADD_TABLE(rof_feature),
771 ADD_TABLE(ci2_feature_comp),
772 ADD_TABLE(ci2_file),
773 ADD_TABLE(install_exec_seq),
774 ADD_TABLE(rof_media),
775 ADD_TABLE(property),
778 static const msi_table spf_tables[] =
780 ADD_TABLE(ci_component),
781 ADD_TABLE(directory),
782 ADD_TABLE(rof_feature),
783 ADD_TABLE(rof_feature_comp),
784 ADD_TABLE(rof_file),
785 ADD_TABLE(spf_install_exec_seq),
786 ADD_TABLE(rof_media),
787 ADD_TABLE(property),
788 ADD_TABLE(spf_custom_action),
789 ADD_TABLE(spf_install_ui_seq),
792 static const msi_table pp_tables[] =
794 ADD_TABLE(ci_component),
795 ADD_TABLE(directory),
796 ADD_TABLE(rof_feature),
797 ADD_TABLE(rof_feature_comp),
798 ADD_TABLE(rof_file),
799 ADD_TABLE(pp_install_exec_seq),
800 ADD_TABLE(rof_media),
801 ADD_TABLE(property),
804 static const msi_table tp_tables[] =
806 ADD_TABLE(tp_component),
807 ADD_TABLE(directory),
808 ADD_TABLE(rof_feature),
809 ADD_TABLE(ci2_feature_comp),
810 ADD_TABLE(ci2_file),
811 ADD_TABLE(install_exec_seq),
812 ADD_TABLE(rof_media),
813 ADD_TABLE(property),
816 static const msi_table cwd_tables[] =
818 ADD_TABLE(cwd_component),
819 ADD_TABLE(directory),
820 ADD_TABLE(rof_feature),
821 ADD_TABLE(ci2_feature_comp),
822 ADD_TABLE(ci2_file),
823 ADD_TABLE(install_exec_seq),
824 ADD_TABLE(rof_media),
825 ADD_TABLE(property),
828 static const msi_table adm_tables[] =
830 ADD_TABLE(adm_component),
831 ADD_TABLE(directory),
832 ADD_TABLE(rof_feature),
833 ADD_TABLE(ci2_feature_comp),
834 ADD_TABLE(ci2_file),
835 ADD_TABLE(install_exec_seq),
836 ADD_TABLE(rof_media),
837 ADD_TABLE(property),
838 ADD_TABLE(adm_custom_action),
839 ADD_TABLE(adm_admin_exec_seq),
842 static const msi_table amp_tables[] =
844 ADD_TABLE(amp_component),
845 ADD_TABLE(directory),
846 ADD_TABLE(rof_feature),
847 ADD_TABLE(ci2_feature_comp),
848 ADD_TABLE(ci2_file),
849 ADD_TABLE(install_exec_seq),
850 ADD_TABLE(rof_media),
851 ADD_TABLE(property),
854 static const msi_table rem_tables[] =
856 ADD_TABLE(rem_component),
857 ADD_TABLE(directory),
858 ADD_TABLE(rof_feature),
859 ADD_TABLE(rem_feature_comp),
860 ADD_TABLE(rem_file),
861 ADD_TABLE(rem_install_exec_seq),
862 ADD_TABLE(rof_media),
863 ADD_TABLE(property),
864 ADD_TABLE(rem_remove_files),
867 static const msi_table mov_tables[] =
869 ADD_TABLE(cwd_component),
870 ADD_TABLE(directory),
871 ADD_TABLE(rof_feature),
872 ADD_TABLE(ci2_feature_comp),
873 ADD_TABLE(ci2_file),
874 ADD_TABLE(install_exec_seq),
875 ADD_TABLE(rof_media),
876 ADD_TABLE(property),
877 ADD_TABLE(mov_move_file),
880 static const msi_table mc_tables[] =
882 ADD_TABLE(mc_component),
883 ADD_TABLE(directory),
884 ADD_TABLE(cc_feature),
885 ADD_TABLE(cie_feature_comp),
886 ADD_TABLE(mc_file),
887 ADD_TABLE(install_exec_seq),
888 ADD_TABLE(mc_media),
889 ADD_TABLE(property),
890 ADD_TABLE(mc_file_hash),
893 static const msi_table df_tables[] =
895 ADD_TABLE(rof_component),
896 ADD_TABLE(df_directory),
897 ADD_TABLE(rof_feature),
898 ADD_TABLE(rof_feature_comp),
899 ADD_TABLE(rof_file),
900 ADD_TABLE(install_exec_seq),
901 ADD_TABLE(rof_media),
902 ADD_TABLE(property),
903 ADD_TABLE(df_duplicate_file),
906 static const msi_table wrv_tables[] =
908 ADD_TABLE(wrv_component),
909 ADD_TABLE(directory),
910 ADD_TABLE(rof_feature),
911 ADD_TABLE(ci2_feature_comp),
912 ADD_TABLE(ci2_file),
913 ADD_TABLE(install_exec_seq),
914 ADD_TABLE(rof_media),
915 ADD_TABLE(property),
916 ADD_TABLE(wrv_registry),
919 static const msi_table sf_tables[] =
921 ADD_TABLE(wrv_component),
922 ADD_TABLE(directory),
923 ADD_TABLE(rof_feature),
924 ADD_TABLE(ci2_feature_comp),
925 ADD_TABLE(ci2_file),
926 ADD_TABLE(install_exec_seq),
927 ADD_TABLE(rof_media),
928 ADD_TABLE(property),
931 /* cabinet definitions */
933 /* make the max size large so there is only one cab file */
934 #define MEDIA_SIZE 0x7FFFFFFF
935 #define FOLDER_THRESHOLD 900000
937 /* the FCI callbacks */
939 static void *mem_alloc(ULONG cb)
941 return HeapAlloc(GetProcessHeap(), 0, cb);
944 static void mem_free(void *memory)
946 HeapFree(GetProcessHeap(), 0, memory);
949 static BOOL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
951 sprintf(pccab->szCab, pv, pccab->iCab);
952 return TRUE;
955 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
957 return 0;
960 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
961 BOOL fContinuation, void *pv)
963 return 0;
966 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
968 HANDLE handle;
969 DWORD dwAccess = 0;
970 DWORD dwShareMode = 0;
971 DWORD dwCreateDisposition = OPEN_EXISTING;
973 dwAccess = GENERIC_READ | GENERIC_WRITE;
974 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
975 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
977 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
978 dwCreateDisposition = OPEN_EXISTING;
979 else
980 dwCreateDisposition = CREATE_NEW;
982 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
983 dwCreateDisposition, 0, NULL);
985 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
987 return (INT_PTR)handle;
990 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
992 HANDLE handle = (HANDLE)hf;
993 DWORD dwRead;
994 BOOL res;
996 res = ReadFile(handle, memory, cb, &dwRead, NULL);
997 ok(res, "Failed to ReadFile\n");
999 return dwRead;
1002 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
1004 HANDLE handle = (HANDLE)hf;
1005 DWORD dwWritten;
1006 BOOL res;
1008 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
1009 ok(res, "Failed to WriteFile\n");
1011 return dwWritten;
1014 static int fci_close(INT_PTR hf, int *err, void *pv)
1016 HANDLE handle = (HANDLE)hf;
1017 ok(CloseHandle(handle), "Failed to CloseHandle\n");
1019 return 0;
1022 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
1024 HANDLE handle = (HANDLE)hf;
1025 DWORD ret;
1027 ret = SetFilePointer(handle, dist, NULL, seektype);
1028 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
1030 return ret;
1033 static int fci_delete(char *pszFile, int *err, void *pv)
1035 BOOL ret = DeleteFileA(pszFile);
1036 ok(ret, "Failed to DeleteFile %s\n", pszFile);
1038 return 0;
1041 static void init_functionpointers(void)
1043 HMODULE hmsi = GetModuleHandleA("msi.dll");
1045 #define GET_PROC(func) \
1046 p ## func = (void*)GetProcAddress(hmsi, #func); \
1047 if(!p ## func) \
1048 trace("GetProcAddress(%s) failed\n", #func);
1050 GET_PROC(MsiQueryComponentStateA);
1051 GET_PROC(MsiSourceListEnumSourcesA);
1052 GET_PROC(MsiSourceListGetInfoA);
1054 #undef GET_PROC
1057 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
1059 CHAR buffer[0x20];
1060 UINT r;
1061 DWORD sz;
1063 sz = sizeof buffer;
1064 r = MsiRecordGetString(rec, field, buffer, &sz);
1065 return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
1068 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
1070 LPSTR tempname;
1072 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
1073 GetTempFileNameA(".", "xx", 0, tempname);
1075 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
1077 lstrcpyA(pszTempName, tempname);
1078 HeapFree(GetProcessHeap(), 0, tempname);
1079 return TRUE;
1082 HeapFree(GetProcessHeap(), 0, tempname);
1084 return FALSE;
1087 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
1088 USHORT *pattribs, int *err, void *pv)
1090 BY_HANDLE_FILE_INFORMATION finfo;
1091 FILETIME filetime;
1092 HANDLE handle;
1093 DWORD attrs;
1094 BOOL res;
1096 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
1097 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
1099 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
1101 res = GetFileInformationByHandle(handle, &finfo);
1102 ok(res, "Expected GetFileInformationByHandle to succeed\n");
1104 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
1105 FileTimeToDosDateTime(&filetime, pdate, ptime);
1107 attrs = GetFileAttributes(pszName);
1108 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
1110 return (INT_PTR)handle;
1113 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
1115 char path[MAX_PATH];
1116 char filename[MAX_PATH];
1118 lstrcpyA(path, CURR_DIR);
1119 lstrcatA(path, "\\");
1120 lstrcatA(path, file);
1122 lstrcpyA(filename, file);
1124 return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
1125 progress, get_open_info, compress);
1128 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
1130 ZeroMemory(pCabParams, sizeof(CCAB));
1132 pCabParams->cb = max_size;
1133 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
1134 pCabParams->setID = 0xbeef;
1135 pCabParams->iCab = 1;
1136 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
1137 lstrcatA(pCabParams->szCabPath, "\\");
1138 lstrcpyA(pCabParams->szCab, name);
1141 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
1143 CCAB cabParams;
1144 LPCSTR ptr;
1145 HFCI hfci;
1146 ERF erf;
1147 BOOL res;
1149 set_cab_parameters(&cabParams, name, max_size);
1151 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1152 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1153 get_temp_file, &cabParams, NULL);
1155 ok(hfci != NULL, "Failed to create an FCI context\n");
1157 ptr = files;
1158 while (*ptr)
1160 res = add_file(hfci, ptr, tcompTYPE_MSZIP);
1161 ok(res, "Failed to add file: %s\n", ptr);
1162 ptr += lstrlen(ptr) + 1;
1165 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1166 ok(res, "Failed to flush the cabinet\n");
1168 res = FCIDestroy(hfci);
1169 ok(res, "Failed to destroy the cabinet\n");
1172 static BOOL get_program_files_dir(LPSTR buf, LPSTR buf2)
1174 HKEY hkey;
1175 DWORD type, size;
1177 if (RegOpenKey(HKEY_LOCAL_MACHINE,
1178 "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
1179 return FALSE;
1181 size = MAX_PATH;
1182 if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size)) {
1183 RegCloseKey(hkey);
1184 return FALSE;
1187 size = MAX_PATH;
1188 if (RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)buf2, &size)) {
1189 RegCloseKey(hkey);
1190 return FALSE;
1193 RegCloseKey(hkey);
1194 return TRUE;
1197 static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
1199 HANDLE file;
1200 DWORD written;
1202 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1203 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
1204 WriteFile(file, data, strlen(data), &written, NULL);
1206 if (size)
1208 SetFilePointer(file, size, NULL, FILE_BEGIN);
1209 SetEndOfFile(file);
1212 CloseHandle(file);
1215 #define create_file(name, size) create_file_data(name, name, size)
1217 static void create_test_files(void)
1219 CreateDirectoryA("msitest", NULL);
1220 create_file("msitest\\one.txt", 100);
1221 CreateDirectoryA("msitest\\first", NULL);
1222 create_file("msitest\\first\\two.txt", 100);
1223 CreateDirectoryA("msitest\\second", NULL);
1224 create_file("msitest\\second\\three.txt", 100);
1226 create_file("four.txt", 100);
1227 create_file("five.txt", 100);
1228 create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
1230 create_file("msitest\\filename", 100);
1231 create_file("msitest\\service.exe", 100);
1233 DeleteFileA("four.txt");
1234 DeleteFileA("five.txt");
1237 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
1239 CHAR path[MAX_PATH];
1241 lstrcpyA(path, PROG_FILES_DIR);
1242 lstrcatA(path, "\\");
1243 lstrcatA(path, rel_path);
1245 if (is_file)
1246 return DeleteFileA(path);
1247 else
1248 return RemoveDirectoryA(path);
1251 static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
1253 CHAR path[MAX_PATH];
1255 lstrcpyA(path, COMMON_FILES_DIR);
1256 lstrcatA(path, "\\");
1257 lstrcatA(path, rel_path);
1259 if (is_file)
1260 return DeleteFileA(path);
1261 else
1262 return RemoveDirectoryA(path);
1265 static void delete_test_files(void)
1267 DeleteFileA("msitest.msi");
1268 DeleteFileA("msitest.cab");
1269 DeleteFileA("msitest\\second\\three.txt");
1270 DeleteFileA("msitest\\first\\two.txt");
1271 DeleteFileA("msitest\\one.txt");
1272 DeleteFileA("msitest\\service.exe");
1273 DeleteFileA("msitest\\filename");
1274 RemoveDirectoryA("msitest\\second");
1275 RemoveDirectoryA("msitest\\first");
1276 RemoveDirectoryA("msitest");
1279 static void write_file(const CHAR *filename, const char *data, int data_size)
1281 DWORD size;
1283 HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
1284 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
1286 WriteFile(hf, data, data_size, &size, NULL);
1287 CloseHandle(hf);
1290 static void write_msi_summary_info(MSIHANDLE db)
1292 MSIHANDLE summary;
1293 UINT r;
1295 r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
1296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1298 r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
1299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1301 r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
1302 "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
1303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1305 r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
1306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1308 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 0, NULL, NULL);
1309 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1311 r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
1312 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1314 /* write the summary changes back to the stream */
1315 r = MsiSummaryInfoPersist(summary);
1316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1318 MsiCloseHandle(summary);
1321 static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
1323 MSIHANDLE db;
1324 UINT r;
1325 int j;
1327 r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
1328 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1330 /* import the tables into the database */
1331 for (j = 0; j < num_tables; j++)
1333 const msi_table *table = &tables[j];
1335 write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
1337 r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
1338 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1340 DeleteFileA(table->filename);
1343 write_msi_summary_info(db);
1345 r = MsiDatabaseCommit(db);
1346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1348 MsiCloseHandle(db);
1351 static void check_service_is_installed(void)
1353 SC_HANDLE scm, service;
1354 BOOL res;
1356 scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
1357 ok(scm != NULL, "Failed to open the SC Manager\n");
1359 service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
1360 ok(service != NULL, "Failed to open TestService\n");
1362 res = DeleteService(service);
1363 ok(res, "Failed to delete TestService\n");
1365 CloseServiceHandle(service);
1366 CloseServiceHandle(scm);
1369 static void test_MsiInstallProduct(void)
1371 UINT r;
1372 CHAR path[MAX_PATH];
1373 LONG res;
1374 HKEY hkey;
1375 DWORD num, size, type;
1376 SC_HANDLE scm;
1378 scm = OpenSCManager(NULL, NULL, GENERIC_ALL);
1379 if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
1381 skip("Services are not implemented, we are most likely on win9x\n");
1382 return;
1384 CloseServiceHandle(scm);
1386 create_test_files();
1387 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1389 r = MsiInstallProductA(msifile, NULL);
1390 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1392 ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
1393 ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
1394 ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
1395 ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
1396 ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
1397 ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
1398 ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
1399 ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
1400 ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
1401 ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
1402 ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
1403 ok(delete_pf("msitest", FALSE), "File not installed\n");
1405 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
1406 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1408 size = MAX_PATH;
1409 type = REG_SZ;
1410 res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
1411 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1412 ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
1414 size = MAX_PATH;
1415 type = REG_SZ;
1416 res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
1417 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
1419 size = sizeof(num);
1420 type = REG_DWORD;
1421 res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
1422 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1423 ok(num == 314, "Expected 314, got %d\n", num);
1425 size = MAX_PATH;
1426 type = REG_SZ;
1427 res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
1428 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
1429 ok(!lstrcmpA(path, "OrderTestValue"), "Expected imaname, got %s\n", path);
1431 check_service_is_installed();
1433 RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
1435 delete_test_files();
1438 static void test_MsiSetComponentState(void)
1440 INSTALLSTATE installed, action;
1441 MSIHANDLE package;
1442 char path[MAX_PATH];
1443 UINT r;
1445 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1447 CoInitialize(NULL);
1449 lstrcpy(path, CURR_DIR);
1450 lstrcat(path, "\\");
1451 lstrcat(path, msifile);
1453 r = MsiOpenPackage(path, &package);
1454 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1456 r = MsiDoAction(package, "CostInitialize");
1457 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1459 r = MsiDoAction(package, "FileCost");
1460 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1462 r = MsiDoAction(package, "CostFinalize");
1463 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1465 r = MsiGetComponentState(package, "dangler", &installed, &action);
1466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1467 ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
1468 ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
1470 r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
1471 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1473 MsiCloseHandle(package);
1474 CoUninitialize();
1476 DeleteFileA(msifile);
1479 static void test_packagecoltypes(void)
1481 MSIHANDLE hdb, view, rec;
1482 char path[MAX_PATH];
1483 LPCSTR query;
1484 UINT r, count;
1486 create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
1488 CoInitialize(NULL);
1490 lstrcpy(path, CURR_DIR);
1491 lstrcat(path, "\\");
1492 lstrcat(path, msifile);
1494 r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
1495 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1497 query = "SELECT * FROM `Media`";
1498 r = MsiDatabaseOpenView( hdb, query, &view );
1499 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
1501 r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
1502 count = MsiRecordGetFieldCount( rec );
1503 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1504 ok(count == 6, "Expected 6, got %d\n", count);
1505 ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
1506 ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
1507 ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
1508 ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
1509 ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
1510 ok(check_record(rec, 6, "Source"), "wrong column label\n");
1511 MsiCloseHandle(rec);
1513 r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
1514 count = MsiRecordGetFieldCount( rec );
1515 ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
1516 ok(count == 6, "Expected 6, got %d\n", count);
1517 ok(check_record(rec, 1, "i2"), "wrong column label\n");
1518 ok(check_record(rec, 2, "i4"), "wrong column label\n");
1519 ok(check_record(rec, 3, "L64"), "wrong column label\n");
1520 ok(check_record(rec, 4, "S255"), "wrong column label\n");
1521 ok(check_record(rec, 5, "S32"), "wrong column label\n");
1522 ok(check_record(rec, 6, "S72"), "wrong column label\n");
1524 MsiCloseHandle(rec);
1525 MsiCloseHandle(view);
1526 MsiCloseHandle(hdb);
1527 DeleteFile(msifile);
1530 static void create_cc_test_files(void)
1532 CCAB cabParams;
1533 HFCI hfci;
1534 ERF erf;
1535 static CHAR cab_context[] = "test%d.cab";
1536 BOOL res;
1538 create_file("maximus", 500);
1539 create_file("augustus", 50000);
1540 create_file("caesar", 500);
1542 set_cab_parameters(&cabParams, "test1.cab", 200);
1544 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1545 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1546 get_temp_file, &cabParams, cab_context);
1547 ok(hfci != NULL, "Failed to create an FCI context\n");
1549 res = add_file(hfci, "maximus", tcompTYPE_MSZIP);
1550 ok(res, "Failed to add file maximus\n");
1552 res = add_file(hfci, "augustus", tcompTYPE_MSZIP);
1553 ok(res, "Failed to add file augustus\n");
1555 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1556 ok(res, "Failed to flush the cabinet\n");
1558 res = FCIDestroy(hfci);
1559 ok(res, "Failed to destroy the cabinet\n");
1561 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1563 DeleteFile("maximus");
1564 DeleteFile("augustus");
1565 DeleteFile("caesar");
1568 static void create_cc2_test_files(void)
1570 CCAB cabParams;
1571 HFCI hfci;
1572 ERF erf;
1573 static CHAR cab_context[] = "test%d.cab";
1574 BOOL res;
1576 create_file("maximus", 500);
1577 create_file("augustus", 50000);
1578 create_file("tiberius", 500);
1579 create_file("caesar", 500);
1581 set_cab_parameters(&cabParams, "test1.cab", 40000);
1583 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
1584 fci_read, fci_write, fci_close, fci_seek, fci_delete,
1585 get_temp_file, &cabParams, cab_context);
1586 ok(hfci != NULL, "Failed to create an FCI context\n");
1588 res = add_file(hfci, "maximus", tcompTYPE_NONE);
1589 ok(res, "Failed to add file maximus\n");
1591 res = add_file(hfci, "augustus", tcompTYPE_NONE);
1592 ok(res, "Failed to add file augustus\n");
1594 res = add_file(hfci, "tiberius", tcompTYPE_NONE);
1595 ok(res, "Failed to add file tiberius\n");
1597 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
1598 ok(res, "Failed to flush the cabinet\n");
1600 res = FCIDestroy(hfci);
1601 ok(res, "Failed to destroy the cabinet\n");
1603 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1605 DeleteFile("maximus");
1606 DeleteFile("augustus");
1607 DeleteFile("tiberius");
1608 DeleteFile("caesar");
1611 static void delete_cab_files(void)
1613 SHFILEOPSTRUCT shfl;
1614 CHAR path[MAX_PATH+10];
1616 lstrcpyA(path, CURR_DIR);
1617 lstrcatA(path, "\\*.cab");
1618 path[strlen(path) + 1] = '\0';
1620 shfl.hwnd = NULL;
1621 shfl.wFunc = FO_DELETE;
1622 shfl.pFrom = path;
1623 shfl.pTo = NULL;
1624 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
1626 SHFileOperation(&shfl);
1629 static void test_continuouscabs(void)
1631 UINT r;
1633 create_cc_test_files();
1634 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1636 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1638 r = MsiInstallProductA(msifile, NULL);
1639 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1640 todo_wine
1642 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1643 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1644 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1646 ok(delete_pf("msitest", FALSE), "File not installed\n");
1648 delete_cab_files();
1649 DeleteFile(msifile);
1651 create_cc2_test_files();
1652 create_database(msifile, cc2_tables, sizeof(cc2_tables) / sizeof(msi_table));
1654 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1656 r = MsiInstallProductA(msifile, NULL);
1657 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1658 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1659 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
1660 ok(delete_pf("msitest\\tiberius", TRUE), "File not installed\n");
1661 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1662 ok(delete_pf("msitest", FALSE), "File not installed\n");
1664 delete_cab_files();
1665 DeleteFile(msifile);
1668 static void test_caborder(void)
1670 UINT r;
1672 create_file("imperator", 100);
1673 create_file("maximus", 500);
1674 create_file("augustus", 50000);
1675 create_file("caesar", 500);
1677 create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
1679 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1681 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1682 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1683 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1685 r = MsiInstallProductA(msifile, NULL);
1686 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1687 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1688 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1689 todo_wine
1691 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1692 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1695 delete_cab_files();
1697 create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
1698 create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
1699 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1701 r = MsiInstallProductA(msifile, NULL);
1702 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1703 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1704 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1705 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1706 todo_wine
1708 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1711 delete_cab_files();
1712 DeleteFile(msifile);
1714 create_cc_test_files();
1715 create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
1717 r = MsiInstallProductA(msifile, NULL);
1718 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1719 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1720 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1721 todo_wine
1723 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1724 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1727 delete_cab_files();
1728 DeleteFile(msifile);
1730 create_cc_test_files();
1731 create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
1733 r = MsiInstallProductA(msifile, NULL);
1734 ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
1735 ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
1736 todo_wine
1738 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
1739 ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
1740 ok(!delete_pf("msitest", FALSE), "File is installed\n");
1743 delete_cab_files();
1744 DeleteFile("imperator");
1745 DeleteFile("maximus");
1746 DeleteFile("augustus");
1747 DeleteFile("caesar");
1748 DeleteFile(msifile);
1751 static void test_mixedmedia(void)
1753 UINT r;
1755 CreateDirectoryA("msitest", NULL);
1756 create_file("msitest\\maximus", 500);
1757 create_file("msitest\\augustus", 500);
1758 create_file("caesar", 500);
1760 create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
1762 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1764 create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
1766 r = MsiInstallProductA(msifile, NULL);
1767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1768 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1769 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1770 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1771 ok(delete_pf("msitest", FALSE), "File not installed\n");
1773 /* Delete the files in the temp (current) folder */
1774 DeleteFile("msitest\\maximus");
1775 DeleteFile("msitest\\augustus");
1776 RemoveDirectory("msitest");
1777 DeleteFile("caesar");
1778 DeleteFile("test1.cab");
1779 DeleteFile(msifile);
1782 static void test_samesequence(void)
1784 UINT r;
1786 create_cc_test_files();
1787 create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
1789 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1791 r = MsiInstallProductA(msifile, NULL);
1792 todo_wine
1794 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1795 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1796 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1798 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1799 ok(delete_pf("msitest", FALSE), "File not installed\n");
1801 delete_cab_files();
1802 DeleteFile(msifile);
1805 static void test_uiLevelFlags(void)
1807 UINT r;
1809 create_cc_test_files();
1810 create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
1812 MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
1814 r = MsiInstallProductA(msifile, NULL);
1815 ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
1816 todo_wine
1818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1819 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1821 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1822 ok(delete_pf("msitest", FALSE), "File not installed\n");
1824 delete_cab_files();
1825 DeleteFile(msifile);
1828 static BOOL file_matches(LPSTR path)
1830 CHAR buf[MAX_PATH];
1831 HANDLE file;
1832 DWORD size;
1834 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1835 NULL, OPEN_EXISTING, 0, NULL);
1837 ZeroMemory(buf, MAX_PATH);
1838 ReadFile(file, buf, 15, &size, NULL);
1839 CloseHandle(file);
1841 return !lstrcmp(buf, "msitest\\maximus");
1844 static void test_readonlyfile(void)
1846 UINT r;
1847 DWORD size;
1848 HANDLE file;
1849 CHAR path[MAX_PATH];
1851 CreateDirectoryA("msitest", NULL);
1852 create_file("msitest\\maximus", 500);
1853 create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
1855 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1857 lstrcpy(path, PROG_FILES_DIR);
1858 lstrcat(path, "\\msitest");
1859 CreateDirectory(path, NULL);
1861 lstrcat(path, "\\maximus");
1862 file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
1863 NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
1865 WriteFile(file, "readonlyfile", 20, &size, NULL);
1866 CloseHandle(file);
1868 r = MsiInstallProductA(msifile, NULL);
1869 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1870 ok(file_matches(path), "Expected file to be overwritten\n");
1871 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1872 ok(delete_pf("msitest", FALSE), "File not installed\n");
1874 /* Delete the files in the temp (current) folder */
1875 DeleteFile("msitest\\maximus");
1876 RemoveDirectory("msitest");
1877 DeleteFile(msifile);
1880 static void test_setdirproperty(void)
1882 UINT r;
1884 CreateDirectoryA("msitest", NULL);
1885 create_file("msitest\\maximus", 500);
1886 create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
1888 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1890 r = MsiInstallProductA(msifile, NULL);
1891 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1892 ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
1893 ok(delete_cf("msitest", FALSE), "File not installed\n");
1895 /* Delete the files in the temp (current) folder */
1896 DeleteFile(msifile);
1897 DeleteFile("msitest\\maximus");
1898 RemoveDirectory("msitest");
1901 static void test_cabisextracted(void)
1903 UINT r;
1905 CreateDirectoryA("msitest", NULL);
1906 create_file("msitest\\gaius", 500);
1907 create_file("maximus", 500);
1908 create_file("augustus", 500);
1909 create_file("caesar", 500);
1911 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
1912 create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
1913 create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
1915 create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
1917 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1919 r = MsiInstallProductA(msifile, NULL);
1920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1921 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1922 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1923 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
1924 ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
1925 ok(delete_pf("msitest", FALSE), "File not installed\n");
1927 /* Delete the files in the temp (current) folder */
1928 delete_cab_files();
1929 DeleteFile(msifile);
1930 DeleteFile("maximus");
1931 DeleteFile("augustus");
1932 DeleteFile("caesar");
1933 DeleteFile("msitest\\gaius");
1934 RemoveDirectory("msitest");
1937 static void test_concurrentinstall(void)
1939 UINT r;
1940 CHAR path[MAX_PATH];
1942 CreateDirectoryA("msitest", NULL);
1943 CreateDirectoryA("msitest\\msitest", NULL);
1944 create_file("msitest\\maximus", 500);
1945 create_file("msitest\\msitest\\augustus", 500);
1947 create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
1949 lstrcpyA(path, CURR_DIR);
1950 lstrcatA(path, "\\msitest\\concurrent.msi");
1951 create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
1953 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1955 r = MsiInstallProductA(msifile, NULL);
1956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1957 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1958 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
1959 ok(delete_pf("msitest", FALSE), "File not installed\n");
1961 DeleteFile(path);
1963 r = MsiInstallProductA(msifile, NULL);
1964 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1965 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
1966 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
1967 ok(delete_pf("msitest", FALSE), "File not installed\n");
1969 DeleteFile(msifile);
1970 DeleteFile("msitest\\msitest\\augustus");
1971 DeleteFile("msitest\\maximus");
1972 RemoveDirectory("msitest\\msitest");
1973 RemoveDirectory("msitest");
1976 static void test_setpropertyfolder(void)
1978 UINT r;
1980 CreateDirectoryA("msitest", NULL);
1981 create_file("msitest\\maximus", 500);
1983 create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
1985 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
1987 r = MsiInstallProductA(msifile, NULL);
1988 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
1989 ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
1990 ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
1991 ok(delete_pf("msitest", FALSE), "File not installed\n");
1993 /* Delete the files in the temp (current) folder */
1994 DeleteFile(msifile);
1995 DeleteFile("msitest\\maximus");
1996 RemoveDirectory("msitest");
1999 static BOOL file_exists(LPCSTR file)
2001 return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
2004 static BOOL pf_exists(LPCSTR file)
2006 CHAR path[MAX_PATH];
2008 lstrcpyA(path, PROG_FILES_DIR);
2009 lstrcatA(path, "\\");
2010 lstrcatA(path, file);
2012 return file_exists(path);
2015 static void delete_pfmsitest_files(void)
2017 SHFILEOPSTRUCT shfl;
2018 CHAR path[MAX_PATH+11];
2020 lstrcpyA(path, PROG_FILES_DIR);
2021 lstrcatA(path, "\\msitest\\*");
2022 path[strlen(path) + 1] = '\0';
2024 shfl.hwnd = NULL;
2025 shfl.wFunc = FO_DELETE;
2026 shfl.pFrom = path;
2027 shfl.pTo = NULL;
2028 shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
2030 SHFileOperation(&shfl);
2032 lstrcpyA(path, PROG_FILES_DIR);
2033 lstrcatA(path, "\\msitest");
2034 RemoveDirectoryA(path);
2037 static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
2039 char val[MAX_PATH];
2040 DWORD size, type;
2041 LONG res;
2043 size = MAX_PATH;
2044 val[0] = '\0';
2045 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
2047 if (res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ))
2049 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
2050 return;
2053 if (!expected)
2054 ok_(__FILE__, line)(lstrlenA(val) == 0, "Expected empty string, got %s\n", val);
2055 else
2057 if (bcase)
2058 ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
2059 else
2060 ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
2064 static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD line)
2066 DWORD val, size, type;
2067 LONG res;
2069 size = sizeof(DWORD);
2070 res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
2072 if (res != ERROR_SUCCESS || type != REG_DWORD)
2074 ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
2075 return;
2078 ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
2081 #define CHECK_REG_STR(prodkey, name, expected) \
2082 check_reg_str(prodkey, name, expected, TRUE, __LINE__);
2084 #define CHECK_REG_ISTR(prodkey, name, expected) \
2085 check_reg_str(prodkey, name, expected, FALSE, __LINE__);
2087 #define CHECK_REG_DWORD(prodkey, name, expected) \
2088 check_reg_dword(prodkey, name, expected, __LINE__);
2090 static void get_date_str(LPSTR date)
2092 SYSTEMTIME systime;
2094 static const char date_fmt[] = "%d%02d%02d";
2095 GetLocalTime(&systime);
2096 sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
2099 static void test_publish_registerproduct(void)
2101 UINT r;
2102 LONG res;
2103 HKEY uninstall, prodkey;
2104 INSTALLSTATE state;
2105 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2106 char date[MAX_PATH];
2107 char temp[MAX_PATH];
2109 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2111 if (!pMsiQueryComponentStateA)
2113 skip("MsiQueryComponentStateA is not available\n");
2114 return;
2117 get_date_str(date);
2118 GetTempPath(MAX_PATH, temp);
2120 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2121 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2123 CreateDirectoryA("msitest", NULL);
2124 create_file("msitest\\maximus", 500);
2126 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2128 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2130 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2131 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2133 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2134 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2136 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2137 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2139 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2140 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2141 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2142 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2144 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2145 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2147 /* RegisterProduct */
2148 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
2149 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2150 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2151 ok(pf_exists("msitest"), "File not installed\n");
2153 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2154 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2156 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2157 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2159 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2160 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2162 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2163 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2164 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2165 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2167 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2168 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2170 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2171 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2172 CHECK_REG_STR(prodkey, "InstallDate", date);
2173 CHECK_REG_STR(prodkey, "InstallSource", temp);
2174 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2175 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2176 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2177 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2178 CHECK_REG_STR(prodkey, "Comments", NULL);
2179 CHECK_REG_STR(prodkey, "Contact", NULL);
2180 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2181 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2182 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2183 CHECK_REG_STR(prodkey, "Readme", NULL);
2184 CHECK_REG_STR(prodkey, "Size", NULL);
2185 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2186 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2187 CHECK_REG_DWORD(prodkey, "Language", 1033);
2188 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2189 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2190 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2191 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2192 todo_wine
2194 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2197 RegCloseKey(prodkey);
2199 /* try to uninstall after RegisterProduct */
2200 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2201 todo_wine
2203 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2205 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2206 ok(pf_exists("msitest"), "File deleted\n");
2208 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2209 todo_wine
2211 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2214 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2215 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2217 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2218 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2220 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2221 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2222 todo_wine
2224 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2226 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2228 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2229 todo_wine
2231 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2234 todo_wine
2236 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2237 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2238 CHECK_REG_STR(prodkey, "InstallDate", date);
2239 CHECK_REG_STR(prodkey, "InstallSource", temp);
2240 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2241 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2242 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2243 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2244 CHECK_REG_STR(prodkey, "Comments", NULL);
2245 CHECK_REG_STR(prodkey, "Contact", NULL);
2246 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2247 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2248 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2249 CHECK_REG_STR(prodkey, "Readme", NULL);
2250 CHECK_REG_STR(prodkey, "Size", NULL);
2251 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2252 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2253 CHECK_REG_DWORD(prodkey, "Language", 1033);
2254 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2255 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2256 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2257 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2258 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2261 RegCloseKey(prodkey);
2263 /* full install to remove */
2264 r = MsiInstallProductA(msifile, "FULL=1");
2265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2266 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2267 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2269 RegCloseKey(uninstall);
2270 DeleteFile(msifile);
2271 DeleteFile("msitest\\maximus");
2272 RemoveDirectory("msitest");
2273 delete_pfmsitest_files();
2276 static void test_publish_publishproduct(void)
2278 UINT r;
2279 LONG res;
2280 HKEY uninstall, prodkey;
2281 INSTALLSTATE state;
2282 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2284 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2286 if (!pMsiQueryComponentStateA)
2288 skip("MsiQueryComponentStateA is not available\n");
2289 return;
2292 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2293 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2295 CreateDirectoryA("msitest", NULL);
2296 create_file("msitest\\maximus", 500);
2298 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2300 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2302 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2303 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2305 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2306 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2308 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2309 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2311 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2312 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2313 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2314 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2316 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2317 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2319 /* PublishProduct */
2320 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
2321 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2322 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2323 ok(pf_exists("msitest"), "File not installed\n");
2325 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2326 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2328 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2329 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2331 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2332 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2334 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2335 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2336 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2337 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2339 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2340 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2342 /* try to uninstall after PublishProduct */
2343 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2345 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2346 ok(pf_exists("msitest"), "File deleted\n");
2348 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2349 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2351 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2352 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2354 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2355 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2357 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2358 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2359 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2360 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2362 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2363 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2365 /* full install to remove */
2366 r = MsiInstallProductA(msifile, "FULL=1");
2367 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2368 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2369 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2371 RegCloseKey(uninstall);
2372 DeleteFile(msifile);
2373 DeleteFile("msitest\\maximus");
2374 RemoveDirectory("msitest");
2375 delete_pfmsitest_files();
2378 static void test_publish_publishfeatures(void)
2380 UINT r;
2381 LONG res;
2382 HKEY uninstall, prodkey;
2383 INSTALLSTATE state;
2384 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2386 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2388 if (!pMsiQueryComponentStateA)
2390 skip("MsiQueryComponentStateA is not available\n");
2391 return;
2394 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2395 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2397 CreateDirectoryA("msitest", NULL);
2398 create_file("msitest\\maximus", 500);
2400 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2402 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2404 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2405 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2407 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2408 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2410 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2411 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2413 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2414 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2415 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2416 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2418 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2419 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2421 /* PublishFeatures */
2422 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
2423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2424 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2425 ok(pf_exists("msitest"), "File not installed\n");
2427 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2428 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2430 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2431 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2433 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2434 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2436 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2437 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2438 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2439 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2441 /* try to uninstall after PublishFeatures */
2442 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2443 todo_wine
2445 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2447 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2448 ok(pf_exists("msitest"), "File deleted\n");
2450 /* PublishFeatures and PublishProduct */
2451 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 PUBLISH_FEATURES=1");
2452 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2453 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2454 ok(pf_exists("msitest"), "File not installed\n");
2456 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2457 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2459 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2460 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2462 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2463 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2465 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2466 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2467 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2468 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2470 /* PublishFeatures and RegisterProduct */
2471 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_FEATURES=1");
2472 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2473 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2474 ok(pf_exists("msitest"), "File not installed\n");
2476 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2477 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2479 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2480 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2482 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2483 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2485 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2486 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2487 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2488 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2490 /* full install to remove */
2491 r = MsiInstallProductA(msifile, "FULL=1");
2492 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2493 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2496 RegCloseKey(uninstall);
2497 DeleteFile(msifile);
2498 DeleteFile("msitest\\maximus");
2499 RemoveDirectory("msitest");
2500 delete_pfmsitest_files();
2503 static void test_publish_registeruser(void)
2505 UINT r;
2506 LONG res;
2507 HKEY uninstall, prodkey;
2508 INSTALLSTATE state;
2509 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2511 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2513 if (!pMsiQueryComponentStateA)
2515 skip("MsiQueryComponentStateA is not available\n");
2516 return;
2519 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2520 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2522 CreateDirectoryA("msitest", NULL);
2523 create_file("msitest\\maximus", 500);
2525 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2527 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2529 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2530 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2532 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2533 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2535 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2536 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2538 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2539 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2540 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2541 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2543 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2544 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2546 /* RegisterUser */
2547 r = MsiInstallProductA(msifile, "REGISTER_USER=1");
2548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2549 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2550 ok(pf_exists("msitest"), "File not installed\n");
2552 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2553 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2555 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2556 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2558 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2559 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2561 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2562 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2563 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2564 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2566 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2567 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2569 /* try to uninstall after RegisterUser */
2570 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2571 todo_wine
2573 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2575 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2576 ok(pf_exists("msitest"), "File deleted\n");
2578 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2579 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2581 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2582 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2584 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2585 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2587 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2588 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2589 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2590 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2592 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2593 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2595 /* full install to remove */
2596 r = MsiInstallProductA(msifile, "FULL=1");
2597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2598 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2599 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2601 RegCloseKey(uninstall);
2602 DeleteFile(msifile);
2603 DeleteFile("msitest\\maximus");
2604 RemoveDirectory("msitest");
2605 delete_pfmsitest_files();
2608 static void get_user_sid(LPSTR *usersid)
2610 HANDLE token;
2611 BYTE buf[1024];
2612 DWORD size;
2613 PTOKEN_USER user;
2614 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
2615 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
2617 *usersid = NULL;
2618 pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA");
2619 if (!pConvertSidToStringSidA)
2620 return;
2622 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
2623 size = sizeof(buf);
2624 GetTokenInformation(token, TokenUser, (void *)buf, size, &size);
2625 user = (PTOKEN_USER)buf;
2626 pConvertSidToStringSidA(user->User.Sid, usersid);
2629 static void test_publish_processcomponents(void)
2631 UINT r;
2632 LONG res;
2633 HKEY uninstall, prodkey, comp;
2634 INSTALLSTATE state;
2635 LPSTR usersid;
2636 CHAR keypath[MAX_PATH];
2637 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2639 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2641 if (!pMsiQueryComponentStateA)
2643 skip("MsiQueryComponentStateA is not available\n");
2644 return;
2647 get_user_sid(&usersid);
2648 if (!usersid)
2650 skip("ConvertSidToStringSidA is not available\n");
2651 return;
2654 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2655 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2657 CreateDirectoryA("msitest", NULL);
2658 create_file("msitest\\maximus", 500);
2660 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2662 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2664 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2665 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2667 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2668 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2670 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2671 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2673 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2674 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2675 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2676 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2678 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2679 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2681 /* ProcessComponent */
2682 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
2683 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2684 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2685 ok(pf_exists("msitest"), "File not installed\n");
2687 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2688 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2690 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2691 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2693 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2694 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2695 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2696 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2698 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2699 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2701 /* try to uninstall after ProcessComponents */
2702 r = MsiInstallProductA(msifile, "REMOVE=ALL");
2703 todo_wine
2705 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2707 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2708 ok(pf_exists("msitest"), "File deleted\n");
2710 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2711 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2713 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2714 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2716 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2717 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2719 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2720 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2721 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2722 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2724 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2725 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2727 /* ProcessComponent with PublishProduct */
2728 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
2729 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2730 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2731 ok(pf_exists("msitest"), "File not installed\n");
2733 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2734 ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
2736 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2737 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2739 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2740 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2742 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2743 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2744 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2745 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2747 /* uninstall */
2748 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2749 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2751 /* ProcessComponent with RegisterProduct */
2752 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PROCESS_COMPONENTS=1");
2753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2754 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2755 ok(pf_exists("msitest"), "File not installed\n");
2757 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2758 ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
2760 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2761 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2763 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2764 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2766 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2767 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2768 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2769 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2771 /* ProcessComponent with RegisterProduct and PublishProduct */
2772 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
2773 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2774 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2775 ok(pf_exists("msitest"), "File not installed\n");
2777 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2778 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2780 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2781 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2783 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2784 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2786 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2787 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2788 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2789 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2791 /* uninstall */
2792 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2793 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2795 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
2796 lstrcatA(keypath, usersid);
2797 lstrcatA(keypath, "\\Components\\CBABC2FDCCB35E749A8944D8C1C098B5");
2799 /* native has trouble removing the comp key unless it's a full install */
2800 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &comp);
2801 if (res == ERROR_SUCCESS)
2803 RegDeleteKeyA(comp, "");
2804 RegCloseKey(comp);
2807 RegCloseKey(uninstall);
2808 DeleteFile(msifile);
2809 DeleteFile("msitest\\maximus");
2810 RemoveDirectory("msitest");
2811 delete_pfmsitest_files();
2814 static void test_publish(void)
2816 UINT r;
2817 LONG res;
2818 HKEY uninstall, prodkey;
2819 INSTALLSTATE state;
2820 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
2821 char date[MAX_PATH];
2822 char temp[MAX_PATH];
2824 static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
2826 if (!pMsiQueryComponentStateA)
2828 skip("MsiQueryComponentStateA is not available\n");
2829 return;
2832 get_date_str(date);
2833 GetTempPath(MAX_PATH, temp);
2835 res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
2836 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2838 CreateDirectoryA("msitest", NULL);
2839 create_file("msitest\\maximus", 500);
2841 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
2843 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
2845 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2846 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2848 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2849 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2851 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2852 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2854 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2855 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2856 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2857 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2859 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2860 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2862 /* nothing published */
2863 r = MsiInstallProductA(msifile, NULL);
2864 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2865 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2866 ok(pf_exists("msitest"), "File not installed\n");
2868 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2869 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2871 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2872 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2874 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2875 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2877 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2878 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2879 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2880 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2882 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2883 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2885 /* PublishProduct and RegisterProduct */
2886 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
2887 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2888 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2889 ok(pf_exists("msitest"), "File not installed\n");
2891 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2892 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2894 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2895 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2897 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2898 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2900 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2901 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2902 ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
2903 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2905 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2906 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2908 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2909 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2910 CHECK_REG_STR(prodkey, "InstallDate", date);
2911 CHECK_REG_STR(prodkey, "InstallSource", temp);
2912 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2913 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2914 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2915 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2916 CHECK_REG_STR(prodkey, "Comments", NULL);
2917 CHECK_REG_STR(prodkey, "Contact", NULL);
2918 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2919 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2920 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2921 CHECK_REG_STR(prodkey, "Readme", NULL);
2922 CHECK_REG_STR(prodkey, "Size", NULL);
2923 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2924 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2925 CHECK_REG_DWORD(prodkey, "Language", 1033);
2926 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
2927 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
2928 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
2929 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
2930 todo_wine
2932 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
2935 RegCloseKey(prodkey);
2937 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
2938 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2939 ok(pf_exists("msitest\\maximus"), "File deleted\n");
2940 ok(pf_exists("msitest"), "File deleted\n");
2942 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2943 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2945 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2946 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2948 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2949 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2951 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2952 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2953 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
2954 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
2956 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2957 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
2959 /* complete install */
2960 r = MsiInstallProductA(msifile, "FULL=1");
2961 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2962 ok(pf_exists("msitest\\maximus"), "File not installed\n");
2963 ok(pf_exists("msitest"), "File not installed\n");
2965 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2966 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
2968 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
2969 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2971 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
2972 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2974 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
2975 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
2976 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2977 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
2979 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
2980 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
2982 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
2983 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
2984 CHECK_REG_STR(prodkey, "InstallDate", date);
2985 CHECK_REG_STR(prodkey, "InstallSource", temp);
2986 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2987 CHECK_REG_STR(prodkey, "Publisher", "Wine");
2988 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
2989 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
2990 CHECK_REG_STR(prodkey, "Comments", NULL);
2991 CHECK_REG_STR(prodkey, "Contact", NULL);
2992 CHECK_REG_STR(prodkey, "HelpLink", NULL);
2993 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
2994 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
2995 CHECK_REG_STR(prodkey, "Readme", NULL);
2996 CHECK_REG_STR(prodkey, "Size", NULL);
2997 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
2998 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
2999 CHECK_REG_DWORD(prodkey, "Language", 1033);
3000 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
3001 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
3002 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
3003 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3004 todo_wine
3006 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
3009 RegCloseKey(prodkey);
3011 /* no UnpublishFeatures */
3012 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3013 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3014 todo_wine
3016 ok(!pf_exists("msitest\\maximus"), "File deleted\n");
3017 ok(!pf_exists("msitest"), "File deleted\n");
3020 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3021 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3023 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3024 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3026 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3027 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3029 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3030 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3031 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3032 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3034 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3035 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3037 /* complete install */
3038 r = MsiInstallProductA(msifile, "FULL=1");
3039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3040 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3041 ok(pf_exists("msitest"), "File not installed\n");
3043 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3044 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
3046 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3047 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3049 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3050 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3052 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3053 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3054 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3055 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3057 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3058 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3060 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
3061 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
3062 CHECK_REG_STR(prodkey, "InstallDate", date);
3063 CHECK_REG_STR(prodkey, "InstallSource", temp);
3064 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3065 CHECK_REG_STR(prodkey, "Publisher", "Wine");
3066 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3067 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
3068 CHECK_REG_STR(prodkey, "Comments", NULL);
3069 CHECK_REG_STR(prodkey, "Contact", NULL);
3070 CHECK_REG_STR(prodkey, "HelpLink", NULL);
3071 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
3072 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
3073 CHECK_REG_STR(prodkey, "Readme", NULL);
3074 CHECK_REG_STR(prodkey, "Size", NULL);
3075 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
3076 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
3077 CHECK_REG_DWORD(prodkey, "Language", 1033);
3078 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
3079 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
3080 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
3081 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3082 todo_wine
3084 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
3087 RegCloseKey(prodkey);
3089 /* UnpublishFeatures, only feature removed. Only works when entire product is removed */
3090 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
3091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3092 ok(pf_exists("msitest\\maximus"), "File deleted\n");
3093 ok(pf_exists("msitest"), "File deleted\n");
3095 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3096 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
3098 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3099 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3101 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3102 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3104 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3105 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3106 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3107 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3109 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3110 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3112 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
3113 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
3114 CHECK_REG_STR(prodkey, "InstallDate", date);
3115 CHECK_REG_STR(prodkey, "InstallSource", temp);
3116 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3117 CHECK_REG_STR(prodkey, "Publisher", "Wine");
3118 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3119 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
3120 CHECK_REG_STR(prodkey, "Comments", NULL);
3121 CHECK_REG_STR(prodkey, "Contact", NULL);
3122 CHECK_REG_STR(prodkey, "HelpLink", NULL);
3123 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
3124 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
3125 CHECK_REG_STR(prodkey, "Readme", NULL);
3126 CHECK_REG_STR(prodkey, "Size", NULL);
3127 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
3128 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
3129 CHECK_REG_DWORD(prodkey, "Language", 1033);
3130 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
3131 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
3132 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
3133 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3134 todo_wine
3136 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
3139 RegCloseKey(prodkey);
3141 /* complete install */
3142 r = MsiInstallProductA(msifile, "FULL=1");
3143 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3144 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3145 ok(pf_exists("msitest"), "File not installed\n");
3147 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3148 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
3150 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3151 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3153 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3154 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3156 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3157 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3158 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3159 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3161 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3162 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3164 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
3165 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
3166 CHECK_REG_STR(prodkey, "InstallDate", date);
3167 CHECK_REG_STR(prodkey, "InstallSource", temp);
3168 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3169 CHECK_REG_STR(prodkey, "Publisher", "Wine");
3170 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3171 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
3172 CHECK_REG_STR(prodkey, "Comments", NULL);
3173 CHECK_REG_STR(prodkey, "Contact", NULL);
3174 CHECK_REG_STR(prodkey, "HelpLink", NULL);
3175 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
3176 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
3177 CHECK_REG_STR(prodkey, "Readme", NULL);
3178 CHECK_REG_STR(prodkey, "Size", NULL);
3179 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
3180 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
3181 CHECK_REG_DWORD(prodkey, "Language", 1033);
3182 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
3183 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
3184 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
3185 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3186 todo_wine
3188 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
3191 RegCloseKey(prodkey);
3193 /* UnpublishFeatures, both features removed */
3194 r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
3195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3196 todo_wine
3198 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
3199 ok(!pf_exists("msitest"), "File not deleted\n");
3202 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3203 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3205 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3206 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3208 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3209 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3211 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3212 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3213 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3214 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3216 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3217 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3219 /* complete install */
3220 r = MsiInstallProductA(msifile, "FULL=1");
3221 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3222 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3223 ok(pf_exists("msitest"), "File not installed\n");
3225 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3226 ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
3228 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3229 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3231 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3232 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3234 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3235 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3237 ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
3239 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3240 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3242 CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
3243 CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
3244 CHECK_REG_STR(prodkey, "InstallDate", date);
3245 CHECK_REG_STR(prodkey, "InstallSource", temp);
3246 CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3247 CHECK_REG_STR(prodkey, "Publisher", "Wine");
3248 CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3249 CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
3250 CHECK_REG_STR(prodkey, "Comments", NULL);
3251 CHECK_REG_STR(prodkey, "Contact", NULL);
3252 CHECK_REG_STR(prodkey, "HelpLink", NULL);
3253 CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
3254 CHECK_REG_STR(prodkey, "InstallLocation", NULL);
3255 CHECK_REG_STR(prodkey, "Readme", NULL);
3256 CHECK_REG_STR(prodkey, "Size", NULL);
3257 CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
3258 CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
3259 CHECK_REG_DWORD(prodkey, "Language", 1033);
3260 CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
3261 CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
3262 CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
3263 CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
3264 todo_wine
3266 CHECK_REG_DWORD(prodkey, "EstimatedSize", 12);
3269 RegCloseKey(prodkey);
3271 /* complete uninstall */
3272 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
3273 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3274 todo_wine
3276 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
3277 ok(!pf_exists("msitest"), "File not deleted\n");
3280 state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
3281 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3283 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
3284 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3286 state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
3287 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3289 r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3290 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
3291 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3292 ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
3294 res = RegOpenKeyA(uninstall, prodcode, &prodkey);
3295 ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3297 /* make sure 'Program Files\msitest' is removed */
3298 delete_pfmsitest_files();
3300 RegCloseKey(uninstall);
3301 DeleteFile(msifile);
3302 DeleteFile("msitest\\maximus");
3303 RemoveDirectory("msitest");
3306 static void test_publishsourcelist(void)
3308 UINT r;
3309 DWORD size;
3310 CHAR value[MAX_PATH];
3311 CHAR path[MAX_PATH];
3312 CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
3314 if (!pMsiSourceListEnumSourcesA || !pMsiSourceListGetInfoA)
3316 skip("MsiSourceListEnumSourcesA and/or MsiSourceListGetInfoA are not available\n");
3317 return;
3320 CreateDirectoryA("msitest", NULL);
3321 create_file("msitest\\maximus", 500);
3323 create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
3325 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3327 r = MsiInstallProductA(msifile, NULL);
3328 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3329 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3330 ok(pf_exists("msitest"), "File not installed\n");
3332 /* nothing published */
3333 size = 0xdeadbeef;
3334 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3335 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
3336 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3337 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3339 size = 0xdeadbeef;
3340 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3341 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
3342 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3343 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3345 r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
3346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3347 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3348 ok(pf_exists("msitest"), "File not installed\n");
3350 /* after RegisterProduct */
3351 size = 0xdeadbeef;
3352 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3353 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
3354 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3355 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3357 size = 0xdeadbeef;
3358 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3359 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
3360 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3361 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3363 r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
3364 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3365 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3366 ok(pf_exists("msitest"), "File not installed\n");
3368 /* after ProcessComponents */
3369 size = 0xdeadbeef;
3370 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3371 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
3372 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3373 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3375 size = 0xdeadbeef;
3376 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3377 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
3378 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3379 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3381 r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
3382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3383 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3384 ok(pf_exists("msitest"), "File not installed\n");
3386 /* after PublishFeatures */
3387 size = 0xdeadbeef;
3388 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3389 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, NULL, &size);
3390 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3391 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3393 size = 0xdeadbeef;
3394 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3395 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, &size);
3396 ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
3397 ok(size == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", size);
3399 r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
3400 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3401 ok(pf_exists("msitest\\maximus"), "File not installed\n");
3402 ok(pf_exists("msitest"), "File not installed\n");
3404 /* after PublishProduct */
3405 size = MAX_PATH;
3406 lstrcpyA(value, "aaa");
3407 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3408 MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
3409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3410 ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
3411 ok(size == 11, "Expected 11, got %d\n", size);
3413 size = MAX_PATH;
3414 lstrcpyA(value, "aaa");
3415 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3416 MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH, value, &size);
3417 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3418 ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
3419 ok(size == 0, "Expected 0, got %d\n", size);
3421 size = MAX_PATH;
3422 lstrcpyA(value, "aaa");
3423 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3424 MSICODE_PRODUCT, INSTALLPROPERTY_DISKPROMPT, value, &size);
3425 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3426 ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
3427 ok(size == 0, "Expected 0, got %d\n", size);
3429 lstrcpyA(path, CURR_DIR);
3430 lstrcatA(path, "\\");
3432 size = MAX_PATH;
3433 lstrcpyA(value, "aaa");
3434 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3435 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
3436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3437 ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
3438 ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
3440 size = MAX_PATH;
3441 lstrcpyA(value, "aaa");
3442 r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3443 MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDTYPE, value, &size);
3444 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3445 ok(!lstrcmpA(value, "n"), "Expected \"n\", got \"%s\"\n", value);
3446 ok(size == 1, "Expected 1, got %d\n", size);
3448 size = MAX_PATH;
3449 lstrcpyA(value, "aaa");
3450 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3451 MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
3452 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3453 ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
3454 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
3456 size = MAX_PATH;
3457 lstrcpyA(value, "aaa");
3458 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3459 MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 0, value, &size);
3460 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3461 ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
3462 ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
3464 size = MAX_PATH;
3465 lstrcpyA(value, "aaa");
3466 r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
3467 MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 1, value, &size);
3468 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
3469 ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
3470 ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
3472 /* complete uninstall */
3473 r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
3474 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3475 todo_wine
3477 ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
3478 ok(!pf_exists("msitest"), "File not deleted\n");
3481 /* make sure 'Program Files\msitest' is removed */
3482 delete_pfmsitest_files();
3484 DeleteFile(msifile);
3485 DeleteFile("msitest\\maximus");
3486 RemoveDirectory("msitest");
3489 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
3491 MSIHANDLE hview = 0;
3492 UINT r;
3494 r = MsiDatabaseOpenView(hdb, query, &hview);
3495 if(r != ERROR_SUCCESS)
3496 return r;
3498 r = MsiViewExecute(hview, hrec);
3499 if(r == ERROR_SUCCESS)
3500 r = MsiViewClose(hview);
3501 MsiCloseHandle(hview);
3502 return r;
3505 static void set_transform_summary_info(void)
3507 UINT r;
3508 MSIHANDLE suminfo = 0;
3510 /* build summmary info */
3511 r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
3512 todo_wine
3514 ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
3517 r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
3518 todo_wine
3520 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3523 r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
3524 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
3525 "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
3526 "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
3527 todo_wine
3529 ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
3532 r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
3533 todo_wine
3535 ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
3538 r = MsiSummaryInfoPersist(suminfo);
3539 todo_wine
3541 ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
3544 r = MsiCloseHandle(suminfo);
3545 ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
3548 static void generate_transform(void)
3550 MSIHANDLE hdb1, hdb2;
3551 LPCSTR query;
3552 UINT r;
3554 /* start with two identical databases */
3555 CopyFile(msifile, msifile2, FALSE);
3557 r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
3558 ok(r == ERROR_SUCCESS , "Failed to create database\n");
3560 r = MsiDatabaseCommit(hdb1);
3561 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
3563 r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
3564 ok(r == ERROR_SUCCESS , "Failed to create database\n");
3566 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
3567 r = run_query(hdb1, 0, query);
3568 ok(r == ERROR_SUCCESS, "failed to add property\n");
3570 /* database needs to be committed */
3571 MsiDatabaseCommit(hdb1);
3573 r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
3574 ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
3576 #if 0 /* not implemented in wine yet */
3577 r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
3578 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3579 #endif
3581 MsiCloseHandle(hdb1);
3582 MsiCloseHandle(hdb2);
3585 /* data for generating a transform */
3587 /* tables transform names - encoded as they would be in an msi database file */
3588 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
3589 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
3590 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
3592 /* data in each table */
3593 static const char data1[] = /* _StringData */
3594 "propval"; /* all the strings squashed together */
3596 static const WCHAR data2[] = { /* _StringPool */
3597 /* len, refs */
3598 0, 0, /* string 0 '' */
3599 4, 1, /* string 1 'prop' */
3600 3, 1, /* string 2 'val' */
3603 static const WCHAR data3[] = { /* Property */
3604 0x0201, 0x0001, 0x0002,
3607 static const struct {
3608 LPCWSTR name;
3609 const void *data;
3610 DWORD size;
3611 } table_transform_data[] =
3613 { name1, data1, sizeof data1 - 1 },
3614 { name2, data2, sizeof data2 },
3615 { name3, data3, sizeof data3 },
3618 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
3620 static void generate_transform_manual(void)
3622 IStorage *stg = NULL;
3623 IStream *stm;
3624 WCHAR name[0x20];
3625 HRESULT r;
3626 DWORD i, count;
3627 const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
3629 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
3631 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
3633 r = StgCreateDocfile(name, mode, 0, &stg);
3634 ok(r == S_OK, "failed to create storage\n");
3635 if (!stg)
3636 return;
3638 r = IStorage_SetClass(stg, &CLSID_MsiTransform);
3639 ok(r == S_OK, "failed to set storage type\n");
3641 for (i=0; i<NUM_TRANSFORM_TABLES; i++)
3643 r = IStorage_CreateStream(stg, table_transform_data[i].name,
3644 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3645 if (FAILED(r))
3647 ok(0, "failed to create stream %08x\n", r);
3648 continue;
3651 r = IStream_Write(stm, table_transform_data[i].data,
3652 table_transform_data[i].size, &count);
3653 if (FAILED(r) || count != table_transform_data[i].size)
3654 ok(0, "failed to write stream\n");
3655 IStream_Release(stm);
3658 IStorage_Release(stg);
3660 set_transform_summary_info();
3663 static void test_transformprop(void)
3665 UINT r;
3667 CreateDirectoryA("msitest", NULL);
3668 create_file("msitest\\augustus", 500);
3670 create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
3672 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3674 r = MsiInstallProductA(msifile, NULL);
3675 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3676 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3677 ok(!delete_pf("msitest", FALSE), "File installed\n");
3679 if (0)
3680 generate_transform();
3681 else
3682 generate_transform_manual();
3684 r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
3685 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3686 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3687 ok(delete_pf("msitest", FALSE), "File not installed\n");
3689 /* Delete the files in the temp (current) folder */
3690 DeleteFile(msifile);
3691 DeleteFile(msifile2);
3692 DeleteFile(mstfile);
3693 DeleteFile("msitest\\augustus");
3694 RemoveDirectory("msitest");
3697 static void test_currentworkingdir(void)
3699 UINT r;
3700 CHAR path[MAX_PATH];
3701 LPSTR ptr, ptr2;
3703 CreateDirectoryA("msitest", NULL);
3704 create_file("msitest\\augustus", 500);
3706 create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
3708 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3710 CreateDirectoryA("diffdir", NULL);
3711 SetCurrentDirectoryA("diffdir");
3713 sprintf(path, "..\\%s", msifile);
3714 r = MsiInstallProductA(path, NULL);
3715 todo_wine
3717 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
3718 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3719 ok(!delete_pf("msitest", FALSE), "File installed\n");
3722 sprintf(path, "%s\\%s", CURR_DIR, msifile);
3723 r = MsiInstallProductA(path, NULL);
3724 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3725 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3726 ok(delete_pf("msitest", FALSE), "File not installed\n");
3728 lstrcpyA(path, CURR_DIR);
3729 if (path[lstrlenA(path) - 1] != '\\')
3730 lstrcatA(path, "\\");
3731 lstrcatA(path, "msitest.msi");
3733 ptr2 = strrchr(path, '\\');
3734 *ptr2 = '\0';
3735 ptr = strrchr(path, '\\');
3736 *ptr2 = '\\';
3737 *(ptr++) = '\0';
3739 SetCurrentDirectoryA(path);
3741 r = MsiInstallProductA(ptr, NULL);
3742 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3743 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3744 ok(delete_pf("msitest", FALSE), "File not installed\n");
3746 SetCurrentDirectoryA(CURR_DIR);
3748 DeleteFile(msifile);
3749 DeleteFile("msitest\\augustus");
3750 RemoveDirectory("msitest");
3751 RemoveDirectory("diffdir");
3754 static void set_admin_summary_info(const CHAR *name)
3756 MSIHANDLE db, summary;
3757 UINT r;
3759 r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
3760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3762 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
3763 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3765 r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
3766 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3768 /* write the summary changes back to the stream */
3769 r = MsiSummaryInfoPersist(summary);
3770 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3772 MsiCloseHandle(summary);
3774 r = MsiDatabaseCommit(db);
3775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3777 MsiCloseHandle(db);
3780 static void test_admin(void)
3782 UINT r;
3784 CreateDirectoryA("msitest", NULL);
3785 create_file("msitest\\augustus", 500);
3787 create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
3788 set_admin_summary_info(msifile);
3790 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3792 r = MsiInstallProductA(msifile, NULL);
3793 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3794 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3795 ok(!delete_pf("msitest", FALSE), "File installed\n");
3796 ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
3797 ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
3799 r = MsiInstallProductA(msifile, "ACTION=ADMIN");
3800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3801 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3802 ok(!delete_pf("msitest", FALSE), "File installed\n");
3803 todo_wine
3805 ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
3806 ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
3809 DeleteFile(msifile);
3810 DeleteFile("msitest\\augustus");
3811 RemoveDirectory("msitest");
3814 static void set_admin_property_stream(LPCSTR file)
3816 IStorage *stg;
3817 IStream *stm;
3818 WCHAR fileW[MAX_PATH];
3819 HRESULT hr;
3820 DWORD count;
3821 const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
3823 /* AdminProperties */
3824 static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
3825 static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',0};
3827 MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
3829 hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
3830 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3831 if (!stg)
3832 return;
3834 hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
3835 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3837 hr = IStream_Write(stm, data, sizeof(data), &count);
3838 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
3840 IStream_Release(stm);
3841 IStorage_Release(stg);
3844 static void test_adminprops(void)
3846 UINT r;
3848 CreateDirectoryA("msitest", NULL);
3849 create_file("msitest\\augustus", 500);
3851 create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
3852 set_admin_summary_info(msifile);
3853 set_admin_property_stream(msifile);
3855 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3857 r = MsiInstallProductA(msifile, NULL);
3858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3859 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
3860 ok(delete_pf("msitest", FALSE), "File installed\n");
3862 DeleteFile(msifile);
3863 DeleteFile("msitest\\augustus");
3864 RemoveDirectory("msitest");
3867 static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file)
3869 CHAR path[MAX_PATH];
3871 lstrcpyA(path, PROG_FILES_DIR);
3872 lstrcatA(path, "\\");
3873 lstrcatA(path, file);
3875 if (is_file)
3876 create_file_data(path, data, 500);
3877 else
3878 CreateDirectoryA(path, NULL);
3881 #define create_pf(file, is_file) create_pf_data(file, file, is_file)
3883 static void test_removefiles(void)
3885 UINT r;
3887 CreateDirectoryA("msitest", NULL);
3888 create_file("msitest\\hydrogen", 500);
3889 create_file("msitest\\helium", 500);
3890 create_file("msitest\\lithium", 500);
3892 create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
3894 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
3896 r = MsiInstallProductA(msifile, NULL);
3897 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3898 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3899 ok(!pf_exists("msitest\\helium"), "File installed\n");
3900 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3901 ok(pf_exists("msitest"), "File not installed\n");
3903 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3904 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3905 ok(!pf_exists("msitest\\helium"), "File not deleted\n");
3906 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3907 todo_wine
3909 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3910 ok(delete_pf("msitest", FALSE), "File deleted\n");
3913 create_pf("msitest", FALSE);
3914 create_pf("msitest\\hydrogen", TRUE);
3915 create_pf("msitest\\helium", TRUE);
3916 create_pf("msitest\\lithium", TRUE);
3918 r = MsiInstallProductA(msifile, NULL);
3919 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3920 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3921 ok(pf_exists("msitest\\helium"), "File not installed\n");
3922 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3923 ok(pf_exists("msitest"), "File not installed\n");
3925 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3927 ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
3928 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3929 todo_wine
3931 ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
3932 ok(delete_pf("msitest", FALSE), "File deleted\n");
3935 create_pf("msitest", FALSE);
3936 create_pf("msitest\\furlong", TRUE);
3937 create_pf("msitest\\firkin", TRUE);
3938 create_pf("msitest\\fortnight", TRUE);
3939 create_pf("msitest\\becquerel", TRUE);
3940 create_pf("msitest\\dioptre", TRUE);
3941 create_pf("msitest\\attoparsec", TRUE);
3942 create_pf("msitest\\storeys", TRUE);
3943 create_pf("msitest\\block", TRUE);
3944 create_pf("msitest\\siriometer", TRUE);
3946 r = MsiInstallProductA(msifile, NULL);
3947 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3948 ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
3949 ok(!pf_exists("msitest\\helium"), "File installed\n");
3950 ok(pf_exists("msitest\\lithium"), "File not installed\n");
3951 ok(pf_exists("msitest\\becquerel"), "File not installed\n");
3952 ok(pf_exists("msitest\\dioptre"), "File not installed\n");
3953 ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
3954 ok(pf_exists("msitest"), "File not installed\n");
3955 todo_wine
3957 ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
3958 ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
3959 ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
3960 ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
3961 ok(!pf_exists("msitest\\block"), "File not deleted\n");
3962 ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
3965 create_pf("msitest\\furlong", TRUE);
3966 create_pf("msitest\\firkin", TRUE);
3967 create_pf("msitest\\fortnight", TRUE);
3968 create_pf("msitest\\storeys", TRUE);
3969 create_pf("msitest\\block", TRUE);
3970 create_pf("msitest\\siriometer", TRUE);
3972 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3973 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3974 ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
3975 ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
3976 ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
3977 ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
3978 ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
3979 ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
3980 ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
3981 todo_wine
3983 ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
3984 ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
3985 ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
3986 ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
3987 ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
3989 ok(delete_pf("msitest", FALSE), "File deleted\n");
3991 DeleteFile(msifile);
3992 DeleteFile("msitest\\hydrogen");
3993 DeleteFile("msitest\\helium");
3994 DeleteFile("msitest\\lithium");
3995 RemoveDirectory("msitest");
3998 static void test_movefiles(void)
4000 UINT r;
4001 char props[MAX_PATH];
4003 CreateDirectoryA("msitest", NULL);
4004 create_file("msitest\\augustus", 100);
4005 create_file("cameroon", 100);
4006 create_file("djibouti", 100);
4007 create_file("egypt", 100);
4008 create_file("finland", 100);
4009 create_file("gambai", 100);
4010 create_file("honduras", 100);
4011 create_file("msitest\\india", 100);
4012 create_file("japan", 100);
4013 create_file("kenya", 100);
4014 CreateDirectoryA("latvia", NULL);
4015 create_file("nauru", 100);
4016 create_file("apple", 100);
4017 create_file("application", 100);
4018 create_file("ape", 100);
4019 create_file("foo", 100);
4020 create_file("fao", 100);
4021 create_file("fbod", 100);
4022 create_file("budding", 100);
4023 create_file("buddy", 100);
4024 create_file("bud", 100);
4025 create_file("bar", 100);
4026 create_file("bur", 100);
4027 create_file("bird", 100);
4029 create_database(msifile, mov_tables, sizeof(mov_tables) / sizeof(msi_table));
4031 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4032 MsiEnableLog(INSTALLLOGMODE_VERBOSE | INSTALLLOGMODE_EXTRADEBUG, "log.txt", 0);
4034 /* if the source or dest property is not a full path,
4035 * windows tries to access it as a network resource
4038 sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
4039 "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
4040 CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);
4042 r = MsiInstallProductA(msifile, props);
4043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4044 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4045 ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
4046 ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
4047 ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
4048 ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
4049 ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
4050 ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
4051 ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
4052 ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
4053 ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
4054 ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
4055 ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
4056 ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
4057 /* either apple or application will be moved depending on directory order */
4058 if (!delete_pf("msitest\\apple", TRUE))
4059 ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
4060 else
4061 ok(!delete_pf("msitest\\application", TRUE), "File should not exist\n");
4062 ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
4063 ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
4064 /* either fao or foo will be moved depending on directory order */
4065 if (delete_pf("msitest\\foo", TRUE))
4066 ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
4067 else
4068 ok(delete_pf("msitest\\fao", TRUE), "File not moved\n");
4069 ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
4070 ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
4071 ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
4072 ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
4073 ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
4074 ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
4075 ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
4076 ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
4077 ok(delete_pf("msitest", FALSE), "File not installed\n");
4078 ok(DeleteFileA("cameroon"), "File moved\n");
4079 ok(!DeleteFileA("djibouti"), "File not moved\n");
4080 ok(DeleteFileA("egypt"), "File moved\n");
4081 ok(DeleteFileA("finland"), "File moved\n");
4082 ok(DeleteFileA("gambai"), "File moved\n");
4083 ok(!DeleteFileA("honduras"), "File not moved\n");
4084 ok(DeleteFileA("msitest\\india"), "File moved\n");
4085 ok(DeleteFileA("japan"), "File moved\n");
4086 ok(!DeleteFileA("kenya"), "File not moved\n");
4087 ok(RemoveDirectoryA("latvia"), "Directory moved\n");
4088 ok(!DeleteFileA("nauru"), "File not moved\n");
4089 ok(!DeleteFileA("apple"), "File not moved\n");
4090 ok(!DeleteFileA("application"), "File not moved\n");
4091 ok(DeleteFileA("ape"), "File moved\n");
4092 ok(!DeleteFileA("foo"), "File not moved\n");
4093 ok(!DeleteFileA("fao"), "File not moved\n");
4094 ok(DeleteFileA("fbod"), "File moved\n");
4095 ok(!DeleteFileA("budding"), "File not moved\n");
4096 ok(!DeleteFileA("buddy"), "File not moved\n");
4097 ok(DeleteFileA("bud"), "File moved\n");
4098 ok(!DeleteFileA("bar"), "File not moved\n");
4099 ok(!DeleteFileA("bur"), "File not moved\n");
4100 ok(DeleteFileA("bird"), "File moved\n");
4102 DeleteFile("msitest\\augustus");
4103 RemoveDirectory("msitest");
4104 DeleteFile(msifile);
4107 static void test_missingcab(void)
4109 UINT r;
4111 CreateDirectoryA("msitest", NULL);
4112 create_file("msitest\\augustus", 500);
4113 create_file("maximus", 500);
4115 create_database(msifile, mc_tables, sizeof(mc_tables) / sizeof(msi_table));
4117 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4119 create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4121 create_pf("msitest", FALSE);
4122 create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
4124 r = MsiInstallProductA(msifile, NULL);
4125 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4126 ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4127 ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4128 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4129 ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
4130 ok(delete_pf("msitest", FALSE), "File not installed\n");
4132 create_pf("msitest", FALSE);
4133 create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
4134 create_pf("msitest\\gaius", TRUE);
4136 r = MsiInstallProductA(msifile, "GAIUS=1");
4137 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4138 todo_wine
4140 ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
4141 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
4143 ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
4144 ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
4145 ok(delete_pf("msitest", FALSE), "File not installed\n");
4147 DeleteFile("msitest\\augustus");
4148 RemoveDirectory("msitest");
4149 DeleteFile("maximus");
4150 DeleteFile("test1.cab");
4151 DeleteFile(msifile);
4154 static void test_duplicatefiles(void)
4156 UINT r;
4158 CreateDirectoryA("msitest", NULL);
4159 create_file("msitest\\maximus", 500);
4160 create_database(msifile, df_tables, sizeof(df_tables) / sizeof(msi_table));
4162 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4164 /* fails if the destination folder is not a valid property */
4166 r = MsiInstallProductA(msifile, NULL);
4167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4168 ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4169 ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
4170 ok(delete_pf("msitest\\this\\doesnot\\exist\\maximus", TRUE), "File not duplicated\n");
4171 ok(delete_pf("msitest\\this\\doesnot\\exist", FALSE), "File not duplicated\n");
4172 ok(delete_pf("msitest\\this\\doesnot", FALSE), "File not duplicated\n");
4173 ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n");
4174 ok(delete_pf("msitest", FALSE), "File not installed\n");
4176 DeleteFile("msitest\\maximus");
4177 RemoveDirectory("msitest");
4178 DeleteFile(msifile);
4181 static void test_writeregistryvalues(void)
4183 UINT r;
4184 LONG res;
4185 HKEY hkey;
4186 DWORD type, size;
4187 CHAR path[MAX_PATH];
4189 CreateDirectoryA("msitest", NULL);
4190 create_file("msitest\\augustus", 500);
4192 create_database(msifile, wrv_tables, sizeof(wrv_tables) / sizeof(msi_table));
4194 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4196 r = MsiInstallProductA(msifile, NULL);
4197 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4198 ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
4199 ok(delete_pf("msitest", FALSE), "File installed\n");
4201 res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
4202 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4204 size = MAX_PATH;
4205 type = REG_MULTI_SZ;
4206 memset(path, 'a', MAX_PATH);
4207 res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
4208 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4209 ok(!memcmp(path, "one\0two\0three\0\0", size), "Wrong multi-sz data\n");
4210 ok(size == 15, "Expected 15, got %d\n", size);
4211 ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
4213 DeleteFile(msifile);
4214 DeleteFile("msitest\\augustus");
4215 RemoveDirectory("msitest");
4218 static void test_sourcefolder(void)
4220 UINT r;
4222 CreateDirectoryA("msitest", NULL);
4223 create_file("augustus", 500);
4225 create_database(msifile, sf_tables, sizeof(sf_tables) / sizeof(msi_table));
4227 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4229 r = MsiInstallProductA(msifile, NULL);
4230 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
4231 todo_wine
4233 ok(r == ERROR_INSTALL_FAILURE,
4234 "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4235 ok(!delete_pf("msitest", FALSE), "File installed\n");
4238 RemoveDirectoryA("msitest");
4240 r = MsiInstallProductA(msifile, NULL);
4241 todo_wine
4243 ok(r == ERROR_INSTALL_FAILURE,
4244 "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
4245 ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
4246 ok(!delete_pf("msitest", FALSE), "File installed\n");
4249 DeleteFile(msifile);
4250 DeleteFile("augustus");
4253 START_TEST(install)
4255 DWORD len;
4256 char temp_path[MAX_PATH], prev_path[MAX_PATH];
4258 init_functionpointers();
4260 GetCurrentDirectoryA(MAX_PATH, prev_path);
4261 GetTempPath(MAX_PATH, temp_path);
4262 SetCurrentDirectoryA(temp_path);
4264 lstrcpyA(CURR_DIR, temp_path);
4265 len = lstrlenA(CURR_DIR);
4267 if(len && (CURR_DIR[len - 1] == '\\'))
4268 CURR_DIR[len - 1] = 0;
4270 get_program_files_dir(PROG_FILES_DIR, COMMON_FILES_DIR);
4272 test_MsiInstallProduct();
4273 test_MsiSetComponentState();
4274 test_packagecoltypes();
4275 test_continuouscabs();
4276 test_caborder();
4277 test_mixedmedia();
4278 test_samesequence();
4279 test_uiLevelFlags();
4280 test_readonlyfile();
4281 test_setdirproperty();
4282 test_cabisextracted();
4283 test_concurrentinstall();
4284 test_setpropertyfolder();
4285 test_publish_registerproduct();
4286 test_publish_publishproduct();
4287 test_publish_publishfeatures();
4288 test_publish_registeruser();
4289 test_publish_processcomponents();
4290 test_publish();
4291 test_publishsourcelist();
4292 test_transformprop();
4293 test_currentworkingdir();
4294 test_admin();
4295 test_adminprops();
4296 test_removefiles();
4297 test_movefiles();
4298 test_missingcab();
4299 test_duplicatefiles();
4300 test_writeregistryvalues();
4301 test_sourcefolder();
4303 SetCurrentDirectoryA(prev_path);