BhrKamal
BhrKamal

Reputation:

How to get the install directory from registryusing win32 API

I am using RegOpenKeyEx() and giving registry path Software\\Mozilla\\Mozilla Firefox ,its giving error_sucess.

But after that how can I get the install directory Data of Mozilla Firefox from that path using RegQueryValueEx()?

Upvotes: 0

Views: 1682

Answers (1)

Kim Gräsman
Kim Gräsman

Reputation: 7586

First you need to open Software\Mozilla\Mozilla Firefox and query the CurrentVersion value for the current active version.

Then, open Software\Mozilla\Mozilla Firefox\\Main and query its Install Directory value.

RegQueryValueEx is used like so;

TCHAR buffer[1024] = {0};
DWORD bufferSize = sizeof(buffer);
DWORD result = RegQueryValueEx( hkeyMain,
                         TEXT("Install Directory"),
                         NULL,
                         NULL,
                         (LPBYTE)buffer,
                         &bufferSize);
if (result == ERROR_SUCCESS)
{
    // buffer now contains the install directory
}

Upvotes: 2

Related Questions