aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Msi
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2019-05-08 14:13:31 -0700
committerRob Mensching <rob@firegiant.com>2019-05-08 14:44:43 -0700
commit75fd55d5a71c492c6ea904768858c51aa97da29f (patch)
tree610047db1d5759a726ce88277bb2dfddcd01da45 /src/WixToolset.Core.WindowsInstaller/Msi
parentd1dbe29f3856d012acf5f96e8e66c43b74ab490d (diff)
downloadwix-75fd55d5a71c492c6ea904768858c51aa97da29f.tar.gz
wix-75fd55d5a71c492c6ea904768858c51aa97da29f.tar.bz2
wix-75fd55d5a71c492c6ea904768858c51aa97da29f.zip
Use new strongly typed tuples
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Msi')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/Database.cs4
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/Installer.cs4
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/Interop/MsiInterop.cs697
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/MsiException.cs3
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/MsiHandle.cs5
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/MsiInterop.cs571
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/MsmInterop.cs505
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/Record.cs3
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/Session.cs4
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/SummaryInformation.cs3
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/View.cs22
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs2
12 files changed, 1097 insertions, 726 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/Database.cs b/src/WixToolset.Core.WindowsInstaller/Msi/Database.cs
index ccb0e6cf..9f08a217 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/Database.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/Database.cs
@@ -1,13 +1,11 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.Globalization; 6 using System.Globalization;
7 using System.IO; 7 using System.IO;
8 using System.Threading; 8 using System.Threading;
9 using WixToolset.Core.Native;
10 using WixToolset.Data;
11 9
12 /// <summary> 10 /// <summary>
13 /// Wrapper class for managing MSI API database handles. 11 /// Wrapper class for managing MSI API database handles.
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/Installer.cs b/src/WixToolset.Core.WindowsInstaller/Msi/Installer.cs
index f8bce602..0edcd633 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/Installer.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/Installer.cs
@@ -1,6 +1,6 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.Diagnostics; 6 using System.Diagnostics;
@@ -281,7 +281,7 @@ namespace WixToolset.Msi
281 /// <param name="hash">Int array that receives the returned file hash information.</param> 281 /// <param name="hash">Int array that receives the returned file hash information.</param>
282 internal static void GetFileHash(string filePath, int options, out int[] hash) 282 internal static void GetFileHash(string filePath, int options, out int[] hash)
283 { 283 {
284 MsiInterop.MSIFILEHASHINFO hashInterop = new MsiInterop.MSIFILEHASHINFO(); 284 MSIFILEHASHINFO hashInterop = new MSIFILEHASHINFO();
285 hashInterop.FileHashInfoSize = 20; 285 hashInterop.FileHashInfoSize = 20;
286 286
287 int error = MsiInterop.MsiGetFileHash(filePath, Convert.ToUInt32(options), hashInterop); 287 int error = MsiInterop.MsiGetFileHash(filePath, Convert.ToUInt32(options), hashInterop);
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/Interop/MsiInterop.cs b/src/WixToolset.Core.WindowsInstaller/Msi/Interop/MsiInterop.cs
deleted file mode 100644
index 054289ee..00000000
--- a/src/WixToolset.Core.WindowsInstaller/Msi/Interop/MsiInterop.cs
+++ /dev/null
@@ -1,697 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2#if false
3namespace WixToolset.Msi.Interop
4{
5 using System;
6 using System.Text;
7 using System.Runtime.InteropServices;
8 using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
9
10 /// <summary>
11 /// A callback function that the installer calls for progress notification and error messages.
12 /// </summary>
13 /// <param name="context">Pointer to an application context.
14 /// This parameter can be used for error checking.</param>
15 /// <param name="messageType">Specifies a combination of one message box style,
16 /// one message box icon type, one default button, and one installation message type.</param>
17 /// <param name="message">Specifies the message text.</param>
18 /// <returns>-1 for an error, 0 if no action was taken, 1 if OK, 3 to abort.</returns>
19 internal delegate int InstallUIHandler(IntPtr context, uint messageType, [MarshalAs(UnmanagedType.LPWStr)] string message);
20
21 /// <summary>
22 /// Class exposing static functions and structs from MSI API.
23 /// </summary>
24 internal sealed class MsiInterop
25 {
26 // Patching constants
27 internal const int MsiMaxStreamNameLength = 62; // http://msdn2.microsoft.com/library/aa370551.aspx
28
29 // Component.Attributes
30 internal const int MsidbComponentAttributesLocalOnly = 0;
31 internal const int MsidbComponentAttributesSourceOnly = 1;
32 internal const int MsidbComponentAttributesOptional = 2;
33 internal const int MsidbComponentAttributesRegistryKeyPath = 4;
34 internal const int MsidbComponentAttributesSharedDllRefCount = 8;
35 internal const int MsidbComponentAttributesPermanent = 16;
36 internal const int MsidbComponentAttributesODBCDataSource = 32;
37 internal const int MsidbComponentAttributesTransitive = 64;
38 internal const int MsidbComponentAttributesNeverOverwrite = 128;
39 internal const int MsidbComponentAttributes64bit = 256;
40 internal const int MsidbComponentAttributesDisableRegistryReflection = 512;
41 internal const int MsidbComponentAttributesUninstallOnSupersedence = 1024;
42 internal const int MsidbComponentAttributesShared = 2048;
43
44 // BBControl.Attributes & Control.Attributes
45 internal const int MsidbControlAttributesVisible = 0x00000001;
46 internal const int MsidbControlAttributesEnabled = 0x00000002;
47 internal const int MsidbControlAttributesSunken = 0x00000004;
48 internal const int MsidbControlAttributesIndirect = 0x00000008;
49 internal const int MsidbControlAttributesInteger = 0x00000010;
50 internal const int MsidbControlAttributesRTLRO = 0x00000020;
51 internal const int MsidbControlAttributesRightAligned = 0x00000040;
52 internal const int MsidbControlAttributesLeftScroll = 0x00000080;
53 internal const int MsidbControlAttributesBiDi = MsidbControlAttributesRTLRO | MsidbControlAttributesRightAligned | MsidbControlAttributesLeftScroll;
54
55 // Text controls
56 internal const int MsidbControlAttributesTransparent = 0x00010000;
57 internal const int MsidbControlAttributesNoPrefix = 0x00020000;
58 internal const int MsidbControlAttributesNoWrap = 0x00040000;
59 internal const int MsidbControlAttributesFormatSize = 0x00080000;
60 internal const int MsidbControlAttributesUsersLanguage = 0x00100000;
61
62 // Edit controls
63 internal const int MsidbControlAttributesMultiline = 0x00010000;
64 internal const int MsidbControlAttributesPasswordInput = 0x00200000;
65
66 // ProgressBar controls
67 internal const int MsidbControlAttributesProgress95 = 0x00010000;
68
69 // VolumeSelectCombo and DirectoryCombo controls
70 internal const int MsidbControlAttributesRemovableVolume = 0x00010000;
71 internal const int MsidbControlAttributesFixedVolume = 0x00020000;
72 internal const int MsidbControlAttributesRemoteVolume = 0x00040000;
73 internal const int MsidbControlAttributesCDROMVolume = 0x00080000;
74 internal const int MsidbControlAttributesRAMDiskVolume = 0x00100000;
75 internal const int MsidbControlAttributesFloppyVolume = 0x00200000;
76
77 // VolumeCostList controls
78 internal const int MsidbControlShowRollbackCost = 0x00400000;
79
80 // ListBox and ComboBox controls
81 internal const int MsidbControlAttributesSorted = 0x00010000;
82 internal const int MsidbControlAttributesComboList = 0x00020000;
83
84 // picture button controls
85 internal const int MsidbControlAttributesImageHandle = 0x00010000;
86 internal const int MsidbControlAttributesPushLike = 0x00020000;
87 internal const int MsidbControlAttributesBitmap = 0x00040000;
88 internal const int MsidbControlAttributesIcon = 0x00080000;
89 internal const int MsidbControlAttributesFixedSize = 0x00100000;
90 internal const int MsidbControlAttributesIconSize16 = 0x00200000;
91 internal const int MsidbControlAttributesIconSize32 = 0x00400000;
92 internal const int MsidbControlAttributesIconSize48 = 0x00600000;
93 internal const int MsidbControlAttributesElevationShield = 0x00800000;
94
95 // RadioButton controls
96 internal const int MsidbControlAttributesHasBorder = 0x01000000;
97
98 // CustomAction.Type
99 // executable types
100 internal const int MsidbCustomActionTypeDll = 0x00000001; // Target = entry point name
101 internal const int MsidbCustomActionTypeExe = 0x00000002; // Target = command line args
102 internal const int MsidbCustomActionTypeTextData = 0x00000003; // Target = text string to be formatted and set into property
103 internal const int MsidbCustomActionTypeJScript = 0x00000005; // Target = entry point name; null if none to call
104 internal const int MsidbCustomActionTypeVBScript = 0x00000006; // Target = entry point name; null if none to call
105 internal const int MsidbCustomActionTypeInstall = 0x00000007; // Target = property list for nested engine initialization
106 internal const int MsidbCustomActionTypeSourceBits = 0x00000030;
107 internal const int MsidbCustomActionTypeTargetBits = 0x00000007;
108 internal const int MsidbCustomActionTypeReturnBits = 0x000000C0;
109 internal const int MsidbCustomActionTypeExecuteBits = 0x00000700;
110
111 // source of code
112 internal const int MsidbCustomActionTypeBinaryData = 0x00000000; // Source = Binary.Name; data stored in stream
113 internal const int MsidbCustomActionTypeSourceFile = 0x00000010; // Source = File.File; file part of installation
114 internal const int MsidbCustomActionTypeDirectory = 0x00000020; // Source = Directory.Directory; folder containing existing file
115 internal const int MsidbCustomActionTypeProperty = 0x00000030; // Source = Property.Property; full path to executable
116
117 // return processing; default is syncronous execution; process return code
118 internal const int MsidbCustomActionTypeContinue = 0x00000040; // ignore action return status; continue running
119 internal const int MsidbCustomActionTypeAsync = 0x00000080; // run asynchronously
120
121 // execution scheduling flags; default is execute whenever sequenced
122 internal const int MsidbCustomActionTypeFirstSequence = 0x00000100; // skip if UI sequence already run
123 internal const int MsidbCustomActionTypeOncePerProcess = 0x00000200; // skip if UI sequence already run in same process
124 internal const int MsidbCustomActionTypeClientRepeat = 0x00000300; // run on client only if UI already run on client
125 internal const int MsidbCustomActionTypeInScript = 0x00000400; // queue for execution within script
126 internal const int MsidbCustomActionTypeRollback = 0x00000100; // in conjunction with InScript: queue in Rollback script
127 internal const int MsidbCustomActionTypeCommit = 0x00000200; // in conjunction with InScript: run Commit ops from script on success
128
129 // security context flag; default to impersonate as user; valid only if InScript
130 internal const int MsidbCustomActionTypeNoImpersonate = 0x00000800; // no impersonation; run in system context
131 internal const int MsidbCustomActionTypeTSAware = 0x00004000; // impersonate for per-machine installs on TS machines
132 internal const int MsidbCustomActionType64BitScript = 0x00001000; // script should run in 64bit process
133 internal const int MsidbCustomActionTypeHideTarget = 0x00002000; // don't record the contents of the Target field in the log file.
134
135 internal const int MsidbCustomActionTypePatchUninstall = 0x00008000; // run on patch uninstall
136
137 // Dialog.Attributes
138 internal const int MsidbDialogAttributesVisible = 0x00000001;
139 internal const int MsidbDialogAttributesModal = 0x00000002;
140 internal const int MsidbDialogAttributesMinimize = 0x00000004;
141 internal const int MsidbDialogAttributesSysModal = 0x00000008;
142 internal const int MsidbDialogAttributesKeepModeless = 0x00000010;
143 internal const int MsidbDialogAttributesTrackDiskSpace = 0x00000020;
144 internal const int MsidbDialogAttributesUseCustomPalette = 0x00000040;
145 internal const int MsidbDialogAttributesRTLRO = 0x00000080;
146 internal const int MsidbDialogAttributesRightAligned = 0x00000100;
147 internal const int MsidbDialogAttributesLeftScroll = 0x00000200;
148 internal const int MsidbDialogAttributesBiDi = MsidbDialogAttributesRTLRO | MsidbDialogAttributesRightAligned | MsidbDialogAttributesLeftScroll;
149 internal const int MsidbDialogAttributesError = 0x00010000;
150 internal const int CommonControlAttributesInvert = MsidbControlAttributesVisible + MsidbControlAttributesEnabled;
151 internal const int DialogAttributesInvert = MsidbDialogAttributesVisible + MsidbDialogAttributesModal + MsidbDialogAttributesMinimize;
152
153 // Feature.Attributes
154 internal const int MsidbFeatureAttributesFavorLocal = 0;
155 internal const int MsidbFeatureAttributesFavorSource = 1;
156 internal const int MsidbFeatureAttributesFollowParent = 2;
157 internal const int MsidbFeatureAttributesFavorAdvertise = 4;
158 internal const int MsidbFeatureAttributesDisallowAdvertise = 8;
159 internal const int MsidbFeatureAttributesUIDisallowAbsent = 16;
160 internal const int MsidbFeatureAttributesNoUnsupportedAdvertise = 32;
161
162 // File.Attributes
163 internal const int MsidbFileAttributesReadOnly = 1;
164 internal const int MsidbFileAttributesHidden = 2;
165 internal const int MsidbFileAttributesSystem = 4;
166 internal const int MsidbFileAttributesVital = 512;
167 internal const int MsidbFileAttributesChecksum = 1024;
168 internal const int MsidbFileAttributesPatchAdded = 4096;
169 internal const int MsidbFileAttributesNoncompressed = 8192;
170 internal const int MsidbFileAttributesCompressed = 16384;
171
172 // IniFile.Action & RemoveIniFile.Action
173 internal const int MsidbIniFileActionAddLine = 0;
174 internal const int MsidbIniFileActionCreateLine = 1;
175 internal const int MsidbIniFileActionRemoveLine = 2;
176 internal const int MsidbIniFileActionAddTag = 3;
177 internal const int MsidbIniFileActionRemoveTag = 4;
178
179 // MoveFile.Options
180 internal const int MsidbMoveFileOptionsMove = 1;
181
182 // ServiceInstall.Attributes
183 internal const int MsidbServiceInstallOwnProcess = 0x00000010;
184 internal const int MsidbServiceInstallShareProcess = 0x00000020;
185 internal const int MsidbServiceInstallInteractive = 0x00000100;
186 internal const int MsidbServiceInstallAutoStart = 0x00000002;
187 internal const int MsidbServiceInstallDemandStart = 0x00000003;
188 internal const int MsidbServiceInstallDisabled = 0x00000004;
189 internal const int MsidbServiceInstallErrorIgnore = 0x00000000;
190 internal const int MsidbServiceInstallErrorNormal = 0x00000001;
191 internal const int MsidbServiceInstallErrorCritical = 0x00000003;
192 internal const int MsidbServiceInstallErrorControlVital = 0x00008000;
193
194 // ServiceConfig.Event
195 internal const int MsidbServiceConfigEventInstall = 0x00000001;
196 internal const int MsidbServiceConfigEventUninstall = 0x00000002;
197 internal const int MsidbServiceConfigEventReinstall = 0x00000004;
198
199 // ServiceControl.Attributes
200 internal const int MsidbServiceControlEventStart = 0x00000001;
201 internal const int MsidbServiceControlEventStop = 0x00000002;
202 internal const int MsidbServiceControlEventDelete = 0x00000008;
203 internal const int MsidbServiceControlEventUninstallStart = 0x00000010;
204 internal const int MsidbServiceControlEventUninstallStop = 0x00000020;
205 internal const int MsidbServiceControlEventUninstallDelete = 0x00000080;
206
207 // TextStyle.StyleBits
208 internal const int MsidbTextStyleStyleBitsBold = 1;
209 internal const int MsidbTextStyleStyleBitsItalic = 2;
210 internal const int MsidbTextStyleStyleBitsUnderline = 4;
211 internal const int MsidbTextStyleStyleBitsStrike = 8;
212
213 // Upgrade.Attributes
214 internal const int MsidbUpgradeAttributesMigrateFeatures = 0x00000001;
215 internal const int MsidbUpgradeAttributesOnlyDetect = 0x00000002;
216 internal const int MsidbUpgradeAttributesIgnoreRemoveFailure = 0x00000004;
217 internal const int MsidbUpgradeAttributesVersionMinInclusive = 0x00000100;
218 internal const int MsidbUpgradeAttributesVersionMaxInclusive = 0x00000200;
219 internal const int MsidbUpgradeAttributesLanguagesExclusive = 0x00000400;
220
221 // Registry Hive Roots
222 internal const int MsidbRegistryRootClassesRoot = 0;
223 internal const int MsidbRegistryRootCurrentUser = 1;
224 internal const int MsidbRegistryRootLocalMachine = 2;
225 internal const int MsidbRegistryRootUsers = 3;
226
227 // Locator Types
228 internal const int MsidbLocatorTypeDirectory = 0;
229 internal const int MsidbLocatorTypeFileName = 1;
230 internal const int MsidbLocatorTypeRawValue = 2;
231 internal const int MsidbLocatorType64bit = 16;
232
233 internal const int MsidbClassAttributesRelativePath = 1;
234
235 // RemoveFile.InstallMode
236 internal const int MsidbRemoveFileInstallModeOnInstall = 0x00000001;
237 internal const int MsidbRemoveFileInstallModeOnRemove = 0x00000002;
238 internal const int MsidbRemoveFileInstallModeOnBoth = 0x00000003;
239
240 // ODBCDataSource.Registration
241 internal const int MsidbODBCDataSourceRegistrationPerMachine = 0;
242 internal const int MsidbODBCDataSourceRegistrationPerUser = 1;
243
244 // ModuleConfiguration.Format
245 internal const int MsidbModuleConfigurationFormatText = 0;
246 internal const int MsidbModuleConfigurationFormatKey = 1;
247 internal const int MsidbModuleConfigurationFormatInteger = 2;
248 internal const int MsidbModuleConfigurationFormatBitfield = 3;
249
250 // ModuleConfiguration.Attributes
251 internal const int MsidbMsmConfigurableOptionKeyNoOrphan = 1;
252 internal const int MsidbMsmConfigurableOptionNonNullable = 2;
253
254 // ' Windows API function ShowWindow constants - used in Shortcut table
255 internal const int SWSHOWNORMAL = 0x00000001;
256 internal const int SWSHOWMAXIMIZED = 0x00000003;
257 internal const int SWSHOWMINNOACTIVE = 0x00000007;
258
259 // NameToBit arrays
260 // UI elements
261 internal static readonly string[] CommonControlAttributes = { "Hidden", "Disabled", "Sunken", "Indirect", "Integer", "RightToLeft", "RightAligned", "LeftScroll" };
262 internal static readonly string[] TextControlAttributes = { "Transparent", "NoPrefix", "NoWrap", "FormatSize", "UserLanguage" };
263 internal static readonly string[] HyperlinkControlAttributes = { "Transparent" };
264 internal static readonly string[] EditControlAttributes = { "Multiline", null, null, null, null, "Password" };
265 internal static readonly string[] ProgressControlAttributes = { "ProgressBlocks" };
266 internal static readonly string[] VolumeControlAttributes = { "Removable", "Fixed", "Remote", "CDROM", "RAMDisk", "Floppy", "ShowRollbackCost" };
267 internal static readonly string[] ListboxControlAttributes = { "Sorted", null, null, null, "UserLanguage" };
268 internal static readonly string[] ListviewControlAttributes = { "Sorted", null, null, null, "FixedSize", "Icon16", "Icon32" };
269 internal static readonly string[] ComboboxControlAttributes = { "Sorted", "ComboList", null, null, "UserLanguage" };
270 internal static readonly string[] RadioControlAttributes = { "Image", "PushLike", "Bitmap", "Icon", "FixedSize", "Icon16", "Icon32", null, "HasBorder" };
271 internal static readonly string[] ButtonControlAttributes = { "Image", null, "Bitmap", "Icon", "FixedSize", "Icon16", "Icon32", "ElevationShield" };
272 internal static readonly string[] IconControlAttributes = { "Image", null, null, null, "FixedSize", "Icon16", "Icon32" };
273 internal static readonly string[] BitmapControlAttributes = { "Image", null, null, null, "FixedSize" };
274 internal static readonly string[] CheckboxControlAttributes = { null, "PushLike", "Bitmap", "Icon", "FixedSize", "Icon16", "Icon32" };
275
276 internal const int MsidbEmbeddedUI = 0x01;
277 internal const int MsidbEmbeddedHandlesBasic = 0x02;
278
279 internal const int INSTALLLOGMODE_FATALEXIT = 0x00001;
280 internal const int INSTALLLOGMODE_ERROR = 0x00002;
281 internal const int INSTALLLOGMODE_WARNING = 0x00004;
282 internal const int INSTALLLOGMODE_USER = 0x00008;
283 internal const int INSTALLLOGMODE_INFO = 0x00010;
284 internal const int INSTALLLOGMODE_FILESINUSE = 0x00020;
285 internal const int INSTALLLOGMODE_RESOLVESOURCE = 0x00040;
286 internal const int INSTALLLOGMODE_OUTOFDISKSPACE = 0x00080;
287 internal const int INSTALLLOGMODE_ACTIONSTART = 0x00100;
288 internal const int INSTALLLOGMODE_ACTIONDATA = 0x00200;
289 internal const int INSTALLLOGMODE_PROGRESS = 0x00400;
290 internal const int INSTALLLOGMODE_COMMONDATA = 0x00800;
291 internal const int INSTALLLOGMODE_INITIALIZE = 0x01000;
292 internal const int INSTALLLOGMODE_TERMINATE = 0x02000;
293 internal const int INSTALLLOGMODE_SHOWDIALOG = 0x04000;
294 internal const int INSTALLLOGMODE_RMFILESINUSE = 0x02000000;
295 internal const int INSTALLLOGMODE_INSTALLSTART = 0x04000000;
296 internal const int INSTALLLOGMODE_INSTALLEND = 0x08000000;
297
298 internal const int MSICONDITIONFALSE = 0; // The table is temporary.
299 internal const int MSICONDITIONTRUE = 1; // The table is persistent.
300 internal const int MSICONDITIONNONE = 2; // The table is unknown.
301 internal const int MSICONDITIONERROR = 3; // An invalid handle or invalid parameter was passed to the function.
302
303 internal const int MSIDBOPENREADONLY = 0;
304 internal const int MSIDBOPENTRANSACT = 1;
305 internal const int MSIDBOPENDIRECT = 2;
306 internal const int MSIDBOPENCREATE = 3;
307 internal const int MSIDBOPENCREATEDIRECT = 4;
308 internal const int MSIDBOPENPATCHFILE = 32;
309
310 internal const int MSIMODIFYSEEK = -1; // Refreshes the information in the supplied record without changing the position in the result set and without affecting subsequent fetch operations. The record may then be used for subsequent Update, Delete, and Refresh. All primary key columns of the table must be in the query and the record must have at least as many fields as the query. Seek cannot be used with multi-table queries. This mode cannot be used with a view containing joins. See also the remarks.
311 internal const int MSIMODIFYREFRESH = 0; // Refreshes the information in the record. Must first call MsiViewFetch with the same record. Fails for a deleted row. Works with read-write and read-only records.
312 internal const int MSIMODIFYINSERT = 1; // Inserts a record. Fails if a row with the same primary keys exists. Fails with a read-only database. This mode cannot be used with a view containing joins.
313 internal const int MSIMODIFYUPDATE = 2; // Updates an existing record. Nonprimary keys only. Must first call MsiViewFetch. Fails with a deleted record. Works only with read-write records.
314 internal const int MSIMODIFYASSIGN = 3; // Writes current data in the cursor to a table row. Updates record if the primary keys match an existing row and inserts if they do not match. Fails with a read-only database. This mode cannot be used with a view containing joins.
315 internal const int MSIMODIFYREPLACE = 4; // Updates or deletes and inserts a record into a table. Must first call MsiViewFetch with the same record. Updates record if the primary keys are unchanged. Deletes old row and inserts new if primary keys have changed. Fails with a read-only database. This mode cannot be used with a view containing joins.
316 internal const int MSIMODIFYMERGE = 5; // Inserts or validates a record in a table. Inserts if primary keys do not match any row and validates if there is a match. Fails if the record does not match the data in the table. Fails if there is a record with a duplicate key that is not identical. Works only with read-write records. This mode cannot be used with a view containing joins.
317 internal const int MSIMODIFYDELETE = 6; // Remove a row from the table. You must first call the MsiViewFetch function with the same record. Fails if the row has been deleted. Works only with read-write records. This mode cannot be used with a view containing joins.
318 internal const int MSIMODIFYINSERTTEMPORARY = 7; // Inserts a temporary record. The information is not persistent. Fails if a row with the same primary key exists. Works only with read-write records. This mode cannot be used with a view containing joins.
319 internal const int MSIMODIFYVALIDATE = 8; // Validates a record. Does not validate across joins. You must first call the MsiViewFetch function with the same record. Obtain validation errors with MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
320 internal const int MSIMODIFYVALIDATENEW = 9; // Validate a new record. Does not validate across joins. Checks for duplicate keys. Obtain validation errors by calling MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
321 internal const int MSIMODIFYVALIDATEFIELD = 10; // Validates fields of a fetched or new record. Can validate one or more fields of an incomplete record. Obtain validation errors by calling MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
322 internal const int MSIMODIFYVALIDATEDELETE = 11; // Validates a record that will be deleted later. You must first call MsiViewFetch. Fails if another row refers to the primary keys of this row. Validation does not check for the existence of the primary keys of this row in properties or strings. Does not check if a column is a foreign key to multiple tables. Obtain validation errors by calling MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
323
324 internal const uint VTI2 = 2;
325 internal const uint VTI4 = 3;
326 internal const uint VTLPWSTR = 30;
327 internal const uint VTFILETIME = 64;
328
329 internal const int MSICOLINFONAMES = 0; // return column names
330 internal const int MSICOLINFOTYPES = 1; // return column definitions, datatype code followed by width
331
332 /// <summary>
333 /// Protect the constructor.
334 /// </summary>
335 private MsiInterop()
336 {
337 }
338
339 /// <summary>
340 /// PInvoke of MsiCloseHandle.
341 /// </summary>
342 /// <param name="database">Handle to a database.</param>
343 /// <returns>Error code.</returns>
344 [DllImport("msi.dll", EntryPoint = "MsiCloseHandle", CharSet = CharSet.Unicode, ExactSpelling = true)]
345 internal static extern int MsiCloseHandle(uint database);
346
347 /// <summary>
348 /// PInvoke of MsiCreateRecord
349 /// </summary>
350 /// <param name="parameters">Count of columns in the record.</param>
351 /// <returns>Handle referencing the record.</returns>
352 [DllImport("msi.dll", EntryPoint = "MsiCreateRecord", CharSet = CharSet.Unicode, ExactSpelling = true)]
353 internal static extern uint MsiCreateRecord(int parameters);
354
355 /// <summary>
356 /// Creates summary information of an existing transform to include validation and error conditions.
357 /// </summary>
358 /// <param name="database">The handle to the database that contains the new database summary information.</param>
359 /// <param name="referenceDatabase">The handle to the database that contains the original summary information.</param>
360 /// <param name="transformFile">The name of the transform to which the summary information is added.</param>
361 /// <param name="errorConditions">The error conditions that should be suppressed when the transform is applied.</param>
362 /// <param name="validations">Specifies the properties to be validated to verify that the transform can be applied to the database.</param>
363 /// <returns>Error code.</returns>
364 [DllImport("msi.dll", EntryPoint = "MsiCreateTransformSummaryInfoW", CharSet = CharSet.Unicode, ExactSpelling = true)]
365 internal static extern int MsiCreateTransformSummaryInfo(uint database, uint referenceDatabase, string transformFile, TransformErrorConditions errorConditions, TransformValidations validations);
366
367 /// <summary>
368 /// Applies a transform to a database.
369 /// </summary>
370 /// <param name="database">Handle to the database obtained from MsiOpenDatabase to transform.</param>
371 /// <param name="transformFile">Specifies the name of the transform file to apply.</param>
372 /// <param name="errorConditions">Error conditions that should be suppressed.</param>
373 /// <returns>Error code.</returns>
374 [DllImport("msi.dll", EntryPoint = "MsiDatabaseApplyTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)]
375 internal static extern int MsiDatabaseApplyTransform(uint database, string transformFile, TransformErrorConditions errorConditions);
376
377 /// <summary>
378 /// PInvoke of MsiDatabaseCommit.
379 /// </summary>
380 /// <param name="database">Handle to a databse.</param>
381 /// <returns>Error code.</returns>
382 [DllImport("msi.dll", EntryPoint = "MsiDatabaseCommit", CharSet = CharSet.Unicode, ExactSpelling = true)]
383 internal static extern int MsiDatabaseCommit(uint database);
384
385 /// <summary>
386 /// PInvoke of MsiDatabaseExportW.
387 /// </summary>
388 /// <param name="database">Handle to a database.</param>
389 /// <param name="tableName">Table name.</param>
390 /// <param name="folderPath">Folder path.</param>
391 /// <param name="fileName">File name.</param>
392 /// <returns>Error code.</returns>
393 [DllImport("msi.dll", EntryPoint = "MsiDatabaseExportW", CharSet = CharSet.Unicode, ExactSpelling = true)]
394 internal static extern int MsiDatabaseExport(uint database, string tableName, string folderPath, string fileName);
395
396 /// <summary>
397 /// Generates a transform file of differences between two databases.
398 /// </summary>
399 /// <param name="database">Handle to the database obtained from MsiOpenDatabase that includes the changes.</param>
400 /// <param name="databaseReference">Handle to the database obtained from MsiOpenDatabase that does not include the changes.</param>
401 /// <param name="transformFile">A null-terminated string that specifies the name of the transform file being generated.
402 /// This parameter can be null. If szTransformFile is null, you can use MsiDatabaseGenerateTransform to test whether two
403 /// databases are identical without creating a transform. If the databases are identical, the function returns ERROR_NO_DATA.
404 /// If the databases are different the function returns NOERROR.</param>
405 /// <param name="reserved1">This is a reserved argument and must be set to 0.</param>
406 /// <param name="reserved2">This is a reserved argument and must be set to 0.</param>
407 /// <returns>Error code.</returns>
408 [DllImport("msi.dll", EntryPoint = "MsiDatabaseGenerateTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)]
409 internal static extern int MsiDatabaseGenerateTransform(uint database, uint databaseReference, string transformFile, int reserved1, int reserved2);
410
411 /// <summary>
412 /// PInvoke of MsiDatabaseImportW.
413 /// </summary>
414 /// <param name="database">Handle to a database.</param>
415 /// <param name="folderPath">Folder path.</param>
416 /// <param name="fileName">File name.</param>
417 /// <returns>Error code.</returns>
418 [DllImport("msi.dll", EntryPoint = "MsiDatabaseImportW", CharSet = CharSet.Unicode, ExactSpelling = true)]
419 internal static extern int MsiDatabaseImport(uint database, string folderPath, string fileName);
420
421 /// <summary>
422 /// PInvoke of MsiDatabaseMergeW.
423 /// </summary>
424 /// <param name="database">The handle to the database obtained from MsiOpenDatabase.</param>
425 /// <param name="databaseMerge">The handle to the database obtained from MsiOpenDatabase to merge into the base database.</param>
426 /// <param name="tableName">The name of the table to receive merge conflict information.</param>
427 /// <returns>Error code.</returns>
428 [DllImport("msi.dll", EntryPoint = "MsiDatabaseMergeW", CharSet = CharSet.Unicode, ExactSpelling = true)]
429 internal static extern int MsiDatabaseMerge(uint database, uint databaseMerge, string tableName);
430
431 /// <summary>
432 /// PInvoke of MsiDatabaseOpenViewW.
433 /// </summary>
434 /// <param name="database">Handle to a database.</param>
435 /// <param name="query">SQL query.</param>
436 /// <param name="view">View handle.</param>
437 /// <returns>Error code.</returns>
438 [DllImport("msi.dll", EntryPoint = "MsiDatabaseOpenViewW", CharSet = CharSet.Unicode, ExactSpelling = true)]
439 internal static extern int MsiDatabaseOpenView(uint database, string query, out uint view);
440
441 /// <summary>
442 /// PInvoke of MsiGetFileHashW.
443 /// </summary>
444 /// <param name="filePath">File path.</param>
445 /// <param name="options">Hash options (must be 0).</param>
446 /// <param name="hash">Buffer to recieve hash.</param>
447 /// <returns>Error code.</returns>
448 [DllImport("msi.dll", EntryPoint = "MsiGetFileHashW", CharSet = CharSet.Unicode, ExactSpelling = true)]
449 internal static extern int MsiGetFileHash(string filePath, uint options, MSIFILEHASHINFO hash);
450
451 /// <summary>
452 /// PInvoke of MsiGetFileVersionW.
453 /// </summary>
454 /// <param name="filePath">File path.</param>
455 /// <param name="versionBuf">Buffer to receive version info.</param>
456 /// <param name="versionBufSize">Size of version buffer.</param>
457 /// <param name="langBuf">Buffer to recieve lang info.</param>
458 /// <param name="langBufSize">Size of lang buffer.</param>
459 /// <returns>Error code.</returns>
460 [DllImport("msi.dll", EntryPoint = "MsiGetFileVersionW", CharSet = CharSet.Unicode, ExactSpelling = true)]
461 internal static extern int MsiGetFileVersion(string filePath, StringBuilder versionBuf, ref int versionBufSize, StringBuilder langBuf, ref int langBufSize);
462
463 /// <summary>
464 /// PInvoke of MsiGetLastErrorRecord.
465 /// </summary>
466 /// <returns>Handle to error record if one exists.</returns>
467 [DllImport("msi.dll", EntryPoint = "MsiGetLastErrorRecord", CharSet = CharSet.Unicode, ExactSpelling = true)]
468 internal static extern uint MsiGetLastErrorRecord();
469
470 /// <summary>
471 /// PInvoke of MsiDatabaseGetPrimaryKeysW.
472 /// </summary>
473 /// <param name="database">Handle to a database.</param>
474 /// <param name="tableName">Table name.</param>
475 /// <param name="record">Handle to receive resulting record.</param>
476 /// <returns>Error code.</returns>
477 [DllImport("msi.dll", EntryPoint = "MsiDatabaseGetPrimaryKeysW", CharSet = CharSet.Unicode, ExactSpelling = true)]
478 internal static extern int MsiDatabaseGetPrimaryKeys(uint database, string tableName, out uint record);
479
480 /// <summary>
481 /// PInvoke of MsiDoActionW.
482 /// </summary>
483 /// <param name="product">Handle to the installation provided to a DLL custom action or
484 /// obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.</param>
485 /// <param name="action">Specifies the action to execute.</param>
486 /// <returns>Error code.</returns>
487 [DllImport("msi.dll", EntryPoint = "MsiDoActionW", CharSet = CharSet.Unicode, ExactSpelling = true)]
488 internal static extern int MsiDoAction(uint product, string action);
489
490 /// <summary>
491 /// PInvoke of MsiGetSummaryInformationW. Can use either database handle or database path as input.
492 /// </summary>
493 /// <param name="database">Handle to a database.</param>
494 /// <param name="databasePath">Path to a database.</param>
495 /// <param name="updateCount">Max number of updated values.</param>
496 /// <param name="summaryInfo">Handle to summary information.</param>
497 /// <returns>Error code.</returns>
498 [DllImport("msi.dll", EntryPoint = "MsiGetSummaryInformationW", CharSet = CharSet.Unicode, ExactSpelling = true)]
499 internal static extern int MsiGetSummaryInformation(uint database, string databasePath, uint updateCount, ref uint summaryInfo);
500
501 /// <summary>
502 /// PInvoke of MsiDatabaseIsTablePersitentW.
503 /// </summary>
504 /// <param name="database">Handle to a database.</param>
505 /// <param name="tableName">Table name.</param>
506 /// <returns>MSICONDITION</returns>
507 [DllImport("msi.dll", EntryPoint = "MsiDatabaseIsTablePersistentW", CharSet = CharSet.Unicode, ExactSpelling = true)]
508 internal static extern int MsiDatabaseIsTablePersistent(uint database, string tableName);
509
510 /// <summary>
511 /// PInvoke of MsiOpenDatabaseW.
512 /// </summary>
513 /// <param name="databasePath">Path to database.</param>
514 /// <param name="persist">Persist mode.</param>
515 /// <param name="database">Handle to database.</param>
516 /// <returns>Error code.</returns>
517 [DllImport("msi.dll", EntryPoint = "MsiOpenDatabaseW", CharSet = CharSet.Unicode, ExactSpelling = true)]
518 internal static extern int MsiOpenDatabase(string databasePath, IntPtr persist, out uint database);
519
520 /// <summary>
521 /// PInvoke of MsiOpenPackageW.
522 /// </summary>
523 /// <param name="packagePath">The path to the package.</param>
524 /// <param name="product">A pointer to a variable that receives the product handle.</param>
525 /// <returns>Error code.</returns>
526 [DllImport("msi.dll", EntryPoint = "MsiOpenPackageW", CharSet = CharSet.Unicode, ExactSpelling = true)]
527 internal static extern int MsiOpenPackage(string packagePath, out uint product);
528
529 /// <summary>
530 /// PInvoke of MsiRecordIsNull.
531 /// </summary>
532 /// <param name="record">MSI Record handle.</param>
533 /// <param name="field">Index of field to check for null value.</param>
534 /// <returns>true if the field is null, false if not, and an error code for any error.</returns>
535 [DllImport("msi.dll", EntryPoint = "MsiRecordIsNull", CharSet = CharSet.Unicode, ExactSpelling = true)]
536 internal static extern int MsiRecordIsNull(uint record, int field);
537
538 /// <summary>
539 /// PInvoke of MsiRecordGetInteger.
540 /// </summary>
541 /// <param name="record">MSI Record handle.</param>
542 /// <param name="field">Index of field to retrieve integer from.</param>
543 /// <returns>Integer value.</returns>
544 [DllImport("msi.dll", EntryPoint = "MsiRecordGetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)]
545 internal static extern int MsiRecordGetInteger(uint record, int field);
546
547 /// <summary>
548 /// PInvoke of MsiRectordSetInteger.
549 /// </summary>
550 /// <param name="record">MSI Record handle.</param>
551 /// <param name="field">Index of field to set integer value in.</param>
552 /// <param name="value">Value to set field to.</param>
553 /// <returns>Error code.</returns>
554 [DllImport("msi.dll", EntryPoint = "MsiRecordSetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)]
555 internal static extern int MsiRecordSetInteger(uint record, int field, int value);
556
557 /// <summary>
558 /// PInvoke of MsiRecordGetStringW.
559 /// </summary>
560 /// <param name="record">MSI Record handle.</param>
561 /// <param name="field">Index of field to get string value from.</param>
562 /// <param name="valueBuf">Buffer to recieve value.</param>
563 /// <param name="valueBufSize">Size of buffer.</param>
564 /// <returns>Error code.</returns>
565 [DllImport("msi.dll", EntryPoint = "MsiRecordGetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)]
566 internal static extern int MsiRecordGetString(uint record, int field, StringBuilder valueBuf, ref int valueBufSize);
567
568 /// <summary>
569 /// PInvoke of MsiRecordSetStringW.
570 /// </summary>
571 /// <param name="record">MSI Record handle.</param>
572 /// <param name="field">Index of field to set string value in.</param>
573 /// <param name="value">String value.</param>
574 /// <returns>Error code.</returns>
575 [DllImport("msi.dll", EntryPoint = "MsiRecordSetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)]
576 internal static extern int MsiRecordSetString(uint record, int field, string value);
577
578 /// <summary>
579 /// PInvoke of MsiRecordSetStreamW.
580 /// </summary>
581 /// <param name="record">MSI Record handle.</param>
582 /// <param name="field">Index of field to set stream value in.</param>
583 /// <param name="filePath">Path to file to set stream value to.</param>
584 /// <returns>Error code.</returns>
585 [DllImport("msi.dll", EntryPoint = "MsiRecordSetStreamW", CharSet = CharSet.Unicode, ExactSpelling = true)]
586 internal static extern int MsiRecordSetStream(uint record, int field, string filePath);
587
588 /// <summary>
589 /// PInvoke of MsiRecordReadStreamW.
590 /// </summary>
591 /// <param name="record">MSI Record handle.</param>
592 /// <param name="field">Index of field to read stream from.</param>
593 /// <param name="dataBuf">Data buffer to recieve stream value.</param>
594 /// <param name="dataBufSize">Size of data buffer.</param>
595 /// <returns>Error code.</returns>
596 [DllImport("msi.dll", EntryPoint = "MsiRecordReadStream", CharSet = CharSet.Unicode, ExactSpelling = true)]
597 internal static extern int MsiRecordReadStream(uint record, int field, byte[] dataBuf, ref int dataBufSize);
598
599 /// <summary>
600 /// PInvoke of MsiRecordGetFieldCount.
601 /// </summary>
602 /// <param name="record">MSI Record handle.</param>
603 /// <returns>Count of fields in the record.</returns>
604 [DllImport("msi.dll", EntryPoint = "MsiRecordGetFieldCount", CharSet = CharSet.Unicode, ExactSpelling = true)]
605 internal static extern int MsiRecordGetFieldCount(uint record);
606
607 /// <summary>
608 /// PInvoke of MsiSetExternalUIW.
609 /// </summary>
610 /// <param name="installUIHandler">Specifies a callback function that conforms to the INSTALLUI_HANDLER specification.</param>
611 /// <param name="installLogMode">Specifies which messages to handle using the external message handler. If the external
612 /// handler returns a non-zero result, then that message will not be sent to the UI, instead the message will be logged
613 /// if logging has been enabled.</param>
614 /// <param name="context">Pointer to an application context that is passed to the callback function.
615 /// This parameter can be used for error checking.</param>
616 /// <returns>The return value is the previously set external handler, or zero (0) if there was no previously set handler.</returns>
617 [DllImport("msi.dll", EntryPoint = "MsiSetExternalUIW", CharSet = CharSet.Unicode, ExactSpelling = true)]
618 internal static extern InstallUIHandler MsiSetExternalUI(InstallUIHandler installUIHandler, int installLogMode, IntPtr context);
619
620 /// <summary>
621 /// PInvoke of MsiSetInternalUI.
622 /// </summary>
623 /// <param name="uiLevel">Specifies the level of complexity of the user interface.</param>
624 /// <param name="hwnd">Pointer to a window. This window becomes the owner of any user interface created.
625 /// A pointer to the previous owner of the user interface is returned.
626 /// If this parameter is null, the owner of the user interface does not change.</param>
627 /// <returns>The previous user interface level is returned. If an invalid dwUILevel is passed, then INSTALLUILEVEL_NOCHANGE is returned.</returns>
628 [DllImport("msi.dll", EntryPoint = "MsiSetInternalUI", CharSet = CharSet.Unicode, ExactSpelling = true)]
629 internal static extern int MsiSetInternalUI(int uiLevel, ref IntPtr hwnd);
630
631 /// <summary>
632 /// PInvoke of MsiSummaryInfoGetPropertyW.
633 /// </summary>
634 /// <param name="summaryInfo">Handle to summary info.</param>
635 /// <param name="property">Property to get value from.</param>
636 /// <param name="dataType">Data type of property.</param>
637 /// <param name="integerValue">Integer to receive integer value.</param>
638 /// <param name="fileTimeValue">File time to receive file time value.</param>
639 /// <param name="stringValueBuf">String buffer to receive string value.</param>
640 /// <param name="stringValueBufSize">Size of string buffer.</param>
641 /// <returns>Error code.</returns>
642 [DllImport("msi.dll", EntryPoint = "MsiSummaryInfoGetPropertyW", CharSet = CharSet.Unicode, ExactSpelling = true)]
643 internal static extern int MsiSummaryInfoGetProperty(uint summaryInfo, int property, out uint dataType, out int integerValue, ref FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize);
644
645 /// <summary>
646 /// PInvoke of MsiViewGetColumnInfo.
647 /// </summary>
648 /// <param name="view">Handle to view.</param>
649 /// <param name="columnInfo">Column info.</param>
650 /// <param name="record">Handle for returned record.</param>
651 /// <returns>Error code.</returns>
652 [DllImport("msi.dll", EntryPoint = "MsiViewGetColumnInfo", CharSet = CharSet.Unicode, ExactSpelling = true)]
653 internal static extern int MsiViewGetColumnInfo(uint view, int columnInfo, out uint record);
654
655 /// <summary>
656 /// PInvoke of MsiViewExecute.
657 /// </summary>
658 /// <param name="view">Handle of view to execute.</param>
659 /// <param name="record">Handle to a record that supplies the parameters for the view.</param>
660 /// <returns>Error code.</returns>
661 [DllImport("msi.dll", EntryPoint = "MsiViewExecute", CharSet = CharSet.Unicode, ExactSpelling = true)]
662 internal static extern int MsiViewExecute(uint view, uint record);
663
664 /// <summary>
665 /// PInvoke of MsiViewFetch.
666 /// </summary>
667 /// <param name="view">Handle of view to fetch a row from.</param>
668 /// <param name="record">Handle to receive record info.</param>
669 /// <returns>Error code.</returns>
670 [DllImport("msi.dll", EntryPoint = "MsiViewFetch", CharSet = CharSet.Unicode, ExactSpelling = true)]
671 internal static extern int MsiViewFetch(uint view, out uint record);
672
673 /// <summary>
674 /// PInvoke of MsiViewModify.
675 /// </summary>
676 /// <param name="view">Handle of view to modify.</param>
677 /// <param name="modifyMode">Modify mode.</param>
678 /// <param name="record">Handle of record.</param>
679 /// <returns>Error code.</returns>
680 [DllImport("msi.dll", EntryPoint = "MsiViewModify", CharSet = CharSet.Unicode, ExactSpelling = true)]
681 internal static extern int MsiViewModify(uint view, int modifyMode, uint record);
682
683 /// <summary>
684 /// contains the file hash information returned by MsiGetFileHash and used in the MsiFileHash table.
685 /// </summary>
686 [StructLayout(LayoutKind.Explicit)]
687 internal class MSIFILEHASHINFO
688 {
689 [FieldOffset(0)] internal uint FileHashInfoSize;
690 [FieldOffset(4)] internal int Data0;
691 [FieldOffset(8)] internal int Data1;
692 [FieldOffset(12)]internal int Data2;
693 [FieldOffset(16)]internal int Data3;
694 }
695 }
696}
697#endif \ No newline at end of file
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/MsiException.cs b/src/WixToolset.Core.WindowsInstaller/Msi/MsiException.cs
index b33bf27a..4e324a60 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/MsiException.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/MsiException.cs
@@ -1,10 +1,9 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.ComponentModel; 6 using System.ComponentModel;
7 using WixToolset.Core.Native;
8 7
9 /// <summary> 8 /// <summary>
10 /// Exception that wraps MsiGetLastError(). 9 /// Exception that wraps MsiGetLastError().
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/MsiHandle.cs b/src/WixToolset.Core.WindowsInstaller/Msi/MsiHandle.cs
index 6d2dc984..9006180b 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/MsiHandle.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/MsiHandle.cs
@@ -1,12 +1,13 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.ComponentModel; 6 using System.ComponentModel;
7#if !DEBUG
7 using System.Diagnostics; 8 using System.Diagnostics;
9#endif
8 using System.Threading; 10 using System.Threading;
9 using WixToolset.Core.Native;
10 11
11 /// <summary> 12 /// <summary>
12 /// Wrapper class for MSI handle. 13 /// Wrapper class for MSI handle.
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/MsiInterop.cs b/src/WixToolset.Core.WindowsInstaller/Msi/MsiInterop.cs
new file mode 100644
index 00000000..8d195033
--- /dev/null
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/MsiInterop.cs
@@ -0,0 +1,571 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.WindowsInstaller.Msi
4{
5 using System;
6 using System.Text;
7 using System.Runtime.InteropServices;
8 using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
9 using WixToolset.Core.Native;
10
11 /// <summary>
12 /// A callback function that the installer calls for progress notification and error messages.
13 /// </summary>
14 /// <param name="context">Pointer to an application context.
15 /// This parameter can be used for error checking.</param>
16 /// <param name="messageType">Specifies a combination of one message box style,
17 /// one message box icon type, one default button, and one installation message type.</param>
18 /// <param name="message">Specifies the message text.</param>
19 /// <returns>-1 for an error, 0 if no action was taken, 1 if OK, 3 to abort.</returns>
20 public delegate int InstallUIHandler(IntPtr context, uint messageType, [MarshalAs(UnmanagedType.LPWStr)] string message);
21
22 /// <summary>
23 /// Enum of predefined persist modes used when opening a database.
24 /// </summary>
25 public enum OpenDatabase
26 {
27 /// <summary>
28 /// Open a database read-only, no persistent changes.
29 /// </summary>
30 ReadOnly = 0,
31
32 /// <summary>
33 /// Open a database read/write in transaction mode.
34 /// </summary>
35 Transact = 1,
36
37 /// <summary>
38 /// Open a database direct read/write without transaction.
39 /// </summary>
40 Direct = 2,
41
42 /// <summary>
43 /// Create a new database, transact mode read/write.
44 /// </summary>
45 Create = 3,
46
47 /// <summary>
48 /// Create a new database, direct mode read/write.
49 /// </summary>
50 CreateDirect = 4,
51
52 /// <summary>
53 /// Indicates a patch file is being opened.
54 /// </summary>
55 OpenPatchFile = 32
56 }
57
58 /// <summary>
59 /// The errors to suppress when applying a transform.
60 /// </summary>
61 [Flags]
62 public enum TransformErrorConditions
63 {
64 /// <summary>
65 /// None of the following conditions.
66 /// </summary>
67 None = 0x0,
68
69 /// <summary>
70 /// Suppress error when adding a row that exists.
71 /// </summary>
72 AddExistingRow = 0x1,
73
74 /// <summary>
75 /// Suppress error when deleting a row that does not exist.
76 /// </summary>
77 DeleteMissingRow = 0x2,
78
79 /// <summary>
80 /// Suppress error when adding a table that exists.
81 /// </summary>
82 AddExistingTable = 0x4,
83
84 /// <summary>
85 /// Suppress error when deleting a table that does not exist.
86 /// </summary>
87 DeleteMissingTable = 0x8,
88
89 /// <summary>
90 /// Suppress error when updating a row that does not exist.
91 /// </summary>
92 UpdateMissingRow = 0x10,
93
94 /// <summary>
95 /// Suppress error when transform and database code pages do not match, and their code pages are neutral.
96 /// </summary>
97 ChangeCodepage = 0x20,
98
99 /// <summary>
100 /// Create the temporary _TransformView table when applying a transform.
101 /// </summary>
102 ViewTransform = 0x100,
103
104 /// <summary>
105 /// Suppress all errors but the option to create the temporary _TransformView table.
106 /// </summary>
107 All = 0x3F
108 }
109
110 /// <summary>
111 /// The validation to run while applying a transform.
112 /// </summary>
113 [Flags]
114 public enum TransformValidations
115 {
116 /// <summary>
117 /// Do not validate properties.
118 /// </summary>
119 None = 0x0,
120
121 /// <summary>
122 /// Default language must match base database.
123 /// </summary>
124 Language = 0x1,
125
126 /// <summary>
127 /// Product must match base database.
128 /// </summary>
129 Product = 0x2,
130
131 /// <summary>
132 /// Check major version only.
133 /// </summary>
134 MajorVersion = 0x8,
135
136 /// <summary>
137 /// Check major and minor versions only.
138 /// </summary>
139 MinorVersion = 0x10,
140
141 /// <summary>
142 /// Check major, minor, and update versions.
143 /// </summary>
144 UpdateVersion = 0x20,
145
146 /// <summary>
147 /// Installed version &lt; base version.
148 /// </summary>
149 NewLessBaseVersion = 0x40,
150
151 /// <summary>
152 /// Installed version &lt;= base version.
153 /// </summary>
154 NewLessEqualBaseVersion = 0x80,
155
156 /// <summary>
157 /// Installed version = base version.
158 /// </summary>
159 NewEqualBaseVersion = 0x100,
160
161 /// <summary>
162 /// Installed version &gt;= base version.
163 /// </summary>
164 NewGreaterEqualBaseVersion = 0x200,
165
166 /// <summary>
167 /// Installed version &gt; base version.
168 /// </summary>
169 NewGreaterBaseVersion = 0x400,
170
171 /// <summary>
172 /// UpgradeCode must match base database.
173 /// </summary>
174 UpgradeCode = 0x800
175 }
176
177 /// <summary>
178 /// Class exposing static functions and structs from MSI API.
179 /// </summary>
180 public sealed class MsiInterop
181 {
182 // Patching constants
183 public const int MsiMaxStreamNameLength = 62; // http://msdn2.microsoft.com/library/aa370551.aspx
184
185 public const int MSICONDITIONFALSE = 0; // The table is temporary.
186 public const int MSICONDITIONTRUE = 1; // The table is persistent.
187 public const int MSICONDITIONNONE = 2; // The table is unknown.
188 public const int MSICONDITIONERROR = 3; // An invalid handle or invalid parameter was passed to the function.
189 /*
190 public const int MSIDBOPENREADONLY = 0;
191 public const int MSIDBOPENTRANSACT = 1;
192 public const int MSIDBOPENDIRECT = 2;
193 public const int MSIDBOPENCREATE = 3;
194 public const int MSIDBOPENCREATEDIRECT = 4;
195 public const int MSIDBOPENPATCHFILE = 32;
196
197 public const int MSIMODIFYSEEK = -1; // Refreshes the information in the supplied record without changing the position in the result set and without affecting subsequent fetch operations. The record may then be used for subsequent Update, Delete, and Refresh. All primary key columns of the table must be in the query and the record must have at least as many fields as the query. Seek cannot be used with multi-table queries. This mode cannot be used with a view containing joins. See also the remarks.
198 public const int MSIMODIFYREFRESH = 0; // Refreshes the information in the record. Must first call MsiViewFetch with the same record. Fails for a deleted row. Works with read-write and read-only records.
199 public const int MSIMODIFYINSERT = 1; // Inserts a record. Fails if a row with the same primary keys exists. Fails with a read-only database. This mode cannot be used with a view containing joins.
200 public const int MSIMODIFYUPDATE = 2; // Updates an existing record. Nonprimary keys only. Must first call MsiViewFetch. Fails with a deleted record. Works only with read-write records.
201 public const int MSIMODIFYASSIGN = 3; // Writes current data in the cursor to a table row. Updates record if the primary keys match an existing row and inserts if they do not match. Fails with a read-only database. This mode cannot be used with a view containing joins.
202 public const int MSIMODIFYREPLACE = 4; // Updates or deletes and inserts a record into a table. Must first call MsiViewFetch with the same record. Updates record if the primary keys are unchanged. Deletes old row and inserts new if primary keys have changed. Fails with a read-only database. This mode cannot be used with a view containing joins.
203 public const int MSIMODIFYMERGE = 5; // Inserts or validates a record in a table. Inserts if primary keys do not match any row and validates if there is a match. Fails if the record does not match the data in the table. Fails if there is a record with a duplicate key that is not identical. Works only with read-write records. This mode cannot be used with a view containing joins.
204 public const int MSIMODIFYDELETE = 6; // Remove a row from the table. You must first call the MsiViewFetch function with the same record. Fails if the row has been deleted. Works only with read-write records. This mode cannot be used with a view containing joins.
205 public const int MSIMODIFYINSERTTEMPORARY = 7; // Inserts a temporary record. The information is not persistent. Fails if a row with the same primary key exists. Works only with read-write records. This mode cannot be used with a view containing joins.
206 public const int MSIMODIFYVALIDATE = 8; // Validates a record. Does not validate across joins. You must first call the MsiViewFetch function with the same record. Obtain validation errors with MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
207 public const int MSIMODIFYVALIDATENEW = 9; // Validate a new record. Does not validate across joins. Checks for duplicate keys. Obtain validation errors by calling MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
208 public const int MSIMODIFYVALIDATEFIELD = 10; // Validates fields of a fetched or new record. Can validate one or more fields of an incomplete record. Obtain validation errors by calling MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
209 public const int MSIMODIFYVALIDATEDELETE = 11; // Validates a record that will be deleted later. You must first call MsiViewFetch. Fails if another row refers to the primary keys of this row. Validation does not check for the existence of the primary keys of this row in properties or strings. Does not check if a column is a foreign key to multiple tables. Obtain validation errors by calling MsiViewGetError. Works with read-write and read-only records. This mode cannot be used with a view containing joins.
210
211 public const uint VTI2 = 2;
212 public const uint VTI4 = 3;
213 public const uint VTLPWSTR = 30;
214 public const uint VTFILETIME = 64;
215 */
216
217 public const int MSICOLINFONAMES = 0; // return column names
218 public const int MSICOLINFOTYPES = 1; // return column definitions, datatype code followed by width
219
220 /// <summary>
221 /// Protect the constructor.
222 /// </summary>
223 private MsiInterop()
224 {
225 }
226
227 /// <summary>
228 /// PInvoke of MsiCloseHandle.
229 /// </summary>
230 /// <param name="database">Handle to a database.</param>
231 /// <returns>Error code.</returns>
232 [DllImport("msi.dll", EntryPoint = "MsiCloseHandle", CharSet = CharSet.Unicode, ExactSpelling = true)]
233 public static extern int MsiCloseHandle(uint database);
234
235 /// <summary>
236 /// PInvoke of MsiCreateRecord
237 /// </summary>
238 /// <param name="parameters">Count of columns in the record.</param>
239 /// <returns>Handle referencing the record.</returns>
240 [DllImport("msi.dll", EntryPoint = "MsiCreateRecord", CharSet = CharSet.Unicode, ExactSpelling = true)]
241 public static extern uint MsiCreateRecord(int parameters);
242
243 /// <summary>
244 /// Creates summary information of an existing transform to include validation and error conditions.
245 /// </summary>
246 /// <param name="database">The handle to the database that contains the new database summary information.</param>
247 /// <param name="referenceDatabase">The handle to the database that contains the original summary information.</param>
248 /// <param name="transformFile">The name of the transform to which the summary information is added.</param>
249 /// <param name="errorConditions">The error conditions that should be suppressed when the transform is applied.</param>
250 /// <param name="validations">Specifies the properties to be validated to verify that the transform can be applied to the database.</param>
251 /// <returns>Error code.</returns>
252 [DllImport("msi.dll", EntryPoint = "MsiCreateTransformSummaryInfoW", CharSet = CharSet.Unicode, ExactSpelling = true)]
253 public static extern int MsiCreateTransformSummaryInfo(uint database, uint referenceDatabase, string transformFile, TransformErrorConditions errorConditions, TransformValidations validations);
254
255 /// <summary>
256 /// Applies a transform to a database.
257 /// </summary>
258 /// <param name="database">Handle to the database obtained from MsiOpenDatabase to transform.</param>
259 /// <param name="transformFile">Specifies the name of the transform file to apply.</param>
260 /// <param name="errorConditions">Error conditions that should be suppressed.</param>
261 /// <returns>Error code.</returns>
262 [DllImport("msi.dll", EntryPoint = "MsiDatabaseApplyTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)]
263 public static extern int MsiDatabaseApplyTransform(uint database, string transformFile, TransformErrorConditions errorConditions);
264
265 /// <summary>
266 /// PInvoke of MsiDatabaseCommit.
267 /// </summary>
268 /// <param name="database">Handle to a databse.</param>
269 /// <returns>Error code.</returns>
270 [DllImport("msi.dll", EntryPoint = "MsiDatabaseCommit", CharSet = CharSet.Unicode, ExactSpelling = true)]
271 public static extern int MsiDatabaseCommit(uint database);
272
273 /// <summary>
274 /// PInvoke of MsiDatabaseExportW.
275 /// </summary>
276 /// <param name="database">Handle to a database.</param>
277 /// <param name="tableName">Table name.</param>
278 /// <param name="folderPath">Folder path.</param>
279 /// <param name="fileName">File name.</param>
280 /// <returns>Error code.</returns>
281 [DllImport("msi.dll", EntryPoint = "MsiDatabaseExportW", CharSet = CharSet.Unicode, ExactSpelling = true)]
282 public static extern int MsiDatabaseExport(uint database, string tableName, string folderPath, string fileName);
283
284 /// <summary>
285 /// Generates a transform file of differences between two databases.
286 /// </summary>
287 /// <param name="database">Handle to the database obtained from MsiOpenDatabase that includes the changes.</param>
288 /// <param name="databaseReference">Handle to the database obtained from MsiOpenDatabase that does not include the changes.</param>
289 /// <param name="transformFile">A null-terminated string that specifies the name of the transform file being generated.
290 /// This parameter can be null. If szTransformFile is null, you can use MsiDatabaseGenerateTransform to test whether two
291 /// databases are identical without creating a transform. If the databases are identical, the function returns ERROR_NO_DATA.
292 /// If the databases are different the function returns NOERROR.</param>
293 /// <param name="reserved1">This is a reserved argument and must be set to 0.</param>
294 /// <param name="reserved2">This is a reserved argument and must be set to 0.</param>
295 /// <returns>Error code.</returns>
296 [DllImport("msi.dll", EntryPoint = "MsiDatabaseGenerateTransformW", CharSet = CharSet.Unicode, ExactSpelling = true)]
297 public static extern int MsiDatabaseGenerateTransform(uint database, uint databaseReference, string transformFile, int reserved1, int reserved2);
298
299 /// <summary>
300 /// PInvoke of MsiDatabaseImportW.
301 /// </summary>
302 /// <param name="database">Handle to a database.</param>
303 /// <param name="folderPath">Folder path.</param>
304 /// <param name="fileName">File name.</param>
305 /// <returns>Error code.</returns>
306 [DllImport("msi.dll", EntryPoint = "MsiDatabaseImportW", CharSet = CharSet.Unicode, ExactSpelling = true)]
307 public static extern int MsiDatabaseImport(uint database, string folderPath, string fileName);
308
309 /// <summary>
310 /// PInvoke of MsiDatabaseMergeW.
311 /// </summary>
312 /// <param name="database">The handle to the database obtained from MsiOpenDatabase.</param>
313 /// <param name="databaseMerge">The handle to the database obtained from MsiOpenDatabase to merge into the base database.</param>
314 /// <param name="tableName">The name of the table to receive merge conflict information.</param>
315 /// <returns>Error code.</returns>
316 [DllImport("msi.dll", EntryPoint = "MsiDatabaseMergeW", CharSet = CharSet.Unicode, ExactSpelling = true)]
317 public static extern int MsiDatabaseMerge(uint database, uint databaseMerge, string tableName);
318
319 /// <summary>
320 /// PInvoke of MsiDatabaseOpenViewW.
321 /// </summary>
322 /// <param name="database">Handle to a database.</param>
323 /// <param name="query">SQL query.</param>
324 /// <param name="view">View handle.</param>
325 /// <returns>Error code.</returns>
326 [DllImport("msi.dll", EntryPoint = "MsiDatabaseOpenViewW", CharSet = CharSet.Unicode, ExactSpelling = true)]
327 public static extern int MsiDatabaseOpenView(uint database, string query, out uint view);
328
329 /// <summary>
330 /// PInvoke of MsiGetFileHashW.
331 /// </summary>
332 /// <param name="filePath">File path.</param>
333 /// <param name="options">Hash options (must be 0).</param>
334 /// <param name="hash">Buffer to recieve hash.</param>
335 /// <returns>Error code.</returns>
336 [DllImport("msi.dll", EntryPoint = "MsiGetFileHashW", CharSet = CharSet.Unicode, ExactSpelling = true)]
337 public static extern int MsiGetFileHash(string filePath, uint options, MSIFILEHASHINFO hash);
338
339 /// <summary>
340 /// PInvoke of MsiGetFileVersionW.
341 /// </summary>
342 /// <param name="filePath">File path.</param>
343 /// <param name="versionBuf">Buffer to receive version info.</param>
344 /// <param name="versionBufSize">Size of version buffer.</param>
345 /// <param name="langBuf">Buffer to recieve lang info.</param>
346 /// <param name="langBufSize">Size of lang buffer.</param>
347 /// <returns>Error code.</returns>
348 [DllImport("msi.dll", EntryPoint = "MsiGetFileVersionW", CharSet = CharSet.Unicode, ExactSpelling = true)]
349 public static extern int MsiGetFileVersion(string filePath, StringBuilder versionBuf, ref int versionBufSize, StringBuilder langBuf, ref int langBufSize);
350
351 /// <summary>
352 /// PInvoke of MsiGetLastErrorRecord.
353 /// </summary>
354 /// <returns>Handle to error record if one exists.</returns>
355 [DllImport("msi.dll", EntryPoint = "MsiGetLastErrorRecord", CharSet = CharSet.Unicode, ExactSpelling = true)]
356 public static extern uint MsiGetLastErrorRecord();
357
358 /// <summary>
359 /// PInvoke of MsiDatabaseGetPrimaryKeysW.
360 /// </summary>
361 /// <param name="database">Handle to a database.</param>
362 /// <param name="tableName">Table name.</param>
363 /// <param name="record">Handle to receive resulting record.</param>
364 /// <returns>Error code.</returns>
365 [DllImport("msi.dll", EntryPoint = "MsiDatabaseGetPrimaryKeysW", CharSet = CharSet.Unicode, ExactSpelling = true)]
366 public static extern int MsiDatabaseGetPrimaryKeys(uint database, string tableName, out uint record);
367
368 /// <summary>
369 /// PInvoke of MsiDoActionW.
370 /// </summary>
371 /// <param name="product">Handle to the installation provided to a DLL custom action or
372 /// obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.</param>
373 /// <param name="action">Specifies the action to execute.</param>
374 /// <returns>Error code.</returns>
375 [DllImport("msi.dll", EntryPoint = "MsiDoActionW", CharSet = CharSet.Unicode, ExactSpelling = true)]
376 public static extern int MsiDoAction(uint product, string action);
377
378 /// <summary>
379 /// PInvoke of MsiGetSummaryInformationW. Can use either database handle or database path as input.
380 /// </summary>
381 /// <param name="database">Handle to a database.</param>
382 /// <param name="databasePath">Path to a database.</param>
383 /// <param name="updateCount">Max number of updated values.</param>
384 /// <param name="summaryInfo">Handle to summary information.</param>
385 /// <returns>Error code.</returns>
386 [DllImport("msi.dll", EntryPoint = "MsiGetSummaryInformationW", CharSet = CharSet.Unicode, ExactSpelling = true)]
387 public static extern int MsiGetSummaryInformation(uint database, string databasePath, uint updateCount, ref uint summaryInfo);
388
389 /// <summary>
390 /// PInvoke of MsiDatabaseIsTablePersitentW.
391 /// </summary>
392 /// <param name="database">Handle to a database.</param>
393 /// <param name="tableName">Table name.</param>
394 /// <returns>MSICONDITION</returns>
395 [DllImport("msi.dll", EntryPoint = "MsiDatabaseIsTablePersistentW", CharSet = CharSet.Unicode, ExactSpelling = true)]
396 public static extern int MsiDatabaseIsTablePersistent(uint database, string tableName);
397
398 /// <summary>
399 /// PInvoke of MsiOpenDatabaseW.
400 /// </summary>
401 /// <param name="databasePath">Path to database.</param>
402 /// <param name="persist">Persist mode.</param>
403 /// <param name="database">Handle to database.</param>
404 /// <returns>Error code.</returns>
405 [DllImport("msi.dll", EntryPoint = "MsiOpenDatabaseW", CharSet = CharSet.Unicode, ExactSpelling = true)]
406 public static extern int MsiOpenDatabase(string databasePath, IntPtr persist, out uint database);
407
408 /// <summary>
409 /// PInvoke of MsiOpenPackageW.
410 /// </summary>
411 /// <param name="packagePath">The path to the package.</param>
412 /// <param name="product">A pointer to a variable that receives the product handle.</param>
413 /// <returns>Error code.</returns>
414 [DllImport("msi.dll", EntryPoint = "MsiOpenPackageW", CharSet = CharSet.Unicode, ExactSpelling = true)]
415 public static extern int MsiOpenPackage(string packagePath, out uint product);
416
417 /// <summary>
418 /// PInvoke of MsiRecordIsNull.
419 /// </summary>
420 /// <param name="record">MSI Record handle.</param>
421 /// <param name="field">Index of field to check for null value.</param>
422 /// <returns>true if the field is null, false if not, and an error code for any error.</returns>
423 [DllImport("msi.dll", EntryPoint = "MsiRecordIsNull", CharSet = CharSet.Unicode, ExactSpelling = true)]
424 public static extern int MsiRecordIsNull(uint record, int field);
425
426 /// <summary>
427 /// PInvoke of MsiRecordGetInteger.
428 /// </summary>
429 /// <param name="record">MSI Record handle.</param>
430 /// <param name="field">Index of field to retrieve integer from.</param>
431 /// <returns>Integer value.</returns>
432 [DllImport("msi.dll", EntryPoint = "MsiRecordGetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)]
433 public static extern int MsiRecordGetInteger(uint record, int field);
434
435 /// <summary>
436 /// PInvoke of MsiRectordSetInteger.
437 /// </summary>
438 /// <param name="record">MSI Record handle.</param>
439 /// <param name="field">Index of field to set integer value in.</param>
440 /// <param name="value">Value to set field to.</param>
441 /// <returns>Error code.</returns>
442 [DllImport("msi.dll", EntryPoint = "MsiRecordSetInteger", CharSet = CharSet.Unicode, ExactSpelling = true)]
443 public static extern int MsiRecordSetInteger(uint record, int field, int value);
444
445 /// <summary>
446 /// PInvoke of MsiRecordGetStringW.
447 /// </summary>
448 /// <param name="record">MSI Record handle.</param>
449 /// <param name="field">Index of field to get string value from.</param>
450 /// <param name="valueBuf">Buffer to recieve value.</param>
451 /// <param name="valueBufSize">Size of buffer.</param>
452 /// <returns>Error code.</returns>
453 [DllImport("msi.dll", EntryPoint = "MsiRecordGetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)]
454 public static extern int MsiRecordGetString(uint record, int field, StringBuilder valueBuf, ref int valueBufSize);
455
456 /// <summary>
457 /// PInvoke of MsiRecordSetStringW.
458 /// </summary>
459 /// <param name="record">MSI Record handle.</param>
460 /// <param name="field">Index of field to set string value in.</param>
461 /// <param name="value">String value.</param>
462 /// <returns>Error code.</returns>
463 [DllImport("msi.dll", EntryPoint = "MsiRecordSetStringW", CharSet = CharSet.Unicode, ExactSpelling = true)]
464 public static extern int MsiRecordSetString(uint record, int field, string value);
465
466 /// <summary>
467 /// PInvoke of MsiRecordSetStreamW.
468 /// </summary>
469 /// <param name="record">MSI Record handle.</param>
470 /// <param name="field">Index of field to set stream value in.</param>
471 /// <param name="filePath">Path to file to set stream value to.</param>
472 /// <returns>Error code.</returns>
473 [DllImport("msi.dll", EntryPoint = "MsiRecordSetStreamW", CharSet = CharSet.Unicode, ExactSpelling = true)]
474 public static extern int MsiRecordSetStream(uint record, int field, string filePath);
475
476 /// <summary>
477 /// PInvoke of MsiRecordReadStreamW.
478 /// </summary>
479 /// <param name="record">MSI Record handle.</param>
480 /// <param name="field">Index of field to read stream from.</param>
481 /// <param name="dataBuf">Data buffer to recieve stream value.</param>
482 /// <param name="dataBufSize">Size of data buffer.</param>
483 /// <returns>Error code.</returns>
484 [DllImport("msi.dll", EntryPoint = "MsiRecordReadStream", CharSet = CharSet.Unicode, ExactSpelling = true)]
485 public static extern int MsiRecordReadStream(uint record, int field, byte[] dataBuf, ref int dataBufSize);
486
487 /// <summary>
488 /// PInvoke of MsiRecordGetFieldCount.
489 /// </summary>
490 /// <param name="record">MSI Record handle.</param>
491 /// <returns>Count of fields in the record.</returns>
492 [DllImport("msi.dll", EntryPoint = "MsiRecordGetFieldCount", CharSet = CharSet.Unicode, ExactSpelling = true)]
493 public static extern int MsiRecordGetFieldCount(uint record);
494
495 /// <summary>
496 /// PInvoke of MsiSetExternalUIW.
497 /// </summary>
498 /// <param name="installUIHandler">Specifies a callback function that conforms to the INSTALLUI_HANDLER specification.</param>
499 /// <param name="installLogMode">Specifies which messages to handle using the external message handler. If the external
500 /// handler returns a non-zero result, then that message will not be sent to the UI, instead the message will be logged
501 /// if logging has been enabled.</param>
502 /// <param name="context">Pointer to an application context that is passed to the callback function.
503 /// This parameter can be used for error checking.</param>
504 /// <returns>The return value is the previously set external handler, or zero (0) if there was no previously set handler.</returns>
505 [DllImport("msi.dll", EntryPoint = "MsiSetExternalUIW", CharSet = CharSet.Unicode, ExactSpelling = true)]
506 public static extern InstallUIHandler MsiSetExternalUI(InstallUIHandler installUIHandler, int installLogMode, IntPtr context);
507
508 /// <summary>
509 /// PInvoke of MsiSetpublicUI.
510 /// </summary>
511 /// <param name="uiLevel">Specifies the level of complexity of the user interface.</param>
512 /// <param name="hwnd">Pointer to a window. This window becomes the owner of any user interface created.
513 /// A pointer to the previous owner of the user interface is returned.
514 /// If this parameter is null, the owner of the user interface does not change.</param>
515 /// <returns>The previous user interface level is returned. If an invalid dwUILevel is passed, then INSTALLUILEVEL_NOCHANGE is returned.</returns>
516 [DllImport("msi.dll", EntryPoint = "MsiSetpublicUI", CharSet = CharSet.Unicode, ExactSpelling = true)]
517 public static extern int MsiSetInternalUI(int uiLevel, ref IntPtr hwnd);
518
519 /// <summary>
520 /// PInvoke of MsiSummaryInfoGetPropertyW.
521 /// </summary>
522 /// <param name="summaryInfo">Handle to summary info.</param>
523 /// <param name="property">Property to get value from.</param>
524 /// <param name="dataType">Data type of property.</param>
525 /// <param name="integerValue">Integer to receive integer value.</param>
526 /// <param name="fileTimeValue">File time to receive file time value.</param>
527 /// <param name="stringValueBuf">String buffer to receive string value.</param>
528 /// <param name="stringValueBufSize">Size of string buffer.</param>
529 /// <returns>Error code.</returns>
530 [DllImport("msi.dll", EntryPoint = "MsiSummaryInfoGetPropertyW", CharSet = CharSet.Unicode, ExactSpelling = true)]
531 public static extern int MsiSummaryInfoGetProperty(uint summaryInfo, int property, out uint dataType, out int integerValue, ref FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize);
532
533 /// <summary>
534 /// PInvoke of MsiViewGetColumnInfo.
535 /// </summary>
536 /// <param name="view">Handle to view.</param>
537 /// <param name="columnInfo">Column info.</param>
538 /// <param name="record">Handle for returned record.</param>
539 /// <returns>Error code.</returns>
540 [DllImport("msi.dll", EntryPoint = "MsiViewGetColumnInfo", CharSet = CharSet.Unicode, ExactSpelling = true)]
541 public static extern int MsiViewGetColumnInfo(uint view, int columnInfo, out uint record);
542
543 /// <summary>
544 /// PInvoke of MsiViewExecute.
545 /// </summary>
546 /// <param name="view">Handle of view to execute.</param>
547 /// <param name="record">Handle to a record that supplies the parameters for the view.</param>
548 /// <returns>Error code.</returns>
549 [DllImport("msi.dll", EntryPoint = "MsiViewExecute", CharSet = CharSet.Unicode, ExactSpelling = true)]
550 public static extern int MsiViewExecute(uint view, uint record);
551
552 /// <summary>
553 /// PInvoke of MsiViewFetch.
554 /// </summary>
555 /// <param name="view">Handle of view to fetch a row from.</param>
556 /// <param name="record">Handle to receive record info.</param>
557 /// <returns>Error code.</returns>
558 [DllImport("msi.dll", EntryPoint = "MsiViewFetch", CharSet = CharSet.Unicode, ExactSpelling = true)]
559 public static extern int MsiViewFetch(uint view, out uint record);
560
561 /// <summary>
562 /// PInvoke of MsiViewModify.
563 /// </summary>
564 /// <param name="view">Handle of view to modify.</param>
565 /// <param name="modifyMode">Modify mode.</param>
566 /// <param name="record">Handle of record.</param>
567 /// <returns>Error code.</returns>
568 [DllImport("msi.dll", EntryPoint = "MsiViewModify", CharSet = CharSet.Unicode, ExactSpelling = true)]
569 public static extern int MsiViewModify(uint view, int modifyMode, uint record);
570 }
571}
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/MsmInterop.cs b/src/WixToolset.Core.WindowsInstaller/Msi/MsmInterop.cs
new file mode 100644
index 00000000..970d5aaa
--- /dev/null
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/MsmInterop.cs
@@ -0,0 +1,505 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolset.Core.WindowsInstaller.Msi
4{
5 using System;
6 using System.Runtime.InteropServices;
7
8 /// <summary>
9 /// Errors returned by merge operations.
10 /// </summary>
11 [Guid("0ADDA825-2C26-11D2-AD65-00A0C9AF11A6")]
12 public enum MsmErrorType
13 {
14 /// <summary>
15 /// A request was made to open a module with a language not supported by the module.
16 /// No more general language is supported by the module.
17 /// Adds msmErrorLanguageUnsupported to the Type property and the requested language
18 /// to the Language Property (Error Object). All Error object properties are empty.
19 /// The OpenModule function returns ERROR_INSTALL_LANGUAGE_UNSUPPORTED (as HRESULT).
20 /// </summary>
21 msmErrorLanguageUnsupported = 1,
22
23 /// <summary>
24 /// A request was made to open a module with a supported language but the module has
25 /// an invalid language transform. Adds msmErrorLanguageFailed to the Type property
26 /// and the applied transform's language to the Language Property of the Error object.
27 /// This may not be the requested language if a more general language was used.
28 /// All other properties of the Error object are empty. The OpenModule function
29 /// returns ERROR_INSTALL_LANGUAGE_UNSUPPORTED (as HRESULT).
30 /// </summary>
31 msmErrorLanguageFailed = 2,
32
33 /// <summary>
34 /// The module cannot be merged because it excludes, or is excluded by, another module
35 /// in the database. Adds msmErrorExclusion to the Type property of the Error object.
36 /// The ModuleKeys property or DatabaseKeys property contains the primary keys of the
37 /// excluded module's row in the ModuleExclusion table. If an existing module excludes
38 /// the module being merged, the excluded module's ModuleSignature information is added
39 /// to ModuleKeys. If the module being merged excludes an existing module, DatabaseKeys
40 /// contains the excluded module's ModuleSignature information. All other properties
41 /// are empty (or -1).
42 /// </summary>
43 msmErrorExclusion = 3,
44
45 /// <summary>
46 /// Merge conflict during merge. The value of the Type property is set to
47 /// msmErrorTableMerge. The DatabaseTable property and DatabaseKeys property contain
48 /// the table name and primary keys of the conflicting row in the database. The
49 /// ModuleTable property and ModuleKeys property contain the table name and primary keys
50 /// of the conflicting row in the module. The ModuleTable and ModuleKeys entries may be
51 /// null if the row does not exist in the database. For example, if the conflict is in a
52 /// generated FeatureComponents table entry. On Windows Installer version 2.0, when
53 /// merging a configurable merge module, configuration may cause these properties to
54 /// refer to rows that do not exist in the module.
55 /// </summary>
56 msmErrorTableMerge = 4,
57
58 /// <summary>
59 /// There was a problem resequencing a sequence table to contain the necessary merged
60 /// actions. The Type property is set to msmErrorResequenceMerge. The DatabaseTable
61 /// and DatabaseKeys properties contain the sequence table name and primary keys
62 /// (action name) of the conflicting row. The ModuleTable and ModuleKeys properties
63 /// contain the sequence table name and primary key (action name) of the conflicting row.
64 /// On Windows Installer version 2.0, when merging a configurable merge module,
65 /// configuration may cause these properties to refer to rows that do not exist in the module.
66 /// </summary>
67 msmErrorResequenceMerge = 5,
68
69 /// <summary>
70 /// Not used.
71 /// </summary>
72 msmErrorFileCreate = 6,
73
74 /// <summary>
75 /// There was a problem creating a directory to extract a file to disk. The Path property
76 /// contains the directory that could not be created. All other properties are empty or -1.
77 /// Not available with Windows Installer version 1.0.
78 /// </summary>
79 msmErrorDirCreate = 7,
80
81 /// <summary>
82 /// A feature name is required to complete the merge, but no feature name was provided.
83 /// The Type property is set to msmErrorFeatureRequired. The DatabaseTable and DatabaseKeys
84 /// contain the table name and primary keys of the conflicting row. The ModuleTable and
85 /// ModuleKeys properties contain the table name and primary keys of the row cannot be merged.
86 /// On Windows Installer version 2.0, when merging a configurable merge module, configuration
87 /// may cause these properties to refer to rows that do not exist in the module.
88 /// If the failure is in a generated FeatureComponents table, the DatabaseTable and
89 /// DatabaseKeys properties are empty and the ModuleTable and ModuleKeys properties refer to
90 /// the row in the Component table causing the failure.
91 /// </summary>
92 msmErrorFeatureRequired = 8,
93
94 /// <summary>
95 /// Available with Window Installer version 2.0. Substitution of a Null value into a
96 /// non-nullable column. This enters msmErrorBadNullSubstitution in the Type property and
97 /// enters "ModuleSubstitution" and the keys from the ModuleSubstitution table for this row
98 /// into the ModuleTable property and ModuleKeys property. All other properties of the Error
99 /// object are set to an empty string or -1. This error causes the immediate failure of the
100 /// merge and the MergeEx function to return E_FAIL.
101 /// </summary>
102 msmErrorBadNullSubstitution = 9,
103
104 /// <summary>
105 /// Available with Window Installer version 2.0. Substitution of Text Format Type or Integer
106 /// Format Type into a Binary Type data column. This type of error returns
107 /// msmErrorBadSubstitutionType in the Type property and enters "ModuleSubstitution" and the
108 /// keys from the ModuleSubstitution table for this row into the ModuleTable property.
109 /// All other properties of the Error object are set to an empty string or -1. This error
110 /// causes the immediate failure of the merge and the MergeEx function to return E_FAIL.
111 /// </summary>
112 msmErrorBadSubstitutionType = 10,
113
114 /// <summary>
115 /// Available with Window Installer Version 2.0. A row in the ModuleSubstitution table
116 /// references a configuration item not defined in the ModuleConfiguration table.
117 /// This type of error returns msmErrorMissingConfigItem in the Type property and enters
118 /// "ModuleSubstitution" and the keys from the ModuleSubstitution table for this row into
119 /// the ModuleTable property. All other properties of the Error object are set to an empty
120 /// string or -1. This error causes the immediate failure of the merge and the MergeEx
121 /// function to return E_FAIL.
122 /// </summary>
123 msmErrorMissingConfigItem = 11,
124
125 /// <summary>
126 /// Available with Window Installer version 2.0. The authoring tool has returned a Null
127 /// value for an item marked with the msmConfigItemNonNullable attribute. An error of this
128 /// type returns msmErrorBadNullResponse in the Type property and enters "ModuleSubstitution"
129 /// and the keys from the ModuleSubstitution table for for the item into the ModuleTable property.
130 /// All other properties of the Error object are set to an empty string or -1. This error
131 /// causes the immediate failure of the merge and the MergeEx function to return E_FAIL.
132 /// </summary>
133 msmErrorBadNullResponse = 12,
134
135 /// <summary>
136 /// Available with Window Installer version 2.0. The authoring tool returned a failure code
137 /// (not S_OK or S_FALSE) when asked for data. An error of this type will return
138 /// msmErrorDataRequestFailed in the Type property and enters "ModuleSubstitution"
139 /// and the keys from the ModuleSubstitution table for the item into the ModuleTable property.
140 /// All other properties of the Error object are set to an empty string or -1. This error
141 /// causes the immediate failure of the merge and the MergeEx function to return E_FAIL.
142 /// </summary>
143 msmErrorDataRequestFailed = 13,
144
145 /// <summary>
146 /// Available with Windows Installer 2.0 and later versions. Indicates that an attempt was
147 /// made to merge a 64-bit module into a package that was not a 64-bit package. An error of
148 /// this type returns msmErrorPlatformMismatch in the Type property. All other properties of
149 /// the error object are set to an empty string or -1. This error causes the immediate failure
150 /// of the merge and causes the Merge function or MergeEx function to return E_FAIL.
151 /// </summary>
152 msmErrorPlatformMismatch = 14,
153 }
154
155 /// <summary>
156 /// IMsmMerge2 interface.
157 /// </summary>
158 [ComImport, Guid("351A72AB-21CB-47ab-B7AA-C4D7B02EA305")]
159 public interface IMsmMerge2
160 {
161 /// <summary>
162 /// The OpenDatabase method of the Merge object opens a Windows Installer installation
163 /// database, located at a specified path, that is to be merged with a module.
164 /// </summary>
165 /// <param name="path">Path to the database being opened.</param>
166 void OpenDatabase(string path);
167
168 /// <summary>
169 /// The OpenModule method of the Merge object opens a Windows Installer merge module
170 /// in read-only mode. A module must be opened before it can be merged with an installation database.
171 /// </summary>
172 /// <param name="fileName">Fully qualified file name pointing to a merge module.</param>
173 /// <param name="language">A valid language identifier (LANGID).</param>
174 void OpenModule(string fileName, short language);
175
176 /// <summary>
177 /// The CloseDatabase method of the Merge object closes the currently open Windows Installer database.
178 /// </summary>
179 /// <param name="commit">true if changes should be saved, false otherwise.</param>
180 void CloseDatabase(bool commit);
181
182 /// <summary>
183 /// The CloseModule method of the Merge object closes the currently open Windows Installer merge module.
184 /// </summary>
185 void CloseModule();
186
187 /// <summary>
188 /// The OpenLog method of the Merge object opens a log file that receives progress and error messages.
189 /// If the log file already exists, the installer appends new messages. If the log file does not exist,
190 /// the installer creates a log file.
191 /// </summary>
192 /// <param name="fileName">Fully qualified filename pointing to a file to open or create.</param>
193 void OpenLog(string fileName);
194
195 /// <summary>
196 /// The CloseLog method of the Merge object closes the current log file.
197 /// </summary>
198 void CloseLog();
199
200 /// <summary>
201 /// The Log method of the Merge object writes a text string to the currently open log file.
202 /// </summary>
203 /// <param name="message">The text string to display.</param>
204 void Log(string message);
205
206 /// <summary>
207 /// Gets the errors from the last merge operation.
208 /// </summary>
209 /// <value>The errors from the last merge operation.</value>
210 IMsmErrors Errors
211 {
212 get;
213 }
214
215 /// <summary>
216 /// Gets a collection of Dependency objects that enumerates a set of unsatisfied dependencies for the current database.
217 /// </summary>
218 /// <value>A collection of Dependency objects that enumerates a set of unsatisfied dependencies for the current database.</value>
219 object Dependencies
220 {
221 get;
222 }
223
224 /// <summary>
225 /// The Merge method of the Merge object executes a merge of the current database and current
226 /// module. The merge attaches the components in the module to the feature identified by Feature.
227 /// The root of the module's directory tree is redirected to the location given by RedirectDir.
228 /// </summary>
229 /// <param name="feature">The name of a feature in the database.</param>
230 /// <param name="redirectDir">The key of an entry in the Directory table of the database.
231 /// This parameter may be NULL or an empty string.</param>
232 void Merge(string feature, string redirectDir);
233
234 /// <summary>
235 /// The Connect method of the Merge object connects a module to an additional feature.
236 /// The module must have already been merged into the database or will be merged into the database.
237 /// The feature must exist before calling this function.
238 /// </summary>
239 /// <param name="feature">The name of a feature already existing in the database.</param>
240 void Connect(string feature);
241
242 /// <summary>
243 /// The ExtractCAB method of the Merge object extracts the embedded .cab file from a module and
244 /// saves it as the specified file. The installer creates this file if it does not already exist
245 /// and overwritten if it does exist.
246 /// </summary>
247 /// <param name="fileName">The fully qualified destination file.</param>
248 void ExtractCAB(string fileName);
249
250 /// <summary>
251 /// The ExtractFiles method of the Merge object extracts the embedded .cab file from a module
252 /// and then writes those files to the destination directory.
253 /// </summary>
254 /// <param name="path">The fully qualified destination directory.</param>
255 void ExtractFiles(string path);
256
257 /// <summary>
258 /// The MergeEx method of the Merge object is equivalent to the Merge function, except that it
259 /// takes an extra argument. The Merge method executes a merge of the current database and
260 /// current module. The merge attaches the components in the module to the feature identified
261 /// by Feature. The root of the module's directory tree is redirected to the location given by RedirectDir.
262 /// </summary>
263 /// <param name="feature">The name of a feature in the database.</param>
264 /// <param name="redirectDir">The key of an entry in the Directory table of the database. This parameter may
265 /// be NULL or an empty string.</param>
266 /// <param name="configuration">The pConfiguration argument is an interface implemented by the client. The argument may
267 /// be NULL. The presence of this argument indicates that the client is capable of supporting the configuration
268 /// functionality, but does not obligate the client to provide configuration data for any specific configurable item.</param>
269 void MergeEx(string feature, string redirectDir, IMsmConfigureModule configuration);
270
271 /// <summary>
272 /// The ExtractFilesEx method of the Merge object extracts the embedded .cab file from a module and
273 /// then writes those files to the destination directory.
274 /// </summary>
275 /// <param name="path">The fully qualified destination directory.</param>
276 /// <param name="longFileNames">Set to specify using long file names for path segments and final file names.</param>
277 /// <param name="filePaths">This is a list of fully-qualified paths for the files that were successfully extracted.
278 /// The list is empty if no files can be extracted. This argument may be null. No list is provided if pFilePaths is null.</param>
279 void ExtractFilesEx(string path, bool longFileNames, ref IntPtr filePaths);
280
281 /// <summary>
282 /// Gets a collection ConfigurableItem objects, each of which represents a single row from the ModuleConfiguration table.
283 /// </summary>
284 /// <value>A collection ConfigurableItem objects, each of which represents a single row from the ModuleConfiguration table.</value>
285 /// <remarks>Semantically, each interface in the enumerator represents an item that can be configured by the module consumer.
286 /// The collection is a read-only collection and implements the standard read-only collection interfaces of Item(), Count() and _NewEnum().
287 /// The IEnumMsmConfigItems enumerator implements Next(), Skip(), Reset(), and Clone() with the standard semantics.</remarks>
288 object ConfigurableItems
289 {
290 get;
291 }
292
293 /// <summary>
294 /// The CreateSourceImage method of the Merge object allows the client to extract the files from a module to
295 /// a source image on disk after a merge, taking into account changes to the module that might have been made
296 /// during module configuration. The list of files to be extracted is taken from the file table of the module
297 /// during the merge process. The list of files consists of every file successfully copied from the file table
298 /// of the module to the target database. File table entries that were not copied due to primary key conflicts
299 /// with existing rows in the database are not a part of this list. At image creation time, the directory for
300 /// each of these files comes from the open (post-merge) database. The path specified in the Path parameter is
301 /// the root of the source image for the install. fLongFileNames determines whether or not long file names are
302 /// used for both path segments and final file names. The function fails if no database is open, no module is
303 /// open, or no merge has been performed.
304 /// </summary>
305 /// <param name="path">The path of the root of the source image for the install.</param>
306 /// <param name="longFileNames">Determines whether or not long file names are used for both path segments and final file names. </param>
307 /// <param name="filePaths">This is a list of fully-qualified paths for the files that were successfully extracted.
308 /// The list is empty if no files can be extracted. This argument may be null. No list is provided if pFilePaths is null.</param>
309 void CreateSourceImage(string path, bool longFileNames, ref IntPtr filePaths);
310
311 /// <summary>
312 /// The get_ModuleFiles function implements the ModuleFiles property of the GetFiles object. This function
313 /// returns the primary keys in the File table of the currently open module. The primary keys are returned
314 /// as a collection of strings. The module must be opened by a call to the OpenModule function before calling get_ModuleFiles.
315 /// </summary>
316 IMsmStrings ModuleFiles
317 {
318 get;
319 }
320 }
321
322 /// <summary>
323 /// Collection of merge errors.
324 /// </summary>
325 [ComImport, Guid("0ADDA82A-2C26-11D2-AD65-00A0C9AF11A6")]
326 public interface IMsmErrors
327 {
328 /// <summary>
329 /// Gets the IMsmError at the specified index.
330 /// </summary>
331 /// <param name="index">The one-based index of the IMsmError to get.</param>
332 IMsmError this[int index]
333 {
334 get;
335 }
336
337 /// <summary>
338 /// Gets the count of IMsmErrors in this collection.
339 /// </summary>
340 /// <value>The count of IMsmErrors in this collection.</value>
341 int Count
342 {
343 get;
344 }
345 }
346
347 /// <summary>
348 /// A merge error.
349 /// </summary>
350 [ComImport, Guid("0ADDA828-2C26-11D2-AD65-00A0C9AF11A6")]
351 public interface IMsmError
352 {
353 /// <summary>
354 /// Gets the type of merge error.
355 /// </summary>
356 /// <value>The type of merge error.</value>
357 MsmErrorType Type
358 {
359 get;
360 }
361
362 /// <summary>
363 /// Gets the path information from the merge error.
364 /// </summary>
365 /// <value>The path information from the merge error.</value>
366 string Path
367 {
368 get;
369 }
370
371 /// <summary>
372 /// Gets the language information from the merge error.
373 /// </summary>
374 /// <value>The language information from the merge error.</value>
375 short Language
376 {
377 get;
378 }
379
380 /// <summary>
381 /// Gets the database table from the merge error.
382 /// </summary>
383 /// <value>The database table from the merge error.</value>
384 string DatabaseTable
385 {
386 get;
387 }
388
389 /// <summary>
390 /// Gets the collection of database keys from the merge error.
391 /// </summary>
392 /// <value>The collection of database keys from the merge error.</value>
393 IMsmStrings DatabaseKeys
394 {
395 get;
396 }
397
398 /// <summary>
399 /// Gets the module table from the merge error.
400 /// </summary>
401 /// <value>The module table from the merge error.</value>
402 string ModuleTable
403 {
404 get;
405 }
406
407 /// <summary>
408 /// Gets the collection of module keys from the merge error.
409 /// </summary>
410 /// <value>The collection of module keys from the merge error.</value>
411 IMsmStrings ModuleKeys
412 {
413 get;
414 }
415 }
416
417 /// <summary>
418 /// A collection of strings.
419 /// </summary>
420 [ComImport, Guid("0ADDA827-2C26-11D2-AD65-00A0C9AF11A6")]
421 public interface IMsmStrings
422 {
423 /// <summary>
424 /// Gets the string at the specified index.
425 /// </summary>
426 /// <param name="index">The one-based index of the string to get.</param>
427 string this[int index]
428 {
429 get;
430 }
431
432 /// <summary>
433 /// Gets the count of strings in this collection.
434 /// </summary>
435 /// <value>The count of strings in this collection.</value>
436 int Count
437 {
438 get;
439 }
440 }
441
442 /// <summary>
443 /// Callback for configurable merge modules.
444 /// </summary>
445 [ComImport, Guid("AC013209-18A7-4851-8A21-2353443D70A0"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
446 public interface IMsmConfigureModule
447 {
448 /// <summary>
449 /// Callback to retrieve text data for configurable merge modules.
450 /// </summary>
451 /// <param name="name">Name of the data to be retrieved.</param>
452 /// <param name="configData">The data corresponding to the name.</param>
453 /// <returns>The error code (HRESULT).</returns>
454 [PreserveSig]
455 int ProvideTextData([In, MarshalAs(UnmanagedType.BStr)] string name, [MarshalAs(UnmanagedType.BStr)] out string configData);
456
457 /// <summary>
458 /// Callback to retrieve integer data for configurable merge modules.
459 /// </summary>
460 /// <param name="name">Name of the data to be retrieved.</param>
461 /// <param name="configData">The data corresponding to the name.</param>
462 /// <returns>The error code (HRESULT).</returns>
463 [PreserveSig]
464 int ProvideIntegerData([In, MarshalAs(UnmanagedType.BStr)] string name, out int configData);
465 }
466
467 /// <summary>
468 /// Merge merge modules into an MSI file.
469 /// </summary>
470 [ComImport, Guid("F94985D5-29F9-4743-9805-99BC3F35B678")]
471 public class MsmMerge2
472 {
473 }
474
475 /// <summary>
476 /// Defines the standard COM IClassFactory interface.
477 /// </summary>
478 [ComImport, Guid("00000001-0000-0000-C000-000000000046")]
479 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
480 public interface IClassFactory
481 {
482 [return:MarshalAs(UnmanagedType.IUnknown)]
483 object CreateInstance(IntPtr unkOuter, [MarshalAs(UnmanagedType.LPStruct)] Guid iid);
484 }
485
486 /// <summary>
487 /// Contains native methods for merge operations.
488 /// </summary>
489 public class MsmInterop
490 {
491 [DllImport("mergemod.dll", EntryPoint="DllGetClassObject", PreserveSig=false)]
492 [return: MarshalAs(UnmanagedType.IUnknown)]
493 private static extern object MergeModGetClassObject([MarshalAs(UnmanagedType.LPStruct)] Guid clsid, [MarshalAs(UnmanagedType.LPStruct)] Guid iid);
494
495 /// <summary>
496 /// Load the merge object directly from a local mergemod.dll without going through COM registration.
497 /// </summary>
498 /// <returns>Merge interface.</returns>
499 public static IMsmMerge2 GetMsmMerge()
500 {
501 IClassFactory classFactory = (IClassFactory) MergeModGetClassObject(typeof(MsmMerge2).GUID, typeof(IClassFactory).GUID);
502 return (IMsmMerge2) classFactory.CreateInstance(IntPtr.Zero, typeof(IMsmMerge2).GUID);
503 }
504 }
505}
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/Record.cs b/src/WixToolset.Core.WindowsInstaller/Msi/Record.cs
index 438aa3b0..7342659b 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/Record.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/Record.cs
@@ -1,11 +1,10 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.ComponentModel; 6 using System.ComponentModel;
7 using System.Text; 7 using System.Text;
8 using WixToolset.Core.Native;
9 8
10 /// <summary> 9 /// <summary>
11 /// Wrapper class around msi.dll interop for a record. 10 /// Wrapper class around msi.dll interop for a record.
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs b/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs
index d3a19711..bb07a501 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/Session.cs
@@ -1,11 +1,9 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.ComponentModel;
7 using System.Globalization; 6 using System.Globalization;
8 using WixToolset.Core.Native;
9 7
10 /// <summary> 8 /// <summary>
11 /// Controls the installation process. 9 /// Controls the installation process.
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/SummaryInformation.cs b/src/WixToolset.Core.WindowsInstaller/Msi/SummaryInformation.cs
index 26831731..5450671f 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/SummaryInformation.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/SummaryInformation.cs
@@ -1,12 +1,11 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.Globalization; 6 using System.Globalization;
7 using System.Text; 7 using System.Text;
8 using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; 8 using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
9 using WixToolset.Core.Native;
10 9
11 /// <summary> 10 /// <summary>
12 /// Summary information for the MSI files. 11 /// Summary information for the MSI files.
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/View.cs b/src/WixToolset.Core.WindowsInstaller/Msi/View.cs
index d6542824..1beb72da 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/View.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/View.cs
@@ -1,11 +1,9 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using System.ComponentModel;
7 using System.Globalization; 6 using System.Globalization;
8 using WixToolset.Core.Native;
9 7
10 /// <summary> 8 /// <summary>
11 /// Enumeration of different modify modes. 9 /// Enumeration of different modify modes.
@@ -17,27 +15,27 @@ namespace WixToolset.Msi
17 /// keys match an existing row and inserts if they do not match. Fails with a read-only 15 /// keys match an existing row and inserts if they do not match. Fails with a read-only
18 /// database. This mode cannot be used with a view containing joins. 16 /// database. This mode cannot be used with a view containing joins.
19 /// </summary> 17 /// </summary>
20 Assign = MsiInterop.MSIMODIFYASSIGN, 18 Assign = 3, // Writes current data in the cursor to a table row. Updates record if the primary keys match an existing row and inserts if they do not match. Fails with a read-only database. This mode cannot be used with a view containing joins.
21 19
22 /// <summary> 20 /// <summary>
23 /// Remove a row from the table. You must first call the Fetch function with the same 21 /// Remove a row from the table. You must first call the Fetch function with the same
24 /// record. Fails if the row has been deleted. Works only with read-write records. This 22 /// record. Fails if the row has been deleted. Works only with read-write records. This
25 /// mode cannot be used with a view containing joins. 23 /// mode cannot be used with a view containing joins.
26 /// </summary> 24 /// </summary>
27 Delete = MsiInterop.MSIMODIFYDELETE, 25 Delete = 6, // Remove a row from the table. You must first call the MsiViewFetch function with the same record. Fails if the row has been deleted. Works only with read-write records. This mode cannot be used with a view containing joins.
28 26
29 /// <summary> 27 /// <summary>
30 /// Inserts a record. Fails if a row with the same primary keys exists. Fails with a read-only 28 /// Inserts a record. Fails if a row with the same primary keys exists. Fails with a read-only
31 /// database. This mode cannot be used with a view containing joins. 29 /// database. This mode cannot be used with a view containing joins.
32 /// </summary> 30 /// </summary>
33 Insert = MsiInterop.MSIMODIFYINSERT, 31 Insert = 1, // Inserts a record. Fails if a row with the same primary keys exists. Fails with a read-only database. This mode cannot be used with a view containing joins.
34 32
35 /// <summary> 33 /// <summary>
36 /// Inserts a temporary record. The information is not persistent. Fails if a row with the 34 /// Inserts a temporary record. The information is not persistent. Fails if a row with the
37 /// same primary key exists. Works only with read-write records. This mode cannot be 35 /// same primary key exists. Works only with read-write records. This mode cannot be
38 /// used with a view containing joins. 36 /// used with a view containing joins.
39 /// </summary> 37 /// </summary>
40 InsertTemporary = MsiInterop.MSIMODIFYINSERTTEMPORARY, 38 InsertTemporary = 7, // Inserts a temporary record. The information is not persistent. Fails if a row with the same primary key exists. Works only with read-write records. This mode cannot be used with a view containing joins.
41 39
42 /// <summary> 40 /// <summary>
43 /// Inserts or validates a record in a table. Inserts if primary keys do not match any row 41 /// Inserts or validates a record in a table. Inserts if primary keys do not match any row
@@ -45,13 +43,13 @@ namespace WixToolset.Msi
45 /// the table. Fails if there is a record with a duplicate key that is not identical. 43 /// the table. Fails if there is a record with a duplicate key that is not identical.
46 /// Works only with read-write records. This mode cannot be used with a view containing joins. 44 /// Works only with read-write records. This mode cannot be used with a view containing joins.
47 /// </summary> 45 /// </summary>
48 Merge = MsiInterop.MSIMODIFYMERGE, 46 Merge = 5, // Inserts or validates a record in a table. Inserts if primary keys do not match any row and validates if there is a match. Fails if the record does not match the data in the table. Fails if there is a record with a duplicate key that is not identical. Works only with read-write records. This mode cannot be used with a view containing joins.
49 47
50 /// <summary> 48 /// <summary>
51 /// Refreshes the information in the record. Must first call Fetch with the 49 /// Refreshes the information in the record. Must first call Fetch with the
52 /// same record. Fails for a deleted row. Works with read-write and read-only records. 50 /// same record. Fails for a deleted row. Works with read-write and read-only records.
53 /// </summary> 51 /// </summary>
54 Refresh = MsiInterop.MSIMODIFYREFRESH, 52 Refresh = 0, // Refreshes the information in the record. Must first call MsiViewFetch with the same record. Fails for a deleted row. Works with read-write and read-only records.
55 53
56 /// <summary> 54 /// <summary>
57 /// Updates or deletes and inserts a record into a table. Must first call Fetch with 55 /// Updates or deletes and inserts a record into a table. Must first call Fetch with
@@ -59,7 +57,7 @@ namespace WixToolset.Msi
59 /// inserts new if primary keys have changed. Fails with a read-only database. This mode cannot 57 /// inserts new if primary keys have changed. Fails with a read-only database. This mode cannot
60 /// be used with a view containing joins. 58 /// be used with a view containing joins.
61 /// </summary> 59 /// </summary>
62 Replace = MsiInterop.MSIMODIFYREPLACE, 60 Replace = 4, // Updates or deletes and inserts a record into a table. Must first call MsiViewFetch with the same record. Updates record if the primary keys are unchanged. Deletes old row and inserts new if primary keys have changed. Fails with a read-only database. This mode cannot be used with a view containing joins.
63 61
64 /// <summary> 62 /// <summary>
65 /// Refreshes the information in the supplied record without changing the position in the 63 /// Refreshes the information in the supplied record without changing the position in the
@@ -69,13 +67,13 @@ namespace WixToolset.Msi
69 /// query. Seek cannot be used with multi-table queries. This mode cannot be used with 67 /// query. Seek cannot be used with multi-table queries. This mode cannot be used with
70 /// a view containing joins. See also the remarks. 68 /// a view containing joins. See also the remarks.
71 /// </summary> 69 /// </summary>
72 Seek = MsiInterop.MSIMODIFYSEEK, 70 Seek = -1, // Refreshes the information in the supplied record without changing the position in the result set and without affecting subsequent fetch operations. The record may then be used for subsequent Update, Delete, and Refresh. All primary key columns of the table must be in the query and the record must have at least as many fields as the query. Seek cannot be used with multi-table queries. This mode cannot be used with a view containing joins. See also the remarks.
73 71
74 /// <summary> 72 /// <summary>
75 /// Updates an existing record. Non-primary keys only. Must first call Fetch. Fails with a 73 /// Updates an existing record. Non-primary keys only. Must first call Fetch. Fails with a
76 /// deleted record. Works only with read-write records. 74 /// deleted record. Works only with read-write records.
77 /// </summary> 75 /// </summary>
78 Update = MsiInterop.MSIMODIFYUPDATE 76 Update = 2, // Updates an existing record. Nonprimary keys only. Must first call MsiViewFetch. Fails with a deleted record. Works only with read-write records.
79 } 77 }
80 78
81 /// <summary> 79 /// <summary>
diff --git a/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs b/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs
index 589da648..a4750723 100644
--- a/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Msi/WixInvalidIdtException.cs
@@ -1,6 +1,6 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Msi 3namespace WixToolset.Core.WindowsInstaller.Msi
4{ 4{
5 using System; 5 using System;
6 using WixToolset.Data; 6 using WixToolset.Data;