diff --git a/src/EpicMorg.SteamPathsLib/EpicMorg.SteamPathsLib.csproj b/src/EpicMorg.SteamPathsLib/EpicMorg.SteamPathsLib.csproj
index 44ec084..09d3fb8 100644
--- a/src/EpicMorg.SteamPathsLib/EpicMorg.SteamPathsLib.csproj
+++ b/src/EpicMorg.SteamPathsLib/EpicMorg.SteamPathsLib.csproj
@@ -44,6 +44,9 @@
+
+
+
diff --git a/src/EpicMorg.SteamPathsLib/SteamPathsUtil.cs b/src/EpicMorg.SteamPathsLib/SteamPathsUtil.cs
index 66e6767..3521e41 100644
--- a/src/EpicMorg.SteamPathsLib/SteamPathsUtil.cs
+++ b/src/EpicMorg.SteamPathsLib/SteamPathsUtil.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using EpicMorg.SteamPathsLib.model;
using Microsoft.Win32;
namespace EpicMorg.SteamPathsLib
@@ -13,21 +14,6 @@ namespace EpicMorg.SteamPathsLib
private static readonly string _valveSteamAppsPattern = @"Software\Valve\Steam\Apps\";
- public static Dictionary GetInfo()
- {
- var result = new Dictionary();
-
- result["ValveKeyRegistry"] = GetValveKeyRegistry();
- result["SteamKeyRegistry"] = GetSteamKeyRegistry();
- result["SteamAppsKeyRegistry"] = GetSteamAppsKeyRegistry();
- result["SteamDirectoryPath"] = GetSteamDirectoryPath();
- result["SteamExePath"] = GetSteamExePath();
- result["SteamExePid"] = GetSteamExePid();
- result["OriginalSourceModDirectoryPath"] = GetOriginalSourceModDirectoryPath();
-
- return result;
- }
-
public static string GetValveKeyRegistry()
{
try
@@ -40,18 +26,6 @@ namespace EpicMorg.SteamPathsLib
};
}
- public static string GetSteamKeyRegistry()
- {
- try
- {
- return Registry.CurrentUser.OpenSubKey(_valveSteamKey).ToString();
- }
- catch (Exception)
- {
- return null;
- };
- }
-
public static string GetSteamAppsKeyRegistry()
{
try
@@ -64,109 +38,80 @@ namespace EpicMorg.SteamPathsLib
};
}
- public static string GetSteamDirectoryPath()
+ public static ActiveProcessSteamData GetActiveProcessSteamData()
{
try
{
- using (var key = Registry.CurrentUser.OpenSubKey(_valveSteamKey))
- {
- var path = key.GetValue("SteamPath").ToString();
- if (path != @"")
- {
- return path;
- }
- }
- }
- catch (Exception) { };
+ var regData = Registry.CurrentUser.OpenSubKey(_valveActiveProcessPID);
- return null;
- }
+ var result = new ActiveProcessSteamData();
- public static string GetSteamExePath()
- {
- try
- {
- using (var key = Registry.CurrentUser.OpenSubKey(_valveSteamKey))
- {
- var path = key.GetValue("SteamExe").ToString();
- if (path != @"")
- {
- return path;
- }
- }
- }
- catch (Exception) { };
+ result.RegistryKey = regData.ToString();
+ result.PID = Convert.ToInt32((regData.GetValue("pid") ?? 0));
- return null;
- }
-
- public static string GetSteamExePid()
- {
- try
- {
- using (var key = Registry.CurrentUser.OpenSubKey(_valveActiveProcessPID))
- {
- var pid = key.GetValue("pid").ToString();
- if (pid != @"0")
- {
- return pid;
- }
- }
- }
- catch (Exception) { };
-
- return null;
- }
-
- public static string GetOriginalSourceModDirectoryPath()
- {
- try
- {
- using (var key = Registry.CurrentUser.OpenSubKey(_valveSteamKey))
- {
- var path = key.GetValue("SourceModInstallPath").ToString();
- if (path != @"")
- {
- return path;
- }
- }
- }
- catch (Exception) { };
-
- return null;
- }
-
- public static string GetInstalledAppKeyRegistryById(int appId)
- {
- try
- {
- return Registry.CurrentUser.OpenSubKey(_valveSteamAppsPattern + appId).ToString();
+ return result;
}
catch (Exception)
{
return null;
- };
+ }
}
- public static bool IsInstalledApps(int appId)
+ public static SteamAppData GetSteamAppDataById(int appId)
+ {
+ var appKey = _valveSteamAppsPattern + appId;
+
+ try
+ {
+ var regData = Registry.CurrentUser.OpenSubKey(appKey);
+
+ var result = new SteamAppData();
+
+ result.RegistryKey = regData.ToString();
+ result.Name = (regData.GetValue("Name") ?? "").ToString();
+
+ result.AppId = appId;
+
+ result.Installed = (regData.GetValue("Installed") ?? 0).Equals(1);
+ result.Updating = (regData.GetValue("Updating") ?? 0).Equals(1);
+ result.Runnig = (regData.GetValue("Running") ?? 0).Equals(1);
+
+ return result;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ public static SteamData GetSteamData()
{
try
{
- var appKey = _valveSteamAppsPattern + appId;
+ var regData = Registry.CurrentUser.OpenSubKey(_valveSteamKey);
- using (var key = Registry.CurrentUser.OpenSubKey(appKey))
- {
- var installedValue = key.GetValue("Installed");
- if (installedValue.Equals(1))
- {
- return true;
- }
- }
+ var result = new SteamData();
+
+ result.RegistryKey = regData.ToString();
+ result.LastGameNameUsed = (regData.GetValue("LastGameNameUsed") ?? "").ToString();
+ result.SourceModInstallPath = (regData.GetValue("SourceModInstallPath") ?? "").ToString();
+ result.SteamExe = (regData.GetValue("SteamExe") ?? "").ToString();
+ result.SteamPath = (regData.GetValue("SteamPath") ?? "").ToString();
+ result.Language = (regData.GetValue("Language") ?? "").ToString();
+ result.PseudoUUID = (regData.GetValue("PseudoUUID") ?? "").ToString();
+ result.ModInstallPath = (regData.GetValue("ModInstallPath") ?? "").ToString();
+
+ result.RunningAppID = Convert.ToInt32((regData.GetValue("RunningAppID") ?? "0").ToString());
+
+ result.RememberPassword = (regData.GetValue("RememberPassword") ?? 0).Equals(1);
+ result.AlreadyRetriedOfflineMode = (regData.GetValue("AlreadyRetriedOfflineMode") ?? 0).Equals(1);
+
+ return result;
+ }
+ catch (Exception)
+ {
+ return null;
}
- catch (Exception) { };
-
- return false;
}
-
}
}
diff --git a/src/EpicMorg.SteamPathsLib/model/ActiveProcessSteamData.cs b/src/EpicMorg.SteamPathsLib/model/ActiveProcessSteamData.cs
new file mode 100644
index 0000000..477b12b
--- /dev/null
+++ b/src/EpicMorg.SteamPathsLib/model/ActiveProcessSteamData.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EpicMorg.SteamPathsLib.model
+{
+ public class ActiveProcessSteamData
+ {
+ public string RegistryKey;
+
+ public int PID;
+ }
+}
diff --git a/src/EpicMorg.SteamPathsLib/model/SteamAppData.cs b/src/EpicMorg.SteamPathsLib/model/SteamAppData.cs
new file mode 100644
index 0000000..0318801
--- /dev/null
+++ b/src/EpicMorg.SteamPathsLib/model/SteamAppData.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EpicMorg.SteamPathsLib.model
+{
+ public class SteamAppData
+ {
+ public string RegistryKey;
+ public string Name;
+
+ public int AppId;
+
+ public bool Installed;
+ public bool Runnig;
+ public bool Updating;
+ }
+}
diff --git a/src/EpicMorg.SteamPathsLib/model/SteamData.cs b/src/EpicMorg.SteamPathsLib/model/SteamData.cs
new file mode 100644
index 0000000..ec71ae8
--- /dev/null
+++ b/src/EpicMorg.SteamPathsLib/model/SteamData.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EpicMorg.SteamPathsLib.model
+{
+ public class SteamData
+ {
+ public string RegistryKey;
+ public string LastGameNameUsed;
+ public string SourceModInstallPath;
+ public string SteamExe;
+ public string SteamPath;
+ public string Language;
+ public string PseudoUUID;
+ public string ModInstallPath;
+
+ public int RunningAppID;
+
+ public bool AlreadyRetriedOfflineMode;
+ public bool RememberPassword;
+
+ }
+}
diff --git a/src/SteamTest/FrmMain.cs b/src/SteamTest/FrmMain.cs
index 787a275..3bb2c4c 100644
--- a/src/SteamTest/FrmMain.cs
+++ b/src/SteamTest/FrmMain.cs
@@ -33,7 +33,8 @@ namespace SteamTest
InitializeComponent();
textBoxTestAppId.Value = (decimal)SOURCE_SDK_BASE_2013_SINGLEPLAYER_APP_ID;
this.Text = Text + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
-; }
+ ;
+ }
private void FrmMain_Load(object sender, EventArgs e)
{
@@ -85,7 +86,8 @@ namespace SteamTest
try
{
// Example of using this awesome library
- var text = SteamPathsUtil.GetSteamKeyRegistry();
+ var steamData = SteamPathsUtil.GetSteamData();
+ var text = steamData != null ? steamData.RegistryKey : "";
checkBoxVavleSteamReg.Checked = true;
checkBoxVavleSteamReg.ForeColor = Color.Green;
@@ -126,7 +128,8 @@ namespace SteamTest
try
{
// Example of using this awesome library
- var text = SteamPathsUtil.GetSteamExePath();
+ var steamData = SteamPathsUtil.GetSteamData();
+ var text = steamData != null ? steamData.SteamExe : "";
checkBoxVavleSteamExe.Checked = true;
checkBoxVavleSteamExe.ForeColor = Color.Green;
@@ -156,7 +159,8 @@ namespace SteamTest
try
{
// Example of using this awesome library
- var text = SteamPathsUtil.GetSteamExePid();
+ var activeProcess = SteamPathsUtil.GetActiveProcessSteamData();
+ var text = (activeProcess != null ? activeProcess.PID : 0).ToString();
checkBoxVavleSteamPID.Checked = true;
checkBoxVavleSteamPID.ForeColor = Color.Green;
@@ -187,7 +191,8 @@ namespace SteamTest
try
{
// Example of using this awesome library
- var text = SteamPathsUtil.GetSteamDirectoryPath();
+ var steamData = SteamPathsUtil.GetSteamData();
+ var text = steamData != null ? steamData.SteamPath : "";
checkBoxVavleSteamPath.Checked = true;
checkBoxVavleSteamPath.ForeColor = Color.Green;
@@ -217,7 +222,8 @@ namespace SteamTest
try
{
// Example of using this awesome library
- var text = SteamPathsUtil.GetOriginalSourceModDirectoryPath();
+ var steamData = SteamPathsUtil.GetSteamData();
+ var text = steamData != null ? steamData.SourceModInstallPath : "";
checkBoxVavleSteamSmodPath.Checked = true;
checkBoxVavleSteamSmodPath.ForeColor = Color.Green;
@@ -261,10 +267,12 @@ namespace SteamTest
CheckSteamAppById(appId, txtBoxVavleSteamAppsCustom, checkBoxVavleSteamAppsCustom, checkBoxVavleSteamAppsCustomInstalled);
}
- private void CheckSteamAppById(int appId, TextBox outputTextBox, CheckBox outputCheckBox, CheckBox outputInstalledCheckBox)
+ private void CheckSteamAppById(int appId, TextBox outputTextBox, CheckBox outputCheckBox, CheckBox outputInstalledCheckBox)
{
- var check = SteamPathsUtil.IsInstalledApps(appId);
- var path = SteamPathsUtil.GetInstalledAppKeyRegistryById(appId);
+ var appData = SteamPathsUtil.GetSteamAppDataById(appId);
+
+ var check = appData != null ? appData.Installed : false;
+ var path = appData != null ? appData.RegistryKey : "";
outputTextBox.Text = path;