Это работает для меня:
// Open the key
HKEY hKey;
if( SUCCEEDED(::RegOpenKey( HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Mozilla\\Mozilla Firefox"), &hKey )) )
{
// Query the required buffer size for the requested value
DWORD cbData;
if( SUCCEEDED(::RegQueryValueEx( hKey, TEXT("CurrentVersion"), NULL, NULL, NULL, &cbData )) )
{
// Now that we have the size, allocate a buffer and query the value
TCHAR* buf = new TCHAR[cbData/sizeof(TCHAR)];
if( SUCCEEDED(::RegQueryValueEx( hKey, TEXT("CurrentVersion"), NULL, NULL, (LPBYTE)buf, &cbData )) )
{
::OutputDebugString( buf );
}
}
}