Created
March 21, 2011 07:48
-
-
Save hanssens/879157 to your computer and use it in GitHub Desktop.
Inventorize System Software (by Registry)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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