943,603 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3473
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 22nd, 2009
0

how to read values from msi database?

Expand Post »
how to read values from msi database?

Thanks
Similar Threads
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 22nd, 2009
1

Re: how to read values from msi database?

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!
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
Sep 22nd, 2009
0

Re: how to read values from msi database?

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?
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 22nd, 2009
1

Re: how to read values from msi database?

Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009
Sep 22nd, 2009
0

Re: how to read values from msi database?

majestic0110, i will examine panayquil's code, then i will synthesize the knowledge and come back.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 22nd, 2009
0

Re: how to read values from msi database?

Excellent, hope it helps!
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
Sep 22nd, 2009
0

Re: how to read values from msi database?

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
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 22nd, 2009
0

Re: how to read values from msi database?

no problem, i downloaded it before you post that.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Sep 22nd, 2009
0

Re: how to read values from msi database?

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
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 23rd, 2009
1

Re: how to read values from msi database?

That MSI Analyzer is pretty cool, but here is a simplified answer I whipped up for ya:

C# Syntax (Toggle Plain Text)
  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. }

C# Syntax (Toggle Plain Text)
  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. }
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: how to set product name for windows installer through command line?
Next Thread in C# Forum Timeline: Deploy crystal report





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC