简体   繁体   中英

need to check already application installed or not using custom installer class

I've to create one C# setup project application, at that time while installing i also include custom actions - install to filezilla server . Before install filezilla server need to check ,if it's already installed or not, if yes means installing application alone otherwise install both application & filezilla server. is there any installer class to accomplish this event . waiting for suggestion

You could try using Microsoft.Win32 namespace for registry classes:

    string regKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
    using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(regKey))
    {
        if (key.GetSubKeyNames().Any(keyName => key.OpenSubKey(keyName).GetValue("DisplayName") == "My App's Display Name"))
            Console.WriteLine("Already installed...");
        else
            Console.WriteLine("Start installing...");
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM