F4MP/tiltedcode/Code/immersive_launcher/steam/SteamLoader.cpp
Jous99 37b16f1547 code upload
codigo original de f4mp y tilted para referencias
2026-01-06 18:45:00 +01:00

38 lines
878 B
C++

#include "SteamLoader.h"
#include "TargetConfig.h"
#include "Utils/Registry.h"
#include <cstdio>
namespace steam
{
constexpr wchar_t kSteamDllName[] = L"steamclient64.dll";
void Load(const fs::path& aGameDir)
{
auto appId = std::to_wstring(CurrentTarget.steamAppId);
SetEnvironmentVariableW(L"SteamAppId", appId.c_str());
auto path = aGameDir / "steam_appid.txt";
FILE* f = nullptr;
_wfopen_s(&f, path.c_str(), L"w");
if (f)
{
fprintf(f, "%d", CurrentTarget.steamAppId);
fclose(f);
}
fs::path steamPath = Registry::ReadString<wchar_t>(HKEY_CURRENT_USER, LR"(SOFTWARE\Valve\Steam)", L"SteamPath");
// wait what
if (!fs::exists(steamPath))
return;
AddDllDirectory(steamPath.c_str());
fs::path clientPath = steamPath / kSteamDllName;
LoadLibraryW(clientPath.c_str());
}
} // namespace steam