aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Native/Msi/Session.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.Native/Msi/Session.cs')
-rw-r--r--src/WixToolset.Core.Native/Msi/Session.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/WixToolset.Core.Native/Msi/Session.cs b/src/WixToolset.Core.Native/Msi/Session.cs
new file mode 100644
index 00000000..743fb2be
--- /dev/null
+++ b/src/WixToolset.Core.Native/Msi/Session.cs
@@ -0,0 +1,42 @@
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.Native.Msi
4{
5 using System.Globalization;
6
7 /// <summary>
8 /// Controls the installation process.
9 /// </summary>
10 public sealed class Session : MsiHandle
11 {
12 /// <summary>
13 /// Instantiate a new Session.
14 /// </summary>
15 /// <param name="database">The database to open.</param>
16 public Session(Database database)
17 {
18 var packagePath = "#" + database.Handle.ToString(CultureInfo.InvariantCulture);
19
20 var error = MsiInterop.MsiOpenPackage(packagePath, out var handle);
21 if (0 != error)
22 {
23 throw new MsiException(error);
24 }
25
26 this.Handle = handle;
27 }
28
29 /// <summary>
30 /// Executes a built-in action, custom action, or user-interface wizard action.
31 /// </summary>
32 /// <param name="action">Specifies the action to execute.</param>
33 public void DoAction(string action)
34 {
35 var error = MsiInterop.MsiDoAction(this.Handle, action);
36 if (0 != error)
37 {
38 throw new MsiException(error);
39 }
40 }
41 }
42}