Skip to content

Commit 5e7af3b

Browse files
committed
Added registry search to where to look for the Launch.lua file.
1 parent f4daa20 commit 5e7af3b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Launcher.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ bool InsertLaunchLua(std::vector<std::wstring> &commandLine, std::string &firstL
110110
}
111111
}
112112

113+
// Check for the registry key left by the installer
114+
// HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Path of Building Community\InstallLocation
115+
{
116+
DWORD dwType = 0;
117+
DWORD dwSize = MAX_PATH;
118+
wchar_t wszValue[MAX_PATH]{};
119+
DWORD dwStatus = RegGetValue(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Path of Building Community", L"InstallLocation", RRF_RT_REG_SZ, &dwType, wszValue, &dwSize);
120+
if (dwStatus == ERROR_SUCCESS && dwSize > sizeof(wchar_t))
121+
{
122+
// Strip the quotes around the value
123+
std::wstring basePath = wszValue[0] == L'\"' ? std::wstring(wszValue + 1, wszValue + dwSize / sizeof(wchar_t) - 2) : std::wstring(wszValue, wszValue + dwSize / sizeof(wchar_t) - 1);
124+
basePath += L"\\Launch.lua";
125+
if (IsValidLuaFile(basePath, firstLine))
126+
{
127+
commandLine.insert(commandLine.begin() + 1, basePath);
128+
return true;
129+
}
130+
}
131+
}
132+
113133
// Look in the %APPDATA% folder, which is where the PoB Fork installer puts the lua files
114134
{
115135
wchar_t wszAppDataPath[MAX_PATH]{};

0 commit comments

Comments
 (0)