Nikhil K S
Nikhil K S

Reputation: 804

How to check other software is installed when installing my software

I want to create a setup to deploy software.My first window of installation is to check master software(other software) is installed in that computer,because i need to add a supporting file to master software's installation folder.

Is that possible in visual studio setup deployment project?

Upvotes: 0

Views: 351

Answers (2)

Nikhil K S
Nikhil K S

Reputation: 804

Below code is working fine for me

    /// <summary>
    /// To check software installed or not
    /// </summary>
    /// <param name="controlPanelDisplayName">Display name of software from control panel</param>
    private static bool IsApplictionInstalled(string controlPanelDisplayName)
    {
        string displayName;
        RegistryKey key;

        // search in: CurrentUser
        key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
        if (null != key)
        {
            foreach (string keyName in key.GetSubKeyNames())
            {
                RegistryKey subkey = key.OpenSubKey(keyName);
                displayName = subkey.GetValue("DisplayName") as string;
                if (controlPanelDisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
                {
                    return true;
                }
            }
        }

        // search in: LocalMachine_32
        key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
        if (null != key)
        {
            foreach (string keyName in key.GetSubKeyNames())
            {
                RegistryKey subkey = key.OpenSubKey(keyName);
                displayName = subkey.GetValue("DisplayName") as string;
                if (controlPanelDisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
                {
                    return true;
                }
            }
        }
        // search in: LocalMachine_64
        key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
        if (null != key)
        {
            foreach (string keyName in key.GetSubKeyNames())
            {
                RegistryKey subkey = key.OpenSubKey(keyName);
                displayName = subkey.GetValue("DisplayName") as string;
                if (controlPanelDisplayName.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
                {
                    return true;
                }
            }
        }
        // NOT FOUND
        return false;
    }

Upvotes: 1

jiten
jiten

Reputation: 5264

Every software you install, must create entry in Registry.So you can read the particular entry in registry from Visual studio Setup project.

Retrieve a Value from the Registry

how to retrieve the MediaPath value for your computer from the registry,

The MediaPath value for your computer is located under the following registry subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion You can retrieve this value by using a launch condition. To do this, follow these steps:

  • In Visual Studio .NET, point to Editor on the View menu, and then click Launch Conditions.
  • In the Launch Conditions Editor, click Search Target Machine.
  • On the Action menu, click Add Registry Search.

By default, Search for RegistryEntry1 is added.

  • On the View menu, click Properties Window to select the Properties window for the registry search that you created in previous step.
  • Change the Name property value to Search for MediaPath.
  • Change the Property property value to MEDIA_PATH.

When you run the setup project, the MediaPath registry value is retrieved to your MEDIA_PATH property.

  • To search HKEY_LOCAL_MACHINE in the registry, click the Root property, and then click vsdrrHKLM in the drop-down list box for the property value.
  • To search the SOFTWARE\Microsoft\Windows\CurrentVersion subkey, type SOFTWARE\Microsoft\Windows\CurrentVersion in the RegKey property value text box.
  • To search for the MediaPath value, type MediaPath in the Value property value text box.

For More See Hare

Upvotes: 1

Related Questions