| | |
how to read values from msi database?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Hi Serkan Sendur, I hope you are well. Reading data from a .msi file is not something I have done myself before but I did some research for you and came up with this :
http://rongchaua.net/blog/c-how-to-r...from-msi-file/
I hope this helps!
http://rongchaua.net/blog/c-how-to-r...from-msi-file/
I hope this helps!
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
•
•
Join Date: Jul 2009
Posts: 921
Reputation:
Solved Threads: 147
Really?
Reading Data from MSI Database
Sorry buddy--I didn't realize it was C++. I can probably translate for you though if you need it.
Reading Data from MSI Database
Sorry buddy--I didn't realize it was C++. I can probably translate for you though if you need it.
Last edited by DdoubleD; Sep 22nd, 2009 at 6:27 pm. Reason: whoops
•
•
Join Date: Jul 2009
Posts: 921
Reputation:
Solved Threads: 147
Scratch that last reply--I couldn't even get it to compile. Here is a link that I compiled and played with a little: MSI Analyzer
•
•
Join Date: Jul 2009
Posts: 921
Reputation:
Solved Threads: 147
That MSI Analyzer is pretty cool, but here is a simplified answer I whipped up for ya:
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; // Deploying a .NET component customization using WindowsInstaller; using System.IO; using System.Collections; namespace MSIDataBaseStuff { public partial class Form1 : Form { [System.Runtime.InteropServices.ComImport(), System.Runtime.InteropServices.Guid ("000C1090-0000-0000-C000-000000000046")] class Installer { } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { FileInfo msiFile = new FileInfo("setup1.msi"); // open MSI database WindowsInstaller.Installer inst = (WindowsInstaller.Installer)new Installer(); Database instDb = inst.OpenDatabase(msiFile.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly); // query the database WindowsInstaller.View view = instDb.OpenView ("Select `Property`,`Value` FROM `Property`"); view.Execute(null); //fetch each record... Record record = view.Fetch(); while (record != null) { int iRow = dataGridView1.Rows.Add(); dataGridView1.Rows[iRow].Cells[0].Value = record.get_StringData(1);// property dataGridView1.Rows[iRow].Cells[1].Value = record.get_StringData(2);// value record = view.Fetch(); } // close the database view.Close(); } } }
C# Syntax (Toggle Plain Text)
partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Property = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Value = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // dataGridView1 // this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Property, this.Value}); this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.Location = new System.Drawing.Point(0, 0); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Size = new System.Drawing.Size(761, 350); this.dataGridView1.TabIndex = 0; // // Property // this.Property.HeaderText = "Property"; this.Property.Name = "Property"; this.Property.Width = 200; // // Value // this.Value.HeaderText = "Value"; this.Value.Name = "Value"; this.Value.Width = 700; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(761, 350); this.Controls.Add(this.dataGridView1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridViewTextBoxColumn Property; private System.Windows.Forms.DataGridViewTextBoxColumn Value; } }
![]() |
Similar Threads
- Read values of checkbox into an array and display the values (JavaScript / DHTML / AJAX)
- how to read form element values (JavaScript / DHTML / AJAX)
- checking if same values exist in the database and generating reports (VB.NET)
- Reading an Access Database (VB.NET)
- problem in accessin table values from access database.. (Java)
- insert values to mysql database (JSP)
- Import excel records into ASP database (ASP)
- How to store in to Database (VB.NET)
Other Threads in the C# Forum
- Previous Thread: how to set product name for windows installer through command line?
- Next Thread: Deploy crystal report
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart basic bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees deserialized design development draganddrop drawing encryption enum event excel file filename files foreach form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string system.servicemodel table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






