原因:注册表内没有找到
相关代码:
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)
{
TArray<FString> Keys;
if (EnumerateRegistryKeys(Key, Keys))
{
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, false);
if(InstallInfo.IsSet())
InstallInfos.Add(InstallInfo.GetValue());
}
}
}
}
return InstallInfos;
}
添加注册表:(PowerShell 管理员模式),重启编辑器就好了
New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\JetBrains Rider 2024.1.3' -Force
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\JetBrains Rider 2024.1.3' -Name 'InstallLocation' -Value 'D:\Application\Dev\JetBrains Rider 2024.1.3'
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\JetBrains Rider 2024.1.3' -Name 'DisplayName' -Value 'JetBrains Rider 2024.1.3'