mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
SteamGame.IsRunning now works correctly
Changed from using the Steam 'Running' Registry Key to using an actual Process detection method. Now works reliably and waits as expected!
This commit is contained in:
parent
706c225dc7
commit
86776f1aba
@ -25,6 +25,7 @@ using HeliosPlus.GameLibraries.SteamAppInfoParser;
|
||||
using TsudaKageyu;
|
||||
using System.Drawing.IconLib;
|
||||
using System.Drawing.IconLib.Exceptions;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace HeliosPlus.GameLibraries
|
||||
{
|
||||
@ -40,6 +41,7 @@ namespace HeliosPlus.GameLibraries
|
||||
private string _steamGameName;
|
||||
private string _steamGamePath;
|
||||
private string _steamGameExe;
|
||||
private string _steamGameProcessName;
|
||||
private string _steamGameIconPath;
|
||||
private static List<SteamGame> _allInstalledSteamGames = null;
|
||||
|
||||
@ -67,6 +69,7 @@ namespace HeliosPlus.GameLibraries
|
||||
_steamGameName = steamGameName;
|
||||
_steamGamePath = steamGamePath;
|
||||
_steamGameExe = steamGameExe;
|
||||
_steamGameProcessName = Path.GetFileNameWithoutExtension(_steamGameExe);
|
||||
_steamGameIconPath = steamGameIconPath;
|
||||
|
||||
}
|
||||
@ -89,7 +92,7 @@ namespace HeliosPlus.GameLibraries
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
/*try
|
||||
{
|
||||
using (
|
||||
var key = Registry.CurrentUser.OpenSubKey(_gameRegistryKey, RegistryKeyPermissionCheck.ReadSubTree))
|
||||
@ -116,7 +119,12 @@ namespace HeliosPlus.GameLibraries
|
||||
if (ex.Source != null)
|
||||
Console.WriteLine("IOException source: {0} - Message: {1}", ex.Source, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}*/
|
||||
|
||||
bool isRunning = Process.GetProcessesByName(_steamGameProcessName)
|
||||
.FirstOrDefault(p => p.MainModule.FileName
|
||||
.StartsWith(GamePath,StringComparison.OrdinalIgnoreCase)) != default(Process);
|
||||
return isRunning;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,6 +679,9 @@ namespace HeliosPlus
|
||||
}*/
|
||||
|
||||
// Wait for the game to exit
|
||||
|
||||
|
||||
|
||||
if (steamGameToRun.IsRunning)
|
||||
{
|
||||
while (true)
|
||||
@ -690,6 +693,7 @@ namespace HeliosPlus
|
||||
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
Console.WriteLine($"{steamGameToRun.GameName} has been exited. Now continuing with cleanup tasks.");
|
||||
}
|
||||
|
||||
// Remove the status notification icon from the status area
|
||||
|
Loading…
Reference in New Issue
Block a user