using Microsoft.Win32; using System.Runtime.InteropServices; using System.IO; using System; using System.Diagnostics; namespace SPT_AKI_Installer.Aki.Helper { public class PreCheckHelper { private const string registryInstall = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov"; /// /// gets the original EFT game path /// /// Path or null public string DetectOriginalGamePath() { // We can't detect the installed path on non-Windows if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return null; var uninstallStringValue = Registry.LocalMachine.OpenSubKey(registryInstall, false) ?.GetValue("UninstallString"); var info = (uninstallStringValue is string key) ? new FileInfo(key) : null; return info?.DirectoryName; } /// /// checks path is not null, out = gamePath /// /// public void GameCheck(out string gamePath) { string Path = DetectOriginalGamePath(); if (Path == null) { LogHelper.Error("EFT IS NOT INSTALLED!"); LogHelper.Error("Press enter to close the app"); Console.ReadKey(); Environment.Exit(0); } gamePath = Path; } /// /// Checks version of EFT installed, Then checks that matches the Zip, out = patch version number 0.12.12.*here* /// /// /// /// /// bool public bool PatcherCheck(string gamePath,string targetPath, out string patchRef) { StringHelper stringHelper = new StringHelper(); FileVersionInfo version = FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")); string versionCheck = stringHelper.Splitter(version.ProductVersion, '-', '.', 2); LogHelper.Info($"GAME VERSION IS: {version.ProductVersion}"); string patcherRef = FileHelper.FindFile(targetPath, versionCheck); if (patcherRef != null) { patchRef = patcherRef; return true; } patchRef = null; return false; } /// /// Checks Aki Zip is 2.3.1 currently /// /// /// /// bool public bool AkiCheck(string targetPath,out string akiRef) { string aki = FileHelper.FindFile(targetPath, "2.3.1"); if (aki != null) { akiRef = aki; return true; } akiRef = null; return false; } } }