user32: Use the stored color and mask bitmaps instead of the raw bits in GetIconInfo.
[wine] / dlls / msi / tests / install.c
1 /*
2  * Copyright (C) 2006 James Hawkins
3  *
4  * A test program for installing MSI products.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define _WIN32_MSI 300
22 #define COBJMACROS
23
24 #include <stdio.h>
25
26 #include <windows.h>
27 #include <msiquery.h>
28 #include <msidefs.h>
29 #include <msi.h>
30 #include <fci.h>
31 #include <objidl.h>
32 #include <srrestoreptapi.h>
33
34 #include "wine/test.h"
35
36 static UINT (WINAPI *pMsiQueryComponentStateA)
37     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE*);
38 static UINT (WINAPI *pMsiSetExternalUIRecord)
39     (INSTALLUI_HANDLER_RECORD, DWORD, LPVOID, PINSTALLUI_HANDLER_RECORD);
40 static UINT (WINAPI *pMsiSourceListEnumSourcesA)
41     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPSTR, LPDWORD);
42 static UINT (WINAPI *pMsiSourceListGetInfoA)
43     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD);
44
45 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
46
47 static HMODULE hsrclient = 0;
48 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
49 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
50
51 static BOOL on_win9x = FALSE;
52
53 static const char *msifile = "msitest.msi";
54 static const char *msifile2 = "winetest2.msi";
55 static const char *mstfile = "winetest.mst";
56 static CHAR CURR_DIR[MAX_PATH];
57 static CHAR PROG_FILES_DIR[MAX_PATH];
58 static CHAR COMMON_FILES_DIR[MAX_PATH];
59
60 /* msi database data */
61
62 static const CHAR component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
63                                     "s72\tS38\ts72\ti2\tS255\tS72\n"
64                                     "Component\tComponent\n"
65                                     "Five\t{8CC92E9D-14B2-4CA4-B2AA-B11D02078087}\tNEWDIR\t2\t\tfive.txt\n"
66                                     "Four\t{FD37B4EA-7209-45C0-8917-535F35A2F080}\tCABOUTDIR\t2\t\tfour.txt\n"
67                                     "One\t{783B242E-E185-4A56-AF86-C09815EC053C}\tMSITESTDIR\t2\tNOT REINSTALL\tone.txt\n"
68                                     "Three\t{010B6ADD-B27D-4EDD-9B3D-34C4F7D61684}\tCHANGEDDIR\t2\t\tthree.txt\n"
69                                     "Two\t{BF03D1A6-20DA-4A65-82F3-6CAC995915CE}\tFIRSTDIR\t2\t\ttwo.txt\n"
70                                     "dangler\t{6091DF25-EF96-45F1-B8E9-A9B1420C7A3C}\tTARGETDIR\t4\t\tregdata\n"
71                                     "component\t\tMSITESTDIR\t0\t1\tfile\n"
72                                     "service_comp\t\tMSITESTDIR\t0\t1\tservice_file";
73
74 static const CHAR directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
75                                     "s72\tS72\tl255\n"
76                                     "Directory\tDirectory\n"
77                                     "CABOUTDIR\tMSITESTDIR\tcabout\n"
78                                     "CHANGEDDIR\tMSITESTDIR\tchanged:second\n"
79                                     "FIRSTDIR\tMSITESTDIR\tfirst\n"
80                                     "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
81                                     "NEWDIR\tCABOUTDIR\tnew\n"
82                                     "ProgramFilesFolder\tTARGETDIR\t.\n"
83                                     "TARGETDIR\t\tSourceDir";
84
85 static const CHAR feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
86                                   "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
87                                   "Feature\tFeature\n"
88                                   "Five\t\tFive\tThe Five Feature\t5\t3\tNEWDIR\t0\n"
89                                   "Four\t\tFour\tThe Four Feature\t4\t3\tCABOUTDIR\t0\n"
90                                   "One\t\tOne\tThe One Feature\t1\t3\tMSITESTDIR\t0\n"
91                                   "Three\t\tThree\tThe Three Feature\t3\t3\tCHANGEDDIR\t0\n"
92                                   "Two\t\tTwo\tThe Two Feature\t2\t3\tFIRSTDIR\t0\n"
93                                   "feature\t\t\t\t2\t1\tTARGETDIR\t0\n"
94                                   "service_feature\t\t\t\t2\t1\tTARGETDIR\t0";
95
96 static const CHAR feature_comp_dat[] = "Feature_\tComponent_\n"
97                                        "s38\ts72\n"
98                                        "FeatureComponents\tFeature_\tComponent_\n"
99                                        "Five\tFive\n"
100                                        "Four\tFour\n"
101                                        "One\tOne\n"
102                                        "Three\tThree\n"
103                                        "Two\tTwo\n"
104                                        "feature\tcomponent\n"
105                                        "service_feature\tservice_comp\n";
106
107 static const CHAR file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
108                                "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
109                                "File\tFile\n"
110                                "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
111                                "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
112                                "one.txt\tOne\tone.txt\t1000\t\t\t0\t1\n"
113                                "three.txt\tThree\tthree.txt\t1000\t\t\t0\t3\n"
114                                "two.txt\tTwo\ttwo.txt\t1000\t\t\t0\t2\n"
115                                "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
116                                "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
117
118 static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
119                                            "s72\tS255\tI2\n"
120                                            "InstallExecuteSequence\tAction\n"
121                                            "AllocateRegistrySpace\tNOT Installed\t1550\n"
122                                            "CostFinalize\t\t1000\n"
123                                            "CostInitialize\t\t800\n"
124                                            "FileCost\t\t900\n"
125                                            "ResolveSource\t\t950\n"
126                                            "MoveFiles\t\t1700\n"
127                                            "InstallFiles\t\t4000\n"
128                                            "DuplicateFiles\t\t4500\n"
129                                            "WriteEnvironmentStrings\t\t4550\n"
130                                            "CreateShortcuts\t\t4600\n"
131                                            "InstallServices\t\t5000\n"
132                                            "InstallFinalize\t\t6600\n"
133                                            "InstallInitialize\t\t1500\n"
134                                            "InstallValidate\t\t1400\n"
135                                            "LaunchConditions\t\t100\n"
136                                            "WriteRegistryValues\tSourceDir And SOURCEDIR\t5000";
137
138 static const CHAR media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
139                                 "i2\ti4\tL64\tS255\tS32\tS72\n"
140                                 "Media\tDiskId\n"
141                                 "1\t3\t\t\tDISK1\t\n"
142                                 "2\t5\t\tmsitest.cab\tDISK2\t\n";
143
144 static const CHAR property_dat[] = "Property\tValue\n"
145                                    "s72\tl0\n"
146                                    "Property\tProperty\n"
147                                    "DefaultUIFont\tDlgFont8\n"
148                                    "HASUIRUN\t0\n"
149                                    "INSTALLLEVEL\t3\n"
150                                    "InstallMode\tTypical\n"
151                                    "Manufacturer\tWine\n"
152                                    "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
153                                    "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
154                                    "ProductID\tnone\n"
155                                    "ProductLanguage\t1033\n"
156                                    "ProductName\tMSITEST\n"
157                                    "ProductVersion\t1.1.1\n"
158                                    "PROMPTROLLBACKCOST\tP\n"
159                                    "Setup\tSetup\n"
160                                    "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
161                                    "AdminProperties\tPOSTADMIN\n"
162                                    "ROOTDRIVE\tC:\\\n"
163                                    "SERVNAME\tTestService\n"
164                                    "SERVDISP\tTestServiceDisp\n";
165
166 static const CHAR aup_property_dat[] = "Property\tValue\n"
167                                        "s72\tl0\n"
168                                        "Property\tProperty\n"
169                                        "DefaultUIFont\tDlgFont8\n"
170                                        "HASUIRUN\t0\n"
171                                        "ALLUSERS\t1\n"
172                                        "INSTALLLEVEL\t3\n"
173                                        "InstallMode\tTypical\n"
174                                        "Manufacturer\tWine\n"
175                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
176                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
177                                        "ProductID\tnone\n"
178                                        "ProductLanguage\t1033\n"
179                                        "ProductName\tMSITEST\n"
180                                        "ProductVersion\t1.1.1\n"
181                                        "PROMPTROLLBACKCOST\tP\n"
182                                        "Setup\tSetup\n"
183                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
184                                        "AdminProperties\tPOSTADMIN\n"
185                                        "ROOTDRIVE\tC:\\\n"
186                                        "SERVNAME\tTestService\n"
187                                        "SERVDISP\tTestServiceDisp\n";
188
189 static const CHAR aup2_property_dat[] = "Property\tValue\n"
190                                         "s72\tl0\n"
191                                         "Property\tProperty\n"
192                                         "DefaultUIFont\tDlgFont8\n"
193                                         "HASUIRUN\t0\n"
194                                         "ALLUSERS\t2\n"
195                                         "INSTALLLEVEL\t3\n"
196                                         "InstallMode\tTypical\n"
197                                         "Manufacturer\tWine\n"
198                                         "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
199                                         "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
200                                         "ProductID\tnone\n"
201                                         "ProductLanguage\t1033\n"
202                                         "ProductName\tMSITEST\n"
203                                         "ProductVersion\t1.1.1\n"
204                                         "PROMPTROLLBACKCOST\tP\n"
205                                         "Setup\tSetup\n"
206                                         "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
207                                         "AdminProperties\tPOSTADMIN\n"
208                                         "ROOTDRIVE\tC:\\\n"
209                                         "SERVNAME\tTestService\n"
210                                         "SERVDISP\tTestServiceDisp\n";
211
212 static const CHAR shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
213                                    "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n"
214                                    "Shortcut\tShortcut\n"
215                                    "Shortcut\tMSITESTDIR\tShortcut\tcomponent\tShortcut\t\tShortcut\t\t\t\t\t\n";
216
217 static const CHAR environment_dat[] = "Environment\tName\tValue\tComponent_\n"
218                                       "s72\tl255\tL255\ts72\n"
219                                       "Environment\tEnvironment\n"
220                                       "Var1\t=-MSITESTVAR1\t1\tOne\n"
221                                       "Var2\tMSITESTVAR2\t1\tOne\n"
222                                       "Var3\t=-MSITESTVAR3\t1\tOne\n"
223                                       "Var4\tMSITESTVAR4\t1\tOne\n"
224                                       "Var5\t-MSITESTVAR5\t\tOne\n"
225                                       "Var6\tMSITESTVAR6\t\tOne\n"
226                                       "Var7\t!-MSITESTVAR7\t\tOne\n"
227                                       "Var8\t!-*MSITESTVAR8\t\tOne\n"
228                                       "Var9\t=-MSITESTVAR9\t\tOne\n"
229                                       "Var10\t=MSITESTVAR10\t\tOne\n"
230                                       "Var11\t+-MSITESTVAR11\t[~];1\tOne\n"
231                                       "Var12\t+-MSITESTVAR11\t[~];2\tOne\n"
232                                       "Var13\t+-MSITESTVAR12\t[~];1\tOne\n"
233                                       "Var14\t=MSITESTVAR13\t[~];1\tOne\n"
234                                       "Var15\t=MSITESTVAR13\t[~];2\tOne\n"
235                                       "Var16\t=MSITESTVAR14\t;1;\tOne\n"
236                                       "Var17\t=MSITESTVAR15\t;;1;;\tOne\n"
237                                       "Var18\t=MSITESTVAR16\t 1 \tOne\n"
238                                       "Var19\t+-MSITESTVAR17\t1\tOne\n"
239                                       "Var20\t+-MSITESTVAR17\t;;2;;[~]\tOne\n"
240                                       "Var21\t+-MSITESTVAR18\t1\tOne\n"
241                                       "Var22\t+-MSITESTVAR18\t[~];;2;;\tOne\n"
242                                       "Var23\t+-MSITESTVAR19\t1\tOne\n"
243                                       "Var24\t+-MSITESTVAR19\t[~]2\tOne\n"
244                                       "Var25\t+-MSITESTVAR20\t1\tOne\n"
245                                       "Var26\t+-MSITESTVAR20\t2[~]\tOne\n";
246
247 /* Expected results, starting from MSITESTVAR11 onwards */
248 static const CHAR *environment_dat_results[] = {"1;2",    /*MSITESTVAR11*/
249                                                 "1",      /*MSITESTVAR12*/
250                                                 "1;2",    /*MSITESTVAR13*/
251                                                 ";1;",    /*MSITESTVAR14*/
252                                                 ";;1;;",  /*MSITESTVAR15*/
253                                                 " 1 ",    /*MSITESTVAR16*/
254                                                 ";;2;;1", /*MSITESTVAR17*/
255                                                 "1;;2;;", /*MSITESTVAR18*/
256                                                 "1",      /*MSITESTVAR19*/
257                                                 "1",      /*MSITESTVAR20*/
258                                                 NULL};
259
260 static const CHAR condition_dat[] = "Feature_\tLevel\tCondition\n"
261                                     "s38\ti2\tS255\n"
262                                     "Condition\tFeature_\tLevel\n"
263                                     "One\t4\t1\n";
264
265 static const CHAR up_property_dat[] = "Property\tValue\n"
266                                       "s72\tl0\n"
267                                       "Property\tProperty\n"
268                                       "DefaultUIFont\tDlgFont8\n"
269                                       "HASUIRUN\t0\n"
270                                       "INSTALLLEVEL\t3\n"
271                                       "InstallMode\tTypical\n"
272                                       "Manufacturer\tWine\n"
273                                       "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
274                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
275                                       "ProductID\tnone\n"
276                                       "ProductLanguage\t1033\n"
277                                       "ProductName\tMSITEST\n"
278                                       "ProductVersion\t1.1.1\n"
279                                       "PROMPTROLLBACKCOST\tP\n"
280                                       "Setup\tSetup\n"
281                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
282                                       "AdminProperties\tPOSTADMIN\n"
283                                       "ROOTDRIVE\tC:\\\n"
284                                       "SERVNAME\tTestService\n"
285                                       "SERVDISP\tTestServiceDisp\n"
286                                       "RemovePreviousVersions\t1\n";
287
288 static const CHAR up2_property_dat[] = "Property\tValue\n"
289                                        "s72\tl0\n"
290                                        "Property\tProperty\n"
291                                        "DefaultUIFont\tDlgFont8\n"
292                                        "HASUIRUN\t0\n"
293                                        "INSTALLLEVEL\t3\n"
294                                        "InstallMode\tTypical\n"
295                                        "Manufacturer\tWine\n"
296                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
297                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
298                                        "ProductID\tnone\n"
299                                        "ProductLanguage\t1033\n"
300                                        "ProductName\tMSITEST\n"
301                                        "ProductVersion\t1.1.2\n"
302                                        "PROMPTROLLBACKCOST\tP\n"
303                                        "Setup\tSetup\n"
304                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
305                                        "AdminProperties\tPOSTADMIN\n"
306                                        "ROOTDRIVE\tC:\\\n"
307                                        "SERVNAME\tTestService\n"
308                                        "SERVDISP\tTestServiceDisp\n";
309
310 static const CHAR up3_property_dat[] = "Property\tValue\n"
311                                        "s72\tl0\n"
312                                        "Property\tProperty\n"
313                                        "DefaultUIFont\tDlgFont8\n"
314                                        "HASUIRUN\t0\n"
315                                        "INSTALLLEVEL\t3\n"
316                                        "InstallMode\tTypical\n"
317                                        "Manufacturer\tWine\n"
318                                        "PIDTemplate\t12345<###-%%%%%%%>@@@@@\n"
319                                        "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
320                                        "ProductID\tnone\n"
321                                        "ProductLanguage\t1033\n"
322                                        "ProductName\tMSITEST\n"
323                                        "ProductVersion\t1.1.2\n"
324                                        "PROMPTROLLBACKCOST\tP\n"
325                                        "Setup\tSetup\n"
326                                        "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n"
327                                        "AdminProperties\tPOSTADMIN\n"
328                                        "ROOTDRIVE\tC:\\\n"
329                                        "SERVNAME\tTestService\n"
330                                        "SERVDISP\tTestServiceDisp\n"
331                                        "RemovePreviousVersions\t1\n";
332
333 static const CHAR registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
334                                    "s72\ti2\tl255\tL255\tL0\ts72\n"
335                                    "Registry\tRegistry\n"
336                                    "Apples\t2\tSOFTWARE\\Wine\\msitest\tName\timaname\tOne\n"
337                                    "Oranges\t2\tSOFTWARE\\Wine\\msitest\tnumber\t#314\tTwo\n"
338                                    "regdata\t2\tSOFTWARE\\Wine\\msitest\tblah\tbad\tdangler\n"
339                                    "OrderTest\t2\tSOFTWARE\\Wine\\msitest\tOrderTestName\tOrderTestValue\tcomponent";
340
341 static const CHAR service_install_dat[] = "ServiceInstall\tName\tDisplayName\tServiceType\tStartType\tErrorControl\t"
342                                           "LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
343                                           "s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
344                                           "ServiceInstall\tServiceInstall\n"
345                                           "TestService\t[SERVNAME]\t[SERVDISP]\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
346
347 static const CHAR service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
348                                           "s72\tl255\ti2\tL255\tI2\ts72\n"
349                                           "ServiceControl\tServiceControl\n"
350                                           "ServiceControl\tTestService\t8\t\t0\tservice_comp";
351
352 static const CHAR sss_service_control_dat[] = "ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"
353                                               "s72\tl255\ti2\tL255\tI2\ts72\n"
354                                               "ServiceControl\tServiceControl\n"
355                                               "ServiceControl\tSpooler\t1\t\t0\tservice_comp";
356
357 static const CHAR sss_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
358                                                "s72\tS255\tI2\n"
359                                                "InstallExecuteSequence\tAction\n"
360                                                "CostFinalize\t\t1000\n"
361                                                "CostInitialize\t\t800\n"
362                                                "FileCost\t\t900\n"
363                                                "ResolveSource\t\t950\n"
364                                                "MoveFiles\t\t1700\n"
365                                                "InstallFiles\t\t4000\n"
366                                                "DuplicateFiles\t\t4500\n"
367                                                "WriteEnvironmentStrings\t\t4550\n"
368                                                "CreateShortcuts\t\t4600\n"
369                                                "StartServices\t\t5000\n"
370                                                "DeleteServices\t\t5500\n"
371                                                "InstallFinalize\t\t6600\n"
372                                                "InstallInitialize\t\t1500\n"
373                                                "InstallValidate\t\t1400\n"
374                                                "LaunchConditions\t\t100\n";
375
376 /* tables for test_continuouscabs */
377 static const CHAR cc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
378                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
379                                        "Component\tComponent\n"
380                                        "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
381                                        "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
382                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
383
384 static const CHAR cc2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
385                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
386                                         "Component\tComponent\n"
387                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
388                                         "augustus\t\tMSITESTDIR\t0\t0\taugustus\n"
389                                         "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
390
391 static const CHAR cc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
392                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
393                                      "Feature\tFeature\n"
394                                      "feature\t\t\t\t2\t1\tTARGETDIR\t0";
395
396 static const CHAR cc_feature_comp_dat[] = "Feature_\tComponent_\n"
397                                           "s38\ts72\n"
398                                           "FeatureComponents\tFeature_\tComponent_\n"
399                                           "feature\tmaximus\n"
400                                           "feature\taugustus\n"
401                                           "feature\tcaesar";
402
403 static const CHAR cc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
404                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
405                                   "File\tFile\n"
406                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
407                                   "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
408                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
409
410 static const CHAR cc2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
411                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
412                                    "File\tFile\n"
413                                    "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
414                                    "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
415                                    "tiberius\tmaximus\ttiberius\t500\t\t\t16384\t3\n"
416                                    "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12";
417
418 static const CHAR cc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
419                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
420                                    "Media\tDiskId\n"
421                                    "1\t10\t\ttest1.cab\tDISK1\t\n"
422                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
423                                    "3\t12\t\ttest3.cab\tDISK3\t\n";
424
425 static const CHAR co_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
426                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
427                                   "File\tFile\n"
428                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
429                                   "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
430                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
431
432 static const CHAR co_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
433                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
434                                    "Media\tDiskId\n"
435                                    "1\t10\t\ttest1.cab\tDISK1\t\n"
436                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
437                                    "3\t3\t\ttest3.cab\tDISK3\t\n";
438
439 static const CHAR co2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
440                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
441                                     "Media\tDiskId\n"
442                                     "1\t10\t\ttest1.cab\tDISK1\t\n"
443                                     "2\t12\t\ttest3.cab\tDISK3\t\n"
444                                     "3\t2\t\ttest2.cab\tDISK2\t\n";
445
446 static const CHAR mm_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
447                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
448                                   "File\tFile\n"
449                                   "maximus\tmaximus\tmaximus\t500\t\t\t512\t1\n"
450                                   "augustus\taugustus\taugustus\t500\t\t\t512\t2\n"
451                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3";
452
453 static const CHAR mm_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
454                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
455                                    "Media\tDiskId\n"
456                                    "1\t3\t\ttest1.cab\tDISK1\t\n";
457
458 static const CHAR ss_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
459                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
460                                    "Media\tDiskId\n"
461                                    "1\t2\t\ttest1.cab\tDISK1\t\n"
462                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
463                                    "3\t12\t\ttest3.cab\tDISK3\t\n";
464
465 /* tables for test_uiLevelFlags */
466 static const CHAR ui_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
467                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
468                                        "Component\tComponent\n"
469                                        "maximus\t\tMSITESTDIR\t0\tHASUIRUN=1\tmaximus\n"
470                                        "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
471                                        "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n";
472
473 static const CHAR ui_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
474                                            "s72\tS255\tI2\n"
475                                            "InstallUISequence\tAction\n"
476                                            "SetUIProperty\t\t5\n"
477                                            "ExecuteAction\t\t1100\n";
478
479 static const CHAR ui_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
480                                            "s72\ti2\tS64\tS0\tS255\n"
481                                            "CustomAction\tAction\n"
482                                            "SetUIProperty\t51\tHASUIRUN\t1\t\n";
483
484 static const CHAR rof_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
485                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
486                                         "Component\tComponent\n"
487                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n";
488
489 static const CHAR rof_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
490                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
491                                       "Feature\tFeature\n"
492                                       "feature\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0\n"
493                                       "montecristo\t\tFeature\tFeature\t2\t1\tTARGETDIR\t0";
494
495 static const CHAR rof_feature_comp_dat[] = "Feature_\tComponent_\n"
496                                            "s38\ts72\n"
497                                            "FeatureComponents\tFeature_\tComponent_\n"
498                                            "feature\tmaximus\n"
499                                            "montecristo\tmaximus";
500
501 static const CHAR rof_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
502                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
503                                    "File\tFile\n"
504                                    "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1";
505
506 static const CHAR rof_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
507                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
508                                     "Media\tDiskId\n"
509                                     "1\t1\t\t\tDISK1\t\n";
510
511 static const CHAR rofc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
512                                     "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
513                                     "File\tFile\n"
514                                     "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1";
515
516 static const CHAR rofc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
517                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
518                                      "Media\tDiskId\n"
519                                      "1\t1\t\ttest1.cab\tDISK1\t\n";
520
521 static const CHAR lus2_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
522                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
523                                      "Media\tDiskId\n"
524                                      "1\t1\t\t#test1.cab\tDISK1\t\n";
525
526 static const CHAR sdp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
527                                                "s72\tS255\tI2\n"
528                                                "InstallExecuteSequence\tAction\n"
529                                                "AllocateRegistrySpace\tNOT Installed\t1550\n"
530                                                "CostFinalize\t\t1000\n"
531                                                "CostInitialize\t\t800\n"
532                                                "FileCost\t\t900\n"
533                                                "InstallFiles\t\t4000\n"
534                                                "InstallFinalize\t\t6600\n"
535                                                "InstallInitialize\t\t1500\n"
536                                                "InstallValidate\t\t1400\n"
537                                                "LaunchConditions\t\t100\n"
538                                                "SetDirProperty\t\t950";
539
540 static const CHAR sdp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
541                                             "s72\ti2\tS64\tS0\tS255\n"
542                                             "CustomAction\tAction\n"
543                                             "SetDirProperty\t51\tMSITESTDIR\t[CommonFilesFolder]msitest\\\t\n";
544
545 static const CHAR cie_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
546                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
547                                         "Component\tComponent\n"
548                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
549                                         "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
550                                         "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
551                                         "gaius\t\tMSITESTDIR\t0\t1\tgaius\n";
552
553 static const CHAR cie_feature_comp_dat[] = "Feature_\tComponent_\n"
554                                            "s38\ts72\n"
555                                            "FeatureComponents\tFeature_\tComponent_\n"
556                                            "feature\tmaximus\n"
557                                            "feature\taugustus\n"
558                                            "feature\tcaesar\n"
559                                            "feature\tgaius";
560
561 static const CHAR cie_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
562                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
563                                    "File\tFile\n"
564                                    "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
565                                    "augustus\taugustus\taugustus\t50000\t\t\t16384\t2\n"
566                                    "caesar\tcaesar\tcaesar\t500\t\t\t16384\t12\n"
567                                    "gaius\tgaius\tgaius\t500\t\t\t8192\t11";
568
569 static const CHAR cie_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
570                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
571                                     "Media\tDiskId\n"
572                                     "1\t1\t\ttest1.cab\tDISK1\t\n"
573                                     "2\t2\t\ttest2.cab\tDISK2\t\n"
574                                     "3\t12\t\ttest3.cab\tDISK3\t\n";
575
576 static const CHAR ci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
577                                               "s72\tS255\tI2\n"
578                                               "InstallExecuteSequence\tAction\n"
579                                               "CostFinalize\t\t1000\n"
580                                               "CostInitialize\t\t800\n"
581                                               "FileCost\t\t900\n"
582                                               "InstallFiles\t\t4000\n"
583                                               "InstallServices\t\t5000\n"
584                                               "InstallFinalize\t\t6600\n"
585                                               "InstallInitialize\t\t1500\n"
586                                               "RunInstall\t\t1600\n"
587                                               "InstallValidate\t\t1400\n"
588                                               "LaunchConditions\t\t100";
589
590 static const CHAR ci_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
591                                             "s72\ti2\tS64\tS0\tS255\n"
592                                             "CustomAction\tAction\n"
593                                             "RunInstall\t87\tmsitest\\concurrent.msi\tMYPROP=[UILevel]\t\n";
594
595 static const CHAR ci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
596                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
597                                        "Component\tComponent\n"
598                                        "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n";
599
600 static const CHAR ci2_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
601                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
602                                         "Component\tComponent\n"
603                                         "augustus\t\tMSITESTDIR\t0\tUILevel=3 AND MYPROP=5\taugustus\n";
604
605 static const CHAR ci2_feature_comp_dat[] = "Feature_\tComponent_\n"
606                                            "s38\ts72\n"
607                                            "FeatureComponents\tFeature_\tComponent_\n"
608                                            "feature\taugustus";
609
610 static const CHAR ci2_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
611                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
612                                    "File\tFile\n"
613                                    "augustus\taugustus\taugustus\t500\t\t\t8192\t1";
614
615 static const CHAR spf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
616                                             "s72\ti2\tS64\tS0\tS255\n"
617                                             "CustomAction\tAction\n"
618                                             "SetFolderProp\t51\tMSITESTDIR\t[ProgramFilesFolder]\\msitest\\added\t\n";
619
620 static const CHAR spf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
621                                                "s72\tS255\tI2\n"
622                                                "InstallExecuteSequence\tAction\n"
623                                                "CostFinalize\t\t1000\n"
624                                                "CostInitialize\t\t800\n"
625                                                "FileCost\t\t900\n"
626                                                "SetFolderProp\t\t950\n"
627                                                "InstallFiles\t\t4000\n"
628                                                "InstallServices\t\t5000\n"
629                                                "InstallFinalize\t\t6600\n"
630                                                "InstallInitialize\t\t1500\n"
631                                                "InstallValidate\t\t1400\n"
632                                                "LaunchConditions\t\t100";
633
634 static const CHAR spf_install_ui_seq_dat[] = "Action\tCondition\tSequence\n"
635                                              "s72\tS255\tI2\n"
636                                              "InstallUISequence\tAction\n"
637                                              "CostInitialize\t\t800\n"
638                                              "FileCost\t\t900\n"
639                                              "CostFinalize\t\t1000\n"
640                                              "ExecuteAction\t\t1100\n";
641
642 static const CHAR pp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
643                                               "s72\tS255\tI2\n"
644                                               "InstallExecuteSequence\tAction\n"
645                                               "ValidateProductID\t\t700\n"
646                                               "CostInitialize\t\t800\n"
647                                               "FileCost\t\t900\n"
648                                               "CostFinalize\t\t1000\n"
649                                               "InstallValidate\t\t1400\n"
650                                               "InstallInitialize\t\t1500\n"
651                                               "ProcessComponents\tPROCESS_COMPONENTS=1 Or FULL=1\t1600\n"
652                                               "UnpublishFeatures\tUNPUBLISH_FEATURES=1 Or FULL=1\t1800\n"
653                                               "RemoveFiles\t\t3500\n"
654                                               "InstallFiles\t\t4000\n"
655                                               "RegisterUser\tREGISTER_USER=1 Or FULL=1\t6000\n"
656                                               "RegisterProduct\tREGISTER_PRODUCT=1 Or FULL=1\t6100\n"
657                                               "PublishFeatures\tPUBLISH_FEATURES=1 Or FULL=1\t6300\n"
658                                               "PublishProduct\tPUBLISH_PRODUCT=1 Or FULL=1\t6400\n"
659                                               "InstallFinalize\t\t6600";
660
661 static const CHAR ppc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
662                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
663                                         "Component\tComponent\n"
664                                         "maximus\t{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}\tMSITESTDIR\t0\tUILevel=5\tmaximus\n"
665                                         "augustus\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\taugustus\n";
666
667 static const CHAR ppc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
668                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
669                                    "File\tFile\n"
670                                    "maximus\tmaximus\tmaximus\t500\t\t\t8192\t1\n"
671                                    "augustus\taugustus\taugustus\t500\t\t\t8192\t2";
672
673 static const CHAR ppc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
674                                     "i2\ti4\tL64\tS255\tS32\tS72\n"
675                                     "Media\tDiskId\n"
676                                     "1\t2\t\t\tDISK1\t\n";
677
678 static const CHAR ppc_feature_comp_dat[] = "Feature_\tComponent_\n"
679                                            "s38\ts72\n"
680                                            "FeatureComponents\tFeature_\tComponent_\n"
681                                            "feature\tmaximus\n"
682                                            "feature\taugustus\n"
683                                            "montecristo\tmaximus";
684
685 static const CHAR tp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
686                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
687                                        "Component\tComponent\n"
688                                        "augustus\t\tMSITESTDIR\t0\tprop=\"val\"\taugustus\n";
689
690 static const CHAR cwd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
691                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
692                                         "Component\tComponent\n"
693                                         "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
694
695 static const CHAR adm_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
696                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
697                                         "Component\tComponent\n"
698                                         "augustus\t\tMSITESTDIR\t0\tPOSTADMIN=1\taugustus";
699
700 static const CHAR adm_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
701                                             "s72\ti2\tS64\tS0\tS255\n"
702                                             "CustomAction\tAction\n"
703                                             "SetPOSTADMIN\t51\tPOSTADMIN\t1\t\n";
704
705 static const CHAR adm_admin_exec_seq_dat[] = "Action\tCondition\tSequence\n"
706                                              "s72\tS255\tI2\n"
707                                              "AdminExecuteSequence\tAction\n"
708                                              "CostFinalize\t\t1000\n"
709                                              "CostInitialize\t\t800\n"
710                                              "FileCost\t\t900\n"
711                                              "SetPOSTADMIN\t\t950\n"
712                                              "InstallFiles\t\t4000\n"
713                                              "InstallFinalize\t\t6600\n"
714                                              "InstallInitialize\t\t1500\n"
715                                              "InstallValidate\t\t1400\n"
716                                              "LaunchConditions\t\t100";
717
718 static const CHAR amp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
719                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
720                                         "Component\tComponent\n"
721                                         "augustus\t\tMSITESTDIR\t0\tMYPROP=2718 and MyProp=42\taugustus\n";
722
723 static const CHAR rem_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
724                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
725                                         "Component\tComponent\n"
726                                         "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t0\t\thydrogen\n"
727                                         "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t1\t\thelium\n"
728                                         "lithium\t\tMSITESTDIR\t2\t\tlithium\n";
729
730 static const CHAR rem_feature_comp_dat[] = "Feature_\tComponent_\n"
731                                            "s38\ts72\n"
732                                            "FeatureComponents\tFeature_\tComponent_\n"
733                                            "feature\thydrogen\n"
734                                            "feature\thelium\n"
735                                            "feature\tlithium";
736
737 static const CHAR rem_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
738                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
739                                    "File\tFile\n"
740                                    "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
741                                    "helium\thelium\thelium\t0\t\t\t8192\t1\n"
742                                    "lithium\tlithium\tlithium\t0\t\t\t8192\t1";
743
744 static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
745                                                "s72\tS255\tI2\n"
746                                                "InstallExecuteSequence\tAction\n"
747                                                "ValidateProductID\t\t700\n"
748                                                "CostInitialize\t\t800\n"
749                                                "FileCost\t\t900\n"
750                                                "CostFinalize\t\t1000\n"
751                                                "InstallValidate\t\t1400\n"
752                                                "InstallInitialize\t\t1500\n"
753                                                "ProcessComponents\t\t1600\n"
754                                                "UnpublishFeatures\t\t1800\n"
755                                                "RemoveFiles\t\t3500\n"
756                                                "InstallFiles\t\t4000\n"
757                                                "RegisterProduct\t\t6100\n"
758                                                "PublishFeatures\t\t6300\n"
759                                                "PublishProduct\t\t6400\n"
760                                                "InstallFinalize\t\t6600";
761
762 static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
763                                            "s72\ts72\tS255\ts72\tI2\n"
764                                            "RemoveFile\tFileKey\n"
765                                            "furlong\thydrogen\tfurlong\tMSITESTDIR\t1\n"
766                                            "firkin\thelium\tfirkin\tMSITESTDIR\t1\n"
767                                            "fortnight\tlithium\tfortnight\tMSITESTDIR\t1\n"
768                                            "becquerel\thydrogen\tbecquerel\tMSITESTDIR\t2\n"
769                                            "dioptre\thelium\tdioptre\tMSITESTDIR\t2\n"
770                                            "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
771                                            "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
772                                            "block\thelium\tblock\tMSITESTDIR\t3\n"
773                                            "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n"
774                                            "nanoacre\thydrogen\t\tCABOUTDIR\t3\n";
775
776 static const CHAR mov_move_file_dat[] = "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
777                                         "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
778                                         "MoveFile\tFileKey\n"
779                                         "abkhazia\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t0\n"
780                                         "bahamas\taugustus\tnonexistent\tdest\tSourceDir\tMSITESTDIR\t1\n"
781                                         "cambodia\taugustus\tcameroon\tcanada\tSourceDir\tMSITESTDIR\t0\n"
782                                         "denmark\taugustus\tdjibouti\tdominica\tSourceDir\tMSITESTDIR\t1\n"
783                                         "ecuador\taugustus\tegypt\telsalvador\tNotAProp\tMSITESTDIR\t1\n"
784                                         "fiji\taugustus\tfinland\tfrance\tSourceDir\tNotAProp\t1\n"
785                                         "gabon\taugustus\tgambia\tgeorgia\tSOURCEFULL\tMSITESTDIR\t1\n"
786                                         "haiti\taugustus\thonduras\thungary\tSourceDir\tDESTFULL\t1\n"
787                                         "iceland\taugustus\tindia\tindonesia\tMSITESTDIR\tMSITESTDIR\t1\n"
788                                         "jamaica\taugustus\tjapan\tjordan\tFILEPATHBAD\tMSITESTDIR\t1\n"
789                                         "kazakhstan\taugustus\t\tkiribati\tFILEPATHGOOD\tMSITESTDIR\t1\n"
790                                         "laos\taugustus\tlatvia\tlebanon\tSourceDir\tMSITESTDIR\t1\n"
791                                         "namibia\taugustus\tnauru\tkiribati\tSourceDir\tMSITESTDIR\t1\n"
792                                         "pakistan\taugustus\tperu\tsfn|poland\tSourceDir\tMSITESTDIR\t1\n"
793                                         "wildcard\taugustus\tapp*\twildcard\tSourceDir\tMSITESTDIR\t1\n"
794                                         "single\taugustus\tf?o\tsingle\tSourceDir\tMSITESTDIR\t1\n"
795                                         "wildcardnodest\taugustus\tbudd*\t\tSourceDir\tMSITESTDIR\t1\n"
796                                         "singlenodest\taugustus\tb?r\t\tSourceDir\tMSITESTDIR\t1\n";
797
798 static const CHAR mc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
799                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
800                                         "Component\tComponent\n"
801                                         "maximus\t\tMSITESTDIR\t0\t1\tmaximus\n"
802                                         "augustus\t\tMSITESTDIR\t0\t1\taugustus\n"
803                                         "caesar\t\tMSITESTDIR\t0\t1\tcaesar\n"
804                                         "gaius\t\tMSITESTDIR\t0\tGAIUS=1\tgaius\n";
805
806 static const CHAR mc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
807                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
808                                   "File\tFile\n"
809                                   "maximus\tmaximus\tmaximus\t500\t\t\t16384\t1\n"
810                                   "augustus\taugustus\taugustus\t500\t\t\t0\t2\n"
811                                   "caesar\tcaesar\tcaesar\t500\t\t\t16384\t3\n"
812                                   "gaius\tgaius\tgaius\t500\t\t\t16384\t4";
813
814 static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
815                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
816                                    "Media\tDiskId\n"
817                                    "1\t1\t\ttest1.cab\tDISK1\t\n"
818                                    "2\t2\t\ttest2.cab\tDISK2\t\n"
819                                    "3\t3\t\ttest3.cab\tDISK3\t\n"
820                                    "4\t4\t\ttest3.cab\tDISK3\t\n";
821
822 static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n"
823                                        "s72\ti2\ti4\ti4\ti4\ti4\n"
824                                        "MsiFileHash\tFile_\n"
825                                        "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824";
826
827 static const CHAR df_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
828                                        "s72\tS72\tl255\n"
829                                        "Directory\tDirectory\n"
830                                        "THIS\tMSITESTDIR\tthis\n"
831                                        "DOESNOT\tTHIS\tdoesnot\n"
832                                        "NONEXISTENT\tDOESNOT\texist\n"
833                                        "MSITESTDIR\tProgramFilesFolder\tmsitest\n"
834                                        "ProgramFilesFolder\tTARGETDIR\t.\n"
835                                        "TARGETDIR\t\tSourceDir";
836
837 static const CHAR df_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
838                                             "s72\ts72\ts72\tS255\tS72\n"
839                                             "DuplicateFile\tFileKey\n"
840                                             "maximus\tmaximus\tmaximus\taugustus\t\n"
841                                             "caesar\tmaximus\tmaximus\t\tNONEXISTENT\n"
842                                             "augustus\tnosuchcomponent\tmaximus\t\tMSITESTDIR\n";
843
844 static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
845                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
846                                         "Component\tComponent\n"
847                                         "augustus\t\tMSITESTDIR\t0\t\taugustus\n";
848
849 static const CHAR wrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
850                                        "s72\ti2\tl255\tL255\tL0\ts72\n"
851                                        "Registry\tRegistry\n"
852                                        "regdata\t2\tSOFTWARE\\Wine\\msitest\tValue\t[~]one[~]two[~]three\taugustus";
853
854 static const CHAR ca51_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
855                                          "s72\tS38\ts72\ti2\tS255\tS72\n"
856                                          "Component\tComponent\n"
857                                          "augustus\t\tMSITESTDIR\t0\tMYPROP=42\taugustus\n";
858
859 static const CHAR ca51_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
860                                                 "s72\tS255\tI2\n"
861                                                 "InstallExecuteSequence\tAction\n"
862                                                 "ValidateProductID\t\t700\n"
863                                                 "GoodSetProperty\t\t725\n"
864                                                 "BadSetProperty\t\t750\n"
865                                                 "CostInitialize\t\t800\n"
866                                                 "ResolveSource\t\t810\n"
867                                                 "FileCost\t\t900\n"
868                                                 "SetSourceDir\tSRCDIR\t910\n"
869                                                 "CostFinalize\t\t1000\n"
870                                                 "InstallValidate\t\t1400\n"
871                                                 "InstallInitialize\t\t1500\n"
872                                                 "InstallFiles\t\t4000\n"
873                                                 "InstallFinalize\t\t6600";
874
875 static const CHAR ca51_custom_action_dat[] = "Action\tType\tSource\tTarget\n"
876                                              "s72\ti2\tS64\tS0\n"
877                                              "CustomAction\tAction\n"
878                                              "GoodSetProperty\t51\tMYPROP\t42\n"
879                                              "BadSetProperty\t51\t\tMYPROP\n"
880                                              "SetSourceDir\t51\tSourceDir\t[SRCDIR]\n";
881
882 static const CHAR is_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
883                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
884                                      "Feature\tFeature\n"
885                                      "one\t\t\t\t2\t1\t\t0\n" /* favorLocal */
886                                      "two\t\t\t\t2\t1\t\t1\n" /* favorSource */
887                                      "three\t\t\t\t2\t1\t\t4\n" /* favorAdvertise */
888                                      "four\t\t\t\t2\t0\t\t0"; /* disabled */
889
890 static const CHAR is_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
891                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
892                                        "Component\tComponent\n"
893                                        "alpha\t\tMSITESTDIR\t0\t\talpha_file\n" /* favorLocal:Local */
894                                        "beta\t\tMSITESTDIR\t1\t\tbeta_file\n" /* favorLocal:Source */
895                                        "gamma\t\tMSITESTDIR\t2\t\tgamma_file\n" /* favorLocal:Optional */
896                                        "theta\t\tMSITESTDIR\t0\t\ttheta_file\n" /* favorSource:Local */
897                                        "delta\t\tMSITESTDIR\t1\t\tdelta_file\n" /* favorSource:Source */
898                                        "epsilon\t\tMSITESTDIR\t2\t\tepsilon_file\n" /* favorSource:Optional */
899                                        "zeta\t\tMSITESTDIR\t0\t\tzeta_file\n" /* favorAdvertise:Local */
900                                        "iota\t\tMSITESTDIR\t1\t\tiota_file\n" /* favorAdvertise:Source */
901                                        "eta\t\tMSITESTDIR\t2\t\teta_file\n" /* favorAdvertise:Optional */
902                                        "kappa\t\tMSITESTDIR\t0\t\tkappa_file\n" /* disabled:Local */
903                                        "lambda\t\tMSITESTDIR\t1\t\tlambda_file\n" /* disabled:Source */
904                                        "mu\t\tMSITESTDIR\t2\t\tmu_file\n"; /* disabled:Optional */
905
906 static const CHAR is_feature_comp_dat[] = "Feature_\tComponent_\n"
907                                           "s38\ts72\n"
908                                           "FeatureComponents\tFeature_\tComponent_\n"
909                                           "one\talpha\n"
910                                           "one\tbeta\n"
911                                           "one\tgamma\n"
912                                           "two\ttheta\n"
913                                           "two\tdelta\n"
914                                           "two\tepsilon\n"
915                                           "three\tzeta\n"
916                                           "three\tiota\n"
917                                           "three\teta\n"
918                                           "four\tkappa\n"
919                                           "four\tlambda\n"
920                                           "four\tmu";
921
922 static const CHAR is_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
923                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
924                                   "File\tFile\n"
925                                   "alpha_file\talpha\talpha\t500\t\t\t8192\t1\n"
926                                   "beta_file\tbeta\tbeta\t500\t\t\t8291\t2\n"
927                                   "gamma_file\tgamma\tgamma\t500\t\t\t8192\t3\n"
928                                   "theta_file\ttheta\ttheta\t500\t\t\t8192\t4\n"
929                                   "delta_file\tdelta\tdelta\t500\t\t\t8192\t5\n"
930                                   "epsilon_file\tepsilon\tepsilon\t500\t\t\t8192\t6\n"
931                                   "zeta_file\tzeta\tzeta\t500\t\t\t8192\t7\n"
932                                   "iota_file\tiota\tiota\t500\t\t\t8192\t8\n"
933                                   "eta_file\teta\teta\t500\t\t\t8192\t9\n"
934                                   "kappa_file\tkappa\tkappa\t500\t\t\t8192\t10\n"
935                                   "lambda_file\tlambda\tlambda\t500\t\t\t8192\t11\n"
936                                   "mu_file\tmu\tmu\t500\t\t\t8192\t12";
937
938 static const CHAR is_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
939                                    "i2\ti4\tL64\tS255\tS32\tS72\n"
940                                    "Media\tDiskId\n"
941                                    "1\t12\t\t\tDISK1\t\n";
942
943 static const CHAR sp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
944                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
945                                         "Component\tComponent\n"
946                                         "augustus\t\tTWODIR\t0\t\taugustus\n";
947
948 static const CHAR sp_directory_dat[] = "Directory\tDirectory_Parent\tDefaultDir\n"
949                                        "s72\tS72\tl255\n"
950                                        "Directory\tDirectory\n"
951                                        "TARGETDIR\t\tSourceDir\n"
952                                        "ProgramFilesFolder\tTARGETDIR\t.\n"
953                                        "MSITESTDIR\tProgramFilesFolder\tmsitest:.\n"
954                                        "ONEDIR\tMSITESTDIR\t.:shortone|longone\n"
955                                        "TWODIR\tONEDIR\t.:shorttwo|longtwo";
956
957 static const CHAR mcp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
958                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
959                                         "Component\tComponent\n"
960                                         "hydrogen\t{C844BD1E-1907-4C00-8BC9-150BD70DF0A1}\tMSITESTDIR\t2\t\thydrogen\n"
961                                         "helium\t{5AD3C142-CEF8-490D-B569-784D80670685}\tMSITESTDIR\t2\t\thelium\n"
962                                         "lithium\t{4AF28FFC-71C7-4307-BDE4-B77C5338F56F}\tMSITESTDIR\t2\tPROPVAR=42\tlithium\n";
963
964 static const CHAR mcp_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
965                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
966                                       "Feature\tFeature\n"
967                                       "hydroxyl\t\thydroxyl\thydroxyl\t2\t1\tTARGETDIR\t0\n"
968                                       "heliox\t\theliox\theliox\t2\t5\tTARGETDIR\t0\n"
969                                       "lithia\t\tlithia\tlithia\t2\t10\tTARGETDIR\t0";
970
971 static const CHAR mcp_feature_comp_dat[] = "Feature_\tComponent_\n"
972                                            "s38\ts72\n"
973                                            "FeatureComponents\tFeature_\tComponent_\n"
974                                            "hydroxyl\thydrogen\n"
975                                            "heliox\thelium\n"
976                                            "lithia\tlithium";
977
978 static const CHAR mcomp_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
979                                      "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
980                                      "File\tFile\n"
981                                      "hydrogen\thydrogen\thydrogen\t0\t\t\t8192\t1\n"
982                                      "helium\thelium\thelium\t0\t\t\t8192\t1\n"
983                                      "lithium\tlithium\tlithium\t0\t\t\t8192\t1\n"
984                                      "beryllium\tmissingcomp\tberyllium\t0\t\t\t8192\t1";
985
986 static const CHAR ai_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
987                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
988                                   "File\tFile\n"
989                                   "five.txt\tFive\tfive.txt\t1000\t\t\t16384\t5\n"
990                                   "four.txt\tFour\tfour.txt\t1000\t\t\t16384\t4\n"
991                                   "one.txt\tOne\tone.txt\t1000\t\t\t16384\t1\n"
992                                   "three.txt\tThree\tthree.txt\t1000\t\t\t16384\t3\n"
993                                   "two.txt\tTwo\ttwo.txt\t1000\t\t\t16384\t2\n"
994                                   "file\tcomponent\tfilename\t100\t\t\t8192\t1\n"
995                                   "service_file\tservice_comp\tservice.exe\t100\t\t\t8192\t1";
996
997 static const CHAR ip_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
998                                               "s72\tS255\tI2\n"
999                                               "InstallExecuteSequence\tAction\n"
1000                                               "CostFinalize\t\t1000\n"
1001                                               "ValidateProductID\t\t700\n"
1002                                               "CostInitialize\t\t800\n"
1003                                               "FileCost\t\t900\n"
1004                                               "RemoveFiles\t\t3500\n"
1005                                               "InstallFiles\t\t4000\n"
1006                                               "RegisterUser\t\t6000\n"
1007                                               "RegisterProduct\t\t6100\n"
1008                                               "PublishFeatures\t\t6300\n"
1009                                               "PublishProduct\t\t6400\n"
1010                                               "InstallFinalize\t\t6600\n"
1011                                               "InstallInitialize\t\t1500\n"
1012                                               "ProcessComponents\t\t1600\n"
1013                                               "UnpublishFeatures\t\t1800\n"
1014                                               "InstallValidate\t\t1400\n"
1015                                               "LaunchConditions\t\t100\n"
1016                                               "TestInstalledProp\tInstalled AND NOT REMOVE\t950\n";
1017
1018 static const CHAR ip_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1019                                            "s72\ti2\tS64\tS0\tS255\n"
1020                                            "CustomAction\tAction\n"
1021                                            "TestInstalledProp\t19\t\tTest failed\t\n";
1022
1023 static const CHAR aup_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1024                                                "s72\tS255\tI2\n"
1025                                                "InstallExecuteSequence\tAction\n"
1026                                                "CostFinalize\t\t1000\n"
1027                                                "ValidateProductID\t\t700\n"
1028                                                "CostInitialize\t\t800\n"
1029                                                "FileCost\t\t900\n"
1030                                                "RemoveFiles\t\t3500\n"
1031                                                "InstallFiles\t\t4000\n"
1032                                                "RegisterUser\t\t6000\n"
1033                                                "RegisterProduct\t\t6100\n"
1034                                                "PublishFeatures\t\t6300\n"
1035                                                "PublishProduct\t\t6400\n"
1036                                                "InstallFinalize\t\t6600\n"
1037                                                "InstallInitialize\t\t1500\n"
1038                                                "ProcessComponents\t\t1600\n"
1039                                                "UnpublishFeatures\t\t1800\n"
1040                                                "InstallValidate\t\t1400\n"
1041                                                "LaunchConditions\t\t100\n"
1042                                                "TestAllUsersProp\tALLUSERS AND NOT REMOVE\t50\n";
1043
1044 static const CHAR aup2_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1045                                                 "s72\tS255\tI2\n"
1046                                                 "InstallExecuteSequence\tAction\n"
1047                                                 "CostFinalize\t\t1000\n"
1048                                                 "ValidateProductID\t\t700\n"
1049                                                 "CostInitialize\t\t800\n"
1050                                                 "FileCost\t\t900\n"
1051                                                 "RemoveFiles\t\t3500\n"
1052                                                 "InstallFiles\t\t4000\n"
1053                                                 "RegisterUser\t\t6000\n"
1054                                                 "RegisterProduct\t\t6100\n"
1055                                                 "PublishFeatures\t\t6300\n"
1056                                                 "PublishProduct\t\t6400\n"
1057                                                 "InstallFinalize\t\t6600\n"
1058                                                 "InstallInitialize\t\t1500\n"
1059                                                 "ProcessComponents\t\t1600\n"
1060                                                 "UnpublishFeatures\t\t1800\n"
1061                                                 "InstallValidate\t\t1400\n"
1062                                                 "LaunchConditions\t\t100\n"
1063                                                 "TestAllUsersProp\tALLUSERS=2 AND NOT REMOVE\t50\n";
1064
1065 static const CHAR aup3_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1066                                                 "s72\tS255\tI2\n"
1067                                                 "InstallExecuteSequence\tAction\n"
1068                                                 "CostFinalize\t\t1000\n"
1069                                                 "ValidateProductID\t\t700\n"
1070                                                 "CostInitialize\t\t800\n"
1071                                                 "FileCost\t\t900\n"
1072                                                 "RemoveFiles\t\t3500\n"
1073                                                 "InstallFiles\t\t4000\n"
1074                                                 "RegisterUser\t\t6000\n"
1075                                                 "RegisterProduct\t\t6100\n"
1076                                                 "PublishFeatures\t\t6300\n"
1077                                                 "PublishProduct\t\t6400\n"
1078                                                 "InstallFinalize\t\t6600\n"
1079                                                 "InstallInitialize\t\t1500\n"
1080                                                 "ProcessComponents\t\t1600\n"
1081                                                 "UnpublishFeatures\t\t1800\n"
1082                                                 "InstallValidate\t\t1400\n"
1083                                                 "LaunchConditions\t\t100\n"
1084                                                 "TestAllUsersProp\tALLUSERS=1 AND NOT REMOVE\t50\n";
1085
1086 static const CHAR aup_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1087                                             "s72\ti2\tS64\tS0\tS255\n"
1088                                             "CustomAction\tAction\n"
1089                                             "TestAllUsersProp\t19\t\tTest failed\t\n";
1090
1091 static const CHAR cf_create_folders_dat[] = "Directory_\tComponent_\n"
1092                                             "s72\ts72\n"
1093                                             "CreateFolder\tDirectory_\tComponent_\n"
1094                                             "FIRSTDIR\tOne\n";
1095
1096 static const CHAR cf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1097                                               "s72\tS255\tI2\n"
1098                                               "InstallExecuteSequence\tAction\n"
1099                                               "CostFinalize\t\t1000\n"
1100                                               "ValidateProductID\t\t700\n"
1101                                               "CostInitialize\t\t800\n"
1102                                               "FileCost\t\t900\n"
1103                                               "RemoveFiles\t\t3500\n"
1104                                               "CreateFolders\t\t3700\n"
1105                                               "InstallExecute\t\t3800\n"
1106                                               "TestCreateFolders\t\t3900\n"
1107                                               "InstallFiles\t\t4000\n"
1108                                               "RegisterUser\t\t6000\n"
1109                                               "RegisterProduct\t\t6100\n"
1110                                               "PublishFeatures\t\t6300\n"
1111                                               "PublishProduct\t\t6400\n"
1112                                               "InstallFinalize\t\t6600\n"
1113                                               "InstallInitialize\t\t1500\n"
1114                                               "ProcessComponents\t\t1600\n"
1115                                               "UnpublishFeatures\t\t1800\n"
1116                                               "InstallValidate\t\t1400\n"
1117                                               "LaunchConditions\t\t100\n";
1118
1119 static const CHAR cf_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1120                                            "s72\ti2\tS64\tS0\tS255\n"
1121                                            "CustomAction\tAction\n"
1122                                            "TestCreateFolders\t19\t\tHalts installation\t\n";
1123
1124 static const CHAR rf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1125                                               "s72\tS255\tI2\n"
1126                                               "InstallExecuteSequence\tAction\n"
1127                                               "CostFinalize\t\t1000\n"
1128                                               "ValidateProductID\t\t700\n"
1129                                               "CostInitialize\t\t800\n"
1130                                               "FileCost\t\t900\n"
1131                                               "RemoveFiles\t\t3500\n"
1132                                               "CreateFolders\t\t3600\n"
1133                                               "RemoveFolders\t\t3700\n"
1134                                               "InstallExecute\t\t3800\n"
1135                                               "TestCreateFolders\t\t3900\n"
1136                                               "InstallFiles\t\t4000\n"
1137                                               "RegisterUser\t\t6000\n"
1138                                               "RegisterProduct\t\t6100\n"
1139                                               "PublishFeatures\t\t6300\n"
1140                                               "PublishProduct\t\t6400\n"
1141                                               "InstallFinalize\t\t6600\n"
1142                                               "InstallInitialize\t\t1500\n"
1143                                               "ProcessComponents\t\t1600\n"
1144                                               "UnpublishFeatures\t\t1800\n"
1145                                               "InstallValidate\t\t1400\n"
1146                                               "LaunchConditions\t\t100\n";
1147
1148
1149 static const CHAR sr_selfreg_dat[] = "File_\tCost\n"
1150                                      "s72\tI2\n"
1151                                      "SelfReg\tFile_\n"
1152                                      "one.txt\t1\n";
1153
1154 static const CHAR sr_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1155                                               "s72\tS255\tI2\n"
1156                                               "InstallExecuteSequence\tAction\n"
1157                                               "CostFinalize\t\t1000\n"
1158                                               "CostInitialize\t\t800\n"
1159                                               "FileCost\t\t900\n"
1160                                               "ResolveSource\t\t950\n"
1161                                               "MoveFiles\t\t1700\n"
1162                                               "SelfUnregModules\t\t3900\n"
1163                                               "InstallFiles\t\t4000\n"
1164                                               "DuplicateFiles\t\t4500\n"
1165                                               "WriteEnvironmentStrings\t\t4550\n"
1166                                               "CreateShortcuts\t\t4600\n"
1167                                               "InstallFinalize\t\t6600\n"
1168                                               "InstallInitialize\t\t1500\n"
1169                                               "InstallValidate\t\t1400\n"
1170                                               "LaunchConditions\t\t100\n";
1171
1172 static const CHAR font_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
1173                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
1174                                      "Media\tDiskId\n"
1175                                      "1\t3\t\t\tDISK1\t\n";
1176
1177 static const CHAR font_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1178                                     "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1179                                     "File\tFile\n"
1180                                     "font.ttf\tfonts\tfont.ttf\t1000\t\t\t8192\t1\n";
1181
1182 static const CHAR font_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1183                                        "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1184                                        "Feature\tFeature\n"
1185                                        "fonts\t\t\tfont feature\t1\t2\tMSITESTDIR\t0\n";
1186
1187 static const CHAR font_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1188                                          "s72\tS38\ts72\ti2\tS255\tS72\n"
1189                                          "Component\tComponent\n"
1190                                          "fonts\t{F5920ED0-1183-4B8F-9330-86CE56557C05}\tMSITESTDIR\t0\t\tfont.ttf\n";
1191
1192 static const CHAR font_feature_comp_dat[] = "Feature_\tComponent_\n"
1193                                             "s38\ts72\n"
1194                                             "FeatureComponents\tFeature_\tComponent_\n"
1195                                             "fonts\tfonts\n";
1196
1197 static const CHAR font_dat[] = "File_\tFontTitle\n"
1198                                "s72\tS128\n"
1199                                "Font\tFile_\n"
1200                                "font.ttf\tmsi test font\n";
1201
1202 static const CHAR font_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1203                                                 "s72\tS255\tI2\n"
1204                                                 "InstallExecuteSequence\tAction\n"
1205                                                 "ValidateProductID\t\t700\n"
1206                                                 "CostInitialize\t\t800\n"
1207                                                 "FileCost\t\t900\n"
1208                                                 "CostFinalize\t\t1000\n"
1209                                                 "InstallValidate\t\t1400\n"
1210                                                 "InstallInitialize\t\t1500\n"
1211                                                 "ProcessComponents\t\t1600\n"
1212                                                 "UnpublishFeatures\t\t1800\n"
1213                                                 "RemoveFiles\t\t3500\n"
1214                                                 "InstallFiles\t\t4000\n"
1215                                                 "RegisterFonts\t\t4100\n"
1216                                                 "UnregisterFonts\t\t4200\n"
1217                                                 "RegisterUser\t\t6000\n"
1218                                                 "RegisterProduct\t\t6100\n"
1219                                                 "PublishFeatures\t\t6300\n"
1220                                                 "PublishProduct\t\t6400\n"
1221                                                 "InstallFinalize\t\t6600";
1222
1223 static const CHAR vp_property_dat[] = "Property\tValue\n"
1224                                       "s72\tl0\n"
1225                                       "Property\tProperty\n"
1226                                       "HASUIRUN\t0\n"
1227                                       "INSTALLLEVEL\t3\n"
1228                                       "InstallMode\tTypical\n"
1229                                       "Manufacturer\tWine\n"
1230                                       "PIDTemplate\t###-#######\n"
1231                                       "ProductCode\t{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}\n"
1232                                       "ProductLanguage\t1033\n"
1233                                       "ProductName\tMSITEST\n"
1234                                       "ProductVersion\t1.1.1\n"
1235                                       "UpgradeCode\t{4C0EAA15-0264-4E5A-8758-609EF142B92D}\n";
1236
1237 static const CHAR vp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1238                                            "s72\ti2\tS64\tS0\tS255\n"
1239                                            "CustomAction\tAction\n"
1240                                            "SetProductID1\t51\tProductID\t1\t\n"
1241                                            "SetProductID2\t51\tProductID\t2\t\n"
1242                                            "TestProductID1\t19\t\t\tHalts installation\n"
1243                                            "TestProductID2\t19\t\t\tHalts installation\n";
1244
1245 static const CHAR vp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1246                                               "s72\tS255\tI2\n"
1247                                               "InstallExecuteSequence\tAction\n"
1248                                               "LaunchConditions\t\t100\n"
1249                                               "CostInitialize\t\t800\n"
1250                                               "FileCost\t\t900\n"
1251                                               "CostFinalize\t\t1000\n"
1252                                               "InstallValidate\t\t1400\n"
1253                                               "InstallInitialize\t\t1500\n"
1254                                               "SetProductID1\tSET_PRODUCT_ID=1\t3000\n"
1255                                               "SetProductID2\tSET_PRODUCT_ID=2\t3100\n"
1256                                               "ValidateProductID\t\t3200\n"
1257                                               "InstallExecute\t\t3300\n"
1258                                               "TestProductID1\tProductID=1\t3400\n"
1259                                               "TestProductID2\tProductID=\"123-1234567\"\t3500\n"
1260                                               "InstallFiles\t\t4000\n"
1261                                               "InstallFinalize\t\t6000\n";
1262
1263 static const CHAR odbc_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1264                                     "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1265                                     "File\tFile\n"
1266                                     "ODBCdriver.dll\todbc\tODBCdriver.dll\t1000\t\t\t8192\t1\n"
1267                                     "ODBCdriver2.dll\todbc\tODBCdriver2.dll\t1000\t\t\t8192\t2\n"
1268                                     "ODBCtranslator.dll\todbc\tODBCtranslator.dll\t1000\t\t\t8192\t3\n"
1269                                     "ODBCtranslator2.dll\todbc\tODBCtranslator2.dll\t1000\t\t\t8192\t4\n"
1270                                     "ODBCsetup.dll\todbc\tODBCsetup.dll\t1000\t\t\t8192\t5\n";
1271
1272 static const CHAR odbc_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1273                                        "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1274                                        "Feature\tFeature\n"
1275                                        "odbc\t\t\todbc feature\t1\t2\tMSITESTDIR\t0\n";
1276
1277 static const CHAR odbc_feature_comp_dat[] = "Feature_\tComponent_\n"
1278                                             "s38\ts72\n"
1279                                             "FeatureComponents\tFeature_\tComponent_\n"
1280                                             "odbc\todbc\n";
1281
1282 static const CHAR odbc_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1283                                          "s72\tS38\ts72\ti2\tS255\tS72\n"
1284                                          "Component\tComponent\n"
1285                                          "odbc\t{B6F3E4AE-35D1-4B72-9044-989F03E20A43}\tMSITESTDIR\t0\t\tODBCdriver.dll\n";
1286
1287 static const CHAR odbc_driver_dat[] = "Driver\tComponent_\tDescription\tFile_\tFile_Setup\n"
1288                                       "s72\ts72\ts255\ts72\tS72\n"
1289                                       "ODBCDriver\tDriver\n"
1290                                       "ODBC test driver\todbc\tODBC test driver\tODBCdriver.dll\t\n"
1291                                       "ODBC test driver2\todbc\tODBC test driver2\tODBCdriver2.dll\tODBCsetup.dll\n";
1292
1293 static const CHAR odbc_translator_dat[] = "Translator\tComponent_\tDescription\tFile_\tFile_Setup\n"
1294                                           "s72\ts72\ts255\ts72\tS72\n"
1295                                           "ODBCTranslator\tTranslator\n"
1296                                           "ODBC test translator\todbc\tODBC test translator\tODBCtranslator.dll\t\n"
1297                                           "ODBC test translator2\todbc\tODBC test translator2\tODBCtranslator2.dll\tODBCsetup.dll\n";
1298
1299 static const CHAR odbc_datasource_dat[] = "DataSource\tComponent_\tDescription\tDriverDescription\tRegistration\n"
1300                                           "s72\ts72\ts255\ts255\ti2\n"
1301                                           "ODBCDataSource\tDataSource\n"
1302                                           "ODBC data source\todbc\tODBC data source\tODBC driver\t0\n";
1303
1304 static const CHAR odbc_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1305                                                 "s72\tS255\tI2\n"
1306                                                 "InstallExecuteSequence\tAction\n"
1307                                                 "LaunchConditions\t\t100\n"
1308                                                 "CostInitialize\t\t800\n"
1309                                                 "FileCost\t\t900\n"
1310                                                 "CostFinalize\t\t1000\n"
1311                                                 "InstallValidate\t\t1400\n"
1312                                                 "InstallInitialize\t\t1500\n"
1313                                                 "ProcessComponents\t\t1600\n"
1314                                                 "InstallODBC\t\t3000\n"
1315                                                 "RemoveODBC\t\t3100\n"
1316                                                 "RemoveFiles\t\t3900\n"
1317                                                 "InstallFiles\t\t4000\n"
1318                                                 "RegisterProduct\t\t5000\n"
1319                                                 "PublishFeatures\t\t5100\n"
1320                                                 "PublishProduct\t\t5200\n"
1321                                                 "InstallFinalize\t\t6000\n";
1322
1323 static const CHAR odbc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n"
1324                                      "i2\ti4\tL64\tS255\tS32\tS72\n"
1325                                      "Media\tDiskId\n"
1326                                      "1\t5\t\t\tDISK1\t\n";
1327
1328 static const CHAR tl_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1329                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1330                                   "File\tFile\n"
1331                                   "typelib.dll\ttypelib\ttypelib.dll\t1000\t\t\t8192\t1\n";
1332
1333 static const CHAR tl_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1334                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1335                                      "Feature\tFeature\n"
1336                                      "typelib\t\t\ttypelib feature\t1\t2\tMSITESTDIR\t0\n";
1337
1338 static const CHAR tl_feature_comp_dat[] = "Feature_\tComponent_\n"
1339                                           "s38\ts72\n"
1340                                           "FeatureComponents\tFeature_\tComponent_\n"
1341                                           "typelib\ttypelib\n";
1342
1343 static const CHAR tl_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1344                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
1345                                        "Component\tComponent\n"
1346                                        "typelib\t{BB4C26FD-89D8-4E49-AF1C-DB4DCB5BF1B0}\tMSITESTDIR\t0\t\ttypelib.dll\n";
1347
1348 static const CHAR tl_typelib_dat[] = "LibID\tLanguage\tComponent_\tVersion\tDescription\tDirectory_\tFeature_\tCost\n"
1349                                      "s38\ti2\ts72\tI4\tL128\tS72\ts38\tI4\n"
1350                                      "TypeLib\tLibID\tLanguage\tComponent_\n"
1351                                      "{EAC5166A-9734-4D91-878F-1DD02304C66C}\t0\ttypelib\t1793\t\tMSITESTDIR\ttypelib\t\n";
1352
1353 static const CHAR tl_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1354                                               "s72\tS255\tI2\n"
1355                                               "InstallExecuteSequence\tAction\n"
1356                                               "LaunchConditions\t\t100\n"
1357                                               "CostInitialize\t\t800\n"
1358                                               "FileCost\t\t900\n"
1359                                               "CostFinalize\t\t1000\n"
1360                                               "InstallValidate\t\t1400\n"
1361                                               "InstallInitialize\t\t1500\n"
1362                                               "ProcessComponents\t\t1600\n"
1363                                               "RemoveFiles\t\t1700\n"
1364                                               "InstallFiles\t\t2000\n"
1365                                               "RegisterTypeLibraries\tREGISTER_TYPELIB=1\t3000\n"
1366                                               "UnregisterTypeLibraries\t\t3100\n"
1367                                               "RegisterProduct\t\t5100\n"
1368                                               "PublishFeatures\t\t5200\n"
1369                                               "PublishProduct\t\t5300\n"
1370                                               "InstallFinalize\t\t6000\n";
1371
1372 static const CHAR crs_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1373                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1374                                    "File\tFile\n"
1375                                    "target.txt\tshortcut\ttarget.txt\t1000\t\t\t8192\t1\n";
1376
1377 static const CHAR crs_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1378                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1379                                       "Feature\tFeature\n"
1380                                       "shortcut\t\t\tshortcut feature\t1\t2\tMSITESTDIR\t0\n";
1381
1382 static const CHAR crs_feature_comp_dat[] = "Feature_\tComponent_\n"
1383                                            "s38\ts72\n"
1384                                            "FeatureComponents\tFeature_\tComponent_\n"
1385                                            "shortcut\tshortcut\n";
1386
1387 static const CHAR crs_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1388                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1389                                         "Component\tComponent\n"
1390                                         "shortcut\t{5D20E3C6-7206-498F-AC28-87AF2F9AD4CC}\tMSITESTDIR\t0\t\ttarget.txt\n";
1391
1392 static const CHAR crs_shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n"
1393                                        "s72\ts72\tl128\ts72\ts72\tL255\tL255\tI2\tS72\tI2\tI2\tS72\n"
1394                                        "Shortcut\tShortcut\n"
1395                                        "shortcut\tMSITESTDIR\tshortcut\tshortcut\t[MSITESTDIR]target.txt\t\t\t\t\t\t\t\n";
1396
1397 static const CHAR crs_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1398                                                "s72\tS255\tI2\n"
1399                                                "InstallExecuteSequence\tAction\n"
1400                                                "LaunchConditions\t\t100\n"
1401                                                "CostInitialize\t\t800\n"
1402                                                "FileCost\t\t900\n"
1403                                                "CostFinalize\t\t1000\n"
1404                                                "InstallValidate\t\t1400\n"
1405                                                "InstallInitialize\t\t1500\n"
1406                                                "ProcessComponents\t\t1600\n"
1407                                                "RemoveFiles\t\t1700\n"
1408                                                "InstallFiles\t\t2000\n"
1409                                                "RemoveShortcuts\t\t3000\n"
1410                                                "CreateShortcuts\t\t3100\n"
1411                                                "RegisterProduct\t\t5000\n"
1412                                                "PublishFeatures\t\t5100\n"
1413                                                "PublishProduct\t\t5200\n"
1414                                                "InstallFinalize\t\t6000\n";
1415
1416 static const CHAR pub_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1417                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1418                                    "File\tFile\n"
1419                                    "english.txt\tpublish\tenglish.txt\t1000\t\t\t8192\t1\n";
1420
1421 static const CHAR pub_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1422                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1423                                       "Feature\tFeature\n"
1424                                       "publish\t\t\tpublish feature\t1\t2\tMSITESTDIR\t0\n";
1425
1426 static const CHAR pub_feature_comp_dat[] = "Feature_\tComponent_\n"
1427                                            "s38\ts72\n"
1428                                            "FeatureComponents\tFeature_\tComponent_\n"
1429                                            "publish\tpublish\n";
1430
1431 static const CHAR pub_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1432                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1433                                         "Component\tComponent\n"
1434                                         "publish\t{B4EA0ACF-6238-426E-9C6D-7869F0F9C768}\tMSITESTDIR\t0\t\tenglish.txt\n";
1435
1436 static const CHAR pub_publish_component_dat[] = "ComponentId\tQualifier\tComponent_\tAppData\tFeature_\n"
1437                                                 "s38\ts255\ts72\tL255\ts38\n"
1438                                                 "PublishComponent\tComponentId\tQualifier\tComponent_\n"
1439                                                 "{92AFCBC0-9CA6-4270-8454-47C5EE2B8FAA}\tenglish.txt\tpublish\t\tpublish\n";
1440
1441 static const CHAR pub_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1442                                                "s72\tS255\tI2\n"
1443                                                "InstallExecuteSequence\tAction\n"
1444                                                "LaunchConditions\t\t100\n"
1445                                                "CostInitialize\t\t800\n"
1446                                                "FileCost\t\t900\n"
1447                                                "CostFinalize\t\t1000\n"
1448                                                "InstallValidate\t\t1400\n"
1449                                                "InstallInitialize\t\t1500\n"
1450                                                "ProcessComponents\t\t1600\n"
1451                                                "RemoveFiles\t\t1700\n"
1452                                                "InstallFiles\t\t2000\n"
1453                                                "PublishComponents\t\t3000\n"
1454                                                "UnpublishComponents\t\t3100\n"
1455                                                "RegisterProduct\t\t5000\n"
1456                                                "PublishFeatures\t\t5100\n"
1457                                                "PublishProduct\t\t5200\n"
1458                                                "InstallFinalize\t\t6000\n";
1459
1460 static const CHAR rd_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1461                                   "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1462                                   "File\tFile\n"
1463                                   "original.txt\tduplicate\toriginal.txt\t1000\t\t\t8192\t1\n"
1464                                   "original2.txt\tduplicate\toriginal2.txt\t1000\t\t\t8192\t2\n"
1465                                   "original3.txt\tduplicate2\toriginal3.txt\t1000\t\t\t8192\t3\n";
1466
1467 static const CHAR rd_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1468                                      "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1469                                      "Feature\tFeature\n"
1470                                      "duplicate\t\t\tduplicate feature\t1\t2\tMSITESTDIR\t0\n";
1471
1472 static const CHAR rd_feature_comp_dat[] = "Feature_\tComponent_\n"
1473                                           "s38\ts72\n"
1474                                           "FeatureComponents\tFeature_\tComponent_\n"
1475                                           "duplicate\tduplicate\n";
1476
1477 static const CHAR rd_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1478                                        "s72\tS38\ts72\ti2\tS255\tS72\n"
1479                                        "Component\tComponent\n"
1480                                        "duplicate\t{EB45D06A-ADFE-44E3-8D41-B7DE150E41AD}\tMSITESTDIR\t0\t\toriginal.txt\n"
1481                                        "duplicate2\t{B8BA60E0-B2E9-488E-9D0E-E60F25F04F97}\tMSITESTDIR\t0\tDUPLICATE2=1\toriginal3.txt\n";
1482
1483 static const CHAR rd_duplicate_file_dat[] = "FileKey\tComponent_\tFile_\tDestName\tDestFolder\n"
1484                                             "s72\ts72\ts72\tS255\tS72\n"
1485                                             "DuplicateFile\tFileKey\n"
1486                                             "duplicate\tduplicate\toriginal.txt\tduplicate.txt\t\n"
1487                                             "duplicate2\tduplicate\toriginal2.txt\t\tMSITESTDIR\n"
1488                                             "duplicate3\tduplicate2\toriginal3.txt\tduplicate2.txt\t\n";
1489
1490 static const CHAR rd_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1491                                               "s72\tS255\tI2\n"
1492                                               "InstallExecuteSequence\tAction\n"
1493                                               "LaunchConditions\t\t100\n"
1494                                               "CostInitialize\t\t800\n"
1495                                               "FileCost\t\t900\n"
1496                                               "CostFinalize\t\t1000\n"
1497                                               "InstallValidate\t\t1400\n"
1498                                               "InstallInitialize\t\t1500\n"
1499                                               "ProcessComponents\t\t1600\n"
1500                                               "RemoveDuplicateFiles\t\t1900\n"
1501                                               "InstallFiles\t\t2000\n"
1502                                               "DuplicateFiles\t\t2100\n"
1503                                               "RegisterProduct\t\t5000\n"
1504                                               "PublishFeatures\t\t5100\n"
1505                                               "PublishProduct\t\t5200\n"
1506                                               "InstallFinalize\t\t6000\n";
1507
1508 static const CHAR rrv_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1509                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1510                                    "File\tFile\n"
1511                                    "registry.txt\tregistry\tregistry.txt\t1000\t\t\t8192\t1\n";
1512
1513 static const CHAR rrv_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1514                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1515                                       "Feature\tFeature\n"
1516                                       "registry\t\t\tregistry feature\t1\t2\tMSITESTDIR\t0\n";
1517
1518 static const CHAR rrv_feature_comp_dat[] = "Feature_\tComponent_\n"
1519                                            "s38\ts72\n"
1520                                            "FeatureComponents\tFeature_\tComponent_\n"
1521                                            "registry\tregistry\n";
1522
1523 static const CHAR rrv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1524                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1525                                         "Component\tComponent\n"
1526                                         "registry\t{DA97585B-962D-45EB-AD32-DA15E60CA9EE}\tMSITESTDIR\t0\t\tregistry.txt\n";
1527
1528 static const CHAR rrv_registry_dat[] = "Registry\tRoot\tKey\tName\tValue\tComponent_\n"
1529                                        "s72\ti2\tl255\tL255\tL0\ts72\n"
1530                                        "Registry\tRegistry\n"
1531                                        "reg1\t2\tSOFTWARE\\Wine\\keyA\t\tA\tregistry\n"
1532                                        "reg2\t2\tSOFTWARE\\Wine\\keyA\tvalueA\tA\tregistry\n"
1533                                        "reg3\t2\tSOFTWARE\\Wine\\key1\t-\t\tregistry\n";
1534
1535 static const CHAR rrv_remove_registry_dat[] = "RemoveRegistry\tRoot\tKey\tName\tComponent_\n"
1536                                               "s72\ti2\tl255\tL255\ts72\n"
1537                                               "RemoveRegistry\tRemoveRegistry\n"
1538                                               "reg1\t2\tSOFTWARE\\Wine\\keyB\t\tregistry\n"
1539                                               "reg2\t2\tSOFTWARE\\Wine\\keyB\tValueB\tregistry\n"
1540                                               "reg3\t2\tSOFTWARE\\Wine\\key2\t-\tregistry\n";
1541
1542 static const CHAR rrv_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1543                                                "s72\tS255\tI2\n"
1544                                                "InstallExecuteSequence\tAction\n"
1545                                                "LaunchConditions\t\t100\n"
1546                                                "CostInitialize\t\t800\n"
1547                                                "FileCost\t\t900\n"
1548                                                "CostFinalize\t\t1000\n"
1549                                                "InstallValidate\t\t1400\n"
1550                                                "InstallInitialize\t\t1500\n"
1551                                                "ProcessComponents\t\t1600\n"
1552                                                "RemoveFiles\t\t1700\n"
1553                                                "InstallFiles\t\t2000\n"
1554                                                "RemoveRegistryValues\t\t3000\n"
1555                                                "RegisterProduct\t\t5000\n"
1556                                                "PublishFeatures\t\t5100\n"
1557                                                "PublishProduct\t\t5200\n"
1558                                                "InstallFinalize\t\t6000\n";
1559
1560 static const CHAR frp_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1561                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1562                                    "File\tFile\n"
1563                                    "product.txt\tproduct\tproduct.txt\t1000\t\t\t8192\t1\n";
1564
1565 static const CHAR frp_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1566                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1567                                       "Feature\tFeature\n"
1568                                       "product\t\t\tproduct feature\t1\t2\tMSITESTDIR\t0\n";
1569
1570 static const CHAR frp_feature_comp_dat[] = "Feature_\tComponent_\n"
1571                                            "s38\ts72\n"
1572                                            "FeatureComponents\tFeature_\tComponent_\n"
1573                                            "product\tproduct\n";
1574
1575 static const CHAR frp_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1576                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1577                                         "Component\tComponent\n"
1578                                         "product\t{44725EE0-EEA8-40BD-8162-A48224A2FEA1}\tMSITESTDIR\t0\t\tproduct.txt\n";
1579
1580 static const CHAR frp_custom_action_dat[] = "Action\tType\tSource\tTarget\tISComments\n"
1581                                             "s72\ti2\tS64\tS0\tS255\n"
1582                                             "CustomAction\tAction\n"
1583                                             "TestProp\t19\t\t\tPROP set\n";
1584
1585 static const CHAR frp_upgrade_dat[] = "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n"
1586                                       "s38\tS20\tS20\tS255\ti4\tS255\ts72\n"
1587                                       "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n"
1588                                       "{4C0EAA15-0264-4E5A-8758-609EF142B92D}\t1.1.1\t2.2.2\t\t768\t\tPROP\n";
1589
1590 static const CHAR frp_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1591                                                "s72\tS255\tI2\n"
1592                                                "InstallExecuteSequence\tAction\n"
1593                                                "FindRelatedProducts\t\t50\n"
1594                                                "TestProp\tPROP AND NOT REMOVE\t51\n"
1595                                                "LaunchConditions\t\t100\n"
1596                                                "CostInitialize\t\t800\n"
1597                                                "FileCost\t\t900\n"
1598                                                "CostFinalize\t\t1000\n"
1599                                                "InstallValidate\t\t1400\n"
1600                                                "InstallInitialize\t\t1500\n"
1601                                                "ProcessComponents\t\t1600\n"
1602                                                "RemoveFiles\t\t1700\n"
1603                                                "InstallFiles\t\t2000\n"
1604                                                "RegisterProduct\t\t5000\n"
1605                                                "PublishFeatures\t\t5100\n"
1606                                                "PublishProduct\t\t5200\n"
1607                                                "InstallFinalize\t\t6000\n";
1608
1609 static const CHAR riv_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1610                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1611                                    "File\tFile\n"
1612                                    "inifile.txt\tinifile\tinifile.txt\t1000\t\t\t8192\t1\n";
1613
1614 static const CHAR riv_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1615                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1616                                       "Feature\tFeature\n"
1617                                       "inifile\t\t\tinifile feature\t1\t2\tMSITESTDIR\t0\n";
1618
1619 static const CHAR riv_feature_comp_dat[] = "Feature_\tComponent_\n"
1620                                            "s38\ts72\n"
1621                                            "FeatureComponents\tFeature_\tComponent_\n"
1622                                            "inifile\tinifile\n";
1623
1624 static const CHAR riv_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1625                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1626                                         "Component\tComponent\n"
1627                                         "inifile\t{A0F15705-4F57-4437-88C4-6C8B37ACC6DE}\tMSITESTDIR\t0\t\tinifile.txt\n";
1628
1629 static const CHAR riv_ini_file_dat[] = "IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n"
1630                                        "s72\tl255\tS72\tl96\tl128\tl255\ti2\ts72\n"
1631                                        "IniFile\tIniFile\n"
1632                                        "inifile1\ttest.ini\tMSITESTDIR\tsection1\tkey1\tvalue1\t0\tinifile\n";
1633
1634 static const CHAR riv_remove_ini_file_dat[] = "RemoveIniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n"
1635                                               "s72\tl255\tS72\tl96\tl128\tL255\ti2\ts72\n"
1636                                               "RemoveIniFile\tRemoveIniFile\n"
1637                                               "inifile1\ttest.ini\tMSITESTDIR\tsectionA\tkeyA\tvalueA\t2\tinifile\n";
1638
1639 static const CHAR riv_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1640                                                "s72\tS255\tI2\n"
1641                                                "InstallExecuteSequence\tAction\n"
1642                                                "LaunchConditions\t\t100\n"
1643                                                "CostInitialize\t\t800\n"
1644                                                "FileCost\t\t900\n"
1645                                                "CostFinalize\t\t1000\n"
1646                                                "InstallValidate\t\t1400\n"
1647                                                "InstallInitialize\t\t1500\n"
1648                                                "ProcessComponents\t\t1600\n"
1649                                                "RemoveFiles\t\t1700\n"
1650                                                "InstallFiles\t\t2000\n"
1651                                                "RemoveIniValues\t\t3000\n"
1652                                                "RegisterProduct\t\t5000\n"
1653                                                "PublishFeatures\t\t5100\n"
1654                                                "PublishProduct\t\t5200\n"
1655                                                "InstallFinalize\t\t6000\n";
1656
1657 static const CHAR res_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1658                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1659                                    "File\tFile\n"
1660                                    "envvar.txt\tenvvar\tenvvar.txt\t1000\t\t\t8192\t1\n";
1661
1662 static const CHAR res_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1663                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1664                                       "Feature\tFeature\n"
1665                                       "envvar\t\t\tenvvar feature\t1\t2\tMSITESTDIR\t0\n";
1666
1667 static const CHAR res_feature_comp_dat[] = "Feature_\tComponent_\n"
1668                                            "s38\ts72\n"
1669                                            "FeatureComponents\tFeature_\tComponent_\n"
1670                                            "envvar\tenvvar\n";
1671
1672 static const CHAR res_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1673                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1674                                         "Component\tComponent\n"
1675                                         "envvar\t{45EE9AF4-E5D1-445F-8BB7-B22D4EEBD29E}\tMSITESTDIR\t0\t\tenvvar.txt\n";
1676
1677 static const CHAR res_environment_dat[] = "Environment\tName\tValue\tComponent_\n"
1678                                           "s72\tl255\tL255\ts72\n"
1679                                           "Environment\tEnvironment\n"
1680                                           "var1\t=-MSITESTVAR1\t1\tenvvar\n"
1681                                           "var2\t=+-MSITESTVAR2\t1\tenvvar\n"
1682                                           "var3\t=MSITESTVAR3\t1\tenvvar\n"
1683                                           "var4\t=-MSITESTVAR4\t\tenvvar\n"
1684                                           "var5\t=MSITESTVAR5\t\tenvvar\n";
1685
1686 static const CHAR res_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1687                                                "s72\tS255\tI2\n"
1688                                                "InstallExecuteSequence\tAction\n"
1689                                                "LaunchConditions\t\t100\n"
1690                                                "CostInitialize\t\t800\n"
1691                                                "FileCost\t\t900\n"
1692                                                "CostFinalize\t\t1000\n"
1693                                                "InstallValidate\t\t1400\n"
1694                                                "InstallInitialize\t\t1500\n"
1695                                                "ProcessComponents\t\t1600\n"
1696                                                "RemoveFiles\t\t1700\n"
1697                                                "InstallFiles\t\t2000\n"
1698                                                "RemoveEnvironmentStrings\t\t3000\n"
1699                                                "RegisterProduct\t\t5000\n"
1700                                                "PublishFeatures\t\t5100\n"
1701                                                "PublishProduct\t\t5200\n"
1702                                                "InstallFinalize\t\t6000\n";
1703
1704 static const CHAR rci_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1705                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1706                                    "File\tFile\n"
1707                                    "class.txt\tclass\tclass.txt\t1000\t\t\t8192\t1\n";
1708
1709 static const CHAR rci_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1710                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1711                                       "Feature\tFeature\n"
1712                                       "class\t\t\tclass feature\t1\t2\tMSITESTDIR\t0\n";
1713
1714 static const CHAR rci_feature_comp_dat[] = "Feature_\tComponent_\n"
1715                                            "s38\ts72\n"
1716                                            "FeatureComponents\tFeature_\tComponent_\n"
1717                                            "class\tclass\n";
1718
1719 static const CHAR rci_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1720                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1721                                         "Component\tComponent\n"
1722                                         "class\t{89A98345-F8A1-422E-A48B-0250B5809F2D}\tMSITESTDIR\t0\t\tclass.txt\n";
1723
1724 static const CHAR rci_appid_dat[] = "AppId\tRemoteServerName\tLocalService\tServiceParameters\tDllSurrogate\tActivateAtStorage\tRunAsInteractiveUser\n"
1725                                     "s38\tS255\tS255\tS255\tS255\tI2\tI2\n"
1726                                     "AppId\tAppId\n"
1727                                     "{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\t\t\t\t\t\t\n";
1728
1729 static const CHAR rci_class_dat[] = "CLSID\tContext\tComponent_\tProgId_Default\tDescription\tAppId_\tFileTypeMask\tIcon_\tIconIndex\tDefInprocHandler\tArgument\tFeature_\tAttributes\n"
1730                                     "s38\ts32\ts72\tS255\tL255\tS38\tS255\tS72\tI2\tS32\tS255\ts38\tI2\n"
1731                                     "Class\tCLSID\tContext\tComponent_\n"
1732                                     "{110913E7-86D1-4BF3-9922-BA103FCDDDFA}\tLocalServer\tclass\t\tdescription\t{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}\tmask1;mask2\t\t\t2\t\tclass\t\n";
1733
1734 static const CHAR rci_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1735                                                "s72\tS255\tI2\n"
1736                                                "InstallExecuteSequence\tAction\n"
1737                                                "LaunchConditions\t\t100\n"
1738                                                "CostInitialize\t\t800\n"
1739                                                "FileCost\t\t900\n"
1740                                                "CostFinalize\t\t1000\n"
1741                                                "InstallValidate\t\t1400\n"
1742                                                "InstallInitialize\t\t1500\n"
1743                                                "ProcessComponents\t\t1600\n"
1744                                                "RemoveFiles\t\t1700\n"
1745                                                "InstallFiles\t\t2000\n"
1746                                                "UnregisterClassInfo\t\t3000\n"
1747                                                "RegisterClassInfo\t\t4000\n"
1748                                                "RegisterProduct\t\t5000\n"
1749                                                "PublishFeatures\t\t5100\n"
1750                                                "PublishProduct\t\t5200\n"
1751                                                "InstallFinalize\t\t6000\n";
1752
1753 static const CHAR rei_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1754                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1755                                    "File\tFile\n"
1756                                    "extension.txt\textension\textension.txt\t1000\t\t\t8192\t1\n";
1757
1758 static const CHAR rei_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1759                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1760                                       "Feature\tFeature\n"
1761                                       "extension\t\t\textension feature\t1\t2\tMSITESTDIR\t0\n";
1762
1763 static const CHAR rei_feature_comp_dat[] = "Feature_\tComponent_\n"
1764                                            "s38\ts72\n"
1765                                            "FeatureComponents\tFeature_\tComponent_\n"
1766                                            "extension\textension\n";
1767
1768 static const CHAR rei_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1769                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1770                                         "Component\tComponent\n"
1771                                         "extension\t{9A3060D4-60BA-4A82-AB55-9FB148AD013C}\tMSITESTDIR\t0\t\textension.txt\n";
1772
1773 static const CHAR rei_extension_dat[] = "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
1774                                         "s255\ts72\tS255\tS64\ts38\n"
1775                                         "Extension\tExtension\tComponent_\n"
1776                                         "extension\textension\tProg.Id.1\t\textension\n";
1777
1778 static const CHAR rei_verb_dat[] = "Extension_\tVerb\tSequence\tCommand\tArgument\n"
1779                                    "s255\ts32\tI2\tL255\tL255\n"
1780                                    "Verb\tExtension_\tVerb\n"
1781                                    "extension\tOpen\t1\t&Open\t/argument\n";
1782
1783 static const CHAR rei_progid_dat[] = "ProgId\tProgId_Parent\tClass_\tDescription\tIcon_\tIconIndex\n"
1784                                      "s255\tS255\tS38\tL255\tS72\tI2\n"
1785                                      "ProgId\tProgId\n"
1786                                      "Prog.Id.1\t\t\tdescription\t\t\n";
1787
1788 static const CHAR rei_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1789                                                "s72\tS255\tI2\n"
1790                                                "InstallExecuteSequence\tAction\n"
1791                                                "LaunchConditions\t\t100\n"
1792                                                "CostInitialize\t\t800\n"
1793                                                "FileCost\t\t900\n"
1794                                                "CostFinalize\t\t1000\n"
1795                                                "InstallValidate\t\t1400\n"
1796                                                "InstallInitialize\t\t1500\n"
1797                                                "ProcessComponents\t\t1600\n"
1798                                                "RemoveFiles\t\t1700\n"
1799                                                "InstallFiles\t\t2000\n"
1800                                                "UnregisterExtensionInfo\t\t3000\n"
1801                                                "RegisterExtensionInfo\t\t4000\n"
1802                                                "RegisterProduct\t\t5000\n"
1803                                                "PublishFeatures\t\t5100\n"
1804                                                "PublishProduct\t\t5200\n"
1805                                                "InstallFinalize\t\t6000\n";
1806
1807 static const CHAR rmi_file_dat[] = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n"
1808                                    "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n"
1809                                    "File\tFile\n"
1810                                    "mime.txt\tmime\tmime.txt\t1000\t\t\t8192\t1\n";
1811
1812 static const CHAR rmi_feature_dat[] = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n"
1813                                       "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n"
1814                                       "Feature\tFeature\n"
1815                                       "mime\t\t\tmime feature\t1\t2\tMSITESTDIR\t0\n";
1816
1817 static const CHAR rmi_feature_comp_dat[] = "Feature_\tComponent_\n"
1818                                            "s38\ts72\n"
1819                                            "FeatureComponents\tFeature_\tComponent_\n"
1820                                            "mime\tmime\n";
1821
1822 static const CHAR rmi_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
1823                                         "s72\tS38\ts72\ti2\tS255\tS72\n"
1824                                         "Component\tComponent\n"
1825                                         "mime\t{A1D630CE-13A7-4882-AFDD-148E2BBAFC6D}\tMSITESTDIR\t0\t\tmime.txt\n";
1826
1827 static const CHAR rmi_extension_dat[] = "Extension\tComponent_\tProgId_\tMIME_\tFeature_\n"
1828                                         "s255\ts72\tS255\tS64\ts38\n"
1829                                         "Extension\tExtension\tComponent_\n"
1830                                         "mime\tmime\t\tmime/type\tmime\n";
1831
1832 static const CHAR rmi_verb_dat[] = "Extension_\tVerb\tSequence\tCommand\tArgument\n"
1833                                    "s255\ts32\tI2\tL255\tL255\n"
1834                                    "Verb\tExtension_\tVerb\n"
1835                                    "mime\tOpen\t1\t&Open\t/argument\n";
1836
1837 static const CHAR rmi_mime_dat[] = "ContentType\tExtension_\tCLSID\n"
1838                                    "s64\ts255\tS38\n"
1839                                    "MIME\tContentType\n"
1840                                    "mime/type\tmime\t\n";
1841
1842 static const CHAR rmi_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
1843                                                "s72\tS255\tI2\n"
1844                                                "InstallExecuteSequence\tAction\n"
1845                                                "LaunchConditions\t\t100\n"
1846                                                "CostInitialize\t\t800\n"
1847                                                "FileCost\t\t900\n"
1848                                                "CostFinalize\t\t1000\n"
1849                                                "InstallValidate\t\t1400\n"
1850                                                "InstallInitialize\t\t1500\n"
1851                                                "ProcessComponents\t\t1600\n"
1852                                                "RemoveFiles\t\t1700\n"
1853                                                "InstallFiles\t\t2000\n"
1854                                                "UnregisterExtensionInfo\t\t3000\n"
1855                                                "UnregisterMIMEInfo\t\t3500\n"
1856                                                "RegisterExtensionInfo\t\t4000\n"
1857                                                "RegisterMIMEInfo\t\t4500\n"
1858                                                "RegisterProduct\t\t5000\n"
1859                                                "PublishFeatures\t\t5100\n"
1860                                                "PublishProduct\t\t5200\n"
1861                                                "InstallFinalize\t\t6000\n";
1862
1863 typedef struct _msi_table
1864 {
1865     const CHAR *filename;
1866     const CHAR *data;
1867     int size;
1868 } msi_table;
1869
1870 #define ADD_TABLE(x) {#x".idt", x##_dat, sizeof(x##_dat)}
1871
1872 static const msi_table tables[] =
1873 {
1874     ADD_TABLE(component),
1875     ADD_TABLE(directory),
1876     ADD_TABLE(feature),
1877     ADD_TABLE(feature_comp),
1878     ADD_TABLE(file),
1879     ADD_TABLE(install_exec_seq),
1880     ADD_TABLE(media),
1881     ADD_TABLE(property),
1882     ADD_TABLE(registry),
1883     ADD_TABLE(service_install),
1884     ADD_TABLE(service_control)
1885 };
1886
1887 static const msi_table sc_tables[] =
1888 {
1889     ADD_TABLE(component),
1890     ADD_TABLE(directory),
1891     ADD_TABLE(feature),
1892     ADD_TABLE(feature_comp),
1893     ADD_TABLE(file),
1894     ADD_TABLE(install_exec_seq),
1895     ADD_TABLE(media),
1896     ADD_TABLE(property),
1897     ADD_TABLE(shortcut)
1898 };
1899
1900 static const msi_table ps_tables[] =
1901 {
1902     ADD_TABLE(component),
1903     ADD_TABLE(directory),
1904     ADD_TABLE(feature),
1905     ADD_TABLE(feature_comp),
1906     ADD_TABLE(file),
1907     ADD_TABLE(install_exec_seq),
1908     ADD_TABLE(media),
1909     ADD_TABLE(property),
1910     ADD_TABLE(condition)
1911 };
1912
1913 static const msi_table env_tables[] =
1914 {
1915     ADD_TABLE(component),
1916     ADD_TABLE(directory),
1917     ADD_TABLE(feature),
1918     ADD_TABLE(feature_comp),
1919     ADD_TABLE(file),
1920     ADD_TABLE(install_exec_seq),
1921     ADD_TABLE(media),
1922     ADD_TABLE(property),
1923     ADD_TABLE(environment)
1924 };
1925
1926 static const msi_table up_tables[] =
1927 {
1928     ADD_TABLE(component),
1929     ADD_TABLE(directory),
1930     ADD_TABLE(feature),
1931     ADD_TABLE(feature_comp),
1932     ADD_TABLE(file),
1933     ADD_TABLE(install_exec_seq),
1934     ADD_TABLE(media),
1935     ADD_TABLE(up_property),
1936     ADD_TABLE(registry),
1937     ADD_TABLE(service_install),
1938     ADD_TABLE(service_control)
1939 };
1940
1941 static const msi_table up2_tables[] =
1942 {
1943     ADD_TABLE(component),
1944     ADD_TABLE(directory),
1945     ADD_TABLE(feature),
1946     ADD_TABLE(feature_comp),
1947     ADD_TABLE(file),
1948     ADD_TABLE(install_exec_seq),
1949     ADD_TABLE(media),
1950     ADD_TABLE(up2_property),
1951     ADD_TABLE(registry),
1952     ADD_TABLE(service_install),
1953     ADD_TABLE(service_control)
1954 };
1955
1956 static const msi_table up3_tables[] =
1957 {
1958     ADD_TABLE(component),
1959     ADD_TABLE(directory),
1960     ADD_TABLE(feature),
1961     ADD_TABLE(feature_comp),
1962     ADD_TABLE(file),
1963     ADD_TABLE(install_exec_seq),
1964     ADD_TABLE(media),
1965     ADD_TABLE(up3_property),
1966     ADD_TABLE(registry),
1967     ADD_TABLE(service_install),
1968     ADD_TABLE(service_control)
1969 };
1970
1971 static const msi_table up4_tables[] =
1972 {
1973     ADD_TABLE(component),
1974     ADD_TABLE(directory),
1975     ADD_TABLE(feature),
1976     ADD_TABLE(feature_comp),
1977     ADD_TABLE(file),
1978     ADD_TABLE(pp_install_exec_seq),
1979     ADD_TABLE(media),
1980     ADD_TABLE(property),
1981     ADD_TABLE(registry),
1982     ADD_TABLE(service_install),
1983     ADD_TABLE(service_control)
1984 };
1985
1986 static const msi_table up5_tables[] =
1987 {
1988     ADD_TABLE(component),
1989     ADD_TABLE(directory),
1990     ADD_TABLE(feature),
1991     ADD_TABLE(feature_comp),
1992     ADD_TABLE(file),
1993     ADD_TABLE(pp_install_exec_seq),
1994     ADD_TABLE(media),
1995     ADD_TABLE(up_property),
1996     ADD_TABLE(registry),
1997     ADD_TABLE(service_install),
1998     ADD_TABLE(service_control)
1999 };
2000
2001 static const msi_table up6_tables[] =
2002 {
2003     ADD_TABLE(component),
2004     ADD_TABLE(directory),
2005     ADD_TABLE(feature),
2006     ADD_TABLE(feature_comp),
2007     ADD_TABLE(file),
2008     ADD_TABLE(pp_install_exec_seq),
2009     ADD_TABLE(media),
2010     ADD_TABLE(up2_property),
2011     ADD_TABLE(registry),
2012     ADD_TABLE(service_install),
2013     ADD_TABLE(service_control)
2014 };
2015
2016 static const msi_table up7_tables[] =
2017 {
2018     ADD_TABLE(component),
2019     ADD_TABLE(directory),
2020     ADD_TABLE(feature),
2021     ADD_TABLE(feature_comp),
2022     ADD_TABLE(file),
2023     ADD_TABLE(pp_install_exec_seq),
2024     ADD_TABLE(media),
2025     ADD_TABLE(up3_property),
2026     ADD_TABLE(registry),
2027     ADD_TABLE(service_install),
2028     ADD_TABLE(service_control)
2029 };
2030
2031 static const msi_table cc_tables[] =
2032 {
2033     ADD_TABLE(cc_component),
2034     ADD_TABLE(directory),
2035     ADD_TABLE(cc_feature),
2036     ADD_TABLE(cc_feature_comp),
2037     ADD_TABLE(cc_file),
2038     ADD_TABLE(install_exec_seq),
2039     ADD_TABLE(cc_media),
2040     ADD_TABLE(property),
2041 };
2042
2043 static const msi_table cc2_tables[] =
2044 {
2045     ADD_TABLE(cc2_component),
2046     ADD_TABLE(directory),
2047     ADD_TABLE(cc_feature),
2048     ADD_TABLE(cc_feature_comp),
2049     ADD_TABLE(cc2_file),
2050     ADD_TABLE(install_exec_seq),
2051     ADD_TABLE(cc_media),
2052     ADD_TABLE(property),
2053 };
2054
2055 static const msi_table co_tables[] =
2056 {
2057     ADD_TABLE(cc_component),
2058     ADD_TABLE(directory),
2059     ADD_TABLE(cc_feature),
2060     ADD_TABLE(cc_feature_comp),
2061     ADD_TABLE(co_file),
2062     ADD_TABLE(install_exec_seq),
2063     ADD_TABLE(co_media),
2064     ADD_TABLE(property),
2065 };
2066
2067 static const msi_table co2_tables[] =
2068 {
2069     ADD_TABLE(cc_component),
2070     ADD_TABLE(directory),
2071     ADD_TABLE(cc_feature),
2072     ADD_TABLE(cc_feature_comp),
2073     ADD_TABLE(cc_file),
2074     ADD_TABLE(install_exec_seq),
2075     ADD_TABLE(co2_media),
2076     ADD_TABLE(property),
2077 };
2078
2079 static const msi_table mm_tables[] =
2080 {
2081     ADD_TABLE(cc_component),
2082     ADD_TABLE(directory),
2083     ADD_TABLE(cc_feature),
2084     ADD_TABLE(cc_feature_comp),
2085     ADD_TABLE(mm_file),
2086     ADD_TABLE(install_exec_seq),
2087     ADD_TABLE(mm_media),
2088     ADD_TABLE(property),
2089 };
2090
2091 static const msi_table ss_tables[] =
2092 {
2093     ADD_TABLE(cc_component),
2094     ADD_TABLE(directory),
2095     ADD_TABLE(cc_feature),
2096     ADD_TABLE(cc_feature_comp),
2097     ADD_TABLE(cc_file),
2098     ADD_TABLE(install_exec_seq),
2099     ADD_TABLE(ss_media),
2100     ADD_TABLE(property),
2101 };
2102
2103 static const msi_table ui_tables[] =
2104 {
2105     ADD_TABLE(ui_component),
2106     ADD_TABLE(directory),
2107     ADD_TABLE(cc_feature),
2108     ADD_TABLE(cc_feature_comp),
2109     ADD_TABLE(cc_file),
2110     ADD_TABLE(install_exec_seq),
2111     ADD_TABLE(ui_install_ui_seq),
2112     ADD_TABLE(ui_custom_action),
2113     ADD_TABLE(cc_media),
2114     ADD_TABLE(property),
2115 };
2116
2117 static const msi_table rof_tables[] =
2118 {
2119     ADD_TABLE(rof_component),
2120     ADD_TABLE(directory),
2121     ADD_TABLE(rof_feature),
2122     ADD_TABLE(rof_feature_comp),
2123     ADD_TABLE(rof_file),
2124     ADD_TABLE(install_exec_seq),
2125     ADD_TABLE(rof_media),
2126     ADD_TABLE(property),
2127 };
2128
2129 static const msi_table rofc_tables[] =
2130 {
2131     ADD_TABLE(rof_component),
2132     ADD_TABLE(directory),
2133     ADD_TABLE(rof_feature),
2134     ADD_TABLE(rof_feature_comp),
2135     ADD_TABLE(rofc_file),
2136     ADD_TABLE(install_exec_seq),
2137     ADD_TABLE(rofc_media),
2138     ADD_TABLE(property),
2139 };
2140
2141 static const msi_table sdp_tables[] =
2142 {
2143     ADD_TABLE(rof_component),
2144     ADD_TABLE(directory),
2145     ADD_TABLE(rof_feature),
2146     ADD_TABLE(rof_feature_comp),
2147     ADD_TABLE(rof_file),
2148     ADD_TABLE(sdp_install_exec_seq),
2149     ADD_TABLE(sdp_custom_action),
2150     ADD_TABLE(rof_media),
2151     ADD_TABLE(property),
2152 };
2153
2154 static const msi_table cie_tables[] =
2155 {
2156     ADD_TABLE(cie_component),
2157     ADD_TABLE(directory),
2158     ADD_TABLE(cc_feature),
2159     ADD_TABLE(cie_feature_comp),
2160     ADD_TABLE(cie_file),
2161     ADD_TABLE(install_exec_seq),
2162     ADD_TABLE(cie_media),
2163     ADD_TABLE(property),
2164 };
2165
2166 static const msi_table ci_tables[] =
2167 {
2168     ADD_TABLE(ci_component),
2169     ADD_TABLE(directory),
2170     ADD_TABLE(rof_feature),
2171     ADD_TABLE(rof_feature_comp),
2172     ADD_TABLE(rof_file),
2173     ADD_TABLE(ci_install_exec_seq),
2174     ADD_TABLE(rof_media),
2175     ADD_TABLE(property),
2176     ADD_TABLE(ci_custom_action),
2177 };
2178
2179 static const msi_table ci2_tables[] =
2180 {
2181     ADD_TABLE(ci2_component),
2182     ADD_TABLE(directory),
2183     ADD_TABLE(rof_feature),
2184     ADD_TABLE(ci2_feature_comp),
2185     ADD_TABLE(ci2_file),
2186     ADD_TABLE(install_exec_seq),
2187     ADD_TABLE(rof_media),
2188     ADD_TABLE(property),
2189 };
2190
2191 static const msi_table spf_tables[] =
2192 {
2193     ADD_TABLE(ci_component),
2194     ADD_TABLE(directory),
2195     ADD_TABLE(rof_feature),
2196     ADD_TABLE(rof_feature_comp),
2197     ADD_TABLE(rof_file),
2198     ADD_TABLE(spf_install_exec_seq),
2199     ADD_TABLE(rof_media),
2200     ADD_TABLE(property),
2201     ADD_TABLE(spf_custom_action),
2202     ADD_TABLE(spf_install_ui_seq),
2203 };
2204
2205 static const msi_table pp_tables[] =
2206 {
2207     ADD_TABLE(ci_component),
2208     ADD_TABLE(directory),
2209     ADD_TABLE(rof_feature),
2210     ADD_TABLE(rof_feature_comp),
2211     ADD_TABLE(rof_file),
2212     ADD_TABLE(pp_install_exec_seq),
2213     ADD_TABLE(rof_media),
2214     ADD_TABLE(property),
2215 };
2216
2217 static const msi_table ppc_tables[] =
2218 {
2219     ADD_TABLE(ppc_component),
2220     ADD_TABLE(directory),
2221     ADD_TABLE(rof_feature),
2222     ADD_TABLE(ppc_feature_comp),
2223     ADD_TABLE(ppc_file),
2224     ADD_TABLE(pp_install_exec_seq),
2225     ADD_TABLE(ppc_media),
2226     ADD_TABLE(property),
2227 };
2228
2229 static const msi_table lus0_tables[] =
2230 {
2231     ADD_TABLE(ci_component),
2232     ADD_TABLE(directory),
2233     ADD_TABLE(rof_feature),
2234     ADD_TABLE(rof_feature_comp),
2235     ADD_TABLE(rof_file),
2236     ADD_TABLE(pp_install_exec_seq),
2237     ADD_TABLE(rof_media),
2238     ADD_TABLE(property),
2239 };
2240
2241 static const msi_table lus1_tables[] =
2242 {
2243     ADD_TABLE(ci_component),
2244     ADD_TABLE(directory),
2245     ADD_TABLE(rof_feature),
2246     ADD_TABLE(rof_feature_comp),
2247     ADD_TABLE(rof_file),
2248     ADD_TABLE(pp_install_exec_seq),
2249     ADD_TABLE(rofc_media),
2250     ADD_TABLE(property),
2251 };
2252
2253 static const msi_table lus2_tables[] =
2254 {
2255     ADD_TABLE(ci_component),
2256     ADD_TABLE(directory),
2257     ADD_TABLE(rof_feature),
2258     ADD_TABLE(rof_feature_comp),
2259     ADD_TABLE(rof_file),
2260     ADD_TABLE(pp_install_exec_seq),
2261     ADD_TABLE(lus2_media),
2262     ADD_TABLE(property),
2263 };
2264
2265 static const msi_table tp_tables[] =
2266 {
2267     ADD_TABLE(tp_component),
2268     ADD_TABLE(directory),
2269     ADD_TABLE(rof_feature),
2270     ADD_TABLE(ci2_feature_comp),
2271     ADD_TABLE(ci2_file),
2272     ADD_TABLE(install_exec_seq),
2273     ADD_TABLE(rof_media),
2274     ADD_TABLE(property),
2275 };
2276
2277 static const msi_table cwd_tables[] =
2278 {
2279     ADD_TABLE(cwd_component),
2280     ADD_TABLE(directory),
2281     ADD_TABLE(rof_feature),
2282     ADD_TABLE(ci2_feature_comp),
2283     ADD_TABLE(ci2_file),
2284     ADD_TABLE(install_exec_seq),
2285     ADD_TABLE(rof_media),
2286     ADD_TABLE(property),
2287 };
2288
2289 static const msi_table adm_tables[] =
2290 {
2291     ADD_TABLE(adm_component),
2292     ADD_TABLE(directory),
2293     ADD_TABLE(rof_feature),
2294     ADD_TABLE(ci2_feature_comp),
2295     ADD_TABLE(ci2_file),
2296     ADD_TABLE(install_exec_seq),
2297     ADD_TABLE(rof_media),
2298     ADD_TABLE(property),
2299     ADD_TABLE(adm_custom_action),
2300     ADD_TABLE(adm_admin_exec_seq),
2301 };
2302
2303 static const msi_table amp_tables[] =
2304 {
2305     ADD_TABLE(amp_component),
2306     ADD_TABLE(directory),
2307     ADD_TABLE(rof_feature),
2308     ADD_TABLE(ci2_feature_comp),
2309     ADD_TABLE(ci2_file),
2310     ADD_TABLE(install_exec_seq),
2311     ADD_TABLE(rof_media),
2312     ADD_TABLE(property),
2313 };
2314
2315 static const msi_table rem_tables[] =
2316 {
2317     ADD_TABLE(rem_component),
2318     ADD_TABLE(directory),
2319     ADD_TABLE(rof_feature),
2320     ADD_TABLE(rem_feature_comp),
2321     ADD_TABLE(rem_file),
2322     ADD_TABLE(rem_install_exec_seq),
2323     ADD_TABLE(rof_media),
2324     ADD_TABLE(property),
2325     ADD_TABLE(rem_remove_files),
2326 };
2327
2328 static const msi_table mov_tables[] =
2329 {
2330     ADD_TABLE(cwd_component),
2331     ADD_TABLE(directory),
2332     ADD_TABLE(rof_feature),
2333     ADD_TABLE(ci2_feature_comp),
2334     ADD_TABLE(ci2_file),
2335     ADD_TABLE(install_exec_seq),
2336     ADD_TABLE(rof_media),
2337     ADD_TABLE(property),
2338     ADD_TABLE(mov_move_file),
2339 };
2340
2341 static const msi_table mc_tables[] =
2342 {
2343     ADD_TABLE(mc_component),
2344     ADD_TABLE(directory),
2345     ADD_TABLE(cc_feature),
2346     ADD_TABLE(cie_feature_comp),
2347     ADD_TABLE(mc_file),
2348     ADD_TABLE(install_exec_seq),
2349     ADD_TABLE(mc_media),
2350     ADD_TABLE(property),
2351     ADD_TABLE(mc_file_hash),
2352 };
2353
2354 static const msi_table df_tables[] =
2355 {
2356     ADD_TABLE(rof_component),
2357     ADD_TABLE(df_directory),
2358     ADD_TABLE(rof_feature),
2359     ADD_TABLE(rof_feature_comp),
2360     ADD_TABLE(rof_file),
2361     ADD_TABLE(install_exec_seq),
2362     ADD_TABLE(rof_media),
2363     ADD_TABLE(property),
2364     ADD_TABLE(df_duplicate_file),
2365 };
2366
2367 static const msi_table wrv_tables[] =
2368 {
2369     ADD_TABLE(wrv_component),
2370     ADD_TABLE(directory),
2371     ADD_TABLE(rof_feature),
2372     ADD_TABLE(ci2_feature_comp),
2373     ADD_TABLE(ci2_file),
2374     ADD_TABLE(install_exec_seq),
2375     ADD_TABLE(rof_media),
2376     ADD_TABLE(property),
2377     ADD_TABLE(wrv_registry),
2378 };
2379
2380 static const msi_table sf_tables[] =
2381 {
2382     ADD_TABLE(wrv_component),
2383     ADD_TABLE(directory),
2384     ADD_TABLE(rof_feature),
2385     ADD_TABLE(ci2_feature_comp),
2386     ADD_TABLE(ci2_file),
2387     ADD_TABLE(install_exec_seq),
2388     ADD_TABLE(rof_media),
2389     ADD_TABLE(property),
2390 };
2391
2392 static const msi_table ca51_tables[] =
2393 {
2394     ADD_TABLE(ca51_component),
2395     ADD_TABLE(directory),
2396     ADD_TABLE(rof_feature),
2397     ADD_TABLE(ci2_feature_comp),
2398     ADD_TABLE(ci2_file),
2399     ADD_TABLE(ca51_install_exec_seq),
2400     ADD_TABLE(rof_media),
2401     ADD_TABLE(property),
2402     ADD_TABLE(ca51_custom_action),
2403 };
2404
2405 static const msi_table is_tables[] =
2406 {
2407     ADD_TABLE(is_component),
2408     ADD_TABLE(directory),
2409     ADD_TABLE(is_feature),
2410     ADD_TABLE(is_feature_comp),
2411     ADD_TABLE(is_file),
2412     ADD_TABLE(install_exec_seq),
2413     ADD_TABLE(is_media),
2414     ADD_TABLE(property),
2415 };
2416
2417 static const msi_table sp_tables[] =
2418 {
2419     ADD_TABLE(sp_component),
2420     ADD_TABLE(sp_directory),
2421     ADD_TABLE(rof_feature),
2422     ADD_TABLE(ci2_feature_comp),
2423     ADD_TABLE(ci2_file),
2424     ADD_TABLE(install_exec_seq),
2425     ADD_TABLE(rof_media),
2426     ADD_TABLE(property),
2427 };
2428
2429 static const msi_table mcp_tables[] =
2430 {
2431     ADD_TABLE(mcp_component),
2432     ADD_TABLE(directory),
2433     ADD_TABLE(mcp_feature),
2434     ADD_TABLE(mcp_feature_comp),
2435     ADD_TABLE(rem_file),
2436     ADD_TABLE(rem_install_exec_seq),
2437     ADD_TABLE(rof_media),
2438     ADD_TABLE(property),
2439 };
2440
2441 static const msi_table mcomp_tables[] =
2442 {
2443     ADD_TABLE(mcp_component),
2444     ADD_TABLE(directory),
2445     ADD_TABLE(mcp_feature),
2446     ADD_TABLE(mcp_feature_comp),
2447     ADD_TABLE(mcomp_file),
2448     ADD_TABLE(rem_install_exec_seq),
2449     ADD_TABLE(rof_media),
2450     ADD_TABLE(property),
2451 };
2452
2453 static const msi_table ai_tables[] =
2454 {
2455     ADD_TABLE(component),
2456     ADD_TABLE(directory),
2457     ADD_TABLE(feature),
2458     ADD_TABLE(feature_comp),
2459     ADD_TABLE(ai_file),
2460     ADD_TABLE(install_exec_seq),
2461     ADD_TABLE(media),
2462     ADD_TABLE(property)
2463 };
2464
2465 static const msi_table pc_tables[] =
2466 {
2467     ADD_TABLE(ca51_component),
2468     ADD_TABLE(directory),
2469     ADD_TABLE(rof_feature),
2470     ADD_TABLE(ci2_feature_comp),
2471     ADD_TABLE(ci2_file),
2472     ADD_TABLE(install_exec_seq),
2473     ADD_TABLE(rof_media),
2474     ADD_TABLE(property)
2475 };
2476
2477 static const msi_table ip_tables[] =
2478 {
2479     ADD_TABLE(component),
2480     ADD_TABLE(directory),
2481     ADD_TABLE(feature),
2482     ADD_TABLE(feature_comp),
2483     ADD_TABLE(file),
2484     ADD_TABLE(ip_install_exec_seq),
2485     ADD_TABLE(ip_custom_action),
2486     ADD_TABLE(media),
2487     ADD_TABLE(property)
2488 };
2489
2490 static const msi_table aup_tables[] =
2491 {
2492     ADD_TABLE(component),
2493     ADD_TABLE(directory),
2494     ADD_TABLE(feature),
2495     ADD_TABLE(feature_comp),
2496     ADD_TABLE(file),
2497     ADD_TABLE(aup_install_exec_seq),
2498     ADD_TABLE(aup_custom_action),
2499     ADD_TABLE(media),
2500     ADD_TABLE(property)
2501 };
2502
2503 static const msi_table aup2_tables[] =
2504 {
2505     ADD_TABLE(component),
2506     ADD_TABLE(directory),
2507     ADD_TABLE(feature),
2508     ADD_TABLE(feature_comp),
2509     ADD_TABLE(file),
2510     ADD_TABLE(aup2_install_exec_seq),
2511     ADD_TABLE(aup_custom_action),
2512     ADD_TABLE(media),
2513     ADD_TABLE(aup_property)
2514 };
2515
2516 static const msi_table aup3_tables[] =
2517 {
2518     ADD_TABLE(component),
2519     ADD_TABLE(directory),
2520     ADD_TABLE(feature),
2521     ADD_TABLE(feature_comp),
2522     ADD_TABLE(file),
2523     ADD_TABLE(aup2_install_exec_seq),
2524     ADD_TABLE(aup_custom_action),
2525     ADD_TABLE(media),
2526     ADD_TABLE(aup2_property)
2527 };
2528
2529 static const msi_table aup4_tables[] =
2530 {
2531     ADD_TABLE(component),
2532     ADD_TABLE(directory),
2533     ADD_TABLE(feature),
2534     ADD_TABLE(feature_comp),
2535     ADD_TABLE(file),
2536     ADD_TABLE(aup3_install_exec_seq),
2537     ADD_TABLE(aup_custom_action),
2538     ADD_TABLE(media),
2539     ADD_TABLE(aup2_property)
2540 };
2541
2542 static const msi_table fiu_tables[] =
2543 {
2544     ADD_TABLE(rof_component),
2545     ADD_TABLE(directory),
2546     ADD_TABLE(rof_feature),
2547     ADD_TABLE(rof_feature_comp),
2548     ADD_TABLE(rof_file),
2549     ADD_TABLE(pp_install_exec_seq),
2550     ADD_TABLE(rof_media),
2551     ADD_TABLE(property),
2552 };
2553
2554 static const msi_table fiuc_tables[] =
2555 {
2556     ADD_TABLE(rof_component),
2557     ADD_TABLE(directory),
2558     ADD_TABLE(rof_feature),
2559     ADD_TABLE(rof_feature_comp),
2560     ADD_TABLE(rofc_file),
2561     ADD_TABLE(pp_install_exec_seq),
2562     ADD_TABLE(rofc_media),
2563     ADD_TABLE(property),
2564 };
2565
2566 static const msi_table cf_tables[] =
2567 {
2568     ADD_TABLE(component),
2569     ADD_TABLE(directory),
2570     ADD_TABLE(feature),
2571     ADD_TABLE(feature_comp),
2572     ADD_TABLE(file),
2573     ADD_TABLE(cf_create_folders),
2574     ADD_TABLE(cf_install_exec_seq),
2575     ADD_TABLE(cf_custom_action),
2576     ADD_TABLE(media),
2577     ADD_TABLE(property)
2578 };
2579
2580 static const msi_table rf_tables[] =
2581 {
2582     ADD_TABLE(component),
2583     ADD_TABLE(directory),
2584     ADD_TABLE(feature),
2585     ADD_TABLE(feature_comp),
2586     ADD_TABLE(file),
2587     ADD_TABLE(cf_create_folders),
2588     ADD_TABLE(rf_install_exec_seq),
2589     ADD_TABLE(cf_custom_action),
2590     ADD_TABLE(media),
2591     ADD_TABLE(property)
2592 };
2593
2594 static const msi_table sss_tables[] =
2595 {
2596     ADD_TABLE(component),
2597     ADD_TABLE(directory),
2598     ADD_TABLE(feature),
2599     ADD_TABLE(feature_comp),
2600     ADD_TABLE(file),
2601     ADD_TABLE(sss_install_exec_seq),
2602     ADD_TABLE(sss_service_control),
2603     ADD_TABLE(media),
2604     ADD_TABLE(property)
2605 };
2606
2607 static const msi_table sds_tables[] =
2608 {
2609     ADD_TABLE(component),
2610     ADD_TABLE(directory),
2611     ADD_TABLE(feature),
2612     ADD_TABLE(feature_comp),
2613     ADD_TABLE(file),
2614     ADD_TABLE(sss_install_exec_seq),
2615     ADD_TABLE(service_control),
2616     ADD_TABLE(media),
2617     ADD_TABLE(property)
2618 };
2619
2620 static const msi_table sr_tables[] =
2621 {
2622     ADD_TABLE(component),
2623     ADD_TABLE(directory),
2624     ADD_TABLE(feature),
2625     ADD_TABLE(feature_comp),
2626     ADD_TABLE(file),
2627     ADD_TABLE(sr_selfreg),
2628     ADD_TABLE(sr_install_exec_seq),
2629     ADD_TABLE(media),
2630     ADD_TABLE(property)
2631 };
2632
2633 static const msi_table font_tables[] =
2634 {
2635     ADD_TABLE(font_component),
2636     ADD_TABLE(directory),
2637     ADD_TABLE(font_feature),
2638     ADD_TABLE(font_feature_comp),
2639     ADD_TABLE(font_file),
2640     ADD_TABLE(font),
2641     ADD_TABLE(font_install_exec_seq),
2642     ADD_TABLE(font_media),
2643     ADD_TABLE(property)
2644 };
2645
2646 static const msi_table vp_tables[] =
2647 {
2648     ADD_TABLE(component),
2649     ADD_TABLE(directory),
2650     ADD_TABLE(feature),
2651     ADD_TABLE(feature_comp),
2652     ADD_TABLE(file),
2653     ADD_TABLE(vp_custom_action),
2654     ADD_TABLE(vp_install_exec_seq),
2655     ADD_TABLE(media),
2656     ADD_TABLE(vp_property)
2657 };
2658
2659 static const msi_table odbc_tables[] =
2660 {
2661     ADD_TABLE(odbc_component),
2662     ADD_TABLE(directory),
2663     ADD_TABLE(odbc_feature),
2664     ADD_TABLE(odbc_feature_comp),
2665     ADD_TABLE(odbc_file),
2666     ADD_TABLE(odbc_driver),
2667     ADD_TABLE(odbc_translator),
2668     ADD_TABLE(odbc_datasource),
2669     ADD_TABLE(odbc_install_exec_seq),
2670     ADD_TABLE(odbc_media),
2671     ADD_TABLE(property)
2672 };
2673
2674 static const msi_table tl_tables[] =
2675 {
2676     ADD_TABLE(tl_component),
2677     ADD_TABLE(directory),
2678     ADD_TABLE(tl_feature),
2679     ADD_TABLE(tl_feature_comp),
2680     ADD_TABLE(tl_file),
2681     ADD_TABLE(tl_typelib),
2682     ADD_TABLE(tl_install_exec_seq),
2683     ADD_TABLE(media),
2684     ADD_TABLE(property)
2685 };
2686
2687 static const msi_table crs_tables[] =
2688 {
2689     ADD_TABLE(crs_component),
2690     ADD_TABLE(directory),
2691     ADD_TABLE(crs_feature),
2692     ADD_TABLE(crs_feature_comp),
2693     ADD_TABLE(crs_file),
2694     ADD_TABLE(crs_shortcut),
2695     ADD_TABLE(crs_install_exec_seq),
2696     ADD_TABLE(media),
2697     ADD_TABLE(property)
2698 };
2699
2700 static const msi_table pub_tables[] =
2701 {
2702     ADD_TABLE(directory),
2703     ADD_TABLE(pub_component),
2704     ADD_TABLE(pub_feature),
2705     ADD_TABLE(pub_feature_comp),
2706     ADD_TABLE(pub_file),
2707     ADD_TABLE(pub_publish_component),
2708     ADD_TABLE(pub_install_exec_seq),
2709     ADD_TABLE(media),
2710     ADD_TABLE(property)
2711 };
2712
2713 static const msi_table rd_tables[] =
2714 {
2715     ADD_TABLE(directory),
2716     ADD_TABLE(rd_component),
2717     ADD_TABLE(rd_feature),
2718     ADD_TABLE(rd_feature_comp),
2719     ADD_TABLE(rd_file),
2720     ADD_TABLE(rd_duplicate_file),
2721     ADD_TABLE(rd_install_exec_seq),
2722     ADD_TABLE(media),
2723     ADD_TABLE(property)
2724 };
2725
2726 static const msi_table rrv_tables[] =
2727 {
2728     ADD_TABLE(directory),
2729     ADD_TABLE(rrv_component),
2730     ADD_TABLE(rrv_feature),
2731     ADD_TABLE(rrv_feature_comp),
2732     ADD_TABLE(rrv_file),
2733     ADD_TABLE(rrv_registry),
2734     ADD_TABLE(rrv_remove_registry),
2735     ADD_TABLE(rrv_install_exec_seq),
2736     ADD_TABLE(media),
2737     ADD_TABLE(property)
2738 };
2739
2740 static const msi_table frp_tables[] =
2741 {
2742     ADD_TABLE(directory),
2743     ADD_TABLE(frp_component),
2744     ADD_TABLE(frp_feature),
2745     ADD_TABLE(frp_feature_comp),
2746     ADD_TABLE(frp_file),
2747     ADD_TABLE(frp_upgrade),
2748     ADD_TABLE(frp_custom_action),
2749     ADD_TABLE(frp_install_exec_seq),
2750     ADD_TABLE(media),
2751     ADD_TABLE(property)
2752 };
2753
2754 static const msi_table riv_tables[] =
2755 {
2756     ADD_TABLE(directory),
2757     ADD_TABLE(riv_component),
2758     ADD_TABLE(riv_feature),
2759     ADD_TABLE(riv_feature_comp),
2760     ADD_TABLE(riv_file),
2761     ADD_TABLE(riv_ini_file),
2762     ADD_TABLE(riv_remove_ini_file),
2763     ADD_TABLE(riv_install_exec_seq),
2764     ADD_TABLE(media),
2765     ADD_TABLE(property)
2766 };
2767
2768 static const msi_table res_tables[] =
2769 {
2770     ADD_TABLE(directory),
2771     ADD_TABLE(res_component),
2772     ADD_TABLE(res_feature),
2773     ADD_TABLE(res_feature_comp),
2774     ADD_TABLE(res_file),
2775     ADD_TABLE(res_environment),
2776     ADD_TABLE(res_install_exec_seq),
2777     ADD_TABLE(media),
2778     ADD_TABLE(property)
2779 };
2780
2781 static const msi_table rci_tables[] =
2782 {
2783     ADD_TABLE(directory),
2784     ADD_TABLE(rci_component),
2785     ADD_TABLE(rci_feature),
2786     ADD_TABLE(rci_feature_comp),
2787     ADD_TABLE(rci_file),
2788     ADD_TABLE(rci_appid),
2789     ADD_TABLE(rci_class),
2790     ADD_TABLE(rci_install_exec_seq),
2791     ADD_TABLE(media),
2792     ADD_TABLE(property)
2793 };
2794
2795 static const msi_table rei_tables[] =
2796 {
2797     ADD_TABLE(directory),
2798     ADD_TABLE(rei_component),
2799     ADD_TABLE(rei_feature),
2800     ADD_TABLE(rei_feature_comp),
2801     ADD_TABLE(rei_file),
2802     ADD_TABLE(rei_extension),
2803     ADD_TABLE(rei_verb),
2804     ADD_TABLE(rei_progid),
2805     ADD_TABLE(rei_install_exec_seq),
2806     ADD_TABLE(media),
2807     ADD_TABLE(property)
2808 };
2809
2810 static const msi_table rmi_tables[] =
2811 {
2812     ADD_TABLE(directory),
2813     ADD_TABLE(rmi_component),
2814     ADD_TABLE(rmi_feature),
2815     ADD_TABLE(rmi_feature_comp),
2816     ADD_TABLE(rmi_file),
2817     ADD_TABLE(rmi_extension),
2818     ADD_TABLE(rmi_verb),
2819     ADD_TABLE(rmi_mime),
2820     ADD_TABLE(rmi_install_exec_seq),
2821     ADD_TABLE(media),
2822     ADD_TABLE(property)
2823 };
2824
2825 /* cabinet definitions */
2826
2827 /* make the max size large so there is only one cab file */
2828 #define MEDIA_SIZE          0x7FFFFFFF
2829 #define FOLDER_THRESHOLD    900000
2830
2831 /* the FCI callbacks */
2832
2833 static void * CDECL mem_alloc(ULONG cb)
2834 {
2835     return HeapAlloc(GetProcessHeap(), 0, cb);
2836 }
2837
2838 static void CDECL mem_free(void *memory)
2839 {
2840     HeapFree(GetProcessHeap(), 0, memory);
2841 }
2842
2843 static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
2844 {
2845     sprintf(pccab->szCab, pv, pccab->iCab);
2846     return TRUE;
2847 }
2848
2849 static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
2850 {
2851     return 0;
2852 }
2853
2854 static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
2855                              BOOL fContinuation, void *pv)
2856 {
2857     return 0;
2858 }
2859
2860 static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
2861 {
2862     HANDLE handle;
2863     DWORD dwAccess = 0;
2864     DWORD dwShareMode = 0;
2865     DWORD dwCreateDisposition = OPEN_EXISTING;
2866     
2867     dwAccess = GENERIC_READ | GENERIC_WRITE;
2868     /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
2869     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
2870
2871     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
2872         dwCreateDisposition = OPEN_EXISTING;
2873     else
2874         dwCreateDisposition = CREATE_NEW;
2875
2876     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
2877                          dwCreateDisposition, 0, NULL);
2878
2879     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
2880
2881     return (INT_PTR)handle;
2882 }
2883
2884 static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
2885 {
2886     HANDLE handle = (HANDLE)hf;
2887     DWORD dwRead;
2888     BOOL res;
2889     
2890     res = ReadFile(handle, memory, cb, &dwRead, NULL);
2891     ok(res, "Failed to ReadFile\n");
2892
2893     return dwRead;
2894 }
2895
2896 static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
2897 {
2898     HANDLE handle = (HANDLE)hf;
2899     DWORD dwWritten;
2900     BOOL res;
2901
2902     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
2903     ok(res, "Failed to WriteFile\n");
2904
2905     return dwWritten;
2906 }
2907
2908 static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
2909 {
2910     HANDLE handle = (HANDLE)hf;
2911     ok(CloseHandle(handle), "Failed to CloseHandle\n");
2912
2913     return 0;
2914 }
2915
2916 static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
2917 {
2918     HANDLE handle = (HANDLE)hf;
2919     DWORD ret;
2920     
2921     ret = SetFilePointer(handle, dist, NULL, seektype);
2922     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
2923
2924     return ret;
2925 }
2926
2927 static int CDECL fci_delete(char *pszFile, int *err, void *pv)
2928 {
2929     BOOL ret = DeleteFileA(pszFile);
2930     ok(ret, "Failed to DeleteFile %s\n", pszFile);
2931
2932     return 0;
2933 }
2934
2935 static void init_functionpointers(void)
2936 {
2937     HMODULE hmsi = GetModuleHandleA("msi.dll");
2938     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
2939
2940 #define GET_PROC(mod, func) \
2941     p ## func = (void*)GetProcAddress(mod, #func); \
2942     if(!p ## func) \
2943       trace("GetProcAddress(%s) failed\n", #func);
2944
2945     GET_PROC(hmsi, MsiQueryComponentStateA);
2946     GET_PROC(hmsi, MsiSetExternalUIRecord);
2947     GET_PROC(hmsi, MsiSourceListEnumSourcesA);
2948     GET_PROC(hmsi, MsiSourceListGetInfoA);
2949
2950     GET_PROC(hadvapi32, ConvertSidToStringSidA);
2951
2952     hsrclient = LoadLibraryA("srclient.dll");
2953     GET_PROC(hsrclient, SRRemoveRestorePoint);
2954     GET_PROC(hsrclient, SRSetRestorePointA);
2955
2956 #undef GET_PROC
2957 }
2958
2959 static BOOL check_win9x(void)
2960 {
2961     SC_HANDLE scm;
2962
2963     scm = OpenSCManager(NULL, NULL, GENERIC_ALL);
2964     if (!scm && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
2965         return TRUE;
2966
2967     CloseServiceHandle(scm);
2968
2969     return FALSE;
2970 }
2971
2972 static LPSTR get_user_sid(LPSTR *usersid)
2973 {
2974     HANDLE token;
2975     BYTE buf[1024];
2976     DWORD size;
2977     PTOKEN_USER user;
2978
2979     if (!pConvertSidToStringSidA)
2980     {
2981         win_skip("ConvertSidToStringSidA is not available\n");
2982         return NULL;
2983     }
2984
2985     *usersid = NULL;
2986     OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
2987     size = sizeof(buf);
2988     GetTokenInformation(token, TokenUser, buf, size, &size);
2989     user = (PTOKEN_USER)buf;
2990     pConvertSidToStringSidA(user->User.Sid, usersid);
2991     ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError());
2992     CloseHandle(token);
2993     return *usersid;
2994 }
2995
2996 static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val)
2997 {
2998     CHAR buffer[0x20];
2999     UINT r;
3000     DWORD sz;
3001
3002     sz = sizeof buffer;
3003     r = MsiRecordGetString(rec, field, buffer, &sz);
3004     return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
3005 }
3006
3007 static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
3008 {
3009     LPSTR tempname;
3010
3011     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
3012     GetTempFileNameA(".", "xx", 0, tempname);
3013
3014     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
3015     {
3016         lstrcpyA(pszTempName, tempname);
3017         HeapFree(GetProcessHeap(), 0, tempname);
3018         return TRUE;
3019     }
3020
3021     HeapFree(GetProcessHeap(), 0, tempname);
3022
3023     return FALSE;
3024 }
3025
3026 static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
3027                                    USHORT *pattribs, int *err, void *pv)
3028 {
3029     BY_HANDLE_FILE_INFORMATION finfo;
3030     FILETIME filetime;
3031     HANDLE handle;
3032     DWORD attrs;
3033     BOOL res;
3034
3035     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
3036                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
3037
3038     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
3039
3040     res = GetFileInformationByHandle(handle, &finfo);
3041     ok(res, "Expected GetFileInformationByHandle to succeed\n");
3042    
3043     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
3044     FileTimeToDosDateTime(&filetime, pdate, ptime);
3045
3046     attrs = GetFileAttributes(pszName);
3047     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
3048
3049     return (INT_PTR)handle;
3050 }
3051
3052 static BOOL add_file(HFCI hfci, const char *file, TCOMP compress)
3053 {
3054     char path[MAX_PATH];
3055     char filename[MAX_PATH];
3056
3057     lstrcpyA(path, CURR_DIR);
3058     lstrcatA(path, "\\");
3059     lstrcatA(path, file);
3060
3061     lstrcpyA(filename, file);
3062
3063     return FCIAddFile(hfci, path, filename, FALSE, get_next_cabinet,
3064                       progress, get_open_info, compress);
3065 }
3066
3067 static void set_cab_parameters(PCCAB pCabParams, const CHAR *name, DWORD max_size)
3068 {
3069     ZeroMemory(pCabParams, sizeof(CCAB));
3070
3071     pCabParams->cb = max_size;
3072     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
3073     pCabParams->setID = 0xbeef;
3074     pCabParams->iCab = 1;
3075     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
3076     lstrcatA(pCabParams->szCabPath, "\\");
3077     lstrcpyA(pCabParams->szCab, name);
3078 }
3079
3080 static void create_cab_file(const CHAR *name, DWORD max_size, const CHAR *files)
3081 {
3082     CCAB cabParams;
3083     LPCSTR ptr;
3084     HFCI hfci;
3085     ERF erf;
3086     BOOL res;
3087
3088     set_cab_parameters(&cabParams, name, max_size);
3089
3090     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
3091                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
3092                       get_temp_file, &cabParams, NULL);
3093
3094     ok(hfci != NULL, "Failed to create an FCI context\n");
3095
3096     ptr = files;
3097     while (*ptr)
3098     {
3099         res = add_file(hfci, ptr, tcompTYPE_MSZIP);
3100         ok(res, "Failed to add file: %s\n", ptr);
3101         ptr += lstrlen(ptr) + 1;
3102     }
3103
3104     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
3105     ok(res, "Failed to flush the cabinet\n");
3106
3107     res = FCIDestroy(hfci);
3108     ok(res, "Failed to destroy the cabinet\n");
3109 }
3110
3111 static BOOL get_program_files_dir(LPSTR buf, LPSTR buf2)
3112 {
3113     HKEY hkey;
3114     DWORD type, size;
3115
3116     if (RegOpenKey(HKEY_LOCAL_MACHINE,
3117                    "Software\\Microsoft\\Windows\\CurrentVersion", &hkey))
3118         return FALSE;
3119
3120     size = MAX_PATH;
3121     if (RegQueryValueExA(hkey, "ProgramFilesDir", 0, &type, (LPBYTE)buf, &size)) {
3122         RegCloseKey(hkey);
3123         return FALSE;
3124     }
3125
3126     size = MAX_PATH;
3127     if (RegQueryValueExA(hkey, "CommonFilesDir", 0, &type, (LPBYTE)buf2, &size)) {
3128         RegCloseKey(hkey);
3129         return FALSE;
3130     }
3131
3132     RegCloseKey(hkey);
3133     return TRUE;
3134 }
3135
3136 static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
3137 {
3138     HANDLE file;
3139     DWORD written;
3140
3141     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
3142     if (file == INVALID_HANDLE_VALUE)
3143         return;
3144
3145     WriteFile(file, data, strlen(data), &written, NULL);
3146
3147     if (size)
3148     {
3149         SetFilePointer(file, size, NULL, FILE_BEGIN);
3150         SetEndOfFile(file);
3151     }
3152
3153     CloseHandle(file);
3154 }
3155
3156 #define create_file(name, size) create_file_data(name, name, size)
3157
3158 static void create_test_files(void)
3159 {
3160     CreateDirectoryA("msitest", NULL);
3161     create_file("msitest\\one.txt", 100);
3162     CreateDirectoryA("msitest\\first", NULL);
3163     create_file("msitest\\first\\two.txt", 100);
3164     CreateDirectoryA("msitest\\second", NULL);
3165     create_file("msitest\\second\\three.txt", 100);
3166
3167     create_file("four.txt", 100);
3168     create_file("five.txt", 100);
3169     create_cab_file("msitest.cab", MEDIA_SIZE, "four.txt\0five.txt\0");
3170
3171     create_file("msitest\\filename", 100);
3172     create_file("msitest\\service.exe", 100);
3173
3174     DeleteFileA("four.txt");
3175     DeleteFileA("five.txt");
3176 }
3177
3178 static BOOL delete_pf(const CHAR *rel_path, BOOL is_file)
3179 {
3180     CHAR path[MAX_PATH];
3181
3182     lstrcpyA(path, PROG_FILES_DIR);
3183     lstrcatA(path, "\\");
3184     lstrcatA(path, rel_path);
3185
3186     if (is_file)
3187         return DeleteFileA(path);
3188     else
3189         return RemoveDirectoryA(path);
3190 }
3191
3192 static BOOL delete_cf(const CHAR *rel_path, BOOL is_file)
3193 {
3194     CHAR path[MAX_PATH];
3195
3196     lstrcpyA(path, COMMON_FILES_DIR);
3197     lstrcatA(path, "\\");
3198     lstrcatA(path, rel_path);
3199
3200     if (is_file)
3201         return DeleteFileA(path);
3202     else
3203         return RemoveDirectoryA(path);
3204 }
3205
3206 static void delete_test_files(void)
3207 {
3208     DeleteFileA("msitest.msi");
3209     DeleteFileA("msitest.cab");
3210     DeleteFileA("msitest\\second\\three.txt");
3211     DeleteFileA("msitest\\first\\two.txt");
3212     DeleteFileA("msitest\\one.txt");
3213     DeleteFileA("msitest\\service.exe");
3214     DeleteFileA("msitest\\filename");
3215     RemoveDirectoryA("msitest\\second");
3216     RemoveDirectoryA("msitest\\first");
3217     RemoveDirectoryA("msitest");
3218 }
3219
3220 static void write_file(const CHAR *filename, const char *data, int data_size)
3221 {
3222     DWORD size;
3223
3224     HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
3225                            CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
3226
3227     WriteFile(hf, data, data_size, &size, NULL);
3228     CloseHandle(hf);
3229 }
3230
3231 static void write_msi_summary_info(MSIHANDLE db, INT wordcount)
3232 {
3233     MSIHANDLE summary;
3234     UINT r;
3235
3236     r = MsiGetSummaryInformationA(db, NULL, 5, &summary);
3237     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3238
3239     r = MsiSummaryInfoSetPropertyA(summary, PID_TEMPLATE, VT_LPSTR, 0, NULL, ";1033");
3240     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3241
3242     r = MsiSummaryInfoSetPropertyA(summary, PID_REVNUMBER, VT_LPSTR, 0, NULL,
3243                                    "{004757CA-5092-49c2-AD20-28E1CE0DF5F2}");
3244     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3245
3246     r = MsiSummaryInfoSetPropertyA(summary, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
3247     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3248
3249     r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, wordcount, NULL, NULL);
3250     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3251
3252     r = MsiSummaryInfoSetPropertyA(summary, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
3253     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3254
3255     /* write the summary changes back to the stream */
3256     r = MsiSummaryInfoPersist(summary);
3257     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3258
3259     MsiCloseHandle(summary);
3260 }
3261
3262 #define create_database(name, tables, num_tables) \
3263     create_database_wordcount(name, tables, num_tables, 0);
3264
3265 static void create_database_wordcount(const CHAR *name, const msi_table *tables,
3266                                       int num_tables, INT wordcount)
3267 {
3268     MSIHANDLE db;
3269     UINT r;
3270     int j;
3271
3272     r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
3273     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3274
3275     /* import the tables into the database */
3276     for (j = 0; j < num_tables; j++)
3277     {
3278         const msi_table *table = &tables[j];
3279
3280         write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
3281
3282         r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
3283         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3284
3285         DeleteFileA(table->filename);
3286     }
3287
3288     write_msi_summary_info(db, wordcount);
3289
3290     r = MsiDatabaseCommit(db);
3291     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3292
3293     MsiCloseHandle(db);
3294 }
3295
3296 static void check_service_is_installed(void)
3297 {
3298     SC_HANDLE scm, service;
3299     BOOL res;
3300
3301     scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
3302     ok(scm != NULL, "Failed to open the SC Manager\n");
3303
3304     service = OpenService(scm, "TestService", SC_MANAGER_ALL_ACCESS);
3305     ok(service != NULL, "Failed to open TestService\n");
3306
3307     res = DeleteService(service);
3308     ok(res, "Failed to delete TestService\n");
3309
3310     CloseServiceHandle(service);
3311     CloseServiceHandle(scm);
3312 }
3313
3314 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
3315 {
3316     RESTOREPOINTINFOA spec;
3317
3318     spec.dwEventType = event_type;
3319     spec.dwRestorePtType = APPLICATION_INSTALL;
3320     spec.llSequenceNumber = status->llSequenceNumber;
3321     lstrcpyA(spec.szDescription, "msitest restore point");
3322
3323     return pSRSetRestorePointA(&spec, status);
3324 }
3325
3326 static void remove_restore_point(DWORD seq_number)
3327 {
3328     DWORD res;
3329
3330     res = pSRRemoveRestorePoint(seq_number);
3331     if (res != ERROR_SUCCESS)
3332         trace("Failed to remove the restore point : %08x\n", res);
3333 }
3334
3335 static void test_MsiInstallProduct(void)
3336 {
3337     UINT r;
3338     CHAR path[MAX_PATH];
3339     LONG res;
3340     HKEY hkey;
3341     DWORD num, size, type;
3342
3343     if (on_win9x)
3344     {
3345         win_skip("Services are not implemented on Win9x and WinMe\n");
3346         return;
3347     }
3348
3349     /* szPackagePath is NULL */
3350     r = MsiInstallProductA(NULL, "INSTALL=ALL");
3351     ok(r == ERROR_INVALID_PARAMETER,
3352        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3353
3354     /* both szPackagePath and szCommandLine are NULL */
3355     r = MsiInstallProductA(NULL, NULL);
3356     ok(r == ERROR_INVALID_PARAMETER,
3357        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
3358
3359     /* szPackagePath is empty */
3360     r = MsiInstallProductA("", "INSTALL=ALL");
3361     ok(r == ERROR_PATH_NOT_FOUND,
3362        "Expected ERROR_PATH_NOT_FOUND, got %d\n", r);
3363
3364     create_test_files();
3365     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
3366
3367     /* install, don't publish */
3368     r = MsiInstallProductA(msifile, NULL);
3369     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3370
3371     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3372     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3373     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3374     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3375     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3376     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3377     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3378     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3379     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3380     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3381     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3382     ok(delete_pf("msitest", FALSE), "File not installed\n");
3383
3384     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3385     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3386
3387     size = MAX_PATH;
3388     type = REG_SZ;
3389     res = RegQueryValueExA(hkey, "Name", NULL, &type, (LPBYTE)path, &size);
3390     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3391     ok(!lstrcmpA(path, "imaname"), "Expected imaname, got %s\n", path);
3392
3393     size = MAX_PATH;
3394     type = REG_SZ;
3395     res = RegQueryValueExA(hkey, "blah", NULL, &type, (LPBYTE)path, &size);
3396     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3397
3398     size = sizeof(num);
3399     type = REG_DWORD;
3400     res = RegQueryValueExA(hkey, "number", NULL, &type, (LPBYTE)&num, &size);
3401     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3402     ok(num == 314, "Expected 314, got %d\n", num);
3403
3404     size = MAX_PATH;
3405     type = REG_SZ;
3406     res = RegQueryValueExA(hkey, "OrderTestName", NULL, &type, (LPBYTE)path, &size);
3407     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3408     ok(!lstrcmpA(path, "OrderTestValue"), "Expected OrderTestValue, got %s\n", path);
3409
3410     check_service_is_installed();
3411
3412     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
3413
3414     /* not published, reinstall */
3415     r = MsiInstallProductA(msifile, NULL);
3416     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3417
3418     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3419     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3420     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3421     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3422     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3423     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3424     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3425     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3426     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3427     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3428     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3429     ok(delete_pf("msitest", FALSE), "File not installed\n");
3430
3431     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3432     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3433     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
3434
3435     create_database(msifile, up_tables, sizeof(up_tables) / sizeof(msi_table));
3436
3437     /* not published, RemovePreviousVersions set */
3438     r = MsiInstallProductA(msifile, NULL);
3439     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3440
3441     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3442     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3443     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3444     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3445     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3446     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3447     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3448     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3449     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3450     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3451     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3452     ok(delete_pf("msitest", FALSE), "File not installed\n");
3453
3454     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3455     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3456     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
3457
3458     create_database(msifile, up2_tables, sizeof(up2_tables) / sizeof(msi_table));
3459
3460     /* not published, version number bumped */
3461     r = MsiInstallProductA(msifile, NULL);
3462     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3463
3464     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3465     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3466     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3467     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3468     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3469     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3470     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3471     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3472     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3473     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3474     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3475     ok(delete_pf("msitest", FALSE), "File not installed\n");
3476
3477     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3478     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3479     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
3480
3481     create_database(msifile, up3_tables, sizeof(up3_tables) / sizeof(msi_table));
3482
3483     /* not published, RemovePreviousVersions set and version number bumped */
3484     r = MsiInstallProductA(msifile, NULL);
3485     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3486
3487     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3488     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3489     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3490     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3491     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3492     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3493     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3494     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3495     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3496     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3497     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3498     ok(delete_pf("msitest", FALSE), "File not installed\n");
3499
3500     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3501     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
3502     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
3503
3504     create_database(msifile, up4_tables, sizeof(up4_tables) / sizeof(msi_table));
3505
3506     /* install, publish product */
3507     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
3508     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3509
3510     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3511     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3512     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3513     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3514     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3515     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3516     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3517     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3518     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3519     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3520     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3521     ok(delete_pf("msitest", FALSE), "File not installed\n");
3522
3523     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3524     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3525
3526     create_database(msifile, up4_tables, sizeof(up4_tables) / sizeof(msi_table));
3527
3528     /* published, reinstall */
3529     r = MsiInstallProductA(msifile, NULL);
3530     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3531
3532     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3533     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3534     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3535     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3536     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3537     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3538     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3539     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3540     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3541     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3542     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3543     ok(delete_pf("msitest", FALSE), "File not installed\n");
3544
3545     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3546     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3547
3548     create_database(msifile, up5_tables, sizeof(up5_tables) / sizeof(msi_table));
3549
3550     /* published product, RemovePreviousVersions set */
3551     r = MsiInstallProductA(msifile, NULL);
3552     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3553
3554     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3555     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3556     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3557     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3558     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3559     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3560     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3561     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3562     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3563     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3564     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3565     ok(delete_pf("msitest", FALSE), "File not installed\n");
3566
3567     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3568     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3569
3570     create_database(msifile, up6_tables, sizeof(up6_tables) / sizeof(msi_table));
3571
3572     /* published product, version number bumped */
3573     r = MsiInstallProductA(msifile, NULL);
3574     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3575
3576     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3577     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3578     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3579     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3580     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3581     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3582     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3583     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3584     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3585     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3586     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3587     ok(delete_pf("msitest", FALSE), "File not installed\n");
3588
3589     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3590     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3591
3592     create_database(msifile, up7_tables, sizeof(up7_tables) / sizeof(msi_table));
3593
3594     /* published product, RemovePreviousVersions set and version number bumped */
3595     r = MsiInstallProductA(msifile, NULL);
3596     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3597
3598     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
3599     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
3600     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
3601     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
3602     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
3603     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
3604     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
3605     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
3606     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
3607     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
3608     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
3609     ok(delete_pf("msitest", FALSE), "File not installed\n");
3610
3611     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
3612     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3613
3614     r = MsiInstallProductA(msifile, "REMOVE=ALL");
3615     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3616
3617     delete_test_files();
3618 }
3619
3620 static void test_MsiSetComponentState(void)
3621 {
3622     INSTALLSTATE installed, action;
3623     MSIHANDLE package;
3624     char path[MAX_PATH];
3625     UINT r;
3626
3627     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
3628
3629     CoInitialize(NULL);
3630
3631     lstrcpy(path, CURR_DIR);
3632     lstrcat(path, "\\");
3633     lstrcat(path, msifile);
3634
3635     r = MsiOpenPackage(path, &package);
3636     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3637
3638     r = MsiDoAction(package, "CostInitialize");
3639     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3640
3641     r = MsiDoAction(package, "FileCost");
3642     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3643
3644     r = MsiDoAction(package, "CostFinalize");
3645     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3646
3647     r = MsiGetComponentState(package, "dangler", &installed, &action);
3648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3649     ok(installed == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", installed);
3650     ok(action == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", action);
3651
3652     r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
3653     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3654
3655     MsiCloseHandle(package);
3656     CoUninitialize();
3657
3658     DeleteFileA(msifile);
3659 }
3660
3661 static void test_packagecoltypes(void)
3662 {
3663     MSIHANDLE hdb, view, rec;
3664     char path[MAX_PATH];
3665     LPCSTR query;
3666     UINT r, count;
3667
3668     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
3669
3670     CoInitialize(NULL);
3671
3672     lstrcpy(path, CURR_DIR);
3673     lstrcat(path, "\\");
3674     lstrcat(path, msifile);
3675
3676     r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
3677     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3678
3679     query = "SELECT * FROM `Media`";
3680     r = MsiDatabaseOpenView( hdb, query, &view );
3681     ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
3682
3683     r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
3684     count = MsiRecordGetFieldCount( rec );
3685     ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
3686     ok(count == 6, "Expected 6, got %d\n", count);
3687     ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
3688     ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
3689     ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
3690     ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
3691     ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
3692     ok(check_record(rec, 6, "Source"), "wrong column label\n");
3693     MsiCloseHandle(rec);
3694
3695     r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
3696     count = MsiRecordGetFieldCount( rec );
3697     ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
3698     ok(count == 6, "Expected 6, got %d\n", count);
3699     ok(check_record(rec, 1, "i2"), "wrong column label\n");
3700     ok(check_record(rec, 2, "i4"), "wrong column label\n");
3701     ok(check_record(rec, 3, "L64"), "wrong column label\n");
3702     ok(check_record(rec, 4, "S255"), "wrong column label\n");
3703     ok(check_record(rec, 5, "S32"), "wrong column label\n");
3704     ok(check_record(rec, 6, "S72"), "wrong column label\n");
3705
3706     MsiCloseHandle(rec);
3707     MsiCloseHandle(view);
3708     MsiCloseHandle(hdb);
3709     CoUninitialize();
3710
3711     DeleteFile(msifile);
3712 }
3713
3714 static void create_cc_test_files(void)
3715 {
3716     CCAB cabParams;
3717     HFCI hfci;
3718     ERF erf;
3719     static CHAR cab_context[] = "test%d.cab";
3720     BOOL res;
3721
3722     create_file("maximus", 500);
3723     create_file("augustus", 50000);
3724     create_file("tiberius", 500);
3725     create_file("caesar", 500);
3726
3727     set_cab_parameters(&cabParams, "test1.cab", 40000);
3728
3729     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
3730                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
3731                       get_temp_file, &cabParams, cab_context);
3732     ok(hfci != NULL, "Failed to create an FCI context\n");
3733
3734     res = add_file(hfci, "maximus", tcompTYPE_NONE);
3735     ok(res, "Failed to add file maximus\n");
3736
3737     res = add_file(hfci, "augustus", tcompTYPE_NONE);
3738     ok(res, "Failed to add file augustus\n");
3739
3740     res = add_file(hfci, "tiberius", tcompTYPE_NONE);
3741     ok(res, "Failed to add file tiberius\n");
3742
3743     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
3744     ok(res, "Failed to flush the cabinet\n");
3745
3746     res = FCIDestroy(hfci);
3747     ok(res, "Failed to destroy the cabinet\n");
3748
3749     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
3750
3751     DeleteFile("maximus");
3752     DeleteFile("augustus");
3753     DeleteFile("tiberius");
3754     DeleteFile("caesar");
3755 }
3756
3757 static void delete_cab_files(void)
3758 {
3759     SHFILEOPSTRUCT shfl;
3760     CHAR path[MAX_PATH+10];
3761
3762     lstrcpyA(path, CURR_DIR);
3763     lstrcatA(path, "\\*.cab");
3764     path[strlen(path) + 1] = '\0';
3765
3766     shfl.hwnd = NULL;
3767     shfl.wFunc = FO_DELETE;
3768     shfl.pFrom = path;
3769     shfl.pTo = NULL;
3770     shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
3771
3772     SHFileOperation(&shfl);
3773 }
3774
3775 static void test_continuouscabs(void)
3776 {
3777     UINT r;
3778
3779     create_cc_test_files();
3780     create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
3781
3782     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3783
3784     r = MsiInstallProductA(msifile, NULL);
3785     if (r == ERROR_SUCCESS) /* win9x has a problem with this */
3786     {
3787         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3788         ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3789         ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3790         ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3791         ok(delete_pf("msitest", FALSE), "File not installed\n");
3792     }
3793
3794     delete_cab_files();
3795     DeleteFile(msifile);
3796
3797     create_cc_test_files();
3798     create_database(msifile, cc2_tables, sizeof(cc2_tables) / sizeof(msi_table));
3799
3800     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3801
3802     r = MsiInstallProductA(msifile, NULL);
3803     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3804     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3805     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
3806     ok(delete_pf("msitest\\tiberius", TRUE), "File not installed\n");
3807     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3808     ok(delete_pf("msitest", FALSE), "File not installed\n");
3809
3810     delete_cab_files();
3811     DeleteFile(msifile);
3812 }
3813
3814 static void test_caborder(void)
3815 {
3816     UINT r;
3817
3818     create_file("imperator", 100);
3819     create_file("maximus", 500);
3820     create_file("augustus", 50000);
3821     create_file("caesar", 500);
3822
3823     create_database(msifile, cc_tables, sizeof(cc_tables) / sizeof(msi_table));
3824
3825     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3826
3827     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
3828     create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
3829     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
3830
3831     r = MsiInstallProductA(msifile, NULL);
3832     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3833     ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3834     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3835     todo_wine
3836     {
3837         ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3838         ok(!delete_pf("msitest", FALSE), "File is installed\n");
3839     }
3840
3841     delete_cab_files();
3842
3843     create_cab_file("test1.cab", MEDIA_SIZE, "imperator\0");
3844     create_cab_file("test2.cab", MEDIA_SIZE, "maximus\0augustus\0");
3845     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
3846
3847     r = MsiInstallProductA(msifile, NULL);
3848     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3849     ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3850     ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3851     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3852     todo_wine
3853     {
3854         ok(!delete_pf("msitest", FALSE), "File is installed\n");
3855     }
3856
3857     delete_cab_files();
3858     DeleteFile(msifile);
3859
3860     create_cc_test_files();
3861     create_database(msifile, co_tables, sizeof(co_tables) / sizeof(msi_table));
3862
3863     r = MsiInstallProductA(msifile, NULL);
3864     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3865     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3866     ok(!delete_pf("msitest", FALSE), "File is installed\n");
3867     todo_wine
3868     {
3869         ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3870         ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3871     }
3872
3873     delete_cab_files();
3874     DeleteFile(msifile);
3875
3876     create_cc_test_files();
3877     create_database(msifile, co2_tables, sizeof(co2_tables) / sizeof(msi_table));
3878
3879     r = MsiInstallProductA(msifile, NULL);
3880     ok(!delete_pf("msitest\\caesar", TRUE), "File is installed\n");
3881     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
3882     todo_wine
3883     {
3884         ok(!delete_pf("msitest\\augustus", TRUE), "File is installed\n");
3885         ok(!delete_pf("msitest\\maximus", TRUE), "File is installed\n");
3886         ok(!delete_pf("msitest", FALSE), "File is installed\n");
3887     }
3888
3889     delete_cab_files();
3890     DeleteFile("imperator");
3891     DeleteFile("maximus");
3892     DeleteFile("augustus");
3893     DeleteFile("caesar");
3894     DeleteFile(msifile);
3895 }
3896
3897 static void test_mixedmedia(void)
3898 {
3899     UINT r;
3900
3901     CreateDirectoryA("msitest", NULL);
3902     create_file("msitest\\maximus", 500);
3903     create_file("msitest\\augustus", 500);
3904     create_file("caesar", 500);
3905
3906     create_database(msifile, mm_tables, sizeof(mm_tables) / sizeof(msi_table));
3907
3908     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3909
3910     create_cab_file("test1.cab", MEDIA_SIZE, "caesar\0");
3911
3912     r = MsiInstallProductA(msifile, NULL);
3913     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3914     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3915     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3916     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3917     ok(delete_pf("msitest", FALSE), "File not installed\n");
3918
3919     /* Delete the files in the temp (current) folder */
3920     DeleteFile("msitest\\maximus");
3921     DeleteFile("msitest\\augustus");
3922     RemoveDirectory("msitest");
3923     DeleteFile("caesar");
3924     DeleteFile("test1.cab");
3925     DeleteFile(msifile);
3926 }
3927
3928 static void test_samesequence(void)
3929 {
3930     UINT r;
3931
3932     create_cc_test_files();
3933     create_database(msifile, ss_tables, sizeof(ss_tables) / sizeof(msi_table));
3934
3935     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3936
3937     r = MsiInstallProductA(msifile, NULL);
3938     if (r == ERROR_SUCCESS) /* win9x has a problem with this */
3939     {
3940         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3941         ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3942         ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3943         ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
3944         ok(delete_pf("msitest", FALSE), "File not installed\n");
3945     }
3946
3947     delete_cab_files();
3948     DeleteFile(msifile);
3949 }
3950
3951 static void test_uiLevelFlags(void)
3952 {
3953     UINT r;
3954
3955     create_cc_test_files();
3956     create_database(msifile, ui_tables, sizeof(ui_tables) / sizeof(msi_table));
3957
3958     MsiSetInternalUI(INSTALLUILEVEL_NONE | INSTALLUILEVEL_SOURCERESONLY, NULL);
3959
3960     r = MsiInstallProductA(msifile, NULL);
3961     if (r == ERROR_SUCCESS) /* win9x has a problem with this */
3962     {
3963         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
3964         ok(!delete_pf("msitest\\maximus", TRUE), "UI install occurred, but execute-only was requested.\n");
3965         ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
3966         ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
3967         ok(delete_pf("msitest", FALSE), "File not installed\n");
3968     }
3969
3970     delete_cab_files();
3971     DeleteFile(msifile);
3972 }
3973
3974 static BOOL file_matches(LPSTR path)
3975 {
3976     CHAR buf[MAX_PATH];
3977     HANDLE file;
3978     DWORD size;
3979
3980     file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
3981                       NULL, OPEN_EXISTING, 0, NULL);
3982
3983     ZeroMemory(buf, MAX_PATH);
3984     ReadFile(file, buf, 15, &size, NULL);
3985     CloseHandle(file);
3986
3987     return !lstrcmp(buf, "msitest\\maximus");
3988 }
3989
3990 static void test_readonlyfile(void)
3991 {
3992     UINT r;
3993     DWORD size;
3994     HANDLE file;
3995     CHAR path[MAX_PATH];
3996
3997     CreateDirectoryA("msitest", NULL);
3998     create_file("msitest\\maximus", 500);
3999     create_database(msifile, rof_tables, sizeof(rof_tables) / sizeof(msi_table));
4000
4001     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4002
4003     lstrcpy(path, PROG_FILES_DIR);
4004     lstrcat(path, "\\msitest");
4005     CreateDirectory(path, NULL);
4006
4007     lstrcat(path, "\\maximus");
4008     file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4009                       NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
4010
4011     WriteFile(file, "readonlyfile", strlen("readonlyfile"), &size, NULL);
4012     CloseHandle(file);
4013
4014     r = MsiInstallProductA(msifile, NULL);
4015     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4016     ok(file_matches(path), "Expected file to be overwritten\n");
4017     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4018     ok(delete_pf("msitest", FALSE), "File not installed\n");
4019
4020     /* Delete the files in the temp (current) folder */
4021     DeleteFile("msitest\\maximus");
4022     RemoveDirectory("msitest");
4023     DeleteFile(msifile);
4024 }
4025
4026 static void test_readonlyfile_cab(void)
4027 {
4028     UINT r;
4029     DWORD size;
4030     HANDLE file;
4031     CHAR path[MAX_PATH];
4032     CHAR buf[16];
4033
4034     CreateDirectoryA("msitest", NULL);
4035     create_file("maximus", 500);
4036     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4037     DeleteFile("maximus");
4038
4039     create_database(msifile, rofc_tables, sizeof(rofc_tables) / sizeof(msi_table));
4040
4041     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4042
4043     lstrcpy(path, PROG_FILES_DIR);
4044     lstrcat(path, "\\msitest");
4045     CreateDirectory(path, NULL);
4046
4047     lstrcat(path, "\\maximus");
4048     file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4049                       NULL, CREATE_NEW, FILE_ATTRIBUTE_READONLY, NULL);
4050
4051     WriteFile(file, "readonlyfile", strlen("readonlyfile"), &size, NULL);
4052     CloseHandle(file);
4053
4054     r = MsiInstallProductA(msifile, NULL);
4055     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4056
4057     memset( buf, 0, sizeof(buf) );
4058     if ((file = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
4059                            NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
4060     {
4061         ReadFile(file, buf, sizeof(buf) - 1, &size, NULL);
4062         CloseHandle(file);
4063     }
4064     ok(!memcmp( buf, "maximus", sizeof("maximus")-1 ), "Expected file to be overwritten, got '%s'\n", buf);
4065     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4066     ok(delete_pf("msitest", FALSE), "File not installed\n");
4067
4068     /* Delete the files in the temp (current) folder */
4069     delete_cab_files();
4070     DeleteFile("msitest\\maximus");
4071     RemoveDirectory("msitest");
4072     DeleteFile(msifile);
4073 }
4074
4075 static BOOL add_cabinet_storage(LPCSTR db, LPCSTR cabinet)
4076 {
4077     WCHAR dbW[MAX_PATH], cabinetW[MAX_PATH];
4078     IStorage *stg;
4079     IStream *stm;
4080     HRESULT hr;
4081     HANDLE handle;
4082
4083     MultiByteToWideChar(CP_ACP, 0, db, -1, dbW, MAX_PATH);
4084     hr = StgOpenStorage(dbW, NULL, STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
4085     if (FAILED(hr))
4086         return FALSE;
4087
4088     MultiByteToWideChar(CP_ACP, 0, cabinet, -1, cabinetW, MAX_PATH);
4089     hr = IStorage_CreateStream(stg, cabinetW, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
4090     if (FAILED(hr))
4091     {
4092         IStorage_Release(stg);
4093         return FALSE;
4094     }
4095
4096     handle = CreateFileW(cabinetW, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
4097     if (handle != INVALID_HANDLE_VALUE)
4098     {
4099         DWORD count;
4100         char buffer[1024];
4101         if (ReadFile(handle, buffer, sizeof(buffer), &count, NULL))
4102             IStream_Write(stm, buffer, count, &count);
4103         CloseHandle(handle);
4104     }
4105
4106     IStream_Release(stm);
4107     IStorage_Release(stg);
4108
4109     return TRUE;
4110 }
4111
4112 static void test_lastusedsource(void)
4113 {
4114     static char prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
4115
4116     UINT r;
4117     char value[MAX_PATH], path[MAX_PATH];
4118     DWORD size;
4119
4120     if (!pMsiSourceListGetInfoA)
4121     {
4122         win_skip("MsiSourceListGetInfoA is not available\n");
4123         return;
4124     }
4125
4126     CreateDirectoryA("msitest", NULL);
4127     create_file("maximus", 500);
4128     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4129     DeleteFile("maximus");
4130
4131     create_database("msifile0.msi", lus0_tables, sizeof(lus0_tables) / sizeof(msi_table));
4132     create_database("msifile1.msi", lus1_tables, sizeof(lus1_tables) / sizeof(msi_table));
4133     create_database("msifile2.msi", lus2_tables, sizeof(lus2_tables) / sizeof(msi_table));
4134
4135     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4136
4137     /* no cabinet file */
4138
4139     size = MAX_PATH;
4140     lstrcpyA(value, "aaa");
4141     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4142                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4143     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4144     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4145
4146     r = MsiInstallProductA("msifile0.msi", "PUBLISH_PRODUCT=1");
4147     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4148
4149     lstrcpyA(path, CURR_DIR);
4150     lstrcatA(path, "\\");
4151
4152     size = MAX_PATH;
4153     lstrcpyA(value, "aaa");
4154     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4155                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4156     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4157     todo_wine
4158     {
4159     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
4160     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
4161     }
4162
4163     r = MsiInstallProductA("msifile0.msi", "REMOVE=ALL");
4164     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4165
4166     /* separate cabinet file */
4167
4168     size = MAX_PATH;
4169     lstrcpyA(value, "aaa");
4170     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4171                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4172     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4173     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4174
4175     r = MsiInstallProductA("msifile1.msi", "PUBLISH_PRODUCT=1");
4176     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4177
4178     lstrcpyA(path, CURR_DIR);
4179     lstrcatA(path, "\\");
4180
4181     size = MAX_PATH;
4182     lstrcpyA(value, "aaa");
4183     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4184                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4185     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4186     todo_wine
4187     {
4188     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
4189     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
4190     }
4191
4192     r = MsiInstallProductA("msifile1.msi", "REMOVE=ALL");
4193     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4194
4195     size = MAX_PATH;
4196     lstrcpyA(value, "aaa");
4197     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4198                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4199     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4200     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4201
4202     /* embedded cabinet stream */
4203
4204     add_cabinet_storage("msifile2.msi", "test1.cab");
4205
4206     r = MsiInstallProductA("msifile2.msi", "PUBLISH_PRODUCT=1");
4207     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4208
4209     size = MAX_PATH;
4210     lstrcpyA(value, "aaa");
4211     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4212                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4213     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4214     todo_wine
4215     {
4216     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
4217     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
4218     }
4219
4220     r = MsiInstallProductA("msifile2.msi", "REMOVE=ALL");
4221     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4222
4223     size = MAX_PATH;
4224     lstrcpyA(value, "aaa");
4225     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
4226                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
4227     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
4228     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
4229
4230     /* Delete the files in the temp (current) folder */
4231     delete_cab_files();
4232     DeleteFile("msitest\\maximus");
4233     RemoveDirectory("msitest");
4234     DeleteFile("msifile0.msi");
4235     DeleteFile("msifile1.msi");
4236     DeleteFile("msifile2.msi");
4237 }
4238
4239 static void test_setdirproperty(void)
4240 {
4241     UINT r;
4242
4243     CreateDirectoryA("msitest", NULL);
4244     create_file("msitest\\maximus", 500);
4245     create_database(msifile, sdp_tables, sizeof(sdp_tables) / sizeof(msi_table));
4246
4247     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4248
4249     r = MsiInstallProductA(msifile, NULL);
4250     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4251     ok(delete_cf("msitest\\maximus", TRUE), "File not installed\n");
4252     ok(delete_cf("msitest", FALSE), "File not installed\n");
4253
4254     /* Delete the files in the temp (current) folder */
4255     DeleteFile(msifile);
4256     DeleteFile("msitest\\maximus");
4257     RemoveDirectory("msitest");
4258 }
4259
4260 static void test_cabisextracted(void)
4261 {
4262     UINT r;
4263
4264     CreateDirectoryA("msitest", NULL);
4265     create_file("msitest\\gaius", 500);
4266     create_file("maximus", 500);
4267     create_file("augustus", 500);
4268     create_file("caesar", 500);
4269
4270     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
4271     create_cab_file("test2.cab", MEDIA_SIZE, "augustus\0");
4272     create_cab_file("test3.cab", MEDIA_SIZE, "caesar\0");
4273
4274     create_database(msifile, cie_tables, sizeof(cie_tables) / sizeof(msi_table));
4275
4276     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4277
4278     r = MsiInstallProductA(msifile, NULL);
4279     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4280     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4281     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
4282     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
4283     ok(delete_pf("msitest\\gaius", TRUE), "File not installed\n");
4284     ok(delete_pf("msitest", FALSE), "File not installed\n");
4285
4286     /* Delete the files in the temp (current) folder */
4287     delete_cab_files();
4288     DeleteFile(msifile);
4289     DeleteFile("maximus");
4290     DeleteFile("augustus");
4291     DeleteFile("caesar");
4292     DeleteFile("msitest\\gaius");
4293     RemoveDirectory("msitest");
4294 }
4295
4296 static void test_concurrentinstall(void)
4297 {
4298     UINT r;
4299     CHAR path[MAX_PATH];
4300
4301     CreateDirectoryA("msitest", NULL);
4302     CreateDirectoryA("msitest\\msitest", NULL);
4303     create_file("msitest\\maximus", 500);
4304     create_file("msitest\\msitest\\augustus", 500);
4305
4306     create_database(msifile, ci_tables, sizeof(ci_tables) / sizeof(msi_table));
4307
4308     lstrcpyA(path, CURR_DIR);
4309     lstrcatA(path, "\\msitest\\concurrent.msi");
4310     create_database(path, ci2_tables, sizeof(ci2_tables) / sizeof(msi_table));
4311
4312     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4313
4314     r = MsiInstallProductA(msifile, NULL);
4315     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4316     if (!delete_pf("msitest\\augustus", TRUE))
4317         trace("concurrent installs not supported\n");
4318     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4319     ok(delete_pf("msitest", FALSE), "File not installed\n");
4320
4321     DeleteFile(path);
4322
4323     r = MsiInstallProductA(msifile, NULL);
4324     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4325     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4326     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
4327     ok(delete_pf("msitest", FALSE), "File not installed\n");
4328
4329     DeleteFile(msifile);
4330     DeleteFile("msitest\\msitest\\augustus");
4331     DeleteFile("msitest\\maximus");
4332     RemoveDirectory("msitest\\msitest");
4333     RemoveDirectory("msitest");
4334 }
4335
4336 static void test_setpropertyfolder(void)
4337 {
4338     UINT r;
4339     CHAR path[MAX_PATH];
4340     DWORD attr;
4341
4342     lstrcpyA(path, PROG_FILES_DIR);
4343     lstrcatA(path, "\\msitest\\added");
4344
4345     CreateDirectoryA("msitest", NULL);
4346     create_file("msitest\\maximus", 500);
4347
4348     create_database(msifile, spf_tables, sizeof(spf_tables) / sizeof(msi_table));
4349
4350     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4351
4352     r = MsiInstallProductA(msifile, NULL);
4353     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
4354     attr = GetFileAttributesA(path);
4355     if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
4356     {
4357         ok(delete_pf("msitest\\added\\maximus", TRUE), "File not installed\n");
4358         ok(delete_pf("msitest\\added", FALSE), "File not installed\n");
4359         ok(delete_pf("msitest", FALSE), "File not installed\n");
4360     }
4361     else
4362     {
4363         trace("changing folder property not supported\n");
4364         ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4365         ok(delete_pf("msitest", FALSE), "File not installed\n");
4366     }
4367
4368     /* Delete the files in the temp (current) folder */
4369     DeleteFile(msifile);
4370     DeleteFile("msitest\\maximus");
4371     RemoveDirectory("msitest");
4372 }
4373
4374 static BOOL file_exists(LPCSTR file)
4375 {
4376     return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
4377 }
4378
4379 static BOOL pf_exists(LPCSTR file)
4380 {
4381     CHAR path[MAX_PATH];
4382
4383     lstrcpyA(path, PROG_FILES_DIR);
4384     lstrcatA(path, "\\");
4385     lstrcatA(path, file);
4386
4387     return file_exists(path);
4388 }
4389
4390 static void delete_pfmsitest_files(void)
4391 {
4392     SHFILEOPSTRUCT shfl;
4393     CHAR path[MAX_PATH+11];
4394
4395     lstrcpyA(path, PROG_FILES_DIR);
4396     lstrcatA(path, "\\msitest\\*");
4397     path[strlen(path) + 1] = '\0';
4398
4399     shfl.hwnd = NULL;
4400     shfl.wFunc = FO_DELETE;
4401     shfl.pFrom = path;
4402     shfl.pTo = NULL;
4403     shfl.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_NORECURSION | FOF_SILENT;
4404
4405     SHFileOperation(&shfl);
4406
4407     lstrcpyA(path, PROG_FILES_DIR);
4408     lstrcatA(path, "\\msitest");
4409     RemoveDirectoryA(path);
4410 }
4411
4412 static void check_reg_str(HKEY prodkey, LPCSTR name, LPCSTR expected, BOOL bcase, DWORD line)
4413 {
4414     char val[MAX_PATH];
4415     DWORD size, type;
4416     LONG res;
4417
4418     size = MAX_PATH;
4419     val[0] = '\0';
4420     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)val, &size);
4421
4422     if (res != ERROR_SUCCESS ||
4423         (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_MULTI_SZ))
4424     {
4425         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4426         return;
4427     }
4428
4429     if (!expected)
4430         ok_(__FILE__, line)(lstrlenA(val) == 0, "Expected empty string, got %s\n", val);
4431     else
4432     {
4433         if (bcase)
4434             ok_(__FILE__, line)(!lstrcmpA(val, expected), "Expected %s, got %s\n", expected, val);
4435         else
4436             ok_(__FILE__, line)(!lstrcmpiA(val, expected), "Expected %s, got %s\n", expected, val);
4437     }
4438 }
4439
4440 static void check_reg_dword(HKEY prodkey, LPCSTR name, DWORD expected, DWORD line)
4441 {
4442     DWORD val, size, type;
4443     LONG res;
4444
4445     size = sizeof(DWORD);
4446     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
4447
4448     if (res != ERROR_SUCCESS || type != REG_DWORD)
4449     {
4450         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4451         return;
4452     }
4453
4454     ok_(__FILE__, line)(val == expected, "Expected %d, got %d\n", expected, val);
4455 }
4456
4457 static void check_reg_dword2(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2, DWORD line)
4458 {
4459     DWORD val, size, type;
4460     LONG res;
4461
4462     size = sizeof(DWORD);
4463     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
4464
4465     if (res != ERROR_SUCCESS || type != REG_DWORD)
4466     {
4467         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4468         return;
4469     }
4470
4471     ok_(__FILE__, line)(val == expected1 || val == expected2, "Expected %d or %d, got %d\n", expected1, expected2, val);
4472 }
4473
4474 static void check_reg_dword3(HKEY prodkey, LPCSTR name, DWORD expected1, DWORD expected2, DWORD expected3, DWORD line)
4475 {
4476     DWORD val, size, type;
4477     LONG res;
4478
4479     size = sizeof(DWORD);
4480     res = RegQueryValueExA(prodkey, name, NULL, &type, (LPBYTE)&val, &size);
4481
4482     if (res != ERROR_SUCCESS || type != REG_DWORD)
4483     {
4484         ok_(__FILE__, line)(FALSE, "Key doesn't exist or wrong type\n");
4485         return;
4486     }
4487
4488     ok_(__FILE__, line)(val == expected1 || val == expected2 || val == expected3,
4489                         "Expected %d, %d or %d, got %d\n", expected1, expected2, expected3, val);
4490 }
4491
4492 #define CHECK_REG_STR(prodkey, name, expected) \
4493     check_reg_str(prodkey, name, expected, TRUE, __LINE__);
4494
4495 #define CHECK_DEL_REG_STR(prodkey, name, expected) \
4496     check_reg_str(prodkey, name, expected, TRUE, __LINE__); \
4497     RegDeleteValueA(prodkey, name);
4498
4499 #define CHECK_REG_ISTR(prodkey, name, expected) \
4500     check_reg_str(prodkey, name, expected, FALSE, __LINE__);
4501
4502 #define CHECK_DEL_REG_ISTR(prodkey, name, expected) \
4503     check_reg_str(prodkey, name, expected, FALSE, __LINE__); \
4504     RegDeleteValueA(prodkey, name);
4505
4506 #define CHECK_REG_DWORD(prodkey, name, expected) \
4507     check_reg_dword(prodkey, name, expected, __LINE__);
4508
4509 #define CHECK_DEL_REG_DWORD(prodkey, name, expected) \
4510     check_reg_dword(prodkey, name, expected, __LINE__); \
4511     RegDeleteValueA(prodkey, name);
4512
4513 #define CHECK_REG_DWORD2(prodkey, name, expected1, expected2) \
4514     check_reg_dword2(prodkey, name, expected1, expected2, __LINE__);
4515
4516 #define CHECK_DEL_REG_DWORD2(prodkey, name, expected1, expected2) \
4517     check_reg_dword2(prodkey, name, expected1, expected2, __LINE__); \
4518     RegDeleteValueA(prodkey, name);
4519
4520 #define CHECK_REG_DWORD3(prodkey, name, expected1, expected2, expected3) \
4521     check_reg_dword3(prodkey, name, expected1, expected2, expected3, __LINE__);
4522
4523 #define CHECK_DEL_REG_DWORD3(prodkey, name, expected1, expected2, expected3) \
4524     check_reg_dword3(prodkey, name, expected1, expected2, expected3, __LINE__); \
4525     RegDeleteValueA(prodkey, name);
4526
4527 static void get_date_str(LPSTR date)
4528 {
4529     SYSTEMTIME systime;
4530
4531     static const char date_fmt[] = "%d%02d%02d";
4532     GetLocalTime(&systime);
4533     sprintf(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
4534 }
4535
4536 static void test_publish_registerproduct(void)
4537 {
4538     UINT r;
4539     LONG res;
4540     HKEY hkey;
4541     HKEY props, usage;
4542     LPSTR usersid;
4543     char date[MAX_PATH];
4544     char temp[MAX_PATH];
4545     char keypath[MAX_PATH];
4546
4547     static const CHAR uninstall[] = "Software\\Microsoft\\Windows\\CurrentVersion"
4548                                     "\\Uninstall\\{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
4549     static const CHAR userdata[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"
4550                                    "\\UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
4551     static const CHAR ugkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer"
4552                                 "\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
4553     static const CHAR userugkey[] = "Software\\Microsoft\\Installer\\UpgradeCodes"
4554                                     "\\51AAE0C44620A5E4788506E91F249BD2";
4555
4556     if (!get_user_sid(&usersid))
4557         return;
4558
4559     get_date_str(date);
4560     GetTempPath(MAX_PATH, temp);
4561
4562     CreateDirectoryA("msitest", NULL);
4563     create_file("msitest\\maximus", 500);
4564
4565     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
4566
4567     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4568
4569     /* RegisterProduct */
4570     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
4571     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4572     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4573     ok(delete_pf("msitest", FALSE), "File not installed\n");
4574
4575     res = RegOpenKeyA(HKEY_CURRENT_USER, userugkey, &hkey);
4576     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
4577
4578     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, uninstall, &hkey);
4579     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4580
4581     CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
4582     CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
4583     CHECK_DEL_REG_STR(hkey, "InstallDate", date);
4584     CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
4585     CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4586     CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
4587     CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4588     CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", NULL);
4589     CHECK_DEL_REG_STR(hkey, "Comments", NULL);
4590     CHECK_DEL_REG_STR(hkey, "Contact", NULL);
4591     CHECK_DEL_REG_STR(hkey, "HelpLink", NULL);
4592     CHECK_DEL_REG_STR(hkey, "HelpTelephone", NULL);
4593     CHECK_DEL_REG_STR(hkey, "InstallLocation", NULL);
4594     CHECK_DEL_REG_STR(hkey, "Readme", NULL);
4595     CHECK_DEL_REG_STR(hkey, "Size", NULL);
4596     CHECK_DEL_REG_STR(hkey, "URLInfoAbout", NULL);
4597     CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", NULL);
4598     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
4599     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
4600     CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
4601     CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
4602     CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
4603     todo_wine
4604     {
4605         CHECK_DEL_REG_DWORD3(hkey, "EstimatedSize", 12, -12, 4);
4606     }
4607
4608     RegDeleteKeyA(hkey, "");
4609     RegCloseKey(hkey);
4610
4611     sprintf(keypath, userdata, usersid);
4612     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
4613     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4614
4615     res = RegOpenKeyA(hkey, "InstallProperties", &props);
4616     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4617
4618     RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */
4619     CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
4620     CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
4621     CHECK_DEL_REG_STR(props, "InstallDate", date);
4622     CHECK_DEL_REG_STR(props, "InstallSource", temp);
4623     CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4624     CHECK_DEL_REG_STR(props, "Publisher", "Wine");
4625     CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4626     CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", NULL);
4627     CHECK_DEL_REG_STR(props, "Comments", NULL);
4628     CHECK_DEL_REG_STR(props, "Contact", NULL);
4629     CHECK_DEL_REG_STR(props, "HelpLink", NULL);
4630     CHECK_DEL_REG_STR(props, "HelpTelephone", NULL);
4631     CHECK_DEL_REG_STR(props, "InstallLocation", NULL);
4632     CHECK_DEL_REG_STR(props, "Readme", NULL);
4633     CHECK_DEL_REG_STR(props, "Size", NULL);
4634     CHECK_DEL_REG_STR(props, "URLInfoAbout", NULL);
4635     CHECK_DEL_REG_STR(props, "URLUpdateInfo", NULL);
4636     CHECK_DEL_REG_DWORD(props, "Language", 1033);
4637     CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
4638     CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
4639     CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
4640     CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
4641     todo_wine
4642     {
4643         CHECK_DEL_REG_DWORD3(props, "EstimatedSize", 12, -12, 4);
4644     }
4645
4646     RegDeleteKeyA(props, "");
4647     RegCloseKey(props);
4648
4649     res = RegOpenKeyA(hkey, "Usage", &usage);
4650     todo_wine
4651     {
4652         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4653     }
4654
4655     RegDeleteKeyA(usage, "");
4656     RegCloseKey(usage);
4657     RegDeleteKeyA(hkey, "");
4658     RegCloseKey(hkey);
4659
4660     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, ugkey, &hkey);
4661     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4662
4663     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
4664
4665     RegDeleteKeyA(hkey, "");
4666     RegCloseKey(hkey);
4667
4668     /* RegisterProduct, machine */
4669     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 ALLUSERS=1");
4670     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4671     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4672     ok(delete_pf("msitest", FALSE), "File not installed\n");
4673
4674     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, userugkey, &hkey);
4675     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
4676
4677     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, uninstall, &hkey);
4678     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4679
4680     CHECK_DEL_REG_STR(hkey, "DisplayName", "MSITEST");
4681     CHECK_DEL_REG_STR(hkey, "DisplayVersion", "1.1.1");
4682     CHECK_DEL_REG_STR(hkey, "InstallDate", date);
4683     CHECK_DEL_REG_STR(hkey, "InstallSource", temp);
4684     CHECK_DEL_REG_ISTR(hkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4685     CHECK_DEL_REG_STR(hkey, "Publisher", "Wine");
4686     CHECK_DEL_REG_STR(hkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4687     CHECK_DEL_REG_STR(hkey, "AuthorizedCDFPrefix", NULL);
4688     CHECK_DEL_REG_STR(hkey, "Comments", NULL);
4689     CHECK_DEL_REG_STR(hkey, "Contact", NULL);
4690     CHECK_DEL_REG_STR(hkey, "HelpLink", NULL);
4691     CHECK_DEL_REG_STR(hkey, "HelpTelephone", NULL);
4692     CHECK_DEL_REG_STR(hkey, "InstallLocation", NULL);
4693     CHECK_DEL_REG_STR(hkey, "Readme", NULL);
4694     CHECK_DEL_REG_STR(hkey, "Size", NULL);
4695     CHECK_DEL_REG_STR(hkey, "URLInfoAbout", NULL);
4696     CHECK_DEL_REG_STR(hkey, "URLUpdateInfo", NULL);
4697     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
4698     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
4699     CHECK_DEL_REG_DWORD(hkey, "VersionMajor", 1);
4700     CHECK_DEL_REG_DWORD(hkey, "VersionMinor", 1);
4701     CHECK_DEL_REG_DWORD(hkey, "WindowsInstaller", 1);
4702     todo_wine
4703     {
4704         CHECK_DEL_REG_DWORD3(hkey, "EstimatedSize", 12, -12, 4);
4705     }
4706
4707     RegDeleteKeyA(hkey, "");
4708     RegCloseKey(hkey);
4709
4710     sprintf(keypath, userdata, "S-1-5-18");
4711     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
4712     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4713
4714     res = RegOpenKeyA(hkey, "InstallProperties", &props);
4715     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4716
4717     RegDeleteValueA(props, "LocalPackage"); /* LocalPackage is nondeterministic */
4718     CHECK_DEL_REG_STR(props, "DisplayName", "MSITEST");
4719     CHECK_DEL_REG_STR(props, "DisplayVersion", "1.1.1");
4720     CHECK_DEL_REG_STR(props, "InstallDate", date);
4721     CHECK_DEL_REG_STR(props, "InstallSource", temp);
4722     CHECK_DEL_REG_ISTR(props, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4723     CHECK_DEL_REG_STR(props, "Publisher", "Wine");
4724     CHECK_DEL_REG_STR(props, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
4725     CHECK_DEL_REG_STR(props, "AuthorizedCDFPrefix", NULL);
4726     CHECK_DEL_REG_STR(props, "Comments", NULL);
4727     CHECK_DEL_REG_STR(props, "Contact", NULL);
4728     CHECK_DEL_REG_STR(props, "HelpLink", NULL);
4729     CHECK_DEL_REG_STR(props, "HelpTelephone", NULL);
4730     CHECK_DEL_REG_STR(props, "InstallLocation", NULL);
4731     CHECK_DEL_REG_STR(props, "Readme", NULL);
4732     CHECK_DEL_REG_STR(props, "Size", NULL);
4733     CHECK_DEL_REG_STR(props, "URLInfoAbout", NULL);
4734     CHECK_DEL_REG_STR(props, "URLUpdateInfo", NULL);
4735     CHECK_DEL_REG_DWORD(props, "Language", 1033);
4736     CHECK_DEL_REG_DWORD(props, "Version", 0x1010001);
4737     CHECK_DEL_REG_DWORD(props, "VersionMajor", 1);
4738     CHECK_DEL_REG_DWORD(props, "VersionMinor", 1);
4739     CHECK_DEL_REG_DWORD(props, "WindowsInstaller", 1);
4740     todo_wine
4741     {
4742         CHECK_DEL_REG_DWORD3(props, "EstimatedSize", 12, -12, 4);
4743     }
4744
4745     RegDeleteKeyA(props, "");
4746     RegCloseKey(props);
4747
4748     res = RegOpenKeyA(hkey, "Usage", &usage);
4749     todo_wine
4750     {
4751         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4752     }
4753
4754     RegDeleteKeyA(usage, "");
4755     RegCloseKey(usage);
4756     RegDeleteKeyA(hkey, "");
4757     RegCloseKey(hkey);
4758
4759     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, ugkey, &hkey);
4760     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4761
4762     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
4763
4764     RegDeleteKeyA(hkey, "");
4765     RegCloseKey(hkey);
4766
4767     DeleteFile(msifile);
4768     DeleteFile("msitest\\maximus");
4769     RemoveDirectory("msitest");
4770     HeapFree(GetProcessHeap(), 0, usersid);
4771 }
4772
4773 static void test_publish_publishproduct(void)
4774 {
4775     UINT r;
4776     LONG res;
4777     LPSTR usersid;
4778     HKEY sourcelist, net, props;
4779     HKEY hkey, patches, media;
4780     CHAR keypath[MAX_PATH];
4781     CHAR temp[MAX_PATH];
4782     CHAR path[MAX_PATH];
4783     BOOL old_installer = FALSE;
4784
4785     static const CHAR prodpath[] = "Software\\Microsoft\\Windows\\CurrentVersion"
4786                                    "\\Installer\\UserData\\%s\\Products"
4787                                    "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
4788     static const CHAR cuprodpath[] = "Software\\Microsoft\\Installer\\Products"
4789                                      "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
4790     static const CHAR cuupgrades[] = "Software\\Microsoft\\Installer\\UpgradeCodes"
4791                                      "\\51AAE0C44620A5E4788506E91F249BD2";
4792     static const CHAR badprod[] = "Software\\Microsoft\\Windows\\CurrentVersion"
4793                                   "\\Installer\\Products"
4794                                   "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
4795     static const CHAR machprod[] = "Installer\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB";
4796     static const CHAR machup[] = "Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2";
4797
4798     if (!get_user_sid(&usersid))
4799         return;
4800
4801     GetTempPath(MAX_PATH, temp);
4802
4803     CreateDirectoryA("msitest", NULL);
4804     create_file("msitest\\maximus", 500);
4805
4806     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
4807
4808     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
4809
4810     /* PublishProduct, current user */
4811     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
4812     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4813     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4814     ok(delete_pf("msitest", FALSE), "File not installed\n");
4815
4816     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, badprod, &hkey);
4817     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
4818
4819     sprintf(keypath, prodpath, usersid);
4820     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
4821     if (res == ERROR_FILE_NOT_FOUND)
4822     {
4823         res = RegOpenKeyA(HKEY_CURRENT_USER, cuprodpath, &hkey);
4824         if (res == ERROR_SUCCESS)
4825         {
4826             win_skip("Windows Installer < 3.0 detected\n");
4827             RegCloseKey(hkey);
4828             old_installer = TRUE;
4829             goto currentuser;
4830         }
4831         else
4832         {
4833             win_skip("Install failed, no need to continue\n");
4834             return;
4835         }
4836     }
4837     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4838
4839     res = RegOpenKeyA(hkey, "InstallProperties", &props);
4840     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
4841
4842     res = RegOpenKeyA(hkey, "Patches", &patches);
4843     todo_wine
4844     {
4845         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4846
4847         CHECK_DEL_REG_STR(patches, "AllPatches", NULL);
4848     }
4849
4850     RegDeleteKeyA(patches, "");
4851     RegCloseKey(patches);
4852     RegDeleteKeyA(hkey, "");
4853     RegCloseKey(hkey);
4854
4855 currentuser:
4856     res = RegOpenKeyA(HKEY_CURRENT_USER, cuprodpath, &hkey);
4857     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4858
4859     CHECK_DEL_REG_STR(hkey, "ProductName", "MSITEST");
4860     CHECK_DEL_REG_STR(hkey, "PackageCode", "AC75740029052c94DA02821EECD05F2F");
4861     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
4862     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
4863     if (!old_installer)
4864         CHECK_DEL_REG_DWORD(hkey, "AuthorizedLUAApp", 0);
4865     CHECK_DEL_REG_DWORD(hkey, "Assignment", 0);
4866     CHECK_DEL_REG_DWORD(hkey, "AdvertiseFlags", 0x184);
4867     CHECK_DEL_REG_DWORD(hkey, "InstanceType", 0);
4868     CHECK_DEL_REG_STR(hkey, "Clients", ":");
4869
4870     res = RegOpenKeyA(hkey, "SourceList", &sourcelist);
4871     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4872
4873     lstrcpyA(path, "n;1;");
4874     lstrcatA(path, temp);
4875     CHECK_DEL_REG_STR(sourcelist, "LastUsedSource", path);
4876     CHECK_DEL_REG_STR(sourcelist, "PackageName", "msitest.msi");
4877
4878     res = RegOpenKeyA(sourcelist, "Net", &net);
4879     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4880
4881     CHECK_DEL_REG_STR(net, "1", temp);
4882
4883     RegDeleteKeyA(net, "");
4884     RegCloseKey(net);
4885
4886     res = RegOpenKeyA(sourcelist, "Media", &media);
4887     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4888
4889     CHECK_DEL_REG_STR(media, "1", "DISK1;");
4890
4891     RegDeleteKeyA(media, "");
4892     RegCloseKey(media);
4893     RegDeleteKeyA(sourcelist, "");
4894     RegCloseKey(sourcelist);
4895     RegDeleteKeyA(hkey, "");
4896     RegCloseKey(hkey);
4897
4898     res = RegOpenKeyA(HKEY_CURRENT_USER, cuupgrades, &hkey);
4899     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4900
4901     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
4902
4903     RegDeleteKeyA(hkey, "");
4904     RegCloseKey(hkey);
4905
4906     /* PublishProduct, machine */
4907     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1 ALLUSERS=1");
4908     if (old_installer)
4909         goto machprod;
4910     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4911     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
4912     ok(delete_pf("msitest", FALSE), "File not installed\n");
4913
4914     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, badprod, &hkey);
4915     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
4916
4917     sprintf(keypath, prodpath, "S-1-5-18");
4918     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
4919     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4920
4921     res = RegOpenKeyA(hkey, "InstallProperties", &props);
4922     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
4923
4924     res = RegOpenKeyA(hkey, "Patches", &patches);
4925     todo_wine
4926     {
4927         ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4928
4929         CHECK_DEL_REG_STR(patches, "AllPatches", NULL);
4930     }
4931
4932     RegDeleteKeyA(patches, "");
4933     RegCloseKey(patches);
4934     RegDeleteKeyA(hkey, "");
4935     RegCloseKey(hkey);
4936
4937 machprod:
4938     res = RegOpenKeyA(HKEY_CLASSES_ROOT, machprod, &hkey);
4939     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4940
4941     CHECK_DEL_REG_STR(hkey, "ProductName", "MSITEST");
4942     CHECK_DEL_REG_STR(hkey, "PackageCode", "AC75740029052c94DA02821EECD05F2F");
4943     CHECK_DEL_REG_DWORD(hkey, "Language", 1033);
4944     CHECK_DEL_REG_DWORD(hkey, "Version", 0x1010001);
4945     if (!old_installer)
4946         CHECK_DEL_REG_DWORD(hkey, "AuthorizedLUAApp", 0);
4947     todo_wine CHECK_DEL_REG_DWORD(hkey, "Assignment", 1);
4948     CHECK_DEL_REG_DWORD(hkey, "AdvertiseFlags", 0x184);
4949     CHECK_DEL_REG_DWORD(hkey, "InstanceType", 0);
4950     CHECK_DEL_REG_STR(hkey, "Clients", ":");
4951
4952     res = RegOpenKeyA(hkey, "SourceList", &sourcelist);
4953     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4954
4955     lstrcpyA(path, "n;1;");
4956     lstrcatA(path, temp);
4957     CHECK_DEL_REG_STR(sourcelist, "LastUsedSource", path);
4958     CHECK_DEL_REG_STR(sourcelist, "PackageName", "msitest.msi");
4959
4960     res = RegOpenKeyA(sourcelist, "Net", &net);
4961     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4962
4963     CHECK_DEL_REG_STR(net, "1", temp);
4964
4965     RegDeleteKeyA(net, "");
4966     RegCloseKey(net);
4967
4968     res = RegOpenKeyA(sourcelist, "Media", &media);
4969     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4970
4971     CHECK_DEL_REG_STR(media, "1", "DISK1;");
4972
4973     RegDeleteKeyA(media, "");
4974     RegCloseKey(media);
4975     RegDeleteKeyA(sourcelist, "");
4976     RegCloseKey(sourcelist);
4977     RegDeleteKeyA(hkey, "");
4978     RegCloseKey(hkey);
4979
4980     res = RegOpenKeyA(HKEY_CLASSES_ROOT, machup, &hkey);
4981     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4982
4983     CHECK_DEL_REG_STR(hkey, "84A88FD7F6998CE40A22FB59F6B9C2BB", NULL);
4984
4985     RegDeleteKeyA(hkey, "");
4986     RegCloseKey(hkey);
4987
4988     DeleteFile(msifile);
4989     DeleteFile("msitest\\maximus");
4990     RemoveDirectory("msitest");
4991     HeapFree(GetProcessHeap(), 0, usersid);
4992 }
4993
4994 static void test_publish_publishfeatures(void)
4995 {
4996     UINT r;
4997     LONG res;
4998     HKEY hkey;
4999     LPSTR usersid;
5000     CHAR keypath[MAX_PATH];
5001
5002     static const CHAR cupath[] = "Software\\Microsoft\\Installer\\Features"
5003                                  "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5004     static const CHAR udpath[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5005                                  "\\Installer\\UserData\\%s\\Products"
5006                                  "\\84A88FD7F6998CE40A22FB59F6B9C2BB\\Features";
5007     static const CHAR featkey[] = "Software\\Microsoft\\Windows\\CurrentVersion"
5008                                   "\\Installer\\Features";
5009     static const CHAR classfeat[] = "Software\\Classes\\Installer\\Features"
5010                                     "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
5011
5012     if (!get_user_sid(&usersid))
5013         return;
5014
5015     CreateDirectoryA("msitest", NULL);
5016     create_file("msitest\\maximus", 500);
5017
5018     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5019
5020     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5021
5022     /* PublishFeatures, current user */
5023     r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
5024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5025     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5026     ok(delete_pf("msitest", FALSE), "File not installed\n");
5027
5028     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, featkey, &hkey);
5029     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5030
5031     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, classfeat, &hkey);
5032     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5033
5034     res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
5035     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5036
5037     CHECK_REG_STR(hkey, "feature", "");
5038     CHECK_REG_STR(hkey, "montecristo", "");
5039
5040     RegDeleteValueA(hkey, "feature");
5041     RegDeleteValueA(hkey, "montecristo");
5042     RegDeleteKeyA(hkey, "");
5043     RegCloseKey(hkey);
5044
5045     sprintf(keypath, udpath, usersid);
5046     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
5047     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5048
5049     CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
5050     CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");
5051
5052     RegDeleteValueA(hkey, "feature");
5053     RegDeleteValueA(hkey, "montecristo");
5054     RegDeleteKeyA(hkey, "");
5055     RegCloseKey(hkey);
5056
5057     /* PublishFeatures, machine */
5058     r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1 ALLUSERS=1");
5059     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5060     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5061     ok(delete_pf("msitest", FALSE), "File not installed\n");
5062
5063     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, featkey, &hkey);
5064     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5065
5066     res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
5067     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5068
5069     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, classfeat, &hkey);
5070     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5071
5072     CHECK_REG_STR(hkey, "feature", "");
5073     CHECK_REG_STR(hkey, "montecristo", "");
5074
5075     RegDeleteValueA(hkey, "feature");
5076     RegDeleteValueA(hkey, "montecristo");
5077     RegDeleteKeyA(hkey, "");
5078     RegCloseKey(hkey);
5079
5080     sprintf(keypath, udpath, "S-1-5-18");
5081     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
5082     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5083
5084     CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
5085     CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");
5086
5087     RegDeleteValueA(hkey, "feature");
5088     RegDeleteValueA(hkey, "montecristo");
5089     RegDeleteKeyA(hkey, "");
5090     RegCloseKey(hkey);
5091
5092     DeleteFile(msifile);
5093     DeleteFile("msitest\\maximus");
5094     RemoveDirectory("msitest");
5095     HeapFree(GetProcessHeap(), 0, usersid);
5096 }
5097
5098 static LPSTR reg_get_val_str(HKEY hkey, LPCSTR name)
5099 {
5100     DWORD len = 0;
5101     LPSTR val;
5102     LONG r;
5103
5104     r = RegQueryValueExA(hkey, name, NULL, NULL, NULL, &len);
5105     if (r != ERROR_SUCCESS)
5106         return NULL;
5107
5108     len += sizeof (WCHAR);
5109     val = HeapAlloc(GetProcessHeap(), 0, len);
5110     if (!val) return NULL;
5111     val[0] = 0;
5112     RegQueryValueExA(hkey, name, NULL, NULL, (LPBYTE)val, &len);
5113     return val;
5114 }
5115
5116 static void get_owner_company(LPSTR *owner, LPSTR *company)
5117 {
5118     LONG res;
5119     HKEY hkey;
5120
5121     *owner = *company = NULL;
5122
5123     res = RegOpenKeyA(HKEY_CURRENT_USER,
5124                       "Software\\Microsoft\\MS Setup (ACME)\\User Info", &hkey);
5125     if (res == ERROR_SUCCESS)
5126     {
5127         *owner = reg_get_val_str(hkey, "DefName");
5128         *company = reg_get_val_str(hkey, "DefCompany");
5129         RegCloseKey(hkey);
5130     }
5131
5132     if (!*owner || !*company)
5133     {
5134         res = RegOpenKeyA(HKEY_LOCAL_MACHINE,
5135                           "Software\\Microsoft\\Windows\\CurrentVersion", &hkey);
5136         if (res == ERROR_SUCCESS)
5137         {
5138             *owner = reg_get_val_str(hkey, "RegisteredOwner");
5139             *company = reg_get_val_str(hkey, "RegisteredOrganization");
5140             RegCloseKey(hkey);
5141         }
5142     }
5143
5144     if (!*owner || !*company)
5145     {
5146         res = RegOpenKeyA(HKEY_LOCAL_MACHINE,
5147                           "Software\\Microsoft\\Windows NT\\CurrentVersion", &hkey);
5148         if (res == ERROR_SUCCESS)
5149         {
5150             *owner = reg_get_val_str(hkey, "RegisteredOwner");
5151             *company = reg_get_val_str(hkey, "RegisteredOrganization");
5152             RegCloseKey(hkey);
5153         }
5154     }
5155 }
5156
5157 static void test_publish_registeruser(void)
5158 {
5159     UINT r;
5160     LONG res;
5161     HKEY props;
5162     LPSTR usersid;
5163     LPSTR owner, company;
5164     CHAR keypath[MAX_PATH];
5165
5166     static const CHAR keyfmt[] =
5167         "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\"
5168         "UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties";
5169
5170     if (!get_user_sid(&usersid))
5171         return;
5172
5173     get_owner_company(&owner, &company);
5174
5175     CreateDirectoryA("msitest", NULL);
5176     create_file("msitest\\maximus", 500);
5177
5178     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5179
5180     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5181
5182     /* RegisterUser, per-user */
5183     r = MsiInstallProductA(msifile, "REGISTER_USER=1");
5184     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5185     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5186     ok(delete_pf("msitest", FALSE), "File not installed\n");
5187
5188     sprintf(keypath, keyfmt, usersid);
5189
5190     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &props);
5191     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5192
5193     CHECK_REG_STR(props, "ProductID", "none");
5194     CHECK_REG_STR(props, "RegCompany", company);
5195     CHECK_REG_STR(props, "RegOwner", owner);
5196
5197     RegDeleteValueA(props, "ProductID");
5198     RegDeleteValueA(props, "RegCompany");
5199     RegDeleteValueA(props, "RegOwner");
5200     RegDeleteKeyA(props, "");
5201     RegCloseKey(props);
5202
5203     /* RegisterUser, machine */
5204     r = MsiInstallProductA(msifile, "REGISTER_USER=1 ALLUSERS=1");
5205     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5206     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5207     ok(delete_pf("msitest", FALSE), "File not installed\n");
5208
5209     sprintf(keypath, keyfmt, "S-1-5-18");
5210
5211     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &props);
5212     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5213
5214     CHECK_REG_STR(props, "ProductID", "none");
5215     CHECK_REG_STR(props, "RegCompany", company);
5216     CHECK_REG_STR(props, "RegOwner", owner);
5217
5218     RegDeleteValueA(props, "ProductID");
5219     RegDeleteValueA(props, "RegCompany");
5220     RegDeleteValueA(props, "RegOwner");
5221     RegDeleteKeyA(props, "");
5222     RegCloseKey(props);
5223
5224     HeapFree(GetProcessHeap(), 0, company);
5225     HeapFree(GetProcessHeap(), 0, owner);
5226
5227     DeleteFile(msifile);
5228     DeleteFile("msitest\\maximus");
5229     RemoveDirectory("msitest");
5230     LocalFree(usersid);
5231 }
5232
5233 static void test_publish_processcomponents(void)
5234 {
5235     UINT r;
5236     LONG res;
5237     DWORD size;
5238     HKEY comp, hkey;
5239     LPSTR usersid;
5240     CHAR val[MAX_PATH];
5241     CHAR keypath[MAX_PATH];
5242     CHAR program_files_maximus[MAX_PATH];
5243
5244     static const CHAR keyfmt[] =
5245         "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\"
5246         "UserData\\%s\\Components\\%s";
5247     static const CHAR compkey[] =
5248         "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Components";
5249
5250     if (!get_user_sid(&usersid))
5251         return;
5252
5253     CreateDirectoryA("msitest", NULL);
5254     create_file("msitest\\maximus", 500);
5255
5256     create_database(msifile, ppc_tables, sizeof(ppc_tables) / sizeof(msi_table));
5257
5258     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5259
5260     /* ProcessComponents, per-user */
5261     r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
5262     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5263     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5264     ok(delete_pf("msitest", FALSE), "File not installed\n");
5265
5266     sprintf(keypath, keyfmt, usersid, "CBABC2FDCCB35E749A8944D8C1C098B5");
5267
5268     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &comp);
5269     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5270
5271     size = MAX_PATH;
5272     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5273                            NULL, NULL, (LPBYTE)val, &size);
5274     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5275
5276     lstrcpyA(program_files_maximus,PROG_FILES_DIR);
5277     lstrcatA(program_files_maximus,"\\msitest\\maximus");
5278
5279     ok(!lstrcmpiA(val, program_files_maximus),
5280        "Expected \"%s\", got \"%s\"\n", program_files_maximus, val);
5281
5282     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
5283     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5284
5285     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5286     RegDeleteKeyA(comp, "");
5287     RegCloseKey(comp);
5288
5289     sprintf(keypath, keyfmt, usersid, "241C3DA58FECD0945B9687D408766058");
5290
5291     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &comp);
5292     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5293
5294     size = MAX_PATH;
5295     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5296                            NULL, NULL, (LPBYTE)val, &size);
5297     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5298     ok(!lstrcmpA(val, "01\\msitest\\augustus"),
5299        "Expected \"01\\msitest\\augustus\", got \"%s\"\n", val);
5300
5301     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
5302     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5303
5304     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5305     RegDeleteKeyA(comp, "");
5306     RegCloseKey(comp);
5307
5308     /* ProcessComponents, machine */
5309     r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1 ALLUSERS=1");
5310     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5311     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
5312     ok(delete_pf("msitest", FALSE), "File not installed\n");
5313
5314     sprintf(keypath, keyfmt, "S-1-5-18", "CBABC2FDCCB35E749A8944D8C1C098B5");
5315
5316     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &comp);
5317     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5318
5319     size = MAX_PATH;
5320     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5321                            NULL, NULL, (LPBYTE)val, &size);
5322     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5323     ok(!lstrcmpiA(val, program_files_maximus),
5324        "Expected \"%s\", got \"%s\"\n", program_files_maximus, val);
5325
5326     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
5327     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5328
5329     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5330     RegDeleteKeyA(comp, "");
5331     RegCloseKey(comp);
5332
5333     sprintf(keypath, keyfmt, "S-1-5-18", "241C3DA58FECD0945B9687D408766058");
5334
5335     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &comp);
5336     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5337
5338     size = MAX_PATH;
5339     res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
5340                            NULL, NULL, (LPBYTE)val, &size);
5341     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5342     ok(!lstrcmpA(val, "01\\msitest\\augustus"),
5343        "Expected \"01\\msitest\\augustus\", got \"%s\"\n", val);
5344
5345     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
5346     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5347
5348     RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
5349     RegDeleteKeyA(comp, "");
5350     RegCloseKey(comp);
5351
5352     DeleteFile(msifile);
5353     DeleteFile("msitest\\maximus");
5354     RemoveDirectory("msitest");
5355     LocalFree(usersid);
5356 }
5357
5358 static void test_publish(void)
5359 {
5360     UINT r;
5361     LONG res;
5362     HKEY uninstall, prodkey;
5363     INSTALLSTATE state;
5364     CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
5365     char date[MAX_PATH];
5366     char temp[MAX_PATH];
5367
5368     static const CHAR subkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
5369
5370     if (!pMsiQueryComponentStateA)
5371     {
5372         win_skip("MsiQueryComponentStateA is not available\n");
5373         return;
5374     }
5375
5376     get_date_str(date);
5377     GetTempPath(MAX_PATH, temp);
5378
5379     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, subkey, &uninstall);
5380     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5381
5382     CreateDirectoryA("msitest", NULL);
5383     create_file("msitest\\maximus", 500);
5384
5385     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5386
5387     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5388
5389     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5390     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5391
5392     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5393     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5394
5395     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5396     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5397
5398     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5399                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5400     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5401     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5402
5403     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5404     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5405
5406     /* nothing published */
5407     r = MsiInstallProductA(msifile, NULL);
5408     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5409     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5410     ok(pf_exists("msitest"), "File not installed\n");
5411
5412     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5413     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5414
5415     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5416     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5417
5418     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5419     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5420
5421     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5422                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5423     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5424     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5425
5426     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5427     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5428
5429     /* PublishProduct and RegisterProduct */
5430     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1");
5431     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5432     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5433     ok(pf_exists("msitest"), "File not installed\n");
5434
5435     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5436     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5437
5438     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5439     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5440
5441     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5442     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5443
5444     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5445                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5446     ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r);
5447     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5448
5449     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5450     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5451
5452     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
5453     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
5454     CHECK_REG_STR(prodkey, "InstallDate", date);
5455     CHECK_REG_STR(prodkey, "InstallSource", temp);
5456     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5457     CHECK_REG_STR(prodkey, "Publisher", "Wine");
5458     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5459     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
5460     CHECK_REG_STR(prodkey, "Comments", NULL);
5461     CHECK_REG_STR(prodkey, "Contact", NULL);
5462     CHECK_REG_STR(prodkey, "HelpLink", NULL);
5463     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
5464     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
5465     CHECK_REG_STR(prodkey, "Readme", NULL);
5466     CHECK_REG_STR(prodkey, "Size", NULL);
5467     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
5468     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
5469     CHECK_REG_DWORD(prodkey, "Language", 1033);
5470     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
5471     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
5472     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
5473     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
5474     todo_wine
5475     {
5476         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
5477     }
5478
5479     RegCloseKey(prodkey);
5480
5481     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
5482     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5483     ok(pf_exists("msitest\\maximus"), "File deleted\n");
5484     ok(pf_exists("msitest"), "File deleted\n");
5485
5486     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5487     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5488
5489     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5490     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5491
5492     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5493     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5494
5495     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5496                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5497     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5498     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5499
5500     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5501     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5502
5503     /* complete install */
5504     r = MsiInstallProductA(msifile, "FULL=1");
5505     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5506     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5507     ok(pf_exists("msitest"), "File not installed\n");
5508
5509     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5510     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5511
5512     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5513     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5514
5515     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5516     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5517
5518     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5519                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5520     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5521     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5522
5523     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5524     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5525
5526     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
5527     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
5528     CHECK_REG_STR(prodkey, "InstallDate", date);
5529     CHECK_REG_STR(prodkey, "InstallSource", temp);
5530     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5531     CHECK_REG_STR(prodkey, "Publisher", "Wine");
5532     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5533     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
5534     CHECK_REG_STR(prodkey, "Comments", NULL);
5535     CHECK_REG_STR(prodkey, "Contact", NULL);
5536     CHECK_REG_STR(prodkey, "HelpLink", NULL);
5537     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
5538     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
5539     CHECK_REG_STR(prodkey, "Readme", NULL);
5540     CHECK_REG_STR(prodkey, "Size", NULL);
5541     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
5542     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
5543     CHECK_REG_DWORD(prodkey, "Language", 1033);
5544     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
5545     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
5546     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
5547     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
5548     todo_wine
5549     {
5550         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
5551     }
5552
5553     RegCloseKey(prodkey);
5554
5555     /* no UnpublishFeatures */
5556     r = MsiInstallProductA(msifile, "REMOVE=ALL");
5557     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5558     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
5559     ok(!pf_exists("msitest"), "Directory not deleted\n");
5560
5561     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5562     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5563
5564     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5565     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5566
5567     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5568     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5569
5570     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5571                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5572     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5573     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5574
5575     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5576     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5577
5578     /* complete install */
5579     r = MsiInstallProductA(msifile, "FULL=1");
5580     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5581     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5582     ok(pf_exists("msitest"), "File not installed\n");
5583
5584     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5585     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5586
5587     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5588     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5589
5590     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5591     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5592
5593     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5594                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5595     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5596     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5597
5598     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5599     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5600
5601     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
5602     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
5603     CHECK_REG_STR(prodkey, "InstallDate", date);
5604     CHECK_REG_STR(prodkey, "InstallSource", temp);
5605     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5606     CHECK_REG_STR(prodkey, "Publisher", "Wine");
5607     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5608     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
5609     CHECK_REG_STR(prodkey, "Comments", NULL);
5610     CHECK_REG_STR(prodkey, "Contact", NULL);
5611     CHECK_REG_STR(prodkey, "HelpLink", NULL);
5612     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
5613     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
5614     CHECK_REG_STR(prodkey, "Readme", NULL);
5615     CHECK_REG_STR(prodkey, "Size", NULL);
5616     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
5617     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
5618     CHECK_REG_DWORD(prodkey, "Language", 1033);
5619     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
5620     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
5621     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
5622     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
5623     todo_wine
5624     {
5625         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
5626     }
5627
5628     RegCloseKey(prodkey);
5629
5630     /* UnpublishFeatures, only feature removed.  Only works when entire product is removed */
5631     r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
5632     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5633     todo_wine ok(pf_exists("msitest\\maximus"), "File deleted\n");
5634     todo_wine ok(pf_exists("msitest"), "Directory deleted\n");
5635
5636     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5637     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5638
5639     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5640     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5641
5642     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5643     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5644
5645     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5646                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5647     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5648     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5649
5650     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5651     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5652
5653     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
5654     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
5655     CHECK_REG_STR(prodkey, "InstallDate", date);
5656     CHECK_REG_STR(prodkey, "InstallSource", temp);
5657     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5658     CHECK_REG_STR(prodkey, "Publisher", "Wine");
5659     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5660     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
5661     CHECK_REG_STR(prodkey, "Comments", NULL);
5662     CHECK_REG_STR(prodkey, "Contact", NULL);
5663     CHECK_REG_STR(prodkey, "HelpLink", NULL);
5664     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
5665     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
5666     CHECK_REG_STR(prodkey, "Readme", NULL);
5667     CHECK_REG_STR(prodkey, "Size", NULL);
5668     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
5669     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
5670     CHECK_REG_DWORD(prodkey, "Language", 1033);
5671     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
5672     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
5673     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
5674     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
5675     todo_wine
5676     {
5677         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
5678     }
5679
5680     RegCloseKey(prodkey);
5681
5682     /* complete install */
5683     r = MsiInstallProductA(msifile, "FULL=1");
5684     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5685     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5686     ok(pf_exists("msitest"), "File not installed\n");
5687
5688     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5689     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5690
5691     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5692     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5693
5694     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5695     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5696
5697     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5698                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5699     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5700     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5701
5702     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5703     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5704
5705     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
5706     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
5707     CHECK_REG_STR(prodkey, "InstallDate", date);
5708     CHECK_REG_STR(prodkey, "InstallSource", temp);
5709     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5710     CHECK_REG_STR(prodkey, "Publisher", "Wine");
5711     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5712     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
5713     CHECK_REG_STR(prodkey, "Comments", NULL);
5714     CHECK_REG_STR(prodkey, "Contact", NULL);
5715     CHECK_REG_STR(prodkey, "HelpLink", NULL);
5716     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
5717     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
5718     CHECK_REG_STR(prodkey, "Readme", NULL);
5719     CHECK_REG_STR(prodkey, "Size", NULL);
5720     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
5721     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
5722     CHECK_REG_DWORD(prodkey, "Language", 1033);
5723     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
5724     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
5725     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
5726     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
5727     todo_wine
5728     {
5729         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -20);
5730     }
5731
5732     RegCloseKey(prodkey);
5733
5734     /* UnpublishFeatures, both features removed */
5735     r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
5736     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5737     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
5738     ok(!pf_exists("msitest"), "Directory not deleted\n");
5739
5740     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5741     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5742
5743     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5744     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5745
5746     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5747     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5748
5749     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5750                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5751     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5752     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5753
5754     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5755     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5756
5757     /* complete install */
5758     r = MsiInstallProductA(msifile, "FULL=1");
5759     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5760     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5761     ok(pf_exists("msitest"), "File not installed\n");
5762
5763     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5764     ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
5765
5766     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5767     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5768
5769     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5770     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5771
5772     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5773                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5774     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5775     ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
5776
5777     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5778     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
5779
5780     CHECK_REG_STR(prodkey, "DisplayName", "MSITEST");
5781     CHECK_REG_STR(prodkey, "DisplayVersion", "1.1.1");
5782     CHECK_REG_STR(prodkey, "InstallDate", date);
5783     CHECK_REG_STR(prodkey, "InstallSource", temp);
5784     CHECK_REG_ISTR(prodkey, "ModifyPath", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5785     CHECK_REG_STR(prodkey, "Publisher", "Wine");
5786     CHECK_REG_STR(prodkey, "UninstallString", "MsiExec.exe /I{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5787     CHECK_REG_STR(prodkey, "AuthorizedCDFPrefix", NULL);
5788     CHECK_REG_STR(prodkey, "Comments", NULL);
5789     CHECK_REG_STR(prodkey, "Contact", NULL);
5790     CHECK_REG_STR(prodkey, "HelpLink", NULL);
5791     CHECK_REG_STR(prodkey, "HelpTelephone", NULL);
5792     CHECK_REG_STR(prodkey, "InstallLocation", NULL);
5793     CHECK_REG_STR(prodkey, "Readme", NULL);
5794     CHECK_REG_STR(prodkey, "Size", NULL);
5795     CHECK_REG_STR(prodkey, "URLInfoAbout", NULL);
5796     CHECK_REG_STR(prodkey, "URLUpdateInfo", NULL);
5797     CHECK_REG_DWORD(prodkey, "Language", 1033);
5798     CHECK_REG_DWORD(prodkey, "Version", 0x1010001);
5799     CHECK_REG_DWORD(prodkey, "VersionMajor", 1);
5800     CHECK_REG_DWORD(prodkey, "VersionMinor", 1);
5801     CHECK_REG_DWORD(prodkey, "WindowsInstaller", 1);
5802     todo_wine
5803     {
5804         CHECK_REG_DWORD2(prodkey, "EstimatedSize", 12, -12);
5805     }
5806
5807     RegCloseKey(prodkey);
5808
5809     /* complete uninstall */
5810     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
5811     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5812     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
5813     ok(!pf_exists("msitest"), "Directory not deleted\n");
5814
5815     state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
5816     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5817
5818     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "feature");
5819     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5820
5821     state = MsiQueryFeatureState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}", "montecristo");
5822     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5823
5824     r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5825                                 "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
5826     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5827     ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
5828
5829     res = RegOpenKeyA(uninstall, prodcode, &prodkey);
5830     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
5831
5832     /* make sure 'Program Files\msitest' is removed */
5833     delete_pfmsitest_files();
5834
5835     RegCloseKey(uninstall);
5836     DeleteFile(msifile);
5837     DeleteFile("msitest\\maximus");
5838     RemoveDirectory("msitest");
5839 }
5840
5841 static void test_publishsourcelist(void)
5842 {
5843     UINT r;
5844     DWORD size;
5845     CHAR value[MAX_PATH];
5846     CHAR path[MAX_PATH];
5847     CHAR prodcode[] = "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}";
5848
5849     if (!pMsiSourceListEnumSourcesA || !pMsiSourceListGetInfoA)
5850     {
5851         win_skip("MsiSourceListEnumSourcesA and/or MsiSourceListGetInfoA are not available\n");
5852         return;
5853     }
5854
5855     CreateDirectoryA("msitest", NULL);
5856     create_file("msitest\\maximus", 500);
5857
5858     create_database(msifile, pp_tables, sizeof(pp_tables) / sizeof(msi_table));
5859
5860     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
5861
5862     r = MsiInstallProductA(msifile, NULL);
5863     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5864     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5865     ok(pf_exists("msitest"), "File not installed\n");
5866
5867     /* nothing published */
5868     size = MAX_PATH;
5869     lstrcpyA(value, "aaa");
5870     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5871                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
5872     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5873     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5874     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5875
5876     size = MAX_PATH;
5877     lstrcpyA(value, "aaa");
5878     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5879                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
5880     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5881     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5882     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5883
5884     r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1");
5885     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5886     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5887     ok(pf_exists("msitest"), "File not installed\n");
5888
5889     /* after RegisterProduct */
5890     size = MAX_PATH;
5891     lstrcpyA(value, "aaa");
5892     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5893                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
5894     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5895     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5896     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5897
5898     size = MAX_PATH;
5899     lstrcpyA(value, "aaa");
5900     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5901                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
5902     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5903     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5904     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5905
5906     r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
5907     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5908     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5909     ok(pf_exists("msitest"), "File not installed\n");
5910
5911     /* after ProcessComponents */
5912     size = MAX_PATH;
5913     lstrcpyA(value, "aaa");
5914     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5915                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
5916     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5917     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5918     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5919
5920     size = MAX_PATH;
5921     lstrcpyA(value, "aaa");
5922     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5923                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
5924     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5925     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5926     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5927
5928     r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=1");
5929     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5930     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5931     ok(pf_exists("msitest"), "File not installed\n");
5932
5933     /* after PublishFeatures */
5934     size = MAX_PATH;
5935     lstrcpyA(value, "aaa");
5936     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5937                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
5938     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5939     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5940     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5941
5942     size = MAX_PATH;
5943     lstrcpyA(value, "aaa");
5944     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5945                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
5946     ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
5947     ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
5948     ok(!lstrcmpA(value, "aaa"), "Expected \"aaa\", got \"%s\"\n", value);
5949
5950     r = MsiInstallProductA(msifile, "PUBLISH_PRODUCT=1");
5951     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5952     ok(pf_exists("msitest\\maximus"), "File not installed\n");
5953     ok(pf_exists("msitest"), "File not installed\n");
5954
5955     /* after PublishProduct */
5956     size = MAX_PATH;
5957     lstrcpyA(value, "aaa");
5958     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5959                                MSICODE_PRODUCT, INSTALLPROPERTY_PACKAGENAME, value, &size);
5960     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5961     ok(!lstrcmpA(value, "msitest.msi"), "Expected 'msitest.msi', got %s\n", value);
5962     ok(size == 11, "Expected 11, got %d\n", size);
5963
5964     size = MAX_PATH;
5965     lstrcpyA(value, "aaa");
5966     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5967                                MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH, value, &size);
5968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5969     ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
5970     ok(size == 0, "Expected 0, got %d\n", size);
5971
5972     size = MAX_PATH;
5973     lstrcpyA(value, "aaa");
5974     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5975                                MSICODE_PRODUCT, INSTALLPROPERTY_DISKPROMPT, value, &size);
5976     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5977     ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
5978     ok(size == 0, "Expected 0, got %d\n", size);
5979
5980     lstrcpyA(path, CURR_DIR);
5981     lstrcatA(path, "\\");
5982
5983     size = MAX_PATH;
5984     lstrcpyA(value, "aaa");
5985     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5986                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDSOURCE, value, &size);
5987     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5988     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
5989     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
5990
5991     size = MAX_PATH;
5992     lstrcpyA(value, "aaa");
5993     r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
5994                                MSICODE_PRODUCT, INSTALLPROPERTY_LASTUSEDTYPE, value, &size);
5995     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5996     ok(!lstrcmpA(value, "n"), "Expected \"n\", got \"%s\"\n", value);
5997     ok(size == 1, "Expected 1, got %d\n", size);
5998
5999     size = MAX_PATH;
6000     lstrcpyA(value, "aaa");
6001     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6002                                    MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, value, &size);
6003     ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6004     ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
6005     ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
6006
6007     size = MAX_PATH;
6008     lstrcpyA(value, "aaa");
6009     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6010                                    MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 0, value, &size);
6011     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6012     ok(!lstrcmpA(value, path), "Expected \"%s\", got \"%s\"\n", path, value);
6013     ok(size == lstrlenA(path), "Expected %d, got %d\n", lstrlenA(path), size);
6014
6015     size = MAX_PATH;
6016     lstrcpyA(value, "aaa");
6017     r = pMsiSourceListEnumSourcesA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
6018                                    MSICODE_PRODUCT | MSISOURCETYPE_NETWORK, 1, value, &size);
6019     ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6020     ok(!lstrcmpA(value, "aaa"), "Expected value to be unchanged, got %s\n", value);
6021     ok(size == MAX_PATH, "Expected MAX_PATH, got %d\n", size);
6022
6023     /* complete uninstall */
6024     r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
6025     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6026     ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
6027     ok(!pf_exists("msitest"), "Directory not deleted\n");
6028
6029     /* make sure 'Program Files\msitest' is removed */
6030     delete_pfmsitest_files();
6031
6032     DeleteFile(msifile);
6033     DeleteFile("msitest\\maximus");
6034     RemoveDirectory("msitest");
6035 }
6036
6037 static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
6038 {
6039     MSIHANDLE hview = 0;
6040     UINT r;
6041
6042     r = MsiDatabaseOpenView(hdb, query, &hview);
6043     if(r != ERROR_SUCCESS)
6044         return r;
6045
6046     r = MsiViewExecute(hview, hrec);
6047     if(r == ERROR_SUCCESS)
6048         r = MsiViewClose(hview);
6049     MsiCloseHandle(hview);
6050     return r;
6051 }
6052
6053 static void set_transform_summary_info(void)
6054 {
6055     UINT r;
6056     MSIHANDLE suminfo = 0;
6057
6058     /* build summary info */
6059     r = MsiGetSummaryInformation(0, mstfile, 3, &suminfo);
6060     ok(r == ERROR_SUCCESS , "Failed to open summaryinfo\n");
6061
6062     r = MsiSummaryInfoSetProperty(suminfo, PID_TITLE, VT_LPSTR, 0, NULL, "MSITEST");
6063     ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
6064
6065     r = MsiSummaryInfoSetProperty(suminfo, PID_REVNUMBER, VT_LPSTR, 0, NULL,
6066                         "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
6067                         "{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}1.1.1;"
6068                         "{4C0EAA15-0264-4E5A-8758-609EF142B92D}");
6069     ok(r == ERROR_SUCCESS , "Failed to set summary info\n");
6070
6071     r = MsiSummaryInfoSetProperty(suminfo, PID_PAGECOUNT, VT_I4, 100, NULL, NULL);
6072     ok(r == ERROR_SUCCESS, "Failed to set summary info\n");
6073
6074     r = MsiSummaryInfoPersist(suminfo);
6075     ok(r == ERROR_SUCCESS , "Failed to make summary info persist\n");
6076
6077     r = MsiCloseHandle(suminfo);
6078     ok(r == ERROR_SUCCESS , "Failed to close suminfo\n");
6079 }
6080
6081 static void generate_transform(void)
6082 {
6083     MSIHANDLE hdb1, hdb2;
6084     LPCSTR query;
6085     UINT r;
6086
6087     /* start with two identical databases */
6088     CopyFile(msifile, msifile2, FALSE);
6089
6090     r = MsiOpenDatabase(msifile2, MSIDBOPEN_TRANSACT, &hdb1);
6091     ok(r == ERROR_SUCCESS , "Failed to create database\n");
6092
6093     r = MsiDatabaseCommit(hdb1);
6094     ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6095
6096     r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb2);
6097     ok(r == ERROR_SUCCESS , "Failed to create database\n");
6098
6099     query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
6100     r = run_query(hdb1, 0, query);
6101     ok(r == ERROR_SUCCESS, "failed to add property\n");
6102
6103     /* database needs to be committed */
6104     MsiDatabaseCommit(hdb1);
6105
6106     r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0);
6107     ok(r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r);
6108
6109 #if 0  /* not implemented in wine yet */
6110     r = MsiCreateTransformSummaryInfo(hdb2, hdb2, mstfile, 0, 0);
6111     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6112 #endif
6113
6114     MsiCloseHandle(hdb1);
6115     MsiCloseHandle(hdb2);
6116 }
6117
6118 /* data for generating a transform */
6119
6120 /* tables transform names - encoded as they would be in an msi database file */
6121 static const WCHAR name1[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
6122 static const WCHAR name2[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
6123 static const WCHAR name3[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
6124
6125 /* data in each table */
6126 static const char data1[] = /* _StringData */
6127     "propval";  /* all the strings squashed together */
6128
6129 static const WCHAR data2[] = { /* _StringPool */
6130 /*  len, refs */
6131     0,   0,    /* string 0 ''     */
6132     4,   1,    /* string 1 'prop' */
6133     3,   1,    /* string 2 'val'  */
6134 };
6135
6136 static const WCHAR data3[] = { /* Property */
6137     0x0201, 0x0001, 0x0002,
6138 };
6139
6140 static const struct {
6141     LPCWSTR name;
6142     const void *data;
6143     DWORD size;
6144 } table_transform_data[] =
6145 {
6146     { name1, data1, sizeof data1 - 1 },
6147     { name2, data2, sizeof data2 },
6148     { name3, data3, sizeof data3 },
6149 };
6150
6151 #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
6152
6153 static void generate_transform_manual(void)
6154 {
6155     IStorage *stg = NULL;
6156     IStream *stm;
6157     WCHAR name[0x20];
6158     HRESULT r;
6159     DWORD i, count;
6160     const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE;
6161
6162     const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
6163
6164     MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
6165
6166     r = StgCreateDocfile(name, mode, 0, &stg);
6167     ok(r == S_OK, "failed to create storage\n");
6168     if (!stg)
6169         return;
6170
6171     r = IStorage_SetClass(stg, &CLSID_MsiTransform);
6172     ok(r == S_OK, "failed to set storage type\n");
6173
6174     for (i=0; i<NUM_TRANSFORM_TABLES; i++)
6175     {
6176         r = IStorage_CreateStream(stg, table_transform_data[i].name,
6177                             STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
6178         if (FAILED(r))
6179         {
6180             ok(0, "failed to create stream %08x\n", r);
6181             continue;
6182         }
6183
6184         r = IStream_Write(stm, table_transform_data[i].data,
6185                           table_transform_data[i].size, &count);
6186         if (FAILED(r) || count != table_transform_data[i].size)
6187             ok(0, "failed to write stream\n");
6188         IStream_Release(stm);
6189     }
6190
6191     IStorage_Release(stg);
6192
6193     set_transform_summary_info();
6194 }
6195
6196 static void test_transformprop(void)
6197 {
6198     UINT r;
6199
6200     CreateDirectoryA("msitest", NULL);
6201     create_file("msitest\\augustus", 500);
6202
6203     create_database(msifile, tp_tables, sizeof(tp_tables) / sizeof(msi_table));
6204
6205     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6206
6207     r = MsiInstallProductA(msifile, NULL);
6208     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6209     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6210     ok(!delete_pf("msitest", FALSE), "File installed\n");
6211
6212     if (0)
6213         generate_transform();
6214     else
6215         generate_transform_manual();
6216
6217     r = MsiInstallProductA(msifile, "TRANSFORMS=winetest.mst");
6218     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6219     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6220     ok(delete_pf("msitest", FALSE), "File not installed\n");
6221
6222     /* Delete the files in the temp (current) folder */
6223     DeleteFile(msifile);
6224     DeleteFile(msifile2);
6225     DeleteFile(mstfile);
6226     DeleteFile("msitest\\augustus");
6227     RemoveDirectory("msitest");
6228 }
6229
6230 static void test_currentworkingdir(void)
6231 {
6232     UINT r;
6233     CHAR drive[MAX_PATH], path[MAX_PATH];
6234     LPSTR ptr;
6235
6236     CreateDirectoryA("msitest", NULL);
6237     create_file("msitest\\augustus", 500);
6238
6239     create_database(msifile, cwd_tables, sizeof(cwd_tables) / sizeof(msi_table));
6240
6241     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6242
6243     CreateDirectoryA("diffdir", NULL);
6244     SetCurrentDirectoryA("diffdir");
6245
6246     sprintf(path, "..\\%s", msifile);
6247     r = MsiInstallProductA(path, NULL);
6248     todo_wine
6249     {
6250         ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
6251         ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6252         ok(!delete_pf("msitest", FALSE), "File installed\n");
6253     }
6254
6255     sprintf(path, "%s\\%s", CURR_DIR, msifile);
6256     r = MsiInstallProductA(path, NULL);
6257     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6258     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6259     ok(delete_pf("msitest", FALSE), "File not installed\n");
6260
6261     lstrcpyA(drive, CURR_DIR);
6262     drive[2] = '\\';
6263     drive[3] = '\0';
6264     SetCurrentDirectoryA(drive);
6265
6266     lstrcpy(path, CURR_DIR);
6267     if (path[lstrlenA(path) - 1] != '\\')
6268         lstrcatA(path, "\\");
6269     lstrcatA(path, msifile);
6270     ptr = strchr(path, ':');
6271     ptr +=2;
6272
6273     r = MsiInstallProductA(ptr, NULL);
6274     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6275     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6276     ok(delete_pf("msitest", FALSE), "File not installed\n");
6277
6278     SetCurrentDirectoryA(CURR_DIR);
6279
6280     DeleteFile(msifile);
6281     DeleteFile("msitest\\augustus");
6282     RemoveDirectory("msitest");
6283     RemoveDirectory("diffdir");
6284 }
6285
6286 static void set_admin_summary_info(const CHAR *name)
6287 {
6288     MSIHANDLE db, summary;
6289     UINT r;
6290
6291     r = MsiOpenDatabaseA(name, MSIDBOPEN_DIRECT, &db);
6292     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6293
6294     r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6295     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6296
6297     r = MsiSummaryInfoSetPropertyA(summary, PID_WORDCOUNT, VT_I4, 5, NULL, NULL);
6298     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6299
6300     /* write the summary changes back to the stream */
6301     r = MsiSummaryInfoPersist(summary);
6302     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6303
6304     MsiCloseHandle(summary);
6305
6306     r = MsiDatabaseCommit(db);
6307     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6308
6309     MsiCloseHandle(db);
6310 }
6311
6312 static void test_admin(void)
6313 {
6314     UINT r;
6315
6316     CreateDirectoryA("msitest", NULL);
6317     create_file("msitest\\augustus", 500);
6318
6319     create_database(msifile, adm_tables, sizeof(adm_tables) / sizeof(msi_table));
6320     set_admin_summary_info(msifile);
6321
6322     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6323
6324     r = MsiInstallProductA(msifile, NULL);
6325     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6326     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6327     ok(!delete_pf("msitest", FALSE), "File installed\n");
6328     ok(!DeleteFile("c:\\msitest\\augustus"), "File installed\n");
6329     ok(!RemoveDirectory("c:\\msitest"), "File installed\n");
6330
6331     r = MsiInstallProductA(msifile, "ACTION=ADMIN");
6332     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6333     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6334     ok(!delete_pf("msitest", FALSE), "File installed\n");
6335     todo_wine
6336     {
6337         ok(DeleteFile("c:\\msitest\\augustus"), "File not installed\n");
6338         ok(RemoveDirectory("c:\\msitest"), "File not installed\n");
6339     }
6340
6341     DeleteFile(msifile);
6342     DeleteFile("msitest\\augustus");
6343     RemoveDirectory("msitest");
6344 }
6345
6346 static void set_admin_property_stream(LPCSTR file)
6347 {
6348     IStorage *stg;
6349     IStream *stm;
6350     WCHAR fileW[MAX_PATH];
6351     HRESULT hr;
6352     DWORD count;
6353     const DWORD mode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
6354
6355     /* AdminProperties */
6356     static const WCHAR stmname[] = {0x41ca,0x4330,0x3e71,0x44b5,0x4233,0x45f5,0x422c,0x4836,0};
6357     static const WCHAR data[] = {'M','Y','P','R','O','P','=','2','7','1','8',' ',
6358         'M','y','P','r','o','p','=','4','2',0};
6359
6360     MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH);
6361
6362     hr = StgOpenStorage(fileW, NULL, mode, NULL, 0, &stg);
6363     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
6364     if (!stg)
6365         return;
6366
6367     hr = IStorage_CreateStream(stg, stmname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
6368     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
6369
6370     hr = IStream_Write(stm, data, sizeof(data), &count);
6371     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
6372
6373     IStream_Release(stm);
6374     IStorage_Release(stg);
6375 }
6376
6377 static void test_adminprops(void)
6378 {
6379     UINT r;
6380
6381     CreateDirectoryA("msitest", NULL);
6382     create_file("msitest\\augustus", 500);
6383
6384     create_database(msifile, amp_tables, sizeof(amp_tables) / sizeof(msi_table));
6385     set_admin_summary_info(msifile);
6386     set_admin_property_stream(msifile);
6387
6388     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6389
6390     r = MsiInstallProductA(msifile, NULL);
6391     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6392     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
6393     ok(delete_pf("msitest", FALSE), "File installed\n");
6394
6395     DeleteFile(msifile);
6396     DeleteFile("msitest\\augustus");
6397     RemoveDirectory("msitest");
6398 }
6399
6400 static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file)
6401 {
6402     CHAR path[MAX_PATH];
6403
6404     lstrcpyA(path, PROG_FILES_DIR);
6405     lstrcatA(path, "\\");
6406     lstrcatA(path, file);
6407
6408     if (is_file)
6409         create_file_data(path, data, 500);
6410     else
6411         CreateDirectoryA(path, NULL);
6412 }
6413
6414 #define create_pf(file, is_file) create_pf_data(file, file, is_file)
6415
6416 static void test_removefiles(void)
6417 {
6418     UINT r;
6419
6420     CreateDirectoryA("msitest", NULL);
6421     create_file("msitest\\hydrogen", 500);
6422     create_file("msitest\\helium", 500);
6423     create_file("msitest\\lithium", 500);
6424
6425     create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
6426
6427     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
6428
6429     r = MsiInstallProductA(msifile, NULL);
6430     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6431     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
6432     ok(!pf_exists("msitest\\helium"), "File installed\n");
6433     ok(pf_exists("msitest\\lithium"), "File not installed\n");
6434     ok(pf_exists("msitest"), "File not installed\n");
6435
6436     r = MsiInstallProductA(msifile, "REMOVE=ALL");
6437     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6438     ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
6439     ok(!pf_exists("msitest\\helium"), "File not deleted\n");
6440     ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
6441     ok(delete_pf("msitest", FALSE), "File deleted\n");
6442
6443     create_pf("msitest", FALSE);
6444     create_pf("msitest\\hydrogen", TRUE);
6445     create_pf("msitest\\helium", TRUE);
6446     create_pf("msitest\\lithium", TRUE);
6447
6448     r = MsiInstallProductA(msifile, NULL);
6449     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6450     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
6451     ok(pf_exists("msitest\\helium"), "File not installed\n");
6452     ok(pf_exists("msitest\\lithium"), "File not installed\n");
6453     ok(pf_exists("msitest"), "File not installed\n");
6454
6455     r = MsiInstallProductA(msifile, "REMOVE=ALL");
6456     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6457     ok(!pf_exists("msitest\\hydrogen"), "File not deleted\n");
6458     ok(delete_pf("msitest\\helium", TRUE), "File deleted\n");
6459     ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
6460     ok(delete_pf("msitest", FALSE), "File deleted\n");
6461
6462     create_pf("msitest", FALSE);
6463     create_pf("msitest\\furlong", TRUE);
6464     create_pf("msitest\\firkin", TRUE);
6465     create_pf("msitest\\fortnight", TRUE);
6466     create_pf("msitest\\becquerel", TRUE);
6467     create_pf("msitest\\dioptre", TRUE);
6468     create_pf("msitest\\attoparsec", TRUE);
6469     create_pf("msitest\\storeys", TRUE);
6470     create_pf("msitest\\block", TRUE);
6471     create_pf("msitest\\siriometer", TRUE);
6472     create_pf("msitest\\cabout", FALSE);
6473     create_pf("msitest\\cabout\\blocker", TRUE);
6474
6475     r = MsiInstallProductA(msifile, NULL);
6476     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6477     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
6478     ok(!pf_exists("msitest\\helium"), "File installed\n");
6479     ok(pf_exists("msitest\\lithium"), "File not installed\n");
6480     ok(!pf_exists("msitest\\furlong"), "File not deleted\n");
6481     ok(!pf_exists("msitest\\firkin"), "File not deleted\n");
6482     ok(!pf_exists("msitest\\fortnight"), "File not deleted\n");
6483     ok(pf_exists("msitest\\becquerel"), "File not installed\n");
6484     ok(pf_exists("msitest\\dioptre"), "File not installed\n");
6485     ok(pf_exists("msitest\\attoparsec"), "File not installed\n");
6486     ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
6487     ok(!pf_exists("msitest\\block"), "File not deleted\n");
6488     ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
6489     ok(pf_exists("msitest\\cabout"), "Directory removed\n");
6490     ok(pf_exists("msitest"), "File not installed\n");
6491
6492     create_pf("msitest\\furlong", TRUE);
6493     create_pf("msitest\\firkin", TRUE);
6494     create_pf("msitest\\fortnight", TRUE);
6495     create_pf("msitest\\storeys", TRUE);
6496     create_pf("msitest\\block", TRUE);
6497     create_pf("msitest\\siriometer", TRUE);
6498
6499     r = MsiInstallProductA(msifile, "REMOVE=ALL");
6500     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6501     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not deleted\n");
6502     ok(!delete_pf("msitest\\helium", TRUE), "File not deleted\n");
6503     ok(delete_pf("msitest\\lithium", TRUE), "File deleted\n");
6504     ok(delete_pf("msitest\\furlong", TRUE), "File deleted\n");
6505     ok(delete_pf("msitest\\firkin", TRUE), "File deleted\n");
6506     ok(delete_pf("msitest\\fortnight", TRUE), "File deleted\n");
6507     ok(!delete_pf("msitest\\becquerel", TRUE), "File not deleted\n");
6508     ok(!delete_pf("msitest\\dioptre", TRUE), "File not deleted\n");
6509     ok(delete_pf("msitest\\attoparsec", TRUE), "File deleted\n");
6510     ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
6511     ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
6512     ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
6513     ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
6514     ok(pf_exists("msitest"), "Directory deleted\n");
6515
6516     r = MsiInstallProductA(msifile, NULL);
6517     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6518     ok(delete_pf("msitest\\hydrogen", TRUE), "File not installed\n");
6519     ok(!delete_pf("msitest\\helium", TRUE), "File installed\n");
6520     ok(delete_pf("msitest\\lithium", TRUE), "File not installed\n");
6521     ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
6522     ok(pf_exists("msitest"), "Directory deleted\n");
6523
6524     delete_pf("msitest\\cabout\\blocker", TRUE);
6525
6526     r = MsiInstallProductA(msifile, "REMOVE=ALL");
6527     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6528     ok(!delete_pf("msitest\\cabout", FALSE), "Directory not deleted\n");
6529     ok(delete_pf("msitest", FALSE), "Directory deleted\n");
6530
6531     DeleteFile(msifile);
6532     DeleteFile("msitest\\hydrogen");
6533     DeleteFile("msitest\\helium");
6534     DeleteFile("msitest\\lithium");
6535     RemoveDirectory("msitest");
6536 }
6537
6538 static void test_movefiles(void)
6539 {
6540     UINT r;
6541     char props[MAX_PATH];
6542
6543     CreateDirectoryA("msitest", NULL);
6544     create_file("msitest\\augustus", 100);
6545     create_file("cameroon", 100);
6546     create_file("djibouti", 100);
6547     create_file("egypt", 100);
6548     create_file("finland", 100);
6549     create_file("gambai", 100);
6550     create_file("honduras", 100);
6551     create_file("msitest\\india", 100);
6552     create_file("japan", 100);
6553     create_file("kenya", 100);
6554     CreateDirectoryA("latvia", NULL);
6555     create_file("nauru", 100);
6556     create_file("peru", 100);
6557     create_file("apple", 100);
6558     create_file("application", 100);
6559     create_file("ape", 100);
6560     create_file("foo", 100);
6561     create_file("fao", 100);
6562     create_file("fbod", 100);
6563     create_file("budding", 100);
6564     create_file("buddy", 100);
6565     create_file("bud", 100);
6566     create_file("bar", 100);
6567     create_file("bur", 100);
6568     create_file("bird", 100);
6569
6570     create_database(msifile, mov_tables, sizeof(mov_tables) / sizeof(msi_table));
6571
6572     MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
6573
6574     /* if the source or dest property is not a full path,
6575      * windows tries to access it as a network resource
6576      */
6577
6578     sprintf(props, "SOURCEFULL=\"%s\\\" DESTFULL=\"%s\\msitest\" "
6579             "FILEPATHBAD=\"%s\\japan\" FILEPATHGOOD=\"%s\\kenya\"",
6580             CURR_DIR, PROG_FILES_DIR, CURR_DIR, CURR_DIR);
6581
6582     r = MsiInstallProductA(msifile, props);
6583     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6584     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6585     ok(!delete_pf("msitest\\dest", TRUE), "File copied\n");
6586     ok(delete_pf("msitest\\canada", TRUE), "File not copied\n");
6587     ok(delete_pf("msitest\\dominica", TRUE), "File not moved\n");
6588     ok(!delete_pf("msitest\\elsalvador", TRUE), "File moved\n");
6589     ok(!delete_pf("msitest\\france", TRUE), "File moved\n");
6590     ok(!delete_pf("msitest\\georgia", TRUE), "File moved\n");
6591     ok(delete_pf("msitest\\hungary", TRUE), "File not moved\n");
6592     ok(!delete_pf("msitest\\indonesia", TRUE), "File moved\n");
6593     ok(!delete_pf("msitest\\jordan", TRUE), "File moved\n");
6594     ok(delete_pf("msitest\\kiribati", TRUE), "File not moved\n");
6595     ok(!delete_pf("msitest\\lebanon", TRUE), "File moved\n");
6596     ok(!delete_pf("msitest\\lebanon", FALSE), "Directory moved\n");
6597     ok(delete_pf("msitest\\poland", TRUE), "File not moved\n");
6598     /* either apple or application will be moved depending on directory order */
6599     if (!delete_pf("msitest\\apple", TRUE))
6600         ok(delete_pf("msitest\\application", TRUE), "File not moved\n");
6601     else
6602         ok(!delete_pf("msitest\\application", TRUE), "File should not exist\n");
6603     ok(delete_pf("msitest\\wildcard", TRUE), "File not moved\n");
6604     ok(!delete_pf("msitest\\ape", TRUE), "File moved\n");
6605     /* either fao or foo will be moved depending on directory order */
6606     if (delete_pf("msitest\\foo", TRUE))
6607         ok(!delete_pf("msitest\\fao", TRUE), "File should not exist\n");
6608     else
6609         ok(delete_pf("msitest\\fao", TRUE), "File not moved\n");
6610     ok(delete_pf("msitest\\single", TRUE), "File not moved\n");
6611     ok(!delete_pf("msitest\\fbod", TRUE), "File moved\n");
6612     ok(delete_pf("msitest\\budding", TRUE), "File not moved\n");
6613     ok(delete_pf("msitest\\buddy", TRUE), "File not moved\n");
6614     ok(!delete_pf("msitest\\bud", TRUE), "File moved\n");
6615     ok(delete_pf("msitest\\bar", TRUE), "File not moved\n");
6616     ok(delete_pf("msitest\\bur", TRUE), "File not moved\n");
6617     ok(!delete_pf("msitest\\bird", TRUE), "File moved\n");
6618     ok(delete_pf("msitest", FALSE), "File not installed\n");
6619     ok(DeleteFileA("cameroon"), "File moved\n");
6620     ok(!DeleteFileA("djibouti"), "File not moved\n");
6621     ok(DeleteFileA("egypt"), "File moved\n");
6622     ok(DeleteFileA("finland"), "File moved\n");
6623     ok(DeleteFileA("gambai"), "File moved\n");
6624     ok(!DeleteFileA("honduras"), "File not moved\n");
6625     ok(DeleteFileA("msitest\\india"), "File moved\n");
6626     ok(DeleteFileA("japan"), "File moved\n");
6627     ok(!DeleteFileA("kenya"), "File not moved\n");
6628     ok(RemoveDirectoryA("latvia"), "Directory moved\n");
6629     ok(!DeleteFileA("nauru"), "File not moved\n");
6630     ok(!DeleteFileA("peru"), "File not moved\n");
6631     ok(!DeleteFileA("apple"), "File not moved\n");
6632     ok(!DeleteFileA("application"), "File not moved\n");
6633     ok(DeleteFileA("ape"), "File moved\n");
6634     ok(!DeleteFileA("foo"), "File not moved\n");
6635     ok(!DeleteFileA("fao"), "File not moved\n");
6636     ok(DeleteFileA("fbod"), "File moved\n");
6637     ok(!DeleteFileA("budding"), "File not moved\n");
6638     ok(!DeleteFileA("buddy"), "File not moved\n");
6639     ok(DeleteFileA("bud"), "File moved\n");
6640     ok(!DeleteFileA("bar"), "File not moved\n");
6641     ok(!DeleteFileA("bur"), "File not moved\n");
6642     ok(DeleteFileA("bird"), "File moved\n");
6643
6644     DeleteFile("msitest\\augustus");
6645     RemoveDirectory("msitest");
6646     DeleteFile(msifile);
6647 }
6648
6649 static void test_missingcab(void)
6650 {
6651     UINT r;
6652
6653     CreateDirectoryA("msitest", NULL);
6654     create_file("msitest\\augustus", 500);
6655     create_file("maximus", 500);
6656
6657     create_database(msifile, mc_tables, sizeof(mc_tables) / sizeof(msi_table));
6658
6659     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6660
6661     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
6662
6663     create_pf("msitest", FALSE);
6664     create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
6665
6666     r = MsiInstallProductA(msifile, NULL);
6667     ok(r == ERROR_SUCCESS ||
6668        broken(r == ERROR_INSTALL_FAILURE), /* win9x */
6669        "Expected ERROR_SUCCESS, got %u\n", r);
6670     if (r == ERROR_SUCCESS)
6671     {
6672       ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
6673       ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
6674     }
6675     ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n");
6676     ok(!delete_pf("msitest\\gaius", TRUE), "File installed\n");
6677     ok(delete_pf("msitest", FALSE), "File not installed\n");
6678
6679     create_pf("msitest", FALSE);
6680     create_pf_data("msitest\\caesar", "abcdefgh", TRUE);
6681     create_pf("msitest\\gaius", TRUE);
6682
6683     r = MsiInstallProductA(msifile, "GAIUS=1");
6684     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
6685     todo_wine
6686     {
6687         ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
6688         ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6689     }
6690     ok(delete_pf("msitest\\caesar", TRUE), "File removed\n");
6691     ok(delete_pf("msitest\\gaius", TRUE), "File removed\n");
6692     ok(delete_pf("msitest", FALSE), "File not installed\n");
6693
6694     DeleteFile("msitest\\augustus");
6695     RemoveDirectory("msitest");
6696     DeleteFile("maximus");
6697     DeleteFile("test1.cab");
6698     DeleteFile(msifile);
6699 }
6700
6701 static void test_duplicatefiles(void)
6702 {
6703     UINT r;
6704
6705     CreateDirectoryA("msitest", NULL);
6706     create_file("msitest\\maximus", 500);
6707     create_database(msifile, df_tables, sizeof(df_tables) / sizeof(msi_table));
6708
6709     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6710
6711     /* fails if the destination folder is not a valid property */
6712
6713     r = MsiInstallProductA(msifile, NULL);
6714     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6715     ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
6716     ok(delete_pf("msitest\\augustus", TRUE), "File not duplicated\n");
6717     ok(delete_pf("msitest\\this\\doesnot\\exist\\maximus", TRUE), "File not duplicated\n");
6718     ok(delete_pf("msitest\\this\\doesnot\\exist", FALSE), "File not duplicated\n");
6719     ok(delete_pf("msitest\\this\\doesnot", FALSE), "File not duplicated\n");
6720     ok(delete_pf("msitest\\this", FALSE), "File not duplicated\n");
6721     ok(delete_pf("msitest", FALSE), "File not installed\n");
6722
6723     DeleteFile("msitest\\maximus");
6724     RemoveDirectory("msitest");
6725     DeleteFile(msifile);
6726 }
6727
6728 static void test_writeregistryvalues(void)
6729 {
6730     UINT r;
6731     LONG res;
6732     HKEY hkey;
6733     DWORD type, size;
6734     CHAR path[MAX_PATH];
6735
6736     CreateDirectoryA("msitest", NULL);
6737     create_file("msitest\\augustus", 500);
6738
6739     create_database(msifile, wrv_tables, sizeof(wrv_tables) / sizeof(msi_table));
6740
6741     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6742
6743     r = MsiInstallProductA(msifile, NULL);
6744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6745     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
6746     ok(delete_pf("msitest", FALSE), "File installed\n");
6747
6748     res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
6749     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6750
6751     size = MAX_PATH;
6752     type = REG_MULTI_SZ;
6753     memset(path, 'a', MAX_PATH);
6754     res = RegQueryValueExA(hkey, "Value", NULL, &type, (LPBYTE)path, &size);
6755     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
6756     ok(!memcmp(path, "one\0two\0three\0\0", size), "Wrong multi-sz data\n");
6757     ok(size == 15, "Expected 15, got %d\n", size);
6758     ok(type == REG_MULTI_SZ, "Expected REG_MULTI_SZ, got %d\n", type);
6759
6760     DeleteFile(msifile);
6761     DeleteFile("msitest\\augustus");
6762     RemoveDirectory("msitest");
6763
6764     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
6765     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine");
6766 }
6767
6768 static void test_sourcefolder(void)
6769 {
6770     UINT r;
6771
6772     CreateDirectoryA("msitest", NULL);
6773     create_file("augustus", 500);
6774
6775     create_database(msifile, sf_tables, sizeof(sf_tables) / sizeof(msi_table));
6776
6777     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6778
6779     r = MsiInstallProductA(msifile, NULL);
6780     ok(r == ERROR_INSTALL_FAILURE,
6781        "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
6782     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6783     todo_wine
6784     {
6785         ok(!delete_pf("msitest", FALSE), "File installed\n");
6786     }
6787
6788     RemoveDirectoryA("msitest");
6789
6790     r = MsiInstallProductA(msifile, NULL);
6791     ok(r == ERROR_INSTALL_FAILURE,
6792        "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
6793     ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
6794     todo_wine
6795     {
6796         ok(!delete_pf("msitest", FALSE), "File installed\n");
6797     }
6798
6799     DeleteFile(msifile);
6800     DeleteFile("augustus");
6801 }
6802
6803 static void test_customaction51(void)
6804 {
6805     UINT r;
6806
6807     CreateDirectoryA("msitest", NULL);
6808     create_file("msitest\\augustus", 500);
6809
6810     create_database(msifile, ca51_tables, sizeof(ca51_tables) / sizeof(msi_table));
6811
6812     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6813
6814     r = MsiInstallProductA(msifile, NULL);
6815     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6816     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
6817     ok(delete_pf("msitest", FALSE), "File installed\n");
6818
6819     DeleteFile(msifile);
6820     DeleteFile("msitest\\augustus");
6821     RemoveDirectory("msitest");
6822 }
6823
6824 static void test_installstate(void)
6825 {
6826     UINT r;
6827
6828     CreateDirectoryA("msitest", NULL);
6829     create_file("msitest\\alpha", 500);
6830     create_file("msitest\\beta", 500);
6831     create_file("msitest\\gamma", 500);
6832     create_file("msitest\\theta", 500);
6833     create_file("msitest\\delta", 500);
6834     create_file("msitest\\epsilon", 500);
6835     create_file("msitest\\zeta", 500);
6836     create_file("msitest\\iota", 500);
6837     create_file("msitest\\eta", 500);
6838     create_file("msitest\\kappa", 500);
6839     create_file("msitest\\lambda", 500);
6840     create_file("msitest\\mu", 500);
6841
6842     create_database(msifile, is_tables, sizeof(is_tables) / sizeof(msi_table));
6843
6844     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6845
6846     r = MsiInstallProductA(msifile, NULL);
6847     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6848     ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
6849     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
6850     ok(delete_pf("msitest\\gamma", TRUE), "File not installed\n");
6851     ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
6852     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
6853     ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
6854     ok(!delete_pf("msitest\\zeta", TRUE), "File installed\n");
6855     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
6856     ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
6857     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
6858     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
6859     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
6860     ok(delete_pf("msitest", FALSE), "File not installed\n");
6861
6862     r = MsiInstallProductA(msifile, "ADDLOCAL=\"one,two,three,four\"");
6863     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6864     ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
6865     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
6866     ok(delete_pf("msitest\\gamma", TRUE), "File not installed\n");
6867     ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
6868     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
6869     ok(delete_pf("msitest\\epsilon", TRUE), "File not installed\n");
6870     ok(delete_pf("msitest\\zeta", TRUE), "File not installed\n");
6871     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
6872     ok(delete_pf("msitest\\eta", TRUE), "File not installed\n");
6873     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
6874     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
6875     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
6876     ok(delete_pf("msitest", FALSE), "File not installed\n");
6877
6878     r = MsiInstallProductA(msifile, "ADDSOURCE=\"one,two,three,four\"");
6879     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6880     ok(delete_pf("msitest\\alpha", TRUE), "File not installed\n");
6881     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
6882     ok(!delete_pf("msitest\\gamma", TRUE), "File installed\n");
6883     ok(delete_pf("msitest\\theta", TRUE), "File not installed\n");
6884     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
6885     ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
6886     ok(delete_pf("msitest\\zeta", TRUE), "File not installed\n");
6887     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
6888     ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
6889     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
6890     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
6891     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
6892     ok(delete_pf("msitest", FALSE), "File not installed\n");
6893
6894     r = MsiInstallProductA(msifile, "REMOVE=\"one,two,three,four\"");
6895     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6896     ok(!delete_pf("msitest\\alpha", TRUE), "File installed\n");
6897     ok(!delete_pf("msitest\\beta", TRUE), "File installed\n");
6898     ok(!delete_pf("msitest\\gamma", TRUE), "File installed\n");
6899     ok(!delete_pf("msitest\\theta", TRUE), "File installed\n");
6900     ok(!delete_pf("msitest\\delta", TRUE), "File installed\n");
6901     ok(!delete_pf("msitest\\epsilon", TRUE), "File installed\n");
6902     ok(!delete_pf("msitest\\zeta", TRUE), "File installed\n");
6903     ok(!delete_pf("msitest\\iota", TRUE), "File installed\n");
6904     ok(!delete_pf("msitest\\eta", TRUE), "File installed\n");
6905     ok(!delete_pf("msitest\\kappa", TRUE), "File installed\n");
6906     ok(!delete_pf("msitest\\lambda", TRUE), "File installed\n");
6907     ok(!delete_pf("msitest\\mu", TRUE), "File installed\n");
6908     ok(!delete_pf("msitest", FALSE), "File installed\n");
6909
6910     DeleteFile(msifile);
6911     DeleteFile("msitest\\alpha");
6912     DeleteFile("msitest\\beta");
6913     DeleteFile("msitest\\gamma");
6914     DeleteFile("msitest\\theta");
6915     DeleteFile("msitest\\delta");
6916     DeleteFile("msitest\\epsilon");
6917     DeleteFile("msitest\\zeta");
6918     DeleteFile("msitest\\iota");
6919     DeleteFile("msitest\\eta");
6920     DeleteFile("msitest\\kappa");
6921     DeleteFile("msitest\\lambda");
6922     DeleteFile("msitest\\mu");
6923     RemoveDirectory("msitest");
6924 }
6925
6926 struct sourcepathmap
6927 {
6928     BOOL sost; /* shortone\shorttwo */
6929     BOOL solt; /* shortone\longtwo */
6930     BOOL lost; /* longone\shorttwo */
6931     BOOL lolt; /* longone\longtwo */
6932     BOOL soste; /* shortone\shorttwo source exists */
6933     BOOL solte; /* shortone\longtwo source exists */
6934     BOOL loste; /* longone\shorttwo source exists */
6935     BOOL lolte; /* longone\longtwo source exists */
6936     UINT err;
6937     DWORD size;
6938 } spmap[256] =
6939 {
6940     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
6941     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6942     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
6943     {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6944     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
6945     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6946     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
6947     {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6948     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
6949     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6950     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
6951     {TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6952     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
6953     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6954     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
6955     {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6956     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6957     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6958     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6959     {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6960     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6961     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6962     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6963     {TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6964     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6965     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6966     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6967     {TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6968     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6969     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6970     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6971     {TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6972     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
6973     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6974     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
6975     {TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6976     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
6977     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6978     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
6979     {TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6980     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
6981     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6982     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
6983     {TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6984     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
6985     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6986     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
6987     {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6988     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6989     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6990     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6991     {TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6992     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6993     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6994     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6995     {TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
6996     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
6997     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
6998     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
6999     {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7000     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7001     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7002     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7003     {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7004     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7005     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7006     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7007     {TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7008     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7009     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7010     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7011     {TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7012     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7013     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7014     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7015     {TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7016     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7017     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7018     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7019     {TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7020     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7021     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7022     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7023     {TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7024     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7025     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7026     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7027     {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7028     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7029     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7030     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7031     {TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7032     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7033     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7034     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7035     {TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7036     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7037     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7038     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7039     {TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7040     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7041     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7042     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7043     {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7044     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7045     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7046     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7047     {TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7048     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7049     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7050     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7051     {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7052     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7053     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7054     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7055     {TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7056     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7057     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7058     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7059     {TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7060     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7061     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7062     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7063     {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7064     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7065     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7066     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7067     {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7068     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7069     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7070     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7071     {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7072     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7073     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7074     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7075     {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7076     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7077     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7078     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7079     {FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7080     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7081     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7082     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7083     {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7084     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7085     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7086     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7087     {FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7088     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7089     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7090     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7091     {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7092     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7093     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7094     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7095     {FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7096     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7097     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7098     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7099     {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7100     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7101     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7102     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7103     {FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7104     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7105     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7106     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7107     {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7108     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7109     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7110     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7111     {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7112     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7113     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7114     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7115     {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7116     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7117     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7118     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7119     {FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7120     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7121     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7122     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7123     {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7124     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7125     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7126     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7127     {FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7128     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7129     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7130     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7131     {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7132     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7133     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7134     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7135     {FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7136     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7137     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7138     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7139     {FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7140     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7141     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7142     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7143     {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7144     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7145     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7146     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7147     {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7148     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7149     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7150     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7151     {FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7152     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7153     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7154     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7155     {FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7156     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7157     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7158     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7159     {FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7160     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7161     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7162     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7163     {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7164     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7165     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7166     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7167     {FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7168     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7169     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7170     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7171     {FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7172     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, ERROR_SUCCESS, 200},
7173     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7174     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, ERROR_SUCCESS, 200},
7175     {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7176     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, ERROR_SUCCESS, 200},
7177     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7178     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, ERROR_SUCCESS, 200},
7179     {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7180     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7181     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7182     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7183     {FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7184     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7185     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7186     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7187     {FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7188     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7189     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7190     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7191     {FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7192     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, ERROR_INSTALL_FAILURE, 0},
7193     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, ERROR_INSTALL_FAILURE, 0},
7194     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, ERROR_INSTALL_FAILURE, 0},
7195     {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, ERROR_INSTALL_FAILURE, 0},
7196 };
7197
7198 static DWORD get_pf_file_size(LPCSTR file)
7199 {
7200     CHAR path[MAX_PATH];
7201     HANDLE hfile;
7202     DWORD size;
7203
7204     lstrcpyA(path, PROG_FILES_DIR);
7205     lstrcatA(path, "\\");
7206     lstrcatA(path, file);
7207
7208     hfile = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
7209     if (hfile == INVALID_HANDLE_VALUE)
7210         return INVALID_FILE_SIZE;
7211
7212     size = GetFileSize(hfile, NULL);
7213     CloseHandle(hfile);
7214     return size;
7215 }
7216
7217 static void test_sourcepath(void)
7218 {
7219     UINT r, i;
7220
7221     if (!winetest_interactive)
7222     {
7223         skip("Run in interactive mode to run source path tests.\n");
7224         return;
7225     }
7226
7227     create_database(msifile, sp_tables, sizeof(sp_tables) / sizeof(msi_table));
7228
7229     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7230
7231     for (i = 0; i < sizeof(spmap) / sizeof(spmap[0]); i++)
7232     {
7233         if (spmap[i].sost)
7234         {
7235             CreateDirectoryA("shortone", NULL);
7236             CreateDirectoryA("shortone\\shorttwo", NULL);
7237         }
7238
7239         if (spmap[i].solt)
7240         {
7241             CreateDirectoryA("shortone", NULL);
7242             CreateDirectoryA("shortone\\longtwo", NULL);
7243         }
7244
7245         if (spmap[i].lost)
7246         {
7247             CreateDirectoryA("longone", NULL);
7248             CreateDirectoryA("longone\\shorttwo", NULL);
7249         }
7250
7251         if (spmap[i].lolt)
7252         {
7253             CreateDirectoryA("longone", NULL);
7254             CreateDirectoryA("longone\\longtwo", NULL);
7255         }
7256
7257         if (spmap[i].soste)
7258             create_file("shortone\\shorttwo\\augustus", 50);
7259         if (spmap[i].solte)
7260             create_file("shortone\\longtwo\\augustus", 100);
7261         if (spmap[i].loste)
7262             create_file("longone\\shorttwo\\augustus", 150);
7263         if (spmap[i].lolte)
7264             create_file("longone\\longtwo\\augustus", 200);
7265
7266         r = MsiInstallProductA(msifile, NULL);
7267         ok(r == spmap[i].err, "%d: Expected %d, got %d\n", i, spmap[i].err, r);
7268         ok(get_pf_file_size("msitest\\augustus") == spmap[i].size,
7269            "%d: Expected %d, got %d\n", i, spmap[i].size,
7270            get_pf_file_size("msitest\\augustus"));
7271
7272         if (r == ERROR_SUCCESS)
7273         {
7274             ok(delete_pf("msitest\\augustus", TRUE), "%d: File not installed\n", i);
7275             ok(delete_pf("msitest", FALSE), "%d: File not installed\n", i);
7276         }
7277         else
7278         {
7279             ok(!delete_pf("msitest\\augustus", TRUE), "%d: File installed\n", i);
7280             todo_wine ok(!delete_pf("msitest", FALSE), "%d: File installed\n", i);
7281         }
7282
7283         DeleteFileA("shortone\\shorttwo\\augustus");
7284         DeleteFileA("shortone\\longtwo\\augustus");
7285         DeleteFileA("longone\\shorttwo\\augustus");
7286         DeleteFileA("longone\\longtwo\\augustus");
7287         RemoveDirectoryA("shortone\\shorttwo");
7288         RemoveDirectoryA("shortone\\longtwo");
7289         RemoveDirectoryA("longone\\shorttwo");
7290         RemoveDirectoryA("longone\\longtwo");
7291         RemoveDirectoryA("shortone");
7292         RemoveDirectoryA("longone");
7293     }
7294
7295     DeleteFileA(msifile);
7296 }
7297
7298 static void test_MsiConfigureProductEx(void)
7299 {
7300     UINT r;
7301     LONG res;
7302     DWORD type, size;
7303     HKEY props, source;
7304     CHAR keypath[MAX_PATH * 2];
7305     CHAR localpack[MAX_PATH];
7306
7307     if (on_win9x)
7308     {
7309         win_skip("Different registry keys on Win9x and WinMe\n");
7310         return;
7311     }
7312
7313     CreateDirectoryA("msitest", NULL);
7314     create_file("msitest\\hydrogen", 500);
7315     create_file("msitest\\helium", 500);
7316     create_file("msitest\\lithium", 500);
7317
7318     create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
7319
7320     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7321
7322     /* NULL szProduct */
7323     r = MsiConfigureProductExA(NULL, INSTALLLEVEL_DEFAULT,
7324                                INSTALLSTATE_DEFAULT, "PROPVAR=42");
7325     ok(r == ERROR_INVALID_PARAMETER,
7326        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7327
7328     /* empty szProduct */
7329     r = MsiConfigureProductExA("", INSTALLLEVEL_DEFAULT,
7330                                INSTALLSTATE_DEFAULT, "PROPVAR=42");
7331     ok(r == ERROR_INVALID_PARAMETER,
7332        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7333
7334     /* garbage szProduct */
7335     r = MsiConfigureProductExA("garbage", INSTALLLEVEL_DEFAULT,
7336                                INSTALLSTATE_DEFAULT, "PROPVAR=42");
7337     ok(r == ERROR_INVALID_PARAMETER,
7338        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7339
7340     /* guid without brackets */
7341     r = MsiConfigureProductExA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D",
7342                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
7343                                "PROPVAR=42");
7344     ok(r == ERROR_INVALID_PARAMETER,
7345        "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
7346
7347     /* guid with brackets */
7348     r = MsiConfigureProductExA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}",
7349                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
7350                                "PROPVAR=42");
7351     ok(r == ERROR_UNKNOWN_PRODUCT,
7352        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7353
7354     /* same length as guid, but random */
7355     r = MsiConfigureProductExA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93",
7356                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
7357                                "PROPVAR=42");
7358     ok(r == ERROR_UNKNOWN_PRODUCT,
7359        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7360
7361     /* product not installed yet */
7362     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7363                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
7364                                "PROPVAR=42");
7365     ok(r == ERROR_UNKNOWN_PRODUCT,
7366        "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r);
7367
7368     /* install the product, per-user unmanaged */
7369     r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
7370     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7371     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7372     ok(pf_exists("msitest\\helium"), "File not installed\n");
7373     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7374     ok(pf_exists("msitest"), "File not installed\n");
7375
7376     /* product is installed per-user managed, remove it */
7377     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7378                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7379                                "PROPVAR=42");
7380     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7381     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
7382     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
7383     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
7384     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
7385
7386     /* product has been removed */
7387     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7388                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
7389                                "PROPVAR=42");
7390     ok(r == ERROR_UNKNOWN_PRODUCT,
7391        "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
7392
7393     /* install the product, machine */
7394     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
7395     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7396     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7397     ok(pf_exists("msitest\\helium"), "File not installed\n");
7398     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7399     ok(pf_exists("msitest"), "File not installed\n");
7400
7401     /* product is installed machine, remove it */
7402     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7403                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7404                                "PROPVAR=42");
7405     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7406     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
7407     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
7408     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
7409     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
7410
7411     /* product has been removed */
7412     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7413                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT,
7414                                "PROPVAR=42");
7415     ok(r == ERROR_UNKNOWN_PRODUCT,
7416        "Expected ERROR_UNKNOWN_PRODUCT, got %u\n", r);
7417
7418     /* install the product, machine */
7419     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
7420     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7421     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7422     ok(pf_exists("msitest\\helium"), "File not installed\n");
7423     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7424     ok(pf_exists("msitest"), "File not installed\n");
7425
7426     DeleteFileA(msifile);
7427
7428     /* local msifile is removed */
7429     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7430                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7431                                "PROPVAR=42");
7432     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7433     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
7434     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
7435     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
7436     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
7437
7438     create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
7439
7440     /* install the product, machine */
7441     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
7442     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7443     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7444     ok(pf_exists("msitest\\helium"), "File not installed\n");
7445     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7446     ok(pf_exists("msitest"), "File not installed\n");
7447
7448     DeleteFileA(msifile);
7449
7450     lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
7451     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
7452     lstrcatA(keypath, "84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties");
7453
7454     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &props);
7455     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7456
7457     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7458                          (const BYTE *)"C:\\idontexist.msi", 18);
7459     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7460
7461     /* LocalPackage is used to find the cached msi package */
7462     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7463                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7464                                "PROPVAR=42");
7465     ok(r == ERROR_INSTALL_SOURCE_ABSENT,
7466        "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
7467     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7468     ok(pf_exists("msitest\\helium"), "File not installed\n");
7469     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7470     ok(pf_exists("msitest"), "File not installed\n");
7471
7472     RegCloseKey(props);
7473     create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
7474
7475     /* LastUsedSource (local msi package) can be used as a last resort */
7476     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7477                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7478                                "PROPVAR=42");
7479     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7480     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
7481     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
7482     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
7483     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
7484
7485     /* install the product, machine */
7486     r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
7487     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7488     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7489     ok(pf_exists("msitest\\helium"), "File not installed\n");
7490     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7491     ok(pf_exists("msitest"), "File not installed\n");
7492
7493     lstrcpyA(keypath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\");
7494     lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
7495     lstrcatA(keypath, "84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties");
7496
7497     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &props);
7498     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7499
7500     res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
7501                          (const BYTE *)"C:\\idontexist.msi", 18);
7502     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7503
7504     lstrcpyA(keypath, "SOFTWARE\\Classes\\Installer\\Products\\");
7505     lstrcatA(keypath, "84A88FD7F6998CE40A22FB59F6B9C2BB\\SourceList");
7506
7507     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &source);
7508     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7509
7510     type = REG_SZ;
7511     size = MAX_PATH;
7512     res = RegQueryValueExA(source, "PackageName", NULL, &type,
7513                            (LPBYTE)localpack, &size);
7514     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7515
7516     res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
7517                          (const BYTE *)"idontexist.msi", 15);
7518     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7519
7520     /* SourceList is altered */
7521     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7522                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7523                                "PROPVAR=42");
7524     ok(r == ERROR_INSTALL_SOURCE_ABSENT,
7525        "Expected ERROR_INSTALL_SOURCE_ABSENT, got %d\n", r);
7526     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7527     ok(pf_exists("msitest\\helium"), "File not installed\n");
7528     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7529     ok(pf_exists("msitest"), "File not installed\n");
7530
7531     /* restore the SourceList */
7532     res = RegSetValueExA(source, "PackageName", 0, REG_SZ,
7533                          (const BYTE *)localpack, lstrlenA(localpack) + 1);
7534     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7535
7536     /* finally remove the product */
7537     r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
7538                                INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT,
7539                                "PROPVAR=42");
7540     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7541     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
7542     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
7543     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
7544     ok(!delete_pf("msitest", FALSE), "File not removed\n");
7545
7546     DeleteFileA(msifile);
7547     RegCloseKey(source);
7548     RegCloseKey(props);
7549     DeleteFileA("msitest\\hydrogen");
7550     DeleteFileA("msitest\\helium");
7551     DeleteFileA("msitest\\lithium");
7552     RemoveDirectoryA("msitest");
7553 }
7554
7555 static void test_missingcomponent(void)
7556 {
7557     UINT r;
7558
7559     CreateDirectoryA("msitest", NULL);
7560     create_file("msitest\\hydrogen", 500);
7561     create_file("msitest\\helium", 500);
7562     create_file("msitest\\lithium", 500);
7563     create_file("beryllium", 500);
7564
7565     create_database(msifile, mcomp_tables, sizeof(mcomp_tables) / sizeof(msi_table));
7566
7567     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7568
7569     r = MsiInstallProductA(msifile, "INSTALLLEVEL=10 PROPVAR=42");
7570     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7571     ok(pf_exists("msitest\\hydrogen"), "File not installed\n");
7572     ok(pf_exists("msitest\\helium"), "File not installed\n");
7573     ok(pf_exists("msitest\\lithium"), "File not installed\n");
7574     ok(!pf_exists("msitest\\beryllium"), "File installed\n");
7575     ok(pf_exists("msitest"), "File not installed\n");
7576
7577     r = MsiInstallProductA(msifile, "REMOVE=ALL INSTALLLEVEL=10 PROPVAR=42");
7578     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7579     ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
7580     ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
7581     ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
7582     ok(!pf_exists("msitest\\beryllium"), "File installed\n");
7583     ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
7584
7585     DeleteFileA(msifile);
7586     DeleteFileA("msitest\\hydrogen");
7587     DeleteFileA("msitest\\helium");
7588     DeleteFileA("msitest\\lithium");
7589     DeleteFileA("beryllium");
7590     RemoveDirectoryA("msitest");
7591 }
7592
7593 static void test_sourcedirprop(void)
7594 {
7595     UINT r;
7596     CHAR props[MAX_PATH];
7597
7598     CreateDirectoryA("msitest", NULL);
7599     create_file("msitest\\augustus", 500);
7600
7601     create_database(msifile, ca51_tables, sizeof(ca51_tables) / sizeof(msi_table));
7602
7603     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7604
7605     r = MsiInstallProductA(msifile, NULL);
7606     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7607     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
7608     ok(delete_pf("msitest", FALSE), "File installed\n");
7609
7610     DeleteFile("msitest\\augustus");
7611     RemoveDirectory("msitest");
7612
7613     CreateDirectoryA("altsource", NULL);
7614     CreateDirectoryA("altsource\\msitest", NULL);
7615     create_file("altsource\\msitest\\augustus", 500);
7616
7617     sprintf(props, "SRCDIR=%s\\altsource\\", CURR_DIR);
7618
7619     r = MsiInstallProductA(msifile, props);
7620     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7621     ok(delete_pf("msitest\\augustus", TRUE), "File installed\n");
7622     ok(delete_pf("msitest", FALSE), "File installed\n");
7623
7624     DeleteFile(msifile);
7625     DeleteFile("altsource\\msitest\\augustus");
7626     RemoveDirectory("altsource\\msitest");
7627     RemoveDirectory("altsource");
7628 }
7629
7630 static void test_adminimage(void)
7631 {
7632     UINT r;
7633
7634     CreateDirectoryA("msitest", NULL);
7635     CreateDirectoryA("msitest\\first", NULL);
7636     CreateDirectoryA("msitest\\second", NULL);
7637     CreateDirectoryA("msitest\\cabout", NULL);
7638     CreateDirectoryA("msitest\\cabout\\new", NULL);
7639     create_file("msitest\\one.txt", 100);
7640     create_file("msitest\\first\\two.txt", 100);
7641     create_file("msitest\\second\\three.txt", 100);
7642     create_file("msitest\\cabout\\four.txt", 100);
7643     create_file("msitest\\cabout\\new\\five.txt", 100);
7644     create_file("msitest\\filename", 100);
7645     create_file("msitest\\service.exe", 100);
7646
7647     create_database_wordcount(msifile, ai_tables,
7648                               sizeof(ai_tables) / sizeof(msi_table),
7649                               msidbSumInfoSourceTypeAdminImage);
7650
7651     r = MsiInstallProductA(msifile, NULL);
7652     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7653
7654     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
7655     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
7656     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
7657     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
7658     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
7659     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
7660     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
7661     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
7662     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
7663     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
7664     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
7665     ok(delete_pf("msitest", FALSE), "File not installed\n");
7666
7667     DeleteFileA("msitest.msi");
7668     DeleteFileA("msitest\\cabout\\new\\five.txt");
7669     DeleteFileA("msitest\\cabout\\four.txt");
7670     DeleteFileA("msitest\\second\\three.txt");
7671     DeleteFileA("msitest\\first\\two.txt");
7672     DeleteFileA("msitest\\one.txt");
7673     DeleteFileA("msitest\\service.exe");
7674     DeleteFileA("msitest\\filename");
7675     RemoveDirectoryA("msitest\\cabout\\new");
7676     RemoveDirectoryA("msitest\\cabout");
7677     RemoveDirectoryA("msitest\\second");
7678     RemoveDirectoryA("msitest\\first");
7679     RemoveDirectoryA("msitest");
7680 }
7681
7682 static void test_propcase(void)
7683 {
7684     UINT r;
7685
7686     CreateDirectoryA("msitest", NULL);
7687     create_file("msitest\\augustus", 500);
7688
7689     create_database(msifile, pc_tables, sizeof(pc_tables) / sizeof(msi_table));
7690
7691     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7692
7693     r = MsiInstallProductA(msifile, "MyProp=42");
7694     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7695     ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n");
7696     ok(delete_pf("msitest", FALSE), "File not installed\n");
7697
7698     DeleteFile(msifile);
7699     DeleteFile("msitest\\augustus");
7700     RemoveDirectory("msitest");
7701 }
7702
7703 static void test_int_widths( void )
7704 {
7705     static const char int0[] = "int0\ni0\nint0\tint0\n1";
7706     static const char int1[] = "int1\ni1\nint1\tint1\n1";
7707     static const char int2[] = "int2\ni2\nint2\tint2\n1";
7708     static const char int3[] = "int3\ni3\nint3\tint3\n1";
7709     static const char int4[] = "int4\ni4\nint4\tint4\n1";
7710     static const char int5[] = "int5\ni5\nint5\tint5\n1";
7711     static const char int8[] = "int8\ni8\nint8\tint8\n1";
7712
7713     static const struct
7714     {
7715         const char  *data;
7716         unsigned int size;
7717         UINT         ret;
7718     }
7719     tests[] =
7720     {
7721         { int0, sizeof(int0) - 1, ERROR_SUCCESS },
7722         { int1, sizeof(int1) - 1, ERROR_SUCCESS },
7723         { int2, sizeof(int2) - 1, ERROR_SUCCESS },
7724         { int3, sizeof(int3) - 1, ERROR_FUNCTION_FAILED },
7725         { int4, sizeof(int4) - 1, ERROR_SUCCESS },
7726         { int5, sizeof(int5) - 1, ERROR_FUNCTION_FAILED },
7727         { int8, sizeof(int8) - 1, ERROR_FUNCTION_FAILED }
7728     };
7729
7730     char tmpdir[MAX_PATH], msitable[MAX_PATH], msidb[MAX_PATH];
7731     MSIHANDLE db;
7732     UINT r, i;
7733
7734     GetTempPathA(MAX_PATH, tmpdir);
7735     CreateDirectoryA(tmpdir, NULL);
7736
7737     strcpy(msitable, tmpdir);
7738     strcat(msitable, "\\msitable.idt");
7739
7740     strcpy(msidb, tmpdir);
7741     strcat(msidb, "\\msitest.msi");
7742
7743     r = MsiOpenDatabaseA(msidb, MSIDBOPEN_CREATE, &db);
7744     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7745
7746     for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
7747     {
7748         write_file(msitable, tests[i].data, tests[i].size);
7749
7750         r = MsiDatabaseImportA(db, tmpdir, "msitable.idt");
7751         ok(r == tests[i].ret, " %u expected %u, got %u\n", i, tests[i].ret, r);
7752
7753         r = MsiDatabaseCommit(db);
7754         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7755         DeleteFileA(msitable);
7756     }
7757
7758     MsiCloseHandle(db);
7759     DeleteFileA(msidb);
7760     RemoveDirectoryA(tmpdir);
7761 }
7762
7763 static void test_shortcut(void)
7764 {
7765     UINT r;
7766     HRESULT hr;
7767
7768     create_test_files();
7769     create_database(msifile, sc_tables, sizeof(sc_tables) / sizeof(msi_table));
7770
7771     r = MsiInstallProductA(msifile, NULL);
7772     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7773
7774     hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
7775     ok(SUCCEEDED(hr), "CoInitialize failed 0x%08x\n", hr);
7776
7777     r = MsiInstallProductA(msifile, NULL);
7778     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7779
7780     CoUninitialize();
7781
7782     hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
7783     ok(SUCCEEDED(hr), "CoInitialize failed 0x%08x\n", hr);
7784
7785     r = MsiInstallProductA(msifile, NULL);
7786     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7787
7788     CoUninitialize();
7789
7790     delete_pf("msitest\\cabout\\new\\five.txt", TRUE);
7791     delete_pf("msitest\\cabout\\new", FALSE);
7792     delete_pf("msitest\\cabout\\four.txt", TRUE);
7793     delete_pf("msitest\\cabout", FALSE);
7794     delete_pf("msitest\\changed\\three.txt", TRUE);
7795     delete_pf("msitest\\changed", FALSE);
7796     delete_pf("msitest\\first\\two.txt", TRUE);
7797     delete_pf("msitest\\first", FALSE);
7798     delete_pf("msitest\\filename", TRUE);
7799     delete_pf("msitest\\one.txt", TRUE);
7800     delete_pf("msitest\\service.exe", TRUE);
7801     delete_pf("msitest\\Shortcut.lnk", TRUE);
7802     delete_pf("msitest", FALSE);
7803     delete_test_files();
7804 }
7805
7806 static void test_envvar(void)
7807 {
7808     UINT r;
7809     HKEY env;
7810     LONG res;
7811     DWORD type, size;
7812     char buffer[16];
7813     UINT i;
7814
7815     if (on_win9x)
7816     {
7817         win_skip("Environment variables are handled differently on Win9x and WinMe\n");
7818         return;
7819     }
7820
7821     create_test_files();
7822     create_database(msifile, env_tables, sizeof(env_tables) / sizeof(msi_table));
7823
7824     res = RegCreateKeyExA(HKEY_CURRENT_USER, "Environment", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &env, NULL);
7825     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7826
7827     res = RegSetValueExA(env, "MSITESTVAR1", 0, REG_SZ, (const BYTE *)"0", 2);
7828     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7829
7830     res = RegSetValueExA(env, "MSITESTVAR2", 0, REG_SZ, (const BYTE *)"0", 2);
7831     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7832
7833     r = MsiInstallProductA(msifile, NULL);
7834     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7835
7836     type = REG_NONE;
7837     size = sizeof(buffer);
7838     buffer[0] = 0;
7839     res = RegQueryValueExA(env, "MSITESTVAR1", NULL, &type, (LPBYTE)buffer, &size);
7840     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7841     ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
7842     ok(!lstrcmp(buffer, "1"), "Expected \"1\", got %s\n", buffer);
7843
7844     res = RegDeleteValueA(env, "MSITESTVAR1");
7845     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7846
7847     type = REG_NONE;
7848     size = sizeof(buffer);
7849     buffer[0] = 0;
7850     res = RegQueryValueExA(env, "MSITESTVAR2", NULL, &type, (LPBYTE)buffer, &size);
7851     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7852     ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
7853     ok(!lstrcmp(buffer, "1"), "Expected \"1\", got %s\n", buffer);
7854
7855     res = RegDeleteValueA(env, "MSITESTVAR2");
7856     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7857
7858     res = RegDeleteValueA(env, "MSITESTVAR3");
7859     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7860
7861     res = RegDeleteValueA(env, "MSITESTVAR4");
7862     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
7863
7864     res = RegDeleteValueA(env, "MSITESTVAR5");
7865     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
7866
7867     res = RegDeleteValueA(env, "MSITESTVAR6");
7868     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
7869
7870     res = RegDeleteValueA(env, "MSITESTVAR7");
7871     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
7872
7873     res = RegDeleteValueA(env, "MSITESTVAR8");
7874     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
7875
7876     res = RegDeleteValueA(env, "MSITESTVAR9");
7877     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
7878
7879     res = RegDeleteValueA(env, "MSITESTVAR10");
7880     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
7881
7882     i = 11;
7883     while (environment_dat_results[(i-11)]) {
7884         char name[20];
7885         sprintf(name, "MSITESTVAR%d", i);
7886
7887         type = REG_NONE;
7888         size = sizeof(buffer);
7889         buffer[0] = 0;
7890         res = RegQueryValueExA(env, name, NULL, &type, (LPBYTE)buffer, &size);
7891         ok(res == ERROR_SUCCESS, "%d: Expected ERROR_SUCCESS, got %d\n", i, res);
7892         ok(type == REG_SZ, "%d: Expected REG_SZ, got %u\n", i, type);
7893         ok(!lstrcmp(buffer, environment_dat_results[(i-11)]), "%d: Expected %s, got %s\n",
7894            i, environment_dat_results[(i-11)], buffer);
7895
7896         res = RegDeleteValueA(env, name);
7897         ok(res == ERROR_SUCCESS, "%d: Expected ERROR_SUCCESS, got %d\n", i, res);
7898         i++;
7899     }
7900
7901
7902     RegCloseKey(env);
7903     delete_pf("msitest\\cabout\\new\\five.txt", TRUE);
7904     delete_pf("msitest\\cabout\\new", FALSE);
7905     delete_pf("msitest\\cabout\\four.txt", TRUE);
7906     delete_pf("msitest\\cabout", FALSE);
7907     delete_pf("msitest\\changed\\three.txt", TRUE);
7908     delete_pf("msitest\\changed", FALSE);
7909     delete_pf("msitest\\first\\two.txt", TRUE);
7910     delete_pf("msitest\\first", FALSE);
7911     delete_pf("msitest\\filename", TRUE);
7912     delete_pf("msitest\\one.txt", TRUE);
7913     delete_pf("msitest\\service.exe", TRUE);
7914     delete_pf("msitest", FALSE);
7915     delete_test_files();
7916 }
7917
7918 static void test_preselected(void)
7919 {
7920     UINT r;
7921
7922     create_test_files();
7923     create_database(msifile, ps_tables, sizeof(ps_tables) / sizeof(msi_table));
7924
7925     r = MsiInstallProductA(msifile, "ADDLOCAL=One");
7926     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7927
7928     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
7929     ok(!delete_pf("msitest\\cabout\\new", FALSE), "File installed\n");
7930     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
7931     ok(!delete_pf("msitest\\cabout", FALSE), "File installed\n");
7932     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
7933     ok(!delete_pf("msitest\\changed", FALSE), "File installed\n");
7934     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
7935     ok(!delete_pf("msitest\\first", FALSE), "File installed\n");
7936     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
7937     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
7938     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
7939     ok(delete_pf("msitest", FALSE), "File not installed\n");
7940
7941     r = MsiInstallProductA(msifile, NULL);
7942     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7943
7944     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
7945     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
7946     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
7947     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
7948     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
7949     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
7950     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
7951     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
7952     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
7953     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
7954     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
7955     ok(delete_pf("msitest", FALSE), "File not installed\n");
7956     delete_test_files();
7957 }
7958
7959 static void test_installed_prop(void)
7960 {
7961     static char prodcode[] = "{7df88a48-996f-4ec8-a022-bf956f9b2cbb}";
7962     UINT r;
7963
7964     create_test_files();
7965     create_database(msifile, ip_tables, sizeof(ip_tables) / sizeof(msi_table));
7966
7967     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7968
7969     r = MsiInstallProductA(msifile, "FULL=1");
7970     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7971
7972     r = MsiInstallProductA(msifile, "FULL=1");
7973     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
7974
7975     r = MsiConfigureProductExA(prodcode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_DEFAULT, "FULL=1");
7976     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
7977
7978     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
7979     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
7980     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
7981     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
7982     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
7983     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
7984     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
7985     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
7986     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
7987     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
7988     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
7989     ok(delete_pf("msitest", FALSE), "File not installed\n");
7990
7991     r = MsiInstallProductA(msifile, "REMOVE=ALL");
7992     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
7993
7994     delete_test_files();
7995 }
7996
7997 static void test_allusers_prop(void)
7998 {
7999     UINT r;
8000
8001     create_test_files();
8002     create_database(msifile, aup_tables, sizeof(aup_tables) / sizeof(msi_table));
8003
8004     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8005
8006     /* ALLUSERS property unset */
8007     r = MsiInstallProductA(msifile, "FULL=1");
8008     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8009
8010     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8011     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8012     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8013     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8014     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8015     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8016     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8017     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8018     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8019     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8020     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8021     ok(delete_pf("msitest", FALSE), "File not installed\n");
8022
8023     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8024     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8025
8026     delete_test_files();
8027
8028     create_test_files();
8029     create_database(msifile, aup2_tables, sizeof(aup2_tables) / sizeof(msi_table));
8030
8031     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8032
8033     /* ALLUSERS property set to 1 */
8034     r = MsiInstallProductA(msifile, "FULL=1");
8035     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8036
8037     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8038     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8039     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8040     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8041     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8042     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8043     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8044     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8045     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8046     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8047     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8048     ok(delete_pf("msitest", FALSE), "File not installed\n");
8049
8050     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8051     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8052
8053     delete_test_files();
8054
8055     create_test_files();
8056     create_database(msifile, aup3_tables, sizeof(aup3_tables) / sizeof(msi_table));
8057
8058     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8059
8060     /* ALLUSERS property set to 2 */
8061     r = MsiInstallProductA(msifile, "FULL=1");
8062     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8063
8064     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8065     ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8066     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8067     ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8068     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8069     ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8070     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8071     ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8072     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8073     ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8074     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8075     ok(delete_pf("msitest", FALSE), "File not installed\n");
8076
8077     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8078     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8079
8080     delete_test_files();
8081
8082     create_test_files();
8083     create_database(msifile, aup4_tables, sizeof(aup4_tables) / sizeof(msi_table));
8084
8085     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8086
8087     /* ALLUSERS property set to 2, conditioned on ALLUSERS = 1 */
8088     r = MsiInstallProductA(msifile, "FULL=1");
8089     if (r == ERROR_SUCCESS)
8090     {
8091         /* Win9x/WinMe */
8092         win_skip("Win9x and WinMe act differently with respect to ALLUSERS\n");
8093
8094         ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8095         ok(delete_pf("msitest\\cabout\\new", FALSE), "File not installed\n");
8096         ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8097         ok(delete_pf("msitest\\cabout", FALSE), "File not installed\n");
8098         ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8099         ok(delete_pf("msitest\\changed", FALSE), "File not installed\n");
8100         ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8101         ok(delete_pf("msitest\\first", FALSE), "File not installed\n");
8102         ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8103         ok(delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8104         ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8105         ok(delete_pf("msitest", FALSE), "File not installed\n");
8106
8107         r = MsiInstallProductA(msifile, "REMOVE=ALL");
8108         ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8109
8110         delete_test_files();
8111     }
8112     else
8113         ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8114 }
8115
8116 static char session_manager[] = "System\\CurrentControlSet\\Control\\Session Manager";
8117 static char rename_ops[]      = "PendingFileRenameOperations";
8118
8119 static void process_pending_renames(HKEY hkey)
8120 {
8121     char *buf, *src, *dst, *buf2, *buf2ptr;
8122     DWORD size, buf2len = 0;
8123     LONG ret;
8124     BOOL found = FALSE;
8125
8126     ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, NULL, &size);
8127     buf = HeapAlloc(GetProcessHeap(), 0, size);
8128     buf2ptr = buf2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
8129     buf[0] = 0;
8130
8131     ret = RegQueryValueExA(hkey, rename_ops, NULL, NULL, (LPBYTE)buf, &size);
8132     ok(!ret, "RegQueryValueExA failed %d (%u)\n", ret, GetLastError());
8133
8134     for (src = buf; *src; src = dst + strlen(dst) + 1)
8135     {
8136         DWORD flags = MOVEFILE_COPY_ALLOWED;
8137
8138         dst = src + strlen(src) + 1;
8139
8140         if (!strstr(src, "msitest"))
8141         {
8142             lstrcpyA(buf2ptr, src);
8143             buf2len += strlen(src) + 1;
8144             buf2ptr += strlen(src) + 1;
8145             if (*dst)
8146             {
8147                 lstrcpyA(buf2ptr, dst);
8148                 buf2ptr += strlen(dst) + 1;
8149                 buf2len += strlen(dst) + 1;
8150             }
8151             buf2ptr++;
8152             buf2len++;
8153             continue;
8154         }
8155
8156         found = TRUE;
8157
8158         if (*dst == '!')
8159         {
8160             flags |= MOVEFILE_REPLACE_EXISTING;
8161             dst++;
8162         }
8163         if (src[0] == '\\' && src[1] == '?' && src[2] == '?' && src[3] == '\\') src += 4;
8164         if (*dst)
8165         {
8166             if (dst[0] == '\\' && dst[1] == '?' && dst[2] == '?' && dst[3] == '\\') dst += 4;
8167             ok(MoveFileExA(src, dst, flags), "Failed to move file %s -> %s (%u)\n", src, dst, GetLastError());
8168         }
8169         else
8170             ok(DeleteFileA(src), "Failed to delete file %s (%u)\n", src, GetLastError());
8171     }
8172
8173     ok(found, "Expected a 'msitest' entry\n");
8174
8175     if (*buf2)
8176     {
8177         buf2len++;
8178         RegSetValueExA(hkey, rename_ops, 0, REG_MULTI_SZ, (LPBYTE)buf2, buf2len);
8179     }
8180     else
8181         RegDeleteValueA(hkey, rename_ops);
8182
8183     HeapFree(GetProcessHeap(), 0, buf);
8184     HeapFree(GetProcessHeap(), 0, buf2);
8185 }
8186
8187 static BOOL file_matches_data(LPCSTR file, LPCSTR data)
8188 {
8189     DWORD len, data_len = strlen(data);
8190     HANDLE handle;
8191     char buf[128];
8192
8193     handle = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
8194     ok(handle != INVALID_HANDLE_VALUE, "failed to open %s (%u)\n", file, GetLastError());
8195
8196     if (ReadFile(handle, buf, sizeof(buf), &len, NULL) && len >= data_len)
8197     {
8198         CloseHandle(handle);
8199         return !memcmp(buf, data, data_len);
8200     }
8201     CloseHandle(handle);
8202     return FALSE;
8203 }
8204
8205 static void test_file_in_use(void)
8206 {
8207     UINT r;
8208     HANDLE file;
8209     HKEY hkey;
8210     char path[MAX_PATH];
8211
8212     if (on_win9x)
8213     {
8214         win_skip("Pending file renaming is implemented differently on Win9x and WinMe\n");
8215         return;
8216     }
8217
8218     RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey);
8219
8220     CreateDirectoryA("msitest", NULL);
8221     create_file("msitest\\maximus", 500);
8222     create_database(msifile, fiu_tables, sizeof(fiu_tables) / sizeof(msi_table));
8223
8224     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8225
8226     lstrcpy(path, PROG_FILES_DIR);
8227     lstrcat(path, "\\msitest");
8228     CreateDirectoryA(path, NULL);
8229
8230     lstrcat(path, "\\maximus");
8231     file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
8232
8233     r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1");
8234     ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r);
8235     ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n");
8236     CloseHandle(file);
8237     ok(!file_matches_data(path, "msitest\\maximus"), "Expected file not to match\n");
8238
8239     process_pending_renames(hkey);
8240     RegCloseKey(hkey);
8241
8242     ok(file_matches_data(path, "msitest\\maximus"), "Expected file to match\n");
8243     ok(delete_pf("msitest\\maximus", TRUE), "File not present\n");
8244     ok(delete_pf("msitest", FALSE), "Directory not present or not empty\n");
8245
8246     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8247     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8248
8249     DeleteFileA("msitest\\maximus");
8250     delete_test_files();
8251 }
8252
8253 static void test_file_in_use_cab(void)
8254 {
8255     UINT r;
8256     HANDLE file;
8257     HKEY hkey;
8258     char path[MAX_PATH];
8259
8260     if (on_win9x)
8261     {
8262         win_skip("Pending file renaming is implemented differently on Win9x and WinMe\n");
8263         return;
8264     }
8265
8266     RegOpenKeyExA(HKEY_LOCAL_MACHINE, session_manager, 0, KEY_ALL_ACCESS, &hkey);
8267
8268     CreateDirectoryA("msitest", NULL);
8269     create_file("maximus", 500);
8270     create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0");
8271     DeleteFile("maximus");
8272
8273     create_database(msifile, fiuc_tables, sizeof(fiuc_tables) / sizeof(msi_table));
8274
8275     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8276
8277     lstrcpy(path, PROG_FILES_DIR);
8278     lstrcat(path, "\\msitest");
8279     CreateDirectoryA(path, NULL);
8280
8281     lstrcat(path, "\\maximus");
8282     file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
8283
8284     r = MsiInstallProductA(msifile, "REBOOT=ReallySuppress FULL=1");
8285     ok(r == ERROR_SUCCESS_REBOOT_REQUIRED, "Expected ERROR_SUCCESS_REBOOT_REQUIRED got %u\n", r);
8286     ok(!file_matches_data(path, "maximus"), "Expected file not to match\n");
8287     CloseHandle(file);
8288     ok(!file_matches_data(path, "maximus"), "Expected file not to match\n");
8289
8290     process_pending_renames(hkey);
8291     RegCloseKey(hkey);
8292
8293     ok(file_matches_data(path, "maximus"), "Expected file to match\n");
8294     ok(delete_pf("msitest\\maximus", TRUE), "File not present\n");
8295     ok(delete_pf("msitest", FALSE), "Directory not present or not empty\n");
8296
8297     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8298     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8299
8300     delete_cab_files();
8301     delete_test_files();
8302 }
8303
8304 static INT CALLBACK handler_a(LPVOID context, UINT type, LPCSTR msg)
8305 {
8306     return IDOK;
8307 }
8308
8309 static INT CALLBACK handler_w(LPVOID context, UINT type, LPCWSTR msg)
8310 {
8311     return IDOK;
8312 }
8313
8314 static INT CALLBACK handler_record(LPVOID context, UINT type, MSIHANDLE record)
8315 {
8316     return IDOK;
8317 }
8318
8319 static void test_MsiSetExternalUI(void)
8320 {
8321     INSTALLUI_HANDLERA ret_a;
8322     INSTALLUI_HANDLERW ret_w;
8323     INSTALLUI_HANDLER_RECORD prev;
8324     UINT error;
8325
8326     ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
8327     ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
8328
8329     ret_a = MsiSetExternalUIA(NULL, 0, NULL);
8330     ok(ret_a == handler_a, "expected %p, got %p\n", handler_a, ret_a);
8331
8332     /* Not present before Installer 3.1 */
8333     if (!pMsiSetExternalUIRecord) {
8334         win_skip("MsiSetExternalUIRecord is not available\n");
8335         return;
8336     }
8337
8338     error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
8339     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
8340     ok(prev == NULL, "expected NULL, got %p\n", prev);
8341
8342     prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
8343     error = pMsiSetExternalUIRecord(NULL, INSTALLLOGMODE_ERROR, NULL, &prev);
8344     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
8345     ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
8346
8347     ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
8348     ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
8349
8350     ret_w = MsiSetExternalUIW(NULL, 0, NULL);
8351     ok(ret_w == handler_w, "expected %p, got %p\n", handler_w, ret_w);
8352
8353     ret_a = MsiSetExternalUIA(handler_a, INSTALLLOGMODE_ERROR, NULL);
8354     ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
8355
8356     ret_w = MsiSetExternalUIW(handler_w, INSTALLLOGMODE_ERROR, NULL);
8357     ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
8358
8359     prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
8360     error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, &prev);
8361     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
8362     ok(prev == NULL, "expected NULL, got %p\n", prev);
8363
8364     ret_a = MsiSetExternalUIA(NULL, 0, NULL);
8365     ok(ret_a == NULL, "expected NULL, got %p\n", ret_a);
8366
8367     ret_w = MsiSetExternalUIW(NULL, 0, NULL);
8368     ok(ret_w == NULL, "expected NULL, got %p\n", ret_w);
8369
8370     prev = (INSTALLUI_HANDLER_RECORD)0xdeadbeef;
8371     error = pMsiSetExternalUIRecord(NULL, 0, NULL, &prev);
8372     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
8373     ok(prev == handler_record, "expected %p, got %p\n", handler_record, prev);
8374
8375     error = pMsiSetExternalUIRecord(handler_record, INSTALLLOGMODE_ERROR, NULL, NULL);
8376     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
8377
8378     error = pMsiSetExternalUIRecord(NULL, 0, NULL, NULL);
8379     ok(!error, "MsiSetExternalUIRecord failed %u\n", error);
8380 }
8381
8382 static void test_feature_override(void)
8383 {
8384     UINT r;
8385
8386     create_test_files();
8387     create_database(msifile, tables, sizeof(tables) / sizeof(msi_table));
8388
8389     r = MsiInstallProductA(msifile, "ADDLOCAL=One");
8390     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8391
8392     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
8393     ok(!delete_pf("msitest\\cabout\\new", FALSE), "File installed\n");
8394     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
8395     ok(!delete_pf("msitest\\cabout", FALSE), "File installed\n");
8396     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
8397     ok(!delete_pf("msitest\\changed", FALSE), "File installed\n");
8398     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
8399     ok(!delete_pf("msitest\\first", FALSE), "File installed\n");
8400     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
8401     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8402     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
8403     ok(delete_pf("msitest", FALSE), "File not installed\n");
8404
8405     delete_test_files();
8406
8407     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\msitest");
8408 }
8409
8410 static void test_create_folder(void)
8411 {
8412     UINT r;
8413
8414     create_test_files();
8415     create_database(msifile, cf_tables, sizeof(cf_tables) / sizeof(msi_table));
8416
8417     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8418
8419     r = MsiInstallProductA(msifile, NULL);
8420     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8421
8422     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
8423     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
8424     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
8425     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
8426     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
8427     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
8428     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
8429     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
8430     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
8431     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8432     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
8433     ok(!delete_pf("msitest", FALSE), "Directory created\n");
8434
8435     r = MsiInstallProductA(msifile, "LOCAL=Two");
8436     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8437
8438     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
8439     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
8440     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
8441     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
8442     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
8443     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
8444     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
8445     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
8446     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
8447     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8448     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
8449     ok(!delete_pf("msitest", FALSE), "Directory created\n");
8450
8451     delete_test_files();
8452 }
8453
8454 static void test_remove_folder(void)
8455 {
8456     UINT r;
8457
8458     create_test_files();
8459     create_database(msifile, rf_tables, sizeof(rf_tables) / sizeof(msi_table));
8460
8461     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8462
8463     r = MsiInstallProductA(msifile, NULL);
8464     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8465
8466     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
8467     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
8468     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
8469     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
8470     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
8471     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
8472     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
8473     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
8474     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
8475     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8476     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
8477     ok(!delete_pf("msitest", FALSE), "Directory created\n");
8478
8479     r = MsiInstallProductA(msifile, "LOCAL=Two");
8480     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8481
8482     ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n");
8483     ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n");
8484     ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n");
8485     ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n");
8486     ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n");
8487     ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n");
8488     ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n");
8489     ok(!delete_pf("msitest\\first", FALSE), "Directory created\n");
8490     ok(!delete_pf("msitest\\filename", TRUE), "File installed\n");
8491     ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n");
8492     ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n");
8493     ok(!delete_pf("msitest", FALSE), "Directory created\n");
8494
8495     delete_test_files();
8496 }
8497
8498 static void test_start_services(void)
8499 {
8500     UINT r;
8501     SC_HANDLE scm, service;
8502     BOOL ret;
8503     DWORD error = ERROR_SUCCESS;
8504
8505     if (on_win9x)
8506     {
8507         win_skip("Services are not implemented on Win9x and WinMe\n");
8508         return;
8509     }
8510     scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
8511     ok(scm != NULL, "Failed to open the SC Manager\n");
8512     if (!scm) return;
8513
8514     service = OpenService(scm, "Spooler", SC_MANAGER_ALL_ACCESS);
8515     if (!service && GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
8516     {
8517         win_skip("The 'Spooler' service does not exist\n");
8518         CloseServiceHandle(scm);
8519         return;
8520     }
8521     ok(service != NULL, "Failed to open Spooler, error %d\n", GetLastError());
8522     if (!service) {
8523         CloseServiceHandle(scm);
8524         return;
8525     }
8526
8527     ret = StartService(service, 0, NULL);
8528     if (!ret && (error = GetLastError()) != ERROR_SERVICE_ALREADY_RUNNING)
8529     {
8530         skip("Terminal service not available, skipping test\n");
8531         CloseServiceHandle(service);
8532         CloseServiceHandle(scm);
8533         return;
8534     }
8535
8536     CloseServiceHandle(service);
8537     CloseServiceHandle(scm);
8538
8539     create_test_files();
8540     create_database(msifile, sss_tables, sizeof(sss_tables) / sizeof(msi_table));
8541
8542     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8543
8544     r = MsiInstallProductA(msifile, NULL);
8545     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8546
8547     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8548     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
8549     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8550     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
8551     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8552     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
8553     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8554     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
8555     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8556     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8557     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8558     ok(delete_pf("msitest", FALSE), "Directory not created\n");
8559
8560     delete_test_files();
8561
8562     if (error == ERROR_SUCCESS)
8563     {
8564         SERVICE_STATUS status;
8565
8566         scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
8567         service = OpenService(scm, "Spooler", SC_MANAGER_ALL_ACCESS);
8568
8569         ret = ControlService(service, SERVICE_CONTROL_STOP, &status);
8570         ok(ret, "ControlService failed %u\n", GetLastError());
8571
8572         CloseServiceHandle(service);
8573         CloseServiceHandle(scm);
8574     }
8575 }
8576
8577 static void test_delete_services(void)
8578 {
8579     UINT r;
8580
8581     create_test_files();
8582     create_database(msifile, sds_tables, sizeof(sds_tables) / sizeof(msi_table));
8583
8584     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8585
8586     r = MsiInstallProductA(msifile, NULL);
8587     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8588
8589     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8590     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
8591     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8592     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
8593     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8594     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
8595     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8596     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
8597     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8598     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8599     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8600     ok(delete_pf("msitest", FALSE), "Directory not created\n");
8601
8602     delete_test_files();
8603 }
8604
8605 static void test_self_registration(void)
8606 {
8607     UINT r;
8608
8609     create_test_files();
8610     create_database(msifile, sr_tables, sizeof(sr_tables) / sizeof(msi_table));
8611
8612     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8613
8614     r = MsiInstallProductA(msifile, NULL);
8615     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8616
8617     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8618     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
8619     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8620     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
8621     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8622     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
8623     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8624     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
8625     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8626     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8627     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8628     ok(delete_pf("msitest", FALSE), "Directory not created\n");
8629
8630     delete_test_files();
8631 }
8632
8633 static void test_register_font(void)
8634 {
8635     static const char regfont1[] = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
8636     static const char regfont2[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts";
8637     LONG ret;
8638     HKEY key;
8639     UINT r;
8640
8641     create_test_files();
8642     create_file("msitest\\font.ttf", 1000);
8643     create_database(msifile, font_tables, sizeof(font_tables) / sizeof(msi_table));
8644
8645     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8646
8647     r = MsiInstallProductA(msifile, NULL);
8648     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8649
8650     ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, regfont1, &key);
8651     if (ret)
8652         RegOpenKeyA(HKEY_LOCAL_MACHINE, regfont2, &key);
8653
8654     ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
8655     ok(ret != ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);
8656
8657     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8658     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8659
8660     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8661
8662     ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
8663     ok(ret == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);
8664
8665     RegDeleteValueA(key, "msi test font");
8666     RegCloseKey(key);
8667     DeleteFileA("msitest\\font.ttf");
8668     delete_test_files();
8669 }
8670
8671 static void test_validate_product_id(void)
8672 {
8673     UINT r;
8674
8675     create_test_files();
8676     create_database(msifile, vp_tables, sizeof(vp_tables) / sizeof(msi_table));
8677
8678     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8679
8680     r = MsiInstallProductA(msifile, NULL);
8681     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8682
8683     r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=1");
8684     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8685
8686     r = MsiInstallProductA(msifile, "SET_PRODUCT_ID=2");
8687     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8688
8689     r = MsiInstallProductA(msifile, "PIDKEY=123-1234567");
8690     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8691
8692     ok(delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File not installed\n");
8693     ok(delete_pf("msitest\\cabout\\new", FALSE), "Directory not created\n");
8694     ok(delete_pf("msitest\\cabout\\four.txt", TRUE), "File not installed\n");
8695     ok(delete_pf("msitest\\cabout", FALSE), "Directory not created\n");
8696     ok(delete_pf("msitest\\changed\\three.txt", TRUE), "File not installed\n");
8697     ok(delete_pf("msitest\\changed", FALSE), "Directory not created\n");
8698     ok(delete_pf("msitest\\first\\two.txt", TRUE), "File not installed\n");
8699     ok(delete_pf("msitest\\first", FALSE), "Directory not created\n");
8700     ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
8701     ok(delete_pf("msitest\\one.txt", TRUE), "File not installed\n");
8702     ok(delete_pf("msitest\\service.exe", TRUE), "File not installed\n");
8703     ok(delete_pf("msitest", FALSE), "Directory not created\n");
8704
8705     delete_test_files();
8706 }
8707
8708 static void test_install_remove_odbc(void)
8709 {
8710     UINT r;
8711
8712     create_test_files();
8713     create_file("msitest\\ODBCdriver.dll", 1000);
8714     create_file("msitest\\ODBCdriver2.dll", 1000);
8715     create_file("msitest\\ODBCtranslator.dll", 1000);
8716     create_file("msitest\\ODBCtranslator2.dll", 1000);
8717     create_file("msitest\\ODBCsetup.dll", 1000);
8718     create_database(msifile, odbc_tables, sizeof(odbc_tables) / sizeof(msi_table));
8719
8720     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8721
8722     r = MsiInstallProductA(msifile, NULL);
8723     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8724
8725     ok(pf_exists("msitest\\ODBCdriver.dll"), "file not created\n");
8726     ok(pf_exists("msitest\\ODBCdriver2.dll"), "file not created\n");
8727     ok(pf_exists("msitest\\ODBCtranslator.dll"), "file not created\n");
8728     ok(pf_exists("msitest\\ODBCtranslator2.dll"), "file not created\n");
8729     ok(pf_exists("msitest\\ODBCsetup.dll"), "file not created\n");
8730
8731     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8732     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8733
8734     ok(!delete_pf("msitest\\ODBCdriver.dll", TRUE), "file not removed\n");
8735     ok(!delete_pf("msitest\\ODBCdriver2.dll", TRUE), "file not removed\n");
8736     ok(!delete_pf("msitest\\ODBCtranslator.dll", TRUE), "file not removed\n");
8737     ok(!delete_pf("msitest\\ODBCtranslator2.dll", TRUE), "file not removed\n");
8738     ok(!delete_pf("msitest\\ODBCsetup.dll", TRUE), "file not removed\n");
8739     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8740
8741     DeleteFileA("msitest\\ODBCdriver.dll");
8742     DeleteFileA("msitest\\ODBCdriver2.dll");
8743     DeleteFileA("msitest\\ODBCtranslator.dll");
8744     DeleteFileA("msitest\\ODBCtranslator2.dll");
8745     DeleteFileA("msitest\\ODBCsetup.dll");
8746     delete_test_files();
8747 }
8748
8749 static void test_register_typelib(void)
8750 {
8751     UINT r;
8752
8753     create_test_files();
8754     create_file("msitest\\typelib.dll", 1000);
8755     create_database(msifile, tl_tables, sizeof(tl_tables) / sizeof(msi_table));
8756
8757     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8758
8759     r = MsiInstallProductA(msifile, "REGISTER_TYPELIB=1");
8760     ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
8761
8762     r = MsiInstallProductA(msifile, NULL);
8763     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8764
8765     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8766     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8767
8768     ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n");
8769     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8770
8771     DeleteFileA("msitest\\typelib.dll");
8772     delete_test_files();
8773 }
8774
8775 static void test_create_remove_shortcut(void)
8776 {
8777     UINT r;
8778
8779     create_test_files();
8780     create_file("msitest\\target.txt", 1000);
8781     create_database(msifile, crs_tables, sizeof(crs_tables) / sizeof(msi_table));
8782
8783     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8784
8785     r = MsiInstallProductA(msifile, NULL);
8786     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8787
8788     ok(pf_exists("msitest\\target.txt"), "file not created\n");
8789     ok(pf_exists("msitest\\shortcut.lnk"), "file not created\n");
8790
8791     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8792     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8793
8794     ok(!delete_pf("msitest\\shortcut.lnk", TRUE), "file not removed\n");
8795     ok(!delete_pf("msitest\\target.txt", TRUE), "file not removed\n");
8796     todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8797
8798     DeleteFileA("msitest\\target.txt");
8799     delete_test_files();
8800 }
8801
8802 static void test_publish_components(void)
8803 {
8804     static char keypath[] =
8805         "Software\\Microsoft\\Installer\\Components\\0CBCFA296AC907244845745CEEB2F8AA";
8806
8807     UINT r;
8808     LONG res;
8809     HKEY key;
8810
8811     create_test_files();
8812     create_file("msitest\\english.txt", 1000);
8813     create_database(msifile, pub_tables, sizeof(pub_tables) / sizeof(msi_table));
8814
8815     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8816
8817     r = MsiInstallProductA(msifile, NULL);
8818     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8819
8820     res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key);
8821     ok(res == ERROR_SUCCESS, "components key not created %d\n", res);
8822
8823     res = RegQueryValueExA(key, "english.txt", NULL, NULL, NULL, NULL);
8824     ok(res == ERROR_SUCCESS, "value not found %d\n", res);
8825     RegCloseKey(key);
8826
8827     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8828     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8829
8830     res = RegOpenKeyA(HKEY_CURRENT_USER, keypath, &key);
8831     ok(res == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", res);
8832
8833     ok(!delete_pf("msitest\\english.txt", TRUE), "file not removed\n");
8834     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8835
8836     DeleteFileA("msitest\\english.txt");
8837     delete_test_files();
8838 }
8839
8840 static void test_remove_duplicate_files(void)
8841 {
8842     UINT r;
8843
8844     create_test_files();
8845     create_file("msitest\\original.txt", 1000);
8846     create_file("msitest\\original2.txt", 1000);
8847     create_file("msitest\\original3.txt", 1000);
8848     create_database(msifile, rd_tables, sizeof(rd_tables) / sizeof(msi_table));
8849
8850     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8851
8852     r = MsiInstallProductA(msifile, NULL);
8853     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8854
8855     ok(pf_exists("msitest\\original.txt"), "file not created\n");
8856     ok(pf_exists("msitest\\original2.txt"), "file not created\n");
8857     ok(!pf_exists("msitest\\original3.txt"), "file created\n");
8858     ok(pf_exists("msitest\\duplicate.txt"), "file not created\n");
8859     ok(!pf_exists("msitest\\duplicate2.txt"), "file created\n");
8860
8861     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8862     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8863
8864     ok(delete_pf("msitest\\original.txt", TRUE), "file removed\n");
8865     ok(!delete_pf("msitest\\original2.txt", TRUE), "file not removed\n");
8866     ok(!delete_pf("msitest\\original3.txt", TRUE), "file not removed\n");
8867     ok(!delete_pf("msitest\\duplicate.txt", TRUE), "file not removed\n");
8868     ok(!delete_pf("msitest\\duplicate2.txt", TRUE), "file not removed\n");
8869     ok(delete_pf("msitest", FALSE), "directory removed\n");
8870
8871     DeleteFileA("msitest\\original.txt");
8872     DeleteFileA("msitest\\original2.txt");
8873     DeleteFileA("msitest\\original3.txt");
8874     delete_test_files();
8875 }
8876
8877 static void test_remove_registry_values(void)
8878 {
8879     UINT r;
8880     LONG res;
8881     HKEY key;
8882
8883     create_test_files();
8884     create_file("msitest\\registry.txt", 1000);
8885     create_database(msifile, rrv_tables, sizeof(rrv_tables) / sizeof(msi_table));
8886
8887     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8888
8889     RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", &key);
8890     RegSetValueExA(key, "value1", 0, REG_SZ, (const BYTE *)"1", 2);
8891     RegCloseKey(key);
8892
8893     RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", &key);
8894     RegSetValueExA(key, "value2", 0, REG_SZ, (const BYTE *)"2", 2);
8895     RegCloseKey(key);
8896
8897     RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA", &key);
8898     RegSetValueExA(key, "", 0, REG_SZ, (const BYTE *)"default", 8);
8899     RegSetValueExA(key, "valueA", 0, REG_SZ, (const BYTE *)"A", 2);
8900     RegSetValueExA(key, "valueB", 0, REG_SZ, (const BYTE *)"B", 2);
8901     RegCloseKey(key);
8902
8903     RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyB", &key);
8904     RegSetValueExA(key, "", 0, REG_SZ, (const BYTE *)"default", 8);
8905     RegSetValueExA(key, "valueB", 0, REG_SZ, (const BYTE *)"B", 2);
8906     RegCloseKey(key);
8907
8908     r = MsiInstallProductA(msifile, NULL);
8909     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8910
8911     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", &key);
8912     ok(res == ERROR_SUCCESS, "key removed\n");
8913     RegCloseKey(key);
8914
8915     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", &key);
8916     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
8917
8918     res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", &key);
8919     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8920     RegCloseKey(key);
8921
8922     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8923     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8924
8925     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key1", &key);
8926     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
8927
8928     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2", &key);
8929     ok(res == ERROR_SUCCESS, "key removed\n");
8930     RegCloseKey(key);
8931
8932     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA", &key);
8933     ok(res == ERROR_SUCCESS, "key removed\n");
8934     RegCloseKey(key);
8935
8936     res = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyB", &key);
8937     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
8938
8939     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\keyA");
8940     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\key2");
8941     RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine");
8942
8943     ok(!delete_pf("msitest\\registry.txt", TRUE), "file not removed\n");
8944     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8945
8946     DeleteFileA("msitest\\registry.txt");
8947     delete_test_files();
8948 }
8949
8950 static void test_find_related_products(void)
8951 {
8952     UINT r;
8953
8954     create_test_files();
8955     create_file("msitest\\product.txt", 1000);
8956     create_database(msifile, frp_tables, sizeof(frp_tables) / sizeof(msi_table));
8957
8958     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
8959
8960     r = MsiInstallProductA(msifile, NULL);
8961     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8962
8963     /* install again, so it finds the upgrade code */
8964     r = MsiInstallProductA(msifile, NULL);
8965     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8966
8967     r = MsiInstallProductA(msifile, "REMOVE=ALL");
8968     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
8969
8970     ok(!delete_pf("msitest\\product.txt", TRUE), "file not removed\n");
8971     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
8972
8973     DeleteFileA("msitest\\product.txt");
8974     delete_test_files();
8975 }
8976
8977 static void test_remove_ini_values(void)
8978 {
8979     UINT r;
8980     DWORD len;
8981     char inifile[MAX_PATH], buf[0x10];
8982     HANDLE file;
8983     BOOL ret;
8984
8985     create_test_files();
8986     create_file("msitest\\inifile.txt", 1000);
8987     create_database(msifile, riv_tables, sizeof(riv_tables) / sizeof(msi_table));
8988
8989     lstrcpyA(inifile, PROG_FILES_DIR);
8990     lstrcatA(inifile, "\\msitest");
8991     CreateDirectoryA(inifile, NULL);
8992     lstrcatA(inifile, "\\test.ini");
8993     file = CreateFileA(inifile, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, 0, NULL);
8994     CloseHandle(file);
8995
8996     ret = WritePrivateProfileStringA("section1", "key1", "value1", inifile);
8997     ok(ret, "failed to write profile string %u\n", GetLastError());
8998
8999     ret = WritePrivateProfileStringA("sectionA", "keyA", "valueA", inifile);
9000     ok(ret, "failed to write profile string %u\n", GetLastError());
9001
9002     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9003
9004     r = MsiInstallProductA(msifile, NULL);
9005     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9006
9007     len = GetPrivateProfileStringA("section1", "key1", NULL, buf, sizeof(buf), inifile);
9008     ok(len == 6, "got %u expected 6\n", len);
9009
9010     len = GetPrivateProfileStringA("sectionA", "keyA", NULL, buf, sizeof(buf), inifile);
9011     ok(!len, "got %u expected 0\n", len);
9012
9013     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9014     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9015
9016     len = GetPrivateProfileStringA("section1", "key1", NULL, buf, sizeof(buf), inifile);
9017     ok(!len, "got %u expected 0\n", len);
9018
9019     len = GetPrivateProfileStringA("sectionA", "keyA", NULL, buf, sizeof(buf), inifile);
9020     ok(!len, "got %u expected 0\n", len);
9021
9022     todo_wine ok(!delete_pf("msitest\\test.ini", TRUE), "file removed\n");
9023     ok(!delete_pf("msitest\\inifile.txt", TRUE), "file not removed\n");
9024     ok(delete_pf("msitest", FALSE), "directory removed\n");
9025
9026     DeleteFileA("msitest\\inifile.txt");
9027     delete_test_files();
9028 }
9029
9030 static void test_remove_env_strings(void)
9031 {
9032     UINT r;
9033     LONG res;
9034     HKEY key;
9035     DWORD type, size;
9036     char buffer[0x10];
9037
9038     if (on_win9x)
9039     {
9040         win_skip("Environment variables are handled differently on win9x and winme\n");
9041         return;
9042     }
9043
9044     create_test_files();
9045     create_file("msitest\\envvar.txt", 1000);
9046     create_database(msifile, res_tables, sizeof(res_tables) / sizeof(msi_table));
9047
9048     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9049
9050     res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key);
9051     ok(!res, "failed to open environment key %d\n", res);
9052
9053     RegSetValueExA(key, "MSITESTVAR1", 0, REG_SZ, (const BYTE *)"1", 2);
9054     RegSetValueExA(key, "MSITESTVAR2", 0, REG_SZ, (const BYTE *)"1", 2);
9055     RegSetValueExA(key, "MSITESTVAR3", 0, REG_SZ, (const BYTE *)"1", 2);
9056     RegSetValueExA(key, "MSITESTVAR4", 0, REG_SZ, (const BYTE *)"1", 2);
9057     RegSetValueExA(key, "MSITESTVAR5", 0, REG_SZ, (const BYTE *)"1", 2);
9058
9059     RegCloseKey(key);
9060
9061     r = MsiInstallProductA(msifile, NULL);
9062     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9063
9064     res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key);
9065     ok(!res, "failed to open environment key %d\n", res);
9066
9067     type = REG_NONE;
9068     buffer[0] = 0;
9069     size = sizeof(buffer);
9070     res = RegQueryValueExA(key, "MSITESTVAR1", NULL, &type, (LPBYTE)buffer, &size);
9071     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9072     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9073     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9074
9075     type = REG_NONE;
9076     buffer[0] = 0;
9077     size = sizeof(buffer);
9078     res = RegQueryValueExA(key, "MSITESTVAR2", NULL, &type, (LPBYTE)buffer, &size);
9079     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9080     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9081     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9082
9083     type = REG_NONE;
9084     buffer[0] = 0;
9085     size = sizeof(buffer);
9086     res = RegQueryValueExA(key, "MSITESTVAR3", NULL, &type, (LPBYTE)buffer, &size);
9087     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9088     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9089     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9090
9091     type = REG_NONE;
9092     buffer[0] = 0;
9093     size = sizeof(buffer);
9094     res = RegQueryValueExA(key, "MSITESTVAR4", NULL, &type, (LPBYTE)buffer, &size);
9095     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9096     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9097     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9098
9099     type = REG_NONE;
9100     buffer[0] = 0;
9101     size = sizeof(buffer);
9102     res = RegQueryValueExA(key, "MSITESTVAR5", NULL, &type, (LPBYTE)buffer, &size);
9103     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9104     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9105     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9106
9107     RegCloseKey(key);
9108
9109     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9110     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9111
9112     res = RegOpenKeyA(HKEY_CURRENT_USER, "Environment", &key);
9113     ok(!res, "failed to open environment key %d\n", res);
9114
9115     res = RegQueryValueExA(key, "MSITESTVAR1", NULL, NULL, NULL, NULL);
9116     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
9117
9118     res = RegQueryValueExA(key, "MSITESTVAR2", NULL, NULL, NULL, NULL);
9119     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
9120
9121     type = REG_NONE;
9122     buffer[0] = 0;
9123     size = sizeof(buffer);
9124     res = RegQueryValueExA(key, "MSITESTVAR3", NULL, &type, (LPBYTE)buffer, &size);
9125     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9126     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9127     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9128     RegDeleteValueA(key, "MSITESTVAR3");
9129
9130     res = RegQueryValueExA(key, "MSITESTVAR4", NULL, NULL, NULL, NULL);
9131     ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
9132
9133     type = REG_NONE;
9134     buffer[0] = 0;
9135     size = sizeof(buffer);
9136     res = RegQueryValueExA(key, "MSITESTVAR5", NULL, &type, (LPBYTE)buffer, &size);
9137     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9138     ok(type == REG_SZ, "expected REG_SZ, got %u\n", type);
9139     ok(!lstrcmp(buffer, "1"), "expected \"1\", got \"%s\"\n", buffer);
9140     RegDeleteValueA(key, "MSITESTVAR5");
9141
9142     RegCloseKey(key);
9143
9144     ok(!delete_pf("msitest\\envvar.txt", TRUE), "file not removed\n");
9145     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9146
9147     DeleteFileA("msitest\\envvar.txt");
9148     delete_test_files();
9149 }
9150
9151 static void test_register_class_info(void)
9152 {
9153     UINT r;
9154     LONG res;
9155     HKEY hkey;
9156
9157     create_test_files();
9158     create_file("msitest\\class.txt", 1000);
9159     create_database(msifile, rci_tables, sizeof(rci_tables) / sizeof(msi_table));
9160
9161     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9162
9163     r = MsiInstallProductA(msifile, NULL);
9164     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9165
9166     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
9167     ok(res == ERROR_SUCCESS, "key not created\n");
9168     RegCloseKey(hkey);
9169
9170     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "FileType\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
9171     ok(res == ERROR_SUCCESS, "key not created\n");
9172     RegCloseKey(hkey);
9173
9174     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "AppID\\{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}", &hkey);
9175     ok(res == ERROR_SUCCESS, "key not created\n");
9176     RegCloseKey(hkey);
9177
9178     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9179     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9180
9181     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "CLSID\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
9182     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
9183
9184     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "FileType\\{110913E7-86D1-4BF3-9922-BA103FCDDDFA}", &hkey);
9185     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
9186
9187     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "AppID\\{CFCC3B38-E683-497D-9AB4-CB40AAFE307F}", &hkey);
9188     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
9189
9190     ok(!delete_pf("msitest\\class.txt", TRUE), "file not removed\n");
9191     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9192
9193     DeleteFileA("msitest\\class.txt");
9194     delete_test_files();
9195 }
9196
9197 static void test_register_extension_info(void)
9198 {
9199     UINT r;
9200     LONG res;
9201     HKEY hkey;
9202
9203     create_test_files();
9204     create_file("msitest\\extension.txt", 1000);
9205     create_database(msifile, rei_tables, sizeof(rei_tables) / sizeof(msi_table));
9206
9207     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9208
9209     r = MsiInstallProductA(msifile, NULL);
9210     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9211
9212     res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey);
9213     ok(res == ERROR_SUCCESS, "key not created\n");
9214     RegCloseKey(hkey);
9215
9216     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Prog.Id.1\\shell\\Open\\command", &hkey);
9217     ok(res == ERROR_SUCCESS, "key not created\n");
9218     RegCloseKey(hkey);
9219
9220     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9221     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9222
9223     res = RegOpenKeyA(HKEY_CLASSES_ROOT, ".extension", &hkey);
9224     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
9225
9226     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "Prog.Id.1", &hkey);
9227     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
9228
9229     ok(!delete_pf("msitest\\extension.txt", TRUE), "file not removed\n");
9230     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9231
9232     DeleteFileA("msitest\\extension.txt");
9233     delete_test_files();
9234 }
9235
9236 static void test_register_mime_info(void)
9237 {
9238     UINT r;
9239     LONG res;
9240     HKEY hkey;
9241
9242     create_test_files();
9243     create_file("msitest\\mime.txt", 1000);
9244     create_database(msifile, rmi_tables, sizeof(rmi_tables) / sizeof(msi_table));
9245
9246     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
9247
9248     r = MsiInstallProductA(msifile, NULL);
9249     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9250
9251     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey);
9252     ok(res == ERROR_SUCCESS, "key not created\n");
9253     RegCloseKey(hkey);
9254
9255     r = MsiInstallProductA(msifile, "REMOVE=ALL");
9256     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
9257
9258     res = RegOpenKeyA(HKEY_CLASSES_ROOT, "MIME\\Database\\Content Type\\mime/type", &hkey);
9259     ok(res == ERROR_FILE_NOT_FOUND, "key not removed\n");
9260
9261     ok(!delete_pf("msitest\\mime.txt", TRUE), "file not removed\n");
9262     ok(!delete_pf("msitest", FALSE), "directory not removed\n");
9263
9264     DeleteFileA("msitest\\mime.txt");
9265     delete_test_files();
9266 }
9267
9268 START_TEST(install)
9269 {
9270     DWORD len;
9271     char temp_path[MAX_PATH], prev_path[MAX_PATH], log_file[MAX_PATH];
9272     STATEMGRSTATUS status;
9273     BOOL ret = FALSE;
9274
9275     init_functionpointers();
9276
9277     on_win9x = check_win9x();
9278
9279     GetCurrentDirectoryA(MAX_PATH, prev_path);
9280     GetTempPath(MAX_PATH, temp_path);
9281     SetCurrentDirectoryA(temp_path);
9282
9283     lstrcpyA(CURR_DIR, temp_path);
9284     len = lstrlenA(CURR_DIR);
9285
9286     if(len && (CURR_DIR[len - 1] == '\\'))
9287         CURR_DIR[len - 1] = 0;
9288
9289     get_program_files_dir(PROG_FILES_DIR, COMMON_FILES_DIR);
9290
9291     /* Create a restore point ourselves so we circumvent the multitude of restore points
9292      * that would have been created by all the installation and removal tests.
9293      */
9294     if (pSRSetRestorePointA)
9295     {
9296         memset(&status, 0, sizeof(status));
9297         ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
9298     }
9299
9300     /* Create only one log file and don't append. We have to pass something
9301      * for the log mode for this to work. The logfile needs to have an absolute
9302      * path otherwise we still end up with some extra logfiles as some tests
9303      * change the current directory.
9304      */
9305     lstrcpyA(log_file, temp_path);
9306     lstrcatA(log_file, "\\msitest.log");
9307     MsiEnableLogA(INSTALLLOGMODE_FATALEXIT, log_file, 0);
9308
9309     test_MsiInstallProduct();
9310     test_MsiSetComponentState();
9311     test_packagecoltypes();
9312     test_continuouscabs();
9313     test_caborder();
9314     test_mixedmedia();
9315     test_samesequence();
9316     test_uiLevelFlags();
9317     test_readonlyfile();
9318     test_readonlyfile_cab();
9319     test_setdirproperty();
9320     test_cabisextracted();
9321     test_concurrentinstall();
9322     test_setpropertyfolder();
9323     test_publish_registerproduct();
9324     test_publish_publishproduct();
9325     test_publish_publishfeatures();
9326     test_publish_registeruser();
9327     test_publish_processcomponents();
9328     test_publish();
9329     test_publishsourcelist();
9330     test_transformprop();
9331     test_currentworkingdir();
9332     test_admin();
9333     test_adminprops();
9334     test_removefiles();
9335     test_movefiles();
9336     test_missingcab();
9337     test_duplicatefiles();
9338     test_writeregistryvalues();
9339     test_sourcefolder();
9340     test_customaction51();
9341     test_installstate();
9342     test_sourcepath();
9343     test_MsiConfigureProductEx();
9344     test_missingcomponent();
9345     test_sourcedirprop();
9346     test_adminimage();
9347     test_propcase();
9348     test_int_widths();
9349     test_shortcut();
9350     test_envvar();
9351     test_lastusedsource();
9352     test_preselected();
9353     test_installed_prop();
9354     test_file_in_use();
9355     test_file_in_use_cab();
9356     test_MsiSetExternalUI();
9357     test_allusers_prop();
9358     test_feature_override();
9359     test_create_folder();
9360     test_remove_folder();
9361     test_start_services();
9362     test_delete_services();
9363     test_self_registration();
9364     test_register_font();
9365     test_validate_product_id();
9366     test_install_remove_odbc();
9367     test_register_typelib();
9368     test_create_remove_shortcut();
9369     test_publish_components();
9370     test_remove_duplicate_files();
9371     test_remove_registry_values();
9372     test_find_related_products();
9373     test_remove_ini_values();
9374     test_remove_env_strings();
9375     test_register_class_info();
9376     test_register_extension_info();
9377     test_register_mime_info();
9378
9379     DeleteFileA(log_file);
9380
9381     if (pSRSetRestorePointA && ret)
9382     {
9383         ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
9384         if (ret)
9385             remove_restore_point(status.llSequenceNumber);
9386     }
9387     FreeLibrary(hsrclient);
9388
9389     SetCurrentDirectoryA(prev_path);
9390 }