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