Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai ALL,

I would to get a message whenever a new software is installed or any software is uninstalled. How to do this using C#. Help me through C#.
Posted
Comments
Philippe Mori 5-Sep-11 20:33pm    
Although not recommanded, you can write custom code that is run when an application is installed or uninstalled... I say not recommanded because I think that using only standard stuff help Windows to be able to handle things like restore, repair...

1 solution

Hi,
The code below display the list of current installed software, so what I would do is, make a xml record, create a function to get new list for synchronization, get the mismatch && finally detect the victim.
C#
string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using(Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
    foreach(string subkey_name in key.GetSubKeyNames())
    {
        using(RegistryKey subkey = key.OpenSubKey(subkey_name))
        {
                Console.WriteLine(subkey.GetValue("DisplayName"));
        }
    }
}

//Another way to do that:

ManagementObjectSearcher managementObjects = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach(ManagementObject managementObject in managementObjects.Get())
{
    Console.WriteLine(mo["Name"]);
}
 
Share this answer
 
Comments
sacraj 5-Sep-11 7:55am    
What you have said is correct. But I would like to get a message as soon as the software is installed or uninstalled how to do that ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900