Location of third party application install location in .msi project in MSVS

Context: I have several plugins (which are actually just DLLs with a different extension) that need to be installed in a subfolder of a third party application. Usually it is enough to just copy them to the specified folder, but sometimes there are other libraries that need to be installed as well. I would like to make this process less error prone for users, so I looked into using a setup project in visual studio to generate the .msi, but I was having trouble setting the install location correctly.

It looks like it assumes the installer is for a complete application and defaults to a location like C: \ Program Files \ MyApp \, but I really need C: \ Program Files \\ Plugins. I would rather not assume that the user has a third party application installed in any particular location, so I would like to find a way to find where this other application was installed. I have searched the Microsoft documentation and experimented a bit on my own, but with no success.

Assuming this is possible, does anyone know how to accomplish what I want?

0


a source to share


2 answers


Most applications will write their installation location somewhere in the registry. We read the values ​​in the next registry key to find where Microsoft Word was installed.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe]

      



Unfortunately, there is no standard way to get the installation location of a particular application. You will have to search the registry to find what you want.

0


a source


If your application was using Windows Installer, you can try this method (C #):



    Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer");
    Installer msi = (Installer)Activator.CreateInstance(type);
    foreach (string productcode in msi.Products)
    {
        string productname = msi.get_ProductInfo(productcode, "InstalledProductName");
        if (productname.Contains("<YOUR PRODUCT NAME HERE>"))
        {
            string installdir = msi.get_ProductInfo(productcode, "InstallLocation");
            Console.WriteLine("{0}: {1} @({2})", productcode, productname, installdir);
        }
    }

      

0


a source







All Articles