mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Modified Game Library installation checks
UplayLibrary was erroring when run without Uplay installed. Needed to tweak it so that DisplayMagician will work without Uplay library or Steam library installed.
This commit is contained in:
parent
65e78a0b29
commit
f1c484637c
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,6 +21,7 @@
|
|||||||
bld/
|
bld/
|
||||||
[Bb]in/
|
[Bb]in/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
|
*.editorconfig
|
||||||
|
|
||||||
# Visual Studio 2015 cache/options directory
|
# Visual Studio 2015 cache/options directory
|
||||||
.vs/
|
.vs/
|
||||||
|
@ -24,6 +24,8 @@ namespace DisplayMagician.GameLibraries
|
|||||||
private static string _steamConfigVdfFile;
|
private static string _steamConfigVdfFile;
|
||||||
private static string _registrySteamKey = @"SOFTWARE\\Valve\\Steam";
|
private static string _registrySteamKey = @"SOFTWARE\\Valve\\Steam";
|
||||||
private static string _registryAppsKey = $@"{_registrySteamKey}\\Apps";
|
private static string _registryAppsKey = $@"{_registrySteamKey}\\Apps";
|
||||||
|
private static bool _isSteamInstalled = false;
|
||||||
|
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
// Other constants that are useful
|
// Other constants that are useful
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -38,6 +40,8 @@ namespace DisplayMagician.GameLibraries
|
|||||||
|
|
||||||
#region Class Constructors
|
#region Class Constructors
|
||||||
static SteamLibrary()
|
static SteamLibrary()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Find the SteamExe location, and the SteamPath for later
|
// Find the SteamExe location, and the SteamPath for later
|
||||||
using (var key = Registry.CurrentUser.OpenSubKey(SteamLibrary.SteamRegistryKey, RegistryKeyPermissionCheck.ReadSubTree))
|
using (var key = Registry.CurrentUser.OpenSubKey(SteamLibrary.SteamRegistryKey, RegistryKeyPermissionCheck.ReadSubTree))
|
||||||
@ -47,7 +51,24 @@ namespace DisplayMagician.GameLibraries
|
|||||||
_steamPath = (string)key?.GetValue(@"SteamPath", string.Empty) ?? string.Empty;
|
_steamPath = (string)key?.GetValue(@"SteamPath", string.Empty) ?? string.Empty;
|
||||||
_steamPath = _steamPath.Replace('/', '\\');
|
_steamPath = _steamPath.Replace('/', '\\');
|
||||||
}
|
}
|
||||||
|
_isSteamInstalled = true;
|
||||||
|
}
|
||||||
|
catch (SecurityException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The user does not have the permissions required to read the Steam registry key.");
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The Microsoft.Win32.RegistryKey is closed when trying to access theSteam registry key (closed keys cannot be accessed).");
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The Steam registry key has been marked for deletion so we cannot access the value during the SteamLibrary check.");
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The user does not have the necessary registry rights to check whether Steam is installed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -108,10 +129,7 @@ namespace DisplayMagician.GameLibraries
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(SteamExe) && File.Exists(SteamExe))
|
return _isSteamInstalled;
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,15 @@ namespace DisplayMagician.GameLibraries
|
|||||||
// Common items to the class
|
// Common items to the class
|
||||||
private static List<Game> _allUplayGames = new List<Game>();
|
private static List<Game> _allUplayGames = new List<Game>();
|
||||||
private static string uplayAppIdRegex = @"/^[0-9A-F]{1,10}$";
|
private static string uplayAppIdRegex = @"/^[0-9A-F]{1,10}$";
|
||||||
|
private static bool _isUplayInstalled = false;
|
||||||
private static string _uplayExe;
|
private static string _uplayExe;
|
||||||
private static string _uplayPath;
|
private static string _uplayPath;
|
||||||
private static string _uplayConfigVdfFile;
|
private static string _uplayConfigVdfFile;
|
||||||
internal static string registryUplayLauncherKey = @"SOFTWARE\WOW6432Node\Ubisoft\Launcher";
|
internal static string registryUplayLauncherKey = @"SOFTWARE\WOW6432Node\Ubisoft\Launcher";
|
||||||
internal static string registryUplayInstallsKey = @"SOFTWARE\WOW6432Node\Ubisoft\Launcher\Installs";
|
internal static string registryUplayInstallsKey = @"SOFTWARE\WOW6432Node\Ubisoft\Launcher\Installs";
|
||||||
internal static string registryUplayOpenCmdKey = @"SOFTWARE\Classes\uplay\Shell\Open\Command";
|
internal static string registryUplayOpenCmdKey = @"SOFTWARE\Classes\uplay\Shell\Open\Command";
|
||||||
|
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
|
||||||
// Other constants that are useful
|
// Other constants that are useful
|
||||||
#endregion
|
#endregion
|
||||||
@ -42,11 +45,31 @@ namespace DisplayMagician.GameLibraries
|
|||||||
|
|
||||||
#region Class Constructors
|
#region Class Constructors
|
||||||
static UplayLibrary()
|
static UplayLibrary()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Find the UplayExe location, and the UplayPath for later
|
// Find the UplayExe location, and the UplayPath for later
|
||||||
RegistryKey uplayInstallKey = Registry.LocalMachine.OpenSubKey(registryUplayLauncherKey, RegistryKeyPermissionCheck.ReadSubTree);
|
RegistryKey uplayInstallKey = Registry.LocalMachine.OpenSubKey(registryUplayLauncherKey, RegistryKeyPermissionCheck.ReadSubTree);
|
||||||
_uplayPath = uplayInstallKey.GetValue("InstallDir", "C:\\Program Files (x86)\\Ubisoft\\Ubisoft Game Launcher\\").ToString();
|
_uplayPath = uplayInstallKey.GetValue("InstallDir", "C:\\Program Files (x86)\\Ubisoft\\Ubisoft Game Launcher\\").ToString();
|
||||||
_uplayExe = $"{_uplayPath}upc.exe";
|
_uplayExe = $"{_uplayPath}upc.exe";
|
||||||
|
_isUplayInstalled = true;
|
||||||
|
}
|
||||||
|
catch (SecurityException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The user does not have the permissions required to read the Uplay InstallDir registry key.");
|
||||||
|
}
|
||||||
|
catch(ObjectDisposedException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The Microsoft.Win32.RegistryKey is closed when trying to access the Uplay InstallDir registry key (closed keys cannot be accessed).");
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The Uplay InstallDir registry key has been marked for deletion so we cannot access the value dueing the UplayLibrary check.");
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
logger.Warn("The user does not have the necessary registry rights to check whether Uplay is installed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -91,10 +114,7 @@ namespace DisplayMagician.GameLibraries
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(UplayExe) && File.Exists(UplayExe))
|
return _isUplayInstalled;
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user