Hi all ,

i'm having a solution which includes a setup project too. when the user installs my program, it asks him t oinstall wamp server too. I want to have the path in which they installed the wamp server, so that i could run the MySQL files from my program (such as mysqldump).
what is the best way to have it ?
im working on VS2008.

thanks
Zvika

Recommended Answers

All 5 Replies

See if this helps.

private string WampInstallPath()
{
    Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("\\\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
    Microsoft.Win32.RegistryKey sk = null;
    string path = "";

    foreach (string subkey in rk.GetSubKeyNames())
    {
        if (subkey.ToLower().StartsWith("wamp"))
        {
            sk = rk.OpenSubKey(subkey);
            path = (string)sk.GetValue("InstallLocation");
            break;
        }
    }
    return path;
}

Hi Oxiegen,
thanks for the reply but it doesnt work
rk is null which means it cant find the registry entry. I tried to look for it manually with regedit and couldnt find it .

im on windows vista 64 bits.

maybe somewhere else ?

My bad.
I forgot to include the Software node. And I just read that registry settings for 32bit programs running on Windows x64 are stored in yet anothor subnode.

Try this path: Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("\\Software\\Microsoft\\Windows\\WOW6432node\\CurrentVersion\\Uninstall");

commented: Solved!!! +10

thanks man
the right path is
SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall

and it works

thanks again
Zvika

You're welcome.
Please mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.