diff options
| author | NΞVΛR <danielo-24@hotmail.com> | 2026-03-01 18:19:38 +0100 |
|---|---|---|
| committer | NΞVΛR <danielo-24@hotmail.com> | 2026-03-01 18:19:38 +0100 |
| commit | fa254306949eec458cdff71c3867ded0e7494d2f (patch) | |
| tree | dc4e4d1ae9f6a0c990a34da0d36795a3cc11c2ce /Minecraft.Client/Windows64/Windows64_Minecraft.cpp | |
| parent | b5111232aa13952f58ed1b3b3525ea825662b95c (diff) | |
Fix for exe not running, not founding the project directory
In _tWinMain (Windows64_Minecraft.cpp) add logic to detect if the executable path contains "\\x64\\". If found, truncate the path at that position, append "\\Minecraft.Client" and call SetCurrentDirectoryA to set the process working directory. This ensures relative resource paths resolve correctly when running from an x64 build output directory; the change is guarded by a substring check and uses MAX_PATH-safe APIs.
Diffstat (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp')
| -rw-r--r-- | Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 931e7f17..50791c02 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -716,6 +716,16 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); + + char exePath[MAX_PATH]; + GetModuleFileNameA(NULL, exePath, MAX_PATH); + char* x64_pos = strstr(exePath, "\\x64\\"); + if (x64_pos) { + *x64_pos = 0; + strcat_s(exePath, MAX_PATH, "\\Minecraft.Client"); + SetCurrentDirectoryA(exePath); + } + // Declare DPI awareness so GetSystemMetrics returns physical pixels SetProcessDPIAware(); g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN); |
