Hi Friends, Today I will be explain that how to get all
software information from a computer system thorough windows application. I have
already explained about how we can get all audio & video devices on a
machine using windows application.
First, we will be adding a new form to our visual studio and
put a listview name listView1 on this from by dragging to toolbox. After getting
the software information we will be bind all information to this listview for display.
These are the some namespace, that will be used-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
We will be use using Microsoft.Win32; namespace.
The Microsoft.Win32 namespace provides two types of
classes: those that handle events raised by the operating system and those that
manipulate the system registry.
//..........this is the method for get
the all software information
private void
GetServerInfo()
{
listView1.View = View.Details;
// progressBar1.Minimum = 0;
string Software = null;
//The registry key:
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey
rk = Registry.LocalMachine.OpenSubKey(SoftwareKey))
{
//Let's go through the registry keys and get
the info we need:
foreach (string
skName in rk.GetSubKeyNames())
{
using (RegistryKey
sk = rk.OpenSubKey(skName))
{
try
{
Software =
sk.GetValue("DisplayName").ToString();
listView1.Items.Add(Software);
list.Add(Software);
//If the key has value, continue, if not, skip it:
if (!(sk.GetValue("DisplayName")
== null))
{
//Is the install location known?
if (sk.GetValue("InstallLocation")
== null)
Software +=
sk.GetValue("DisplayName");
else
Software +=
sk.GetValue("DisplayName");
}
}
catch (Exception ex)
{
//No, that exception is not getting away... :P
}
}
}
}
}
This is the snapshot for the software information.
No comments:
Post a Comment