mirror of
https://github.com/EpicMorg/SteamPathsLib.git
synced 2024-12-26 22:45:29 +03:00
initial code
❤️❤️❤️
This commit is contained in:
parent
89f0778e66
commit
f9bf02bd5c
@ -41,7 +41,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="SteamPathsUtil.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
@ -1,12 +1,159 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace EpicMorg.SteamPathsLib
|
||||
{
|
||||
public class SteamPathsUtil
|
||||
{
|
||||
private static readonly string _valveKey = @"Software\Valve";
|
||||
private static readonly string _valveSteamKey = @"Software\Valve\Steam";
|
||||
private static readonly string _valveSteamAppsKey = @"Software\Valve\Steam\Apps";
|
||||
private static readonly string _valveActiveProcessPID = @"Software\Valve\Steam\ActiveProcess";
|
||||
|
||||
private static readonly string _valveSteamAppsPattern = @"Software\Valve\Steam\Apps\";
|
||||
|
||||
public static Dictionary<string, string> GetInfo()
|
||||
{
|
||||
var result = new Dictionary<string, string>();
|
||||
|
||||
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
|
||||
{
|
||||
return Registry.CurrentUser.OpenSubKey(_valveKey).ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetSteamKeyRegistry()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Registry.CurrentUser.OpenSubKey(_valveSteamKey).ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetSteamAppsKeyRegistry()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Registry.CurrentUser.OpenSubKey(_valveSteamAppsKey).ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetSteamDirectoryPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(_valveSteamKey))
|
||||
{
|
||||
var path = key.GetValue("SteamPath").ToString();
|
||||
if (path != @"")
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { };
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetSteamExePath()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(_valveSteamKey))
|
||||
{
|
||||
var path = key.GetValue("SteamExe").ToString();
|
||||
if (path != @"")
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { };
|
||||
|
||||
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 bool IsInstalledApps(int number)
|
||||
{
|
||||
try
|
||||
{
|
||||
var appKey = _valveSteamAppsPattern + number;
|
||||
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(appKey))
|
||||
{
|
||||
var installedValue = key.GetValue("Installed");
|
||||
if (installedValue.Equals(1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { };
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29509.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamPathsLib", "SteamPathsLib\SteamPathsLib.csproj", "{00E7A45F-69F7-41FC-B2A7-566E2904E49B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EpicMorg.SteamPathsLib", "EpicMorg.SteamPathsLib\EpicMorg.SteamPathsLib.csproj", "{E34AE985-7C7E-49BA-A2B0-70D88F865265}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,10 +11,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{00E7A45F-69F7-41FC-B2A7-566E2904E49B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{00E7A45F-69F7-41FC-B2A7-566E2904E49B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{00E7A45F-69F7-41FC-B2A7-566E2904E49B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{00E7A45F-69F7-41FC-B2A7-566E2904E49B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E34AE985-7C7E-49BA-A2B0-70D88F865265}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E34AE985-7C7E-49BA-A2B0-70D88F865265}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E34AE985-7C7E-49BA-A2B0-70D88F865265}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E34AE985-7C7E-49BA-A2B0-70D88F865265}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
Reference in New Issue
Block a user