0

This question already has an answer here:

I'm trying to open installed softwares with their names

I use this codes below to open them but it doesn't detect all installed softwares.

Process proc = new Process();
                    proc.EnableRaisingEvents = false;
                    proc.StartInfo.FileName = progName;
                    proc.Start();

Is there any way detect and open all of them with their names?

progName

is a string that changes with input.


  • I'm not sure I see the link between finding all installed applications and trying to launch a process. What is progName? What exactly are you trying to do? - sab669
  • progName is a string that changes with input. I'm trying to open the software I write. It's working with some the softwares like firefox, chrome but not all - J.Bourne
  • Sounds like it's more of an issue with how your operating system associates applications and file types. If you have some random proprietary format and the application which opens it doesn't have the ability to accept a file to open then there's not much you can do. For example, you could do Process.Start("notepad++.exe", someFilePath); only because n++ offers that functionality. If you write a custom win forms application which allows dragging and dropping of text files into a textbox for display, Process.Start("myApplication.exe", someFilePath); won't do much of anything. - sab669

1 답변


0

You can try with this method:

using Microsoft.Win32;

public List<string> GetAllInstalledPrograms()
    {
        List<string> res = new List<string>();

        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))
                {
                    res.Add(subkey.GetValue("DisplayName").ToString());
                }
            }
        }

        return res;
    }

Linked


Related

Latest