예제 #1
0
        /// <summary>
        /// Extacts the patch metadata as XML.
        /// </summary>
        /// <param name="path">Path to patch.</param>
        /// <returns>String XML.</returns>
        public static string ExtractPatchXml(string path)
        {
            var buffer = new StringBuilder(65535);
            var size   = buffer.Capacity;

            var error = MsiInterop.MsiExtractPatchXMLData(path, 0, buffer, ref size);

            if (234 == error)
            {
                buffer.EnsureCapacity(++size);
                error = MsiInterop.MsiExtractPatchXMLData(path, 0, buffer, ref size);
            }

            if (error != 0)
            {
                throw new MsiException(error);
            }

            return(buffer.ToString());
        }
예제 #2
0
        private void GetSummaryInformationValue(int index, out uint dataType, out int intValue, out StringBuilder stringValue, out FILETIME timeValue)
        {
            var bufSize = 64;

            stringValue = new StringBuilder(bufSize);
            timeValue.dwHighDateTime = 0;
            timeValue.dwLowDateTime  = 0;

            var error = MsiInterop.MsiSummaryInfoGetProperty(this.Handle, index, out dataType, out intValue, ref timeValue, stringValue, ref bufSize);

            if (234 == error)
            {
                stringValue.EnsureCapacity(++bufSize);
                error = MsiInterop.MsiSummaryInfoGetProperty(this.Handle, index, out dataType, out intValue, ref timeValue, stringValue, ref bufSize);
            }

            if (0 != error)
            {
                throw new MsiException(error);
            }
        }
예제 #3
0
        /// <summary>
        /// Takes the path to a file and returns a 128-bit hash of that file.
        /// </summary>
        /// <param name="filePath">Path to file that is to be hashed.</param>
        /// <param name="options">The value in this column must be 0. This parameter is reserved for future use.</param>
        /// <param name="hash">Int array that receives the returned file hash information.</param>
        public static void GetFileHash(string filePath, int options, out int[] hash)
        {
            var hashInterop = new MSIFILEHASHINFO();

            hashInterop.FileHashInfoSize = 20;

            var error = MsiInterop.MsiGetFileHash(filePath, Convert.ToUInt32(options), hashInterop);

            if (0 != error)
            {
                throw new MsiException(error);
            }

            Debug.Assert(20 == hashInterop.FileHashInfoSize);

            hash    = new int[4];
            hash[0] = hashInterop.Data0;
            hash[1] = hashInterop.Data1;
            hash[2] = hashInterop.Data2;
            hash[3] = hashInterop.Data3;
        }
예제 #4
0
        /// <summary>
        /// Constructor that creates a view given a database handle and a query.
        /// </summary>
        /// <param name="db">Handle to the database to run the query on.</param>
        /// <param name="query">Query to be executed.</param>
        public View(Database db, string query)
        {
            if (null == db)
            {
                throw new ArgumentNullException(nameof(db));
            }

            if (null == query)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var error = MsiInterop.MsiDatabaseOpenView(db.Handle, query, out var handle);

            if (0 != error)
            {
                throw new MsiException(error);
            }

            this.Handle = handle;
        }
예제 #5
0
 /// <summary>
 /// Verifies the existence or absence of a table.
 /// </summary>
 /// <param name="tableName">Table name to to verify the existence of.</param>
 /// <returns>Returns true if the table exists, false if it does not.</returns>
 public bool TableExists(string tableName)
 {
     var result = MsiInterop.MsiDatabaseIsTablePersistent(this.Handle, tableName);
     return MsiInterop.MSICONDITIONTRUE == result;
 }
예제 #6
0
 /// <summary>
 /// Enables the installer's internal user interface.
 /// </summary>
 /// <param name="uiLevel">Specifies the level of complexity of the user interface.</param>
 /// <param name="hwnd">Pointer to a window. This window becomes the owner of any user interface created.</param>
 /// <returns>The previous user interface level is returned. If an invalid dwUILevel is passed, then INSTALLUILEVEL_NOCHANGE is returned.</returns>
 public static int SetInternalUI(int uiLevel, ref IntPtr hwnd)
 {
     return(MsiInterop.MsiSetInternalUI(uiLevel, ref hwnd));
 }
예제 #7
0
 /// <summary>
 /// Enables an external user-interface handler.
 /// </summary>
 /// <param name="installUIHandler">Specifies a callback function.</param>
 /// <param name="messageFilter">Specifies which messages to handle using the external message handler.</param>
 /// <param name="context">Pointer to an application context that is passed to the callback function.</param>
 /// <returns>The return value is the previously set external handler, or null if there was no previously set handler.</returns>
 public static InstallUIHandler SetExternalUI(InstallUIHandler installUIHandler, int messageFilter, IntPtr context)
 {
     return(MsiInterop.MsiSetExternalUI(installUIHandler, messageFilter, context));
 }