Пример #1
0
        /// <summary>
        /// Get stream at specified location.
        /// </summary>
        /// <param name="field">Index into record to get stream.</param>
        /// <param name="buffer">buffer to receive bytes from stream.</param>
        /// <param name="requestedBufferSize">Buffer size to read.</param>
        /// <returns>Stream read into string.</returns>
        public int GetStream(int field, byte[] buffer, int requestedBufferSize)
        {
            int bufferSize = 255;

            if (requestedBufferSize > 0)
            {
                bufferSize = requestedBufferSize;
            }

            int error = MsiInterop.MsiRecordReadStream(this.Handle, field, buffer, ref bufferSize);

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

            return(bufferSize);
        }
Пример #2
0
        /// <summary>
        /// Gets string value at specified location.
        /// </summary>
        /// <param name="field">Index into record to get string.</param>
        /// <returns>String value</returns>
        public string GetString(int field)
        {
            int           bufferSize = 255;
            StringBuilder buffer     = new StringBuilder(bufferSize);
            int           error      = MsiInterop.MsiRecordGetString(this.Handle, field, buffer, ref bufferSize);

            if (234 == error)
            {
                buffer.EnsureCapacity(++bufferSize);
                error = MsiInterop.MsiRecordGetString(this.Handle, field, buffer, ref bufferSize);
            }

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

            return(0 < buffer.Length ? buffer.ToString() : null);
        }
Пример #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>
        internal static void GetFileHash(string filePath, int options, out int[] hash)
        {
            MSIFILEHASHINFO hashInterop = new MSIFILEHASHINFO();

            hashInterop.FileHashInfoSize = 20;

            int 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("db");
            }

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

            uint handle = 0;

            int error = MsiInterop.MsiDatabaseOpenView(db.Handle, query, out 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)
        {
            int result = MsiInterop.MsiDatabaseIsTablePersistent(this.Handle, tableName);

            return(MsiInterop.MSICONDITIONTRUE == result);
        }
Пример #6
0
 /// <summary>
 /// Gets integer value at specified location.
 /// </summary>
 /// <param name="field">Index into record to get integer</param>
 /// <returns>Integer value</returns>
 public int GetInteger(int field)
 {
     return(MsiInterop.MsiRecordGetInteger(this.Handle, field));
 }
Пример #7
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>
 internal static int SetInternalUI(int uiLevel, ref IntPtr hwnd)
 {
     return(MsiInterop.MsiSetInternalUI(uiLevel, ref hwnd));
 }
Пример #8
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>
 internal static InstallUIHandler SetExternalUI(InstallUIHandler installUIHandler, int messageFilter, IntPtr context)
 {
     return(MsiInterop.MsiSetExternalUI(installUIHandler, messageFilter, context));
 }