Browse Source

Read Steam location and user from registry

tags/v1.4.0
NorbiPeti 3 years ago
parent
commit
5aa0f788c3
3 changed files with 14 additions and 1 deletions
  1. +1
    -0
      GCMM/GCMM.csproj
  2. +1
    -0
      GCMM/MainForm.cs
  3. +12
    -1
      GCMM/MainUtils.cs

+ 1
- 0
GCMM/GCMM.csproj View File

@@ -24,6 +24,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>


+ 1
- 0
GCMM/MainForm.cs View File

@@ -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();


+ 12
- 1
GCMM/MainUtils.cs View File

@@ -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)


Loading…
Cancel
Save