diff --git a/GCMM/GCMM.csproj b/GCMM/GCMM.csproj index 1c92119..4bba088 100644 --- a/GCMM/GCMM.csproj +++ b/GCMM/GCMM.csproj @@ -24,6 +24,7 @@ + diff --git a/GCMM/MainForm.cs b/GCMM/MainForm.cs index f2e55f0..46663de 100644 --- a/GCMM/MainForm.cs +++ b/GCMM/MainForm.cs @@ -64,6 +64,7 @@ You may also want to verify the game's files by right clicking the game in Steam mods.Clear(); //This method may get called twice when ran from the command line UpdateButton(installbtn, false); modinfobox.Text = defaultInfo; + GetSteamLocationAndUser(); //TODO: If user is null then start Steam if (string.IsNullOrWhiteSpace(Settings.Default.GamePath) || GetExe() == null) { Settings.Default.GamePath = GetGameFolder(); diff --git a/GCMM/MainUtils.cs b/GCMM/MainUtils.cs index b09987e..076200e 100644 --- a/GCMM/MainUtils.cs +++ b/GCMM/MainUtils.cs @@ -1,4 +1,5 @@ using GCMM.Properties; +using Microsoft.Win32; using System; using System.Collections.Generic; using System.Diagnostics; @@ -35,7 +36,7 @@ namespace GCMM { //TODO string libs; if (Environment.OSVersion.Platform == PlatformID.Win32NT) - libs = Settings.Default.SteamConfigFileForAutoLaunch + @"\steamapps\libraryfolders.vdf"; + libs = Settings.Default.SteamConfigFileForAutoLaunch + @"\steamapps\libraryfolders.vdf"; //TODO: Not the Steam folder anymore! else return null; foreach (var line in File.ReadAllLines(libs).Concat(new[] {@"C:\Program Files (x86)\Steam\"})) @@ -83,7 +84,17 @@ namespace GCMM private void UpdateSteamConfigToAutoStart(bool autoLaunch) { + //TODO + } + private (string, int) GetSteamLocationAndUser() + { + if (Environment.OSVersion.Platform != PlatformID.Win32NT) return (null, 0); + using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam\ActiveProcess")) + { + string path = Directory.GetParent((string)key.GetValue("SteamClientDll")).FullName; + return (path, (int)key.GetValue("ActiveUser")); + } } private void CheckStartGame(object sender, EventArgs e)