From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- .../Msi/Session.cs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/WixToolset.Core.WindowsInstaller/Msi/Session.cs (limited to 'src/WixToolset.Core.WindowsInstaller/Msi/Session.cs') 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 @@ +// 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. + +namespace WixToolset.Msi +{ + using System; + using System.ComponentModel; + using System.Globalization; + using WixToolset.Core.Native; + + /// + /// Controls the installation process. + /// + internal sealed class Session : MsiHandle + { + /// + /// Instantiate a new Session. + /// + /// The database to open. + public Session(Database database) + { + string packagePath = String.Format(CultureInfo.InvariantCulture, "#{0}", (uint)database.Handle); + + uint handle = 0; + int error = MsiInterop.MsiOpenPackage(packagePath, out handle); + if (0 != error) + { + throw new MsiException(error); + } + this.Handle = handle; + } + + /// + /// Executes a built-in action, custom action, or user-interface wizard action. + /// + /// Specifies the action to execute. + public void DoAction(string action) + { + int error = MsiInterop.MsiDoAction(this.Handle, action); + if (0 != error) + { + throw new MsiException(error); + } + } + } +} -- cgit v1.2.3-55-g6feb