To discover “Click Once” applications currently installed in a machine, below code helps to find out currently installed click once applications.
The GetInstalledClickOnceApps() method read the installed click once applications from Registry;add it to the list and return the list.
The LoadInstalledClickOnceApps() method binds installed application names and version to the list view.
The Load() method is the root method.
Code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Load();
}
///
/// Load
///
private void Load()
{
try
{
LoadInstalledClickOnceApps();
}
catch (Exception ex)
{
MessageBox.Show("Not able to load the installed click once applications!");
}
}
///
/// Bind installed application names to the VIEW
///
private void LoadInstalledClickOnceApps()
{
IDictionary iClickOnceApps = GetInstalledClickOnceApps();
foreach (KeyValuePair keyValuePair in iClickOnceApps)
{
listAppView.Items.Add(new ListViewItem(new[] { keyValuePair.Value, keyValuePair.Key }));
}
}
///
/// Read the installed click once applications from Registry;add it to the list and return the list
///
///
private IDictionary GetInstalledClickOnceApps()
{
IDictionary installedApps = new Dictionary();
RegistryKey registryKeys = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
string[] appKeyNames = registryKeys.GetSubKeyNames();
string displayName = null;
string displayVersion = null;
foreach (string appKeyName in appKeyNames)
{
RegistryKey appKey = registryKeys.OpenSubKey(appKeyName);
displayName = (string)appKey.GetValue("DisplayName");
displayVersion = (string)appKey.GetValue("DisplayVersion");
installedApps.Add(displayVersion, displayName);
appKey.Close();
}
registryKeys.Close();
return installedApps;
}
}
The GetInstalledClickOnceApps() method read the installed click once applications from Registry;add it to the list and return the list.
The LoadInstalledClickOnceApps() method binds installed application names and version to the list view.
The Load() method is the root method.
Code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Load();
}
///
/// Load
///
private void Load()
{
try
{
LoadInstalledClickOnceApps();
}
catch (Exception ex)
{
MessageBox.Show("Not able to load the installed click once applications!");
}
}
///
/// Bind installed application names to the VIEW
///
private void LoadInstalledClickOnceApps()
{
IDictionary
foreach (KeyValuePair
{
listAppView.Items.Add(new ListViewItem(new[] { keyValuePair.Value, keyValuePair.Key }));
}
}
///
/// Read the installed click once applications from Registry;add it to the list and return the list
///
///
private IDictionary
{
IDictionary
RegistryKey registryKeys = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
string[] appKeyNames = registryKeys.GetSubKeyNames();
string displayName = null;
string displayVersion = null;
foreach (string appKeyName in appKeyNames)
{
RegistryKey appKey = registryKeys.OpenSubKey(appKeyName);
displayName = (string)appKey.GetValue("DisplayName");
displayVersion = (string)appKey.GetValue("DisplayVersion");
installedApps.Add(displayVersion, displayName);
appKey.Close();
}
registryKeys.Close();
return installedApps;
}
}