-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGTAInstall.cs
67 lines (54 loc) · 1.81 KB
/
GTAInstall.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Microsoft.Win32;
using System.Collections.Generic;
using System.IO;
namespace GTAVModdingLauncher
{
public class GTAInstall
{
public static GTAInstall[] FindInstalls()
{
List<GTAInstall> installs = new List<GTAInstall>();
RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Rockstar Games\\Grand Theft Auto V", false);
if(regKey != null)
{
string path = regKey.GetValue("InstallFolder") as string;
if(path != null && Directory.Exists(path))
installs.Add(new GTAInstall(false, path, InstallType.Retail));
regKey.Close();
}
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Rockstar Games\\GTAV", false);
if(regKey != null)
{
string path = regKey.GetValue("InstallFolderSteam") as string;
regKey.Close();
if(path != null)
{
path = path.Substring(0, path.Length - 4);
if(Directory.Exists(path))
installs.Add(new GTAInstall(false, path, InstallType.Steam));
}
}
else if(SteamHelper.IsAvailable)
{
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(SteamHelper.ExecutablePath), "steamapps\\common\\Grand Theft Auto V");
if(File.Exists(System.IO.Path.Combine(path, "gta5.exe")))
installs.Add(new GTAInstall(false, path, InstallType.Steam));
}
return installs.ToArray();
}
public bool IsCustom { get; set; }
public string Path { get; set; }
public InstallType Type { get; set; }
public GTAInstall(string path, InstallType type) : this(true, path, type) {}
private GTAInstall(bool custom, string path, InstallType type)
{
this.IsCustom = custom;
this.Path = path;
this.Type = type;
}
public override string ToString()
{
return this.Path + " [" + this.Type + "]";
}
}
}