wchar_t buffer[MAX_PATH];
wchar_t* szValueName;
wchar_t* SubKeyName;
wchar_t* installPath;
HKEY hKey;
DWORD dwBufLen;
LONG lret;
HRESULT hr = E_FAIL;
DWORD* reservedNULL = NULL;
DWORD reservedZero = 0;
szValueName = L"Path";
SubKeyName = L"SOFTWARE\\7-Zip";
lret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
SubKeyName,
reservedZero,
KEY_READ,
&hKey);
if (lret == ERROR_SUCCESS)
{
dwBufLen = MAX_PATH;
lret = RegQueryValueEx(hKey,
szValueName,
reservedNULL,
NULL,
(BYTE*)buffer,
&dwBufLen);
if (lret == ERROR_SUCCESS)
{
installPath = buffer;
hr = S_OK;
} RegCloseKey(hKey);
}