By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,012 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,012 IT Pros & Developers. It's quick & easy.

Getting a list of installed programs on windows using C#

P: n/a
Hi

I need some help here. I would appreciate it if any one can help me. My
2 questions is this:

1. How do you get a list of installed applications on Windows?
2. How do I get a program's description from a exe?
(Example - sqlservr.exe = Microsoft SQL Server 2000)

I am using C# with Visual Studio .net 2003. Thanks in advance...
Paul Horn
Pretoria
South Africa

Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
While not exactly programmatic, I’d suggest looking into Belarc Advisor
(http://www.belarc.com/free_download.html).

Brendan
"Paul Horn" wrote:
Hi

I need some help here. I would appreciate it if any one can help me. My
2 questions is this:

1. How do you get a list of installed applications on Windows?
2. How do I get a program's description from a exe?
(Example - sqlservr.exe = Microsoft SQL Server 2000)

I am using C# with Visual Studio .net 2003. Thanks in advance...
Paul Horn
Pretoria
South Africa

Nov 17 '05 #2

P: n/a
Try,
Microsoft.Win32.RegistryKey subKey1 =
regKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\C urrentVersion\\Uninstall");
string[] subKeyNames = subKey1.GetSubKeyNames();

foreach (string subKeyName in subKeyNames)
{
Microsoft.Win32.RegistryKey subKey2 = subKey1.OpenSubKey(subKeyName);

if (ValueNameExists(subKey2.GetValueNames(), "DisplayName") &&
ValueNameExists(subKey2.GetValueNames(), "DisplayVersion"))
{
listViewApps.Items.Add(new ListViewItem(new string[]{
subKey2.GetValue("DisplayName").ToString(),
subKey2.GetValue("DisplayVersion").ToString() }));
}

subKey2.Close();
}

subKey1.Close();

and...

private bool ValueNameExists(string[] valueNames, string valueName)
{
foreach (string s in valueNames)
{
if (s.ToLower() == valueName.ToLower()) return true;
}

return false;
}

Regards,
Phil.

"Paul Horn" wrote:
Hi

I need some help here. I would appreciate it if any one can help me. My
2 questions is this:

1. How do you get a list of installed applications on Windows?
2. How do I get a program's description from a exe?
(Example - sqlservr.exe = Microsoft SQL Server 2000)

I am using C# with Visual Studio .net 2003. Thanks in advance...
Paul Horn
Pretoria
South Africa

Nov 17 '05 #3

P: n/a
Forgot about the file description.

Try,

System.Diagnostics.FileVersionInfo fileVersionInfo =
System.Diagnostics.FileVersionInfo.GetVersionInfo( fileName);
string fileDescription = fileVersionInfo.FileDescription;

Regards,
Phil.

"Paul Horn" wrote:
Hi

I need some help here. I would appreciate it if any one can help me. My
2 questions is this:

1. How do you get a list of installed applications on Windows?
2. How do I get a program's description from a exe?
(Example - sqlservr.exe = Microsoft SQL Server 2000)

I am using C# with Visual Studio .net 2003. Thanks in advance...
Paul Horn
Pretoria
South Africa

Nov 17 '05 #4

P: n/a
Forgot to add this line at the beginning

Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine;

Regards,
Phil.

"Phil Williams" wrote:
Try,
Microsoft.Win32.RegistryKey subKey1 =
regKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\C urrentVersion\\Uninstall");
string[] subKeyNames = subKey1.GetSubKeyNames();

foreach (string subKeyName in subKeyNames)
{
Microsoft.Win32.RegistryKey subKey2 = subKey1.OpenSubKey(subKeyName);

if (ValueNameExists(subKey2.GetValueNames(), "DisplayName") &&
ValueNameExists(subKey2.GetValueNames(), "DisplayVersion"))
{
listViewApps.Items.Add(new ListViewItem(new string[]{
subKey2.GetValue("DisplayName").ToString(),
subKey2.GetValue("DisplayVersion").ToString() }));
}

subKey2.Close();
}

subKey1.Close();

and...

private bool ValueNameExists(string[] valueNames, string valueName)
{
foreach (string s in valueNames)
{
if (s.ToLower() == valueName.ToLower()) return true;
}

return false;
}

Regards,
Phil.

"Paul Horn" wrote:
Hi

I need some help here. I would appreciate it if any one can help me. My
2 questions is this:

1. How do you get a list of installed applications on Windows?
2. How do I get a program's description from a exe?
(Example - sqlservr.exe = Microsoft SQL Server 2000)

I am using C# with Visual Studio .net 2003. Thanks in advance...
Paul Horn
Pretoria
South Africa

Nov 17 '05 #5

P: n/a
Thanx Phil, I will have a look.

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.