diff options
author | Patrick Müssig <patrick.muessig@gmx.de> | 2016-12-06 23:02:37 +0100 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2016-12-07 23:27:53 -0500 |
commit | 47d5aef404e0a5c27d49b37faff9bd32ced6f3ff (patch) | |
tree | bd7b8446aa5fc13c7caca4696202a4ca23dd510f | |
parent | acbd33fb027093c7ff4a0a138eb42e7518eeabf8 (diff) | |
download | SMAPI-47d5aef404e0a5c27d49b37faff9bd32ced6f3ff.tar.gz SMAPI-47d5aef404e0a5c27d49b37faff9bd32ced6f3ff.tar.bz2 SMAPI-47d5aef404e0a5c27d49b37faff9bd32ced6f3ff.zip |
SMAPI installer is able to read SDV install path from registry key
-rw-r--r-- | src/StardewModdingAPI.Installer/InteractiveInstaller.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs index ffdef37b..49014352 100644 --- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs +++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Reflection; +using Microsoft.Win32; using StardewModdingApi.Installer.Enums; namespace StardewModdingApi.Installer @@ -318,6 +319,41 @@ namespace StardewModdingApi.Installer return new DirectoryInfo(defaultPath); } + if (platform == Platform.Windows) + { + // Needed to get 64Keys + RegistryKey localKey = Environment.Is64BitOperatingSystem ? RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) : Registry.LocalMachine; + + string stardewValleyPath; + var registry = localKey.OpenSubKey(@"SOFTWARE\WOW6432Node\GOG.com\Games\1453375253"); + if (registry != null) + { + stardewValleyPath = (string)registry.GetValue("PATH"); + if (!string.IsNullOrEmpty(stardewValleyPath)) + { + registry.Close(); + if (Directory.Exists(stardewValleyPath)) + { + return new DirectoryInfo(stardewValleyPath); + } + } + } + + registry = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150"); + if (registry != null) + { + stardewValleyPath = (string)registry.GetValue("InstallLocation"); + if (!string.IsNullOrEmpty(stardewValleyPath)) + { + registry.Close(); + if (Directory.Exists(stardewValleyPath)) + { + return new DirectoryInfo(stardewValleyPath); + } + } + } + } + // ask user Console.WriteLine("Oops, couldn't find the game automatically."); while (true) |