static TArray CollectPathsFromRegistry()

in Source/RiderSourceCodeAccess/Private/RiderPathLocator/Win/RiderPathLocatorWin.cpp [113:150]


static TArray<FInstallInfo> CollectPathsFromRegistry( const Windows::HKEY RootKey, const FString& RegistryKey)
{
	TArray<FInstallInfo> InstallInfos;
	HKEY Key;
	const LONG Result = RegOpenKeyEx(RootKey, *RegistryKey, 0, KEY_READ, &Key);
	if (Result != ERROR_SUCCESS) return InstallInfos;
	
	TArray<FString> Keys;
	if (!EnumerateRegistryKeys(Key, Keys)) return InstallInfos;
	
	for (const FString& key : Keys)
	{
		if (!key.Contains(TEXT("Rider"))) continue;

		HKEY SubKey;
		const LONG SubResult = RegOpenKeyEx(Key, *key, 0, KEY_READ, &SubKey);
		if (SubResult != ERROR_SUCCESS) continue;

		TArray<FString> Values;
		if (!EnumerateRegistryValues(SubKey, Values)) continue;

		for (const auto& Value : Values)
		{
			if (Value != TEXT("InstallLocation")) continue;
			FString InstallLocation;
			if (GetStringRegKey(SubKey, Value, InstallLocation) != ERROR_SUCCESS) continue;
			
			const FString ExePath = FPaths::Combine(InstallLocation, TEXT("bin"), TEXT("rider64.exe"));
			TOptional<FInstallInfo> InstallInfo = FRiderPathLocator::GetInstallInfoFromRiderPath(ExePath, FInstallInfo::EInstallType::Installed);
			if(InstallInfo.IsSet())
			{
				InstallInfos.Add(InstallInfo.GetValue());
			}
		}
	}

	return InstallInfos;
}