diff --git a/HMCLauncher/HMCL/main.cpp b/HMCLauncher/HMCL/main.cpp index 066052afb..ee2543f6f 100644 --- a/HMCLauncher/HMCL/main.cpp +++ b/HMCLauncher/HMCL/main.cpp @@ -48,11 +48,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, // TODO: check whether the bundled JRE is valid. // First try the Java packaged together. - bool is64Bit = false; - GetArch(is64Bit); // if failed to determine architecture of operating system, - // consider 32-bit. + bool isX64 = false; - if (is64Bit) { + SYSTEM_INFO systemInfo; + GetNativeSystemInfo(&systemInfo); + + isX64 = (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64); + + if (isX64) { RawLaunchJVM(L"jre-x64\\bin\\javaw.exe", workdir, exeName); } else { RawLaunchJVM(L"jre-x86\\bin\\javaw.exe", workdir, exeName); diff --git a/HMCLauncher/HMCL/os.cpp b/HMCLauncher/HMCL/os.cpp index 42be922a9..27c36da28 100644 --- a/HMCLauncher/HMCL/os.cpp +++ b/HMCLauncher/HMCL/os.cpp @@ -71,35 +71,6 @@ bool FindFirstFileExists(LPCWSTR lpPath, DWORD dwFilter) { return ret; } -bool GetArch(bool &is64Bit) { -#if _WIN64 - is64Bit = true; - return true; -#elif _WIN32 - typedef BOOL(WINAPI * LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); - - BOOL isWow64 = FALSE; - - // IsWow64Process is not available on all supported versions of Windows. - // Use GetModuleHandle to get a handle to the DLL that contains the function - // and GetProcAddress to get a pointer to the function if available. - - LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( - GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); - - if (fnIsWow64Process) { - if (!fnIsWow64Process(GetCurrentProcess(), &isWow64)) return false; - - is64Bit = isWow64; - return true; - } else // IsWow64Process is not supported, fail to detect. - return false; - -#else -#error _WIN64 and _WIN32 are both undefined. -#endif -} - bool MyGetFileVersionInfo(const std::wstring &filePath, Version &version) { DWORD verHandle = 0; UINT size = 0; diff --git a/HMCLauncher/HMCL/os.h b/HMCLauncher/HMCL/os.h index 9a985758f..129cae201 100644 --- a/HMCLauncher/HMCL/os.h +++ b/HMCLauncher/HMCL/os.h @@ -24,6 +24,4 @@ bool MyCreateProcess(const std::wstring &command, const std::wstring &workdir); // Check if file lpPath exists. bool FindFirstFileExists(LPCWSTR lpPath, DWORD dwFilter); -bool GetArch(bool &is64Bit); - bool MyGetFileVersionInfo(const std::wstring &filePath, Version &version); \ No newline at end of file