2022-05-14 12:19:40 +01:00
|
|
|
|
using Microsoft.Win32;
|
2022-07-25 22:31:30 +01:00
|
|
|
|
using SPT_AKI_Installer.Aki.Core.Model;
|
|
|
|
|
using System;
|
2022-05-14 12:19:40 +01:00
|
|
|
|
using System.Diagnostics;
|
2022-07-09 13:14:03 -04:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Runtime.InteropServices;
|
2022-05-14 12:19:40 +01:00
|
|
|
|
|
|
|
|
|
namespace SPT_AKI_Installer.Aki.Helper
|
|
|
|
|
{
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public static class PreCheckHelper
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
|
|
|
|
private const string registryInstall = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
|
|
|
|
|
|
2022-05-19 14:41:44 +01:00
|
|
|
|
public static string DetectOriginalGamePath()
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
|
|
|
|
// 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;
|
2022-07-09 13:14:03 -04:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
return info?.DirectoryName;
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 22:31:30 +01:00
|
|
|
|
public static GenericResult DetectOriginalGameVersion(string gamePath)
|
2022-05-14 12:19:40 +01:00
|
|
|
|
{
|
2022-07-25 22:31:30 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string version = FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
|
|
|
|
|
return GenericResult.FromSuccess(version);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return GenericResult.FromError($"File not found: {ex.Message}");
|
|
|
|
|
}
|
2022-05-14 12:19:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|