how to read values from msi database?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

how to read values from msi database?

 
0
  #1
Sep 22nd, 2009
how to read values from msi database?

Thanks
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,293
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: how to read values from msi database?

 
1
  #2
Sep 22nd, 2009
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!
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!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: how to read values from msi database?

 
0
  #3
Sep 22nd, 2009
Thanks,
i looked at that code but
Database dbMsiFile = new Database(strFileMsi, OpenDatabase.ReadOnly);
even in that code it is not a defined type, what is that Database class?
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 114
Reputation: papanyquiL is on a distinguished road 
Solved Threads: 11
papanyquiL papanyquiL is offline Offline
Junior Poster

Re: how to read values from msi database?

 
1
  #4
Sep 22nd, 2009
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: how to read values from msi database?

 
0
  #5
Sep 22nd, 2009
majestic0110, i will examine panayquil's code, then i will synthesize the knowledge and come back.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,293
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: how to read values from msi database?

 
0
  #6
Sep 22nd, 2009
Excellent, hope it 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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 921
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 147
DdoubleD DdoubleD is offline Offline
Posting Shark

Re: how to read values from msi database?

 
0
  #7
Sep 22nd, 2009
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.
Last edited by DdoubleD; Sep 22nd, 2009 at 6:27 pm. Reason: whoops
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: how to read values from msi database?

 
0
  #8
Sep 22nd, 2009
no problem, i downloaded it before you post that.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 921
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 147
DdoubleD DdoubleD is offline Offline
Posting Shark

Re: how to read values from msi database?

 
0
  #9
Sep 22nd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 921
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 147
DdoubleD DdoubleD is offline Offline
Posting Shark

Re: how to read values from msi database?

 
1
  #10
Sep 23rd, 2009
That MSI Analyzer is pretty cool, but here is a simplified answer I whipped up for ya:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Runtime.InteropServices; // Deploying a .NET component customization
  10. using WindowsInstaller;
  11. using System.IO;
  12. using System.Collections;
  13.  
  14. namespace MSIDataBaseStuff
  15. {
  16. public partial class Form1 : Form
  17. {
  18. [System.Runtime.InteropServices.ComImport(),
  19. System.Runtime.InteropServices.Guid
  20. ("000C1090-0000-0000-C000-000000000046")]
  21. class Installer { }
  22.  
  23. public Form1()
  24. {
  25. InitializeComponent();
  26. }
  27.  
  28. private void Form1_Load(object sender, EventArgs e)
  29. {
  30. FileInfo msiFile = new FileInfo("setup1.msi");
  31.  
  32. // open MSI database
  33. WindowsInstaller.Installer inst = (WindowsInstaller.Installer)new Installer();
  34. Database instDb = inst.OpenDatabase(msiFile.FullName,
  35. WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);
  36.  
  37. // query the database
  38. WindowsInstaller.View view = instDb.OpenView
  39. ("Select `Property`,`Value` FROM `Property`");
  40. view.Execute(null);
  41.  
  42. //fetch each record...
  43. Record record = view.Fetch();
  44. while (record != null)
  45. {
  46. int iRow = dataGridView1.Rows.Add();
  47. dataGridView1.Rows[iRow].Cells[0].Value = record.get_StringData(1);// property
  48. dataGridView1.Rows[iRow].Cells[1].Value = record.get_StringData(2);// value
  49.  
  50. record = view.Fetch();
  51. }
  52.  
  53. // close the database
  54. view.Close();
  55. }
  56. }
  57. }

  1. partial class Form1
  2. {
  3. /// <summary>
  4. /// Required designer variable.
  5. /// </summary>
  6. private System.ComponentModel.IContainer components = null;
  7.  
  8. /// <summary>
  9. /// Clean up any resources being used.
  10. /// </summary>
  11. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  12. protected override void Dispose(bool disposing)
  13. {
  14. if (disposing && (components != null))
  15. {
  16. components.Dispose();
  17. }
  18. base.Dispose(disposing);
  19. }
  20.  
  21. #region Windows Form Designer generated code
  22.  
  23. /// <summary>
  24. /// Required method for Designer support - do not modify
  25. /// the contents of this method with the code editor.
  26. /// </summary>
  27. private void InitializeComponent()
  28. {
  29. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  30. this.Property = new System.Windows.Forms.DataGridViewTextBoxColumn();
  31. this.Value = new System.Windows.Forms.DataGridViewTextBoxColumn();
  32. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  33. this.SuspendLayout();
  34. //
  35. // dataGridView1
  36. //
  37. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  38. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  39. this.Property,
  40. this.Value});
  41. this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
  42. this.dataGridView1.Location = new System.Drawing.Point(0, 0);
  43. this.dataGridView1.Name = "dataGridView1";
  44. this.dataGridView1.Size = new System.Drawing.Size(761, 350);
  45. this.dataGridView1.TabIndex = 0;
  46. //
  47. // Property
  48. //
  49. this.Property.HeaderText = "Property";
  50. this.Property.Name = "Property";
  51. this.Property.Width = 200;
  52. //
  53. // Value
  54. //
  55. this.Value.HeaderText = "Value";
  56. this.Value.Name = "Value";
  57. this.Value.Width = 700;
  58. //
  59. // Form1
  60. //
  61. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  62. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  63. this.ClientSize = new System.Drawing.Size(761, 350);
  64. this.Controls.Add(this.dataGridView1);
  65. this.Name = "Form1";
  66. this.Text = "Form1";
  67. this.Load += new System.EventHandler(this.Form1_Load);
  68. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  69. this.ResumeLayout(false);
  70.  
  71. }
  72.  
  73. #endregion
  74.  
  75. private System.Windows.Forms.DataGridView dataGridView1;
  76. private System.Windows.Forms.DataGridViewTextBoxColumn Property;
  77. private System.Windows.Forms.DataGridViewTextBoxColumn Value;
  78. }
  79. }
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC