// 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); } } } }