- Steam install directory is now cached in memory
- Paradox Launcher install directory is now obtained via the Registry and also cached in memory
This commit is contained in:
pointfeev 2022-02-17 13:07:49 -05:00
parent 406d606c2a
commit 3cd8c45959
3 changed files with 28 additions and 10 deletions

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>2.4.1.2</Version>
<Version>2.4.1.3</Version>
<PackageIcon>Resources\ini.ico</PackageIcon>
<PackageIconUrl />
<Description>Automatically generates and installs CreamAPI files for Steam games on the user's computer. It can also generate and install CreamAPI for the Paradox Launcher should the user select a Paradox Interactive game.</Description>

View file

@ -15,8 +15,6 @@ using CreamInstaller.Forms.Components;
using Gameloop.Vdf.Linq;
using Microsoft.Win32;
namespace CreamInstaller;
internal partial class SelectForm : CustomForm
@ -32,8 +30,7 @@ internal partial class SelectForm : CustomForm
{
List<string> gameDirectories = new();
if (Program.Canceled) return gameDirectories;
string steamInstallPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Valve\\Steam", "InstallPath", null) as string;
steamInstallPath ??= Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Valve\\Steam", "InstallPath", null) as string;
string steamInstallPath = Program.SteamInstallPath;
if (steamInstallPath != null && Directory.Exists(steamInstallPath))
{
string libraryFolder = steamInstallPath + @"\steamapps";
@ -178,8 +175,8 @@ internal partial class SelectForm : CustomForm
{
if (Program.Canceled) return;
List<Tuple<int, string, string, int, string>> applicablePrograms = new();
if (Directory.Exists(Program.ParadoxLauncherDirectory))
applicablePrograms.Add(new(0, "Paradox Launcher", "", 0, Program.ParadoxLauncherDirectory));
if (Directory.Exists(Program.ParadoxLauncherInstallPath))
applicablePrograms.Add(new(0, "Paradox Launcher", "", 0, Program.ParadoxLauncherInstallPath));
List<string> gameLibraryDirectories = await GameLibraryDirectories();
foreach (string libraryDirectory in gameLibraryDirectories)
{
@ -482,9 +479,9 @@ internal partial class SelectForm : CustomForm
Dictionary<string, Image> images = new();
Task.Run(async () =>
{
if (Directory.Exists(Program.ParadoxLauncherDirectory))
if (Directory.Exists(Program.ParadoxLauncherInstallPath))
{
foreach (string file in Directory.GetFiles(Program.ParadoxLauncherDirectory, "*.exe"))
foreach (string file in Directory.GetFiles(Program.ParadoxLauncherInstallPath, "*.exe"))
{
images["Paradox Launcher"] = Program.GetFileIconImage(file);
break;

View file

@ -12,6 +12,8 @@ using System.Windows.Forms;
using CreamInstaller.Classes;
using Microsoft.Win32;
namespace CreamInstaller;
internal static class Program
@ -28,7 +30,26 @@ internal static class Program
internal static readonly string[] ProtectedGameDirectories = { @"\EasyAntiCheat", @"\BattlEye" }; // DLL detections
internal static readonly string[] ProtectedGameDirectoryExceptions = { "Arma 3" }; // Arma 3's BattlEye doesn't detect DLL changes?
internal static readonly string ParadoxLauncherDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Programs\Paradox Interactive";
internal static string steamInstallPath = null;
internal static string SteamInstallPath
{
get
{
steamInstallPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Valve\Steam", "InstallPath", null) as string;
steamInstallPath ??= Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Valve\Steam", "InstallPath", null) as string;
return steamInstallPath;
}
}
internal static string paradoxLauncherInstallPath = null;
internal static string ParadoxLauncherInstallPath
{
get
{
paradoxLauncherInstallPath ??= Registry.GetValue(@"HKEY_CURRENT_USER\Software\Paradox Interactive\Paradox Launcher v2", "LauncherInstallation", null) as string;
return paradoxLauncherInstallPath;
}
}
internal static bool IsGameBlocked(string name, string directory)
{