Skip to content

Instantly share code, notes, and snippets.

@hanssens
Created March 21, 2011 07:48
Show Gist options
  • Save hanssens/879157 to your computer and use it in GitHub Desktop.
Save hanssens/879157 to your computer and use it in GitHub Desktop.
Inventorize System Software (by Registry)
protected void Inventorize()
{
// Generate a container:
DataTable dtResult = new DataTable();
dtResult.Columns.Add("DisplayName");
dtResult.Columns.Add("DisplayVersion");
dtResult.Columns.Add("Publisher");
#region -- RxOps --
string keyUninstall = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey rk = Registry.LocalMachine.OpenSubKey(keyUninstall, false);
RegistryKey sk;
List<string> listOfSubKeys = rk.GetSubKeyNames().ToList();
for (int i = 0; i < listOfSubKeys.Count; i++)
{
sk = rk.OpenSubKey(listOfSubKeys[i]);
if (sk.GetValue("DisplayName") != null)
{
DataRow newRow = dtResult.NewRow();
newRow["DisplayName"] = sk.GetValue("DisplayName");
newRow["DisplayVersion"] = sk.GetValue("DisplayVersion");
newRow["Publisher"] = sk.GetValue("Publisher");
dtResult.Rows.Add(newRow);
}
}
#endregion
// Set databinding:
this.gridInventory.SetDataBinding(dtResult, string.Empty);
this.gridInventory.RetrieveStructure();
// Grouping:
this.gridInventory.RootTable.Groups.Add("Publisher", Janus.Windows.GridEX.SortOrder.Ascending);
this.gridInventory.CollapseGroups();
//this.gridInventory.DataSource = listResults;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment