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.
This commit is contained in:
NΞVΛR
2026-03-01 18:19:38 +01:00
parent b5111232aa
commit fa25430694

View File

@@ -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);