Read Steam location and user from registry
This commit is contained in:
parent
3520015649
commit
5aa0f788c3
3 changed files with 14 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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…
Reference in a new issue