From 3cd8c45959196ff1a25bf19fd925ecc6fdff11a2 Mon Sep 17 00:00:00 2001 From: pointfeev Date: Thu, 17 Feb 2022 13:07:49 -0500 Subject: [PATCH] v2.4.1.3 - Steam install directory is now cached in memory - Paradox Launcher install directory is now obtained via the Registry and also cached in memory --- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Forms/SelectForm.cs | 13 +++++-------- CreamInstaller/Program.cs | 23 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 5880849..5027cb6 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 2.4.1.2 + 2.4.1.3 Resources\ini.ico 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. diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 048600b..1ff6e98 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -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 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> 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 gameLibraryDirectories = await GameLibraryDirectories(); foreach (string libraryDirectory in gameLibraryDirectories) { @@ -482,9 +479,9 @@ internal partial class SelectForm : CustomForm Dictionary 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; diff --git a/CreamInstaller/Program.cs b/CreamInstaller/Program.cs index ee05f9b..1cc5613 100644 --- a/CreamInstaller/Program.cs +++ b/CreamInstaller/Program.cs @@ -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) {