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 Microsoft.Win32; namespace WindowsFormsApplicationTest2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string DispalyName = null; string RegistryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\UnInstall"; DataTable dt = new DataTable(); dt.Columns.Add("Software Name", typeof(string)); dt.Columns.Add("Software Version", typeof(string)); dt.Columns.Add("Software Publicher", typeof(string)); DataRow dr = null; using (RegistryKey RegistryKey1 = Registry.LocalMachine.OpenSubKey(RegistryKey)) { if (RegistryKey1 != null) { foreach (var varName in RegistryKey1.GetSubKeyNames()) { using (RegistryKey RegisteyKey2 = RegistryKey1.OpenSubKey(varName)) { if (RegisteyKey2 != null) { DispalyName = Convert.ToString(RegisteyKey2.GetValue("DispalyName")); //if (DispalyName.Equals("")) //{ // continue; //} //else //{ dr = dt.NewRow(); dr[0] = (string)RegisteyKey2.GetValue("DispalyName"); if (RegisteyKey2.GetValue("DispalyVersion") == null || RegisteyKey2.GetValue("DispalyVersion")=="") dr[1] = ""; else dr[1] = (string)RegisteyKey2.GetValue("DispalyVersion"); dr[2] = (string)RegisteyKey2.GetValue("Publisher"); dt.Rows.Add(dr); //} } } } } } GridSoftware .Columns .Clear (); GridSoftware .DataSource =dt; } private void Form1_Load(object sender, EventArgs e) { } } }
dt.Rows.Add(dr);
dt.Rows.Add(drstring1,drstring2,drstring3);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)