Esempio n. 1
0
        public string QueryMSI(string fileLocation, string query)
        {
            string   result  = string.Empty;
            FileInfo msiFile = new FileInfo(fileLocation);

            //Hashtable msiData = new Hashtable();
            WindowsInstaller.Installer inst = (WindowsInstaller.Installer) new Installer();
            try
            {
                Database instDb            = inst.OpenDatabase(msiFile.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
                WindowsInstaller.View view = instDb.OpenView(query);
                view.Execute(null);
                Record record = view.Fetch();



                //string fileName = record.get_StringData(1);



                // record = view.Fetch();


                result = record.get_StringData(1);
                view.Close();
            }

            catch (Exception ex)
            { }

            return(result);
        }
Esempio n. 2
0
        private DataTable QueryMSIFileandVersions(string query)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Filename");
            dt.Columns.Add("Version");



            FileInfo msiFile = new FileInfo(_mSIfileLocation);

            //Hashtable msiData = new Hashtable();
            WindowsInstaller.Installer inst = (WindowsInstaller.Installer) new Installer();
            try
            {
                Database instDb            = inst.OpenDatabase(msiFile.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
                WindowsInstaller.View view = instDb.OpenView(query);
                view.Execute(null);
                Record record = view.Fetch();


                while (record != null)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = record.get_StringData(1);
                    dr[1] = record.get_StringData(2);


                    dt.Rows.Add(dr);



                    record = view.Fetch();
                }

                // close the database


                view.Close();
            }
            catch (Exception ex)
            {
            }

            return(dt);
        }
Esempio n. 3
0
        private Dictionary <string, string> QueryMSI(string query)
        {
            Dictionary <string, string> FilesAndVersion = new Dictionary <string, string>();
            FileInfo msiFile = new FileInfo(_mSIfileLocation);

            //Hashtable msiData = new Hashtable();
            WindowsInstaller.Installer inst = (WindowsInstaller.Installer) new Installer();
            try
            {
                Database instDb            = inst.OpenDatabase(msiFile.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
                WindowsInstaller.View view = instDb.OpenView(query);
                view.Execute(null);
                Record record = view.Fetch();


                while (record != null)
                {
                    //string fileName = record.get_StringData(1);



                    record = view.Fetch();
                    FilesAndVersion.Add(record.get_StringData(1), record.get_StringData(2));
                }

                // close the database


                view.Close();
            }



            catch (Exception ex)
            {
            }

            return(FilesAndVersion);
        }