i want to display that information using c#. And i will be more than happy if i can interface add/remove programs functionality from c#.
Thanks
i want to display that information using c#. And i will be more than happy if i can interface add/remove programs functionality from c#.
Thanks
Cmd options:
control appwiz.cpl,,0 // change or remove programs
control appwiz.cpl,,1 // add new programs
control appwiz.cpl,,2 // add remove windows components
control appwiz.cpl,,3 // set program access and defailts
how to access the information displayed on the Add/Remove programs in windows control.
Please correct me if I am wrong. Do you want to have a list of installed programs?
static void GetInstalled()
{
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
Console.WriteLine(sk.GetValue("DisplayName"));
}
}
}
}
Borrowed from:
http://weblogs.asp.net/rosherove/archive/2003/09/24/28864.aspx
Please correct me if I am wrong. Do you want to have a list of installed programs?
yes i want that list and further to be able to operate with add/remove programs using c#.
static void GetInstalled() { string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey)) { foreach (string skName in rk.GetSubKeyNames()) { using (RegistryKey sk = rk.OpenSubKey(skName)) { Console.WriteLine(sk.GetValue("DisplayName")); } } } }
Borrowed from:
http://weblogs.asp.net/rosherove/archive/2003/09/24/28864.aspx
So add/remove programs bases its knowledge on windows registry? is it that easy? no other internal workings?
Cmd options:
control appwiz.cpl,,0 // change or remove programs
control appwiz.cpl,,1 // add new programs
control appwiz.cpl,,2 // add remove windows components
control appwiz.cpl,,3 // set program access and defailts
please give me some c# code sample even pseudocode.
>> So add/remove programs bases its knowledge on windows registry? is it that easy? no other internal workings?
More or less. The registry might point to a manifest of files depending on the type of installer used so it will know how to clean itself up.
Scott if you put that code in to a sample project and attach, i will mark this thread as solved :)
Haha -- why do you want me to do that? :)
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 SERKAN.THE.MAN
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Lines = GetInstalled();
}
public static string[] GetInstalled()
{
List<string> result = new List<string>();
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
string prog = Convert.ToString(sk.GetValue("DisplayName"));
if (!string.IsNullOrEmpty(prog))
result.Add(prog);
}
}
}
return result.ToArray();
}
}
}
please give me some c# code sample even pseudocode.
Those are options for launching a separate appwiz process with the selected option. To launch the process:
Process appwiz = new Process();
appwiz.StartInfo.FileName = "control";
appwiz.StartInfo.Arguments = "appwiz.cpl,,0";// change or remove program option
appwiz.Start();
Thanks Scott, but it seems that it doesnt show all the programs that are installed. I think registry information is not enough or we need to grab some more information from other folders under registry.
Ideas?
Sorry, I thought you were interested also in calling the wizard with that option. Information to build that list from the registry is easily obtained on the web, but I could not find any C# API to execute any commands.
Cheers!
Thanks Scott, but it seems that it doesnt show all the programs that are installed. I think registry information is not enough or we need to grab some more information from other folders under registry.
Ideas?
This may or may not apply in your case, and you may wish to browse your registry to see first. Anyway, I ran into this additional key while browsing this topic and figured I would pass it on:
The (code) appeared to only get about half of the applications that I have installed on my Vista Ultimate 64-bit development box. After some poking around the registry, I discovered that the half that it got were all the 64-bit applications and that the 32-bit applications were hiding under SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall.
Sorry, I thought you were interested also in calling the wizard with that option. Information to build that list from the registry is easily obtained on the web, but I could not find any C# API to execute any commands.
Cheers!
That's fine, i asked for any ideas. i dont prefer one way to another if i dont have enough information about that subject. So i may even go your way. I work asynchronously, sometimes it takes a month for me to mark a thread as solved but for sure i turn to that thread back if i started it.
This may or may not apply in your case, and you may wish to browse your registry to see first. Anyway, I ran into this additional key while browsing this topic and figured I would pass it on:
I would ++rep you if Daniweb would allow it. I didn't realise it split up 64 bit applications. I live in a 32bit world :(
I would ++rep you if Daniweb would allow it. I didn't realise it split up 64 bit applications. I live in a 32bit world :(
Yea, I'm 32 bit too, but I did notice that Serkan is running Vista in another thread, so maybe it will help. Cheers!
I would ++rep you if Daniweb would allow it. I didn't realise it split up 64 bit applications. I live in a 32bit world :(
if you cant ++rep him, you are always welcomed to ++rep me :)
I would also like to point out that the code sknake posted is a "per machine" list of installed programs, some programs are installed on a "user" level and would not appear in this list.
also most MSI installed applications won't appear in this list either. I am not sure where they are all stored. But this method is no longer considered a solution.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.