diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/hmcl/UpdateHandler.java b/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/hmcl/UpdateHandler.java index a827f816d..f027fff1e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/hmcl/UpdateHandler.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/hmcl/UpdateHandler.java @@ -34,6 +34,7 @@ import org.jackhuang.hmcl.util.TaskCancellationAction; import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.io.JarUtils; import org.jackhuang.hmcl.util.platform.JavaVersion; +import org.jackhuang.hmcl.util.platform.OperatingSystem; import java.io.IOException; import java.nio.file.Files; @@ -51,7 +52,8 @@ import static org.jackhuang.hmcl.util.Logging.LOG; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public final class UpdateHandler { - private UpdateHandler() {} + private UpdateHandler() { + } /** * @return whether to exit @@ -71,6 +73,11 @@ public final class UpdateHandler { } if (args.length == 2 && args[0].equals("--apply-to")) { + if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && !OperatingSystem.isWindows7OrLater()) { + SwingUtils.showErrorDialog(i18n("fatal.apply_update_need_win7", Metadata.PUBLISH_URL)); + return true; + } + try { applyUpdate(Paths.get(args[1])); } catch (IOException e) { @@ -91,6 +98,11 @@ public final class UpdateHandler { public static void updateFrom(RemoteVersion version) { checkFxUserThread(); + if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && !OperatingSystem.isWindows7OrLater()) { + Controllers.dialog(i18n("fatal.apply_update_need_win7", Metadata.PUBLISH_URL), i18n("message.error"), MessageType.ERROR); + return; + } + Controllers.dialog(new UpgradeDialog(version, () -> { Path downloaded; try { diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index b8387d7c4..644be1704 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -379,6 +379,9 @@ fatal.apply_update_failure=We are sorry, but Hello Minecraft! Launcher is unable \n\ You can update manually by downloading a newer version of the launcher from %s.\n\ If the problem persists, please consider reporting this to us. +fatal.apply_update_need_win7=Hello Minecraft! Launcher cannot automatically update on Windows XP/Vista.\n\ +\n\ +You can update manually by downloading a newer version of the launcher from %s. fatal.samba=If you launched HMCL from a Samba network drive, some features might not be working. Please try updating your Java version or copy and run the launcher in a local folder. fatal.illegal_char=Your user path contains an illegal character '\=', you will not be able to use authlib-injector or change the skin of your offline account. fatal.unsupported_platform=Minecraft is not yet fully supported for your platform, so you may experience missing functionality,\nor even be unable to launch the game.\n\ diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 717c41ad6..d650eb6bc 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -365,6 +365,7 @@ fatal.config_loading_failure.unix=Hello Minecraft! Launcher 無法載入設定 fatal.mac_app_translocation=由於 macOS 的安全機制,Hello Minecraft! Launcher 被系統隔離至臨時資料夾中。\n請將Hello Minecraft! Launcher 移動到其他資料夾後再嘗試啟動,否則你的設定和遊戲數據可能會在重啟後遺失。\n是否繼續啟動? fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即將升級完成,請重新開啟 Hello Minecraft! Launcher。 fatal.apply_update_failure=我們很抱歉 Hello Minecraft! Launcher 無法自動完成升級程式,因為出現了一些問題。\n但你依然可以從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。\n你可以訪問 https://docs.hmcl.net/help.html 網頁進行迴響。 +fatal.apply_update_need_win7=Hello Minecraft! Launcher 無法在 Windows XP/Vista 上進行自動更新,請從 %s 處手動下載 Hello Minecraft! Launcher 來完成升級。 fatal.samba=如果您正在通過 Samba 共亯的資料夾中運行 Hello Minecraft! Launcher,啟動器可能無法正常工作,請嘗試更新您的 Java 或在本地資料夾內運行 HMCL。 fatal.illegal_char=由於您的用戶資料夾路徑中存在非法字元‘=’,您將無法使用外置登入帳戶以及離線登入更換皮膚功能。 fatal.unsupported_platform=Minecraft 尚未你您的平臺提供完善支持,所以可能影響遊戲體驗或無法啟動遊戲。\n若無法啟動 Minecraft 1.17 及以上版本,可以嘗試在版本設定中打開“使用 OpenGL 軟渲染器”選項,使用 CPU 渲染以獲得更好的相容性。 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index 2f745b608..d03ccf9e2 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -367,6 +367,7 @@ fatal.config_loading_failure.unix=Hello Minecraft! Launcher 无法加载配置 fatal.mac_app_translocation=由于 macOS 的安全机制,Hello Minecraft! Launcher 被系统隔离至临时文件夹中。\n请将 Hello Minecraft! Launcher 移动到其他文件夹后再尝试启动,否则你的设置和游戏数据可能会在重启后丢失。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。\n是否继续启动? fatal.migration_requires_manual_reboot=Hello Minecraft! Launcher 即将完成升级,请重新打开 Hello Minecraft! Launcher。\n如遇到问题,你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 fatal.apply_update_failure=我们很抱歉 Hello Minecraft! Launcher 无法自动完成升级,因为出现了一些问题。\n但你依可以从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级\n你可以访问 https://docs.hmcl.net/help.html 网页进行反馈。 +fatal.apply_update_need_win7=Hello Minecraft! Launcher 无法在 Windows XP/Vista 上进行自动更新,请从 %s 处手动下载 Hello Minecraft! Launcher 来完成升级。 fatal.samba=如果你正在通过 Samba 共享的文件夹中运行 Hello Minecraft! Launcher,启动器可能无法正常工作。请尝试更新你的 Java 或在本地文件夹内运行 Hello Minecraft! Launcher。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 fatal.illegal_char=由于你的用户文件夹路径中存在非法字符‘=’,你将无法使用外置登录账户以及离线登录更换皮肤功能。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。 fatal.unsupported_platform=Minecraft 尚未为您的平台提供完善支持,所以可能影响游戏体验或无法启动游戏。\n若无法启动 Minecraft 1.17 及以上版本,可以尝试在版本设置中打开“使用 OpenGL 软渲染器”选项,使用 CPU 渲染以获得更好的兼容性。\n如遇到问题,你可以点击右上角帮助按钮进行求助。 diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/OperatingSystem.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/OperatingSystem.java index 271a0faf2..145a934fd 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/OperatingSystem.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/platform/OperatingSystem.java @@ -227,6 +227,30 @@ public enum OperatingSystem { return UNKNOWN; } + public static boolean isWindows7OrLater() { + if (CURRENT_OS != WINDOWS) { + return false; + } + + int major; + int dotIndex = SYSTEM_VERSION.indexOf('.'); + try { + if (dotIndex < 0) { + major = Integer.parseInt(SYSTEM_VERSION); + } else { + major = Integer.parseInt(SYSTEM_VERSION.substring(0, dotIndex)); + } + } catch (NumberFormatException ignored) { + return false; + } + + // Windows XP: NT 5.1~5.2 + // Windows Vista: NT 6.0 + // Windows 7: NT 6.1 + + return major >= 6 && !SYSTEM_VERSION.startsWith("6.0"); + } + @SuppressWarnings("deprecation") public static Optional getPhysicalMemoryStatus() { if (CURRENT_OS == LINUX) { diff --git a/HMCLauncher/HMCL/HMCL.vcxproj b/HMCLauncher/HMCL/HMCL.vcxproj index af96ee8f8..fe4858207 100644 --- a/HMCLauncher/HMCL/HMCL.vcxproj +++ b/HMCLauncher/HMCL/HMCL.vcxproj @@ -23,33 +23,33 @@ {672B1019-E741-4C0D-A986-627E2ACE157B} Win32Proj HMCL - 10.0.18362.0 + 10.0 HMCLauncher Application true - v141_xp + v143 Unicode Application false - v141_xp + v143 true Unicode Application true - v141 + v143 Unicode Application false - v141_xp + v143 true Unicode diff --git a/HMCLauncher/HMCL/main.cpp b/HMCLauncher/HMCL/main.cpp index 2aad481e8..0d589c168 100644 --- a/HMCLauncher/HMCL/main.cpp +++ b/HMCLauncher/HMCL/main.cpp @@ -75,23 +75,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, bool useChinese = GetUserDefaultUILanguage() == 2052; // zh-CN - OSVERSIONINFOEX osvi; - DWORDLONG dwlConditionMask = 0; - int op = VER_GREATER_EQUAL; - - // Initialize the OSVERSIONINFOEX structure. - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - osvi.dwMajorVersion = 6; - osvi.dwMinorVersion = 1; - - // Initialize the condition mask. - VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); - VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); - - // Try downloading Java on Windows 7 or later - bool isWin7OrLater = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask); - SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); // TODO: check whether the bundled JRE is valid. @@ -156,19 +139,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, FindJavaInDirAndLaunchJVM(hmclJavaDir, workdir, exeName, jvmOptions); } -error: LPCWSTR downloadLink; - if (isWin7OrLater) { - if (isARM64) { - downloadLink = L"https://docs.hmcl.net/downloads/windows/arm64.html"; - } if (isX64) { - downloadLink = L"https://docs.hmcl.net/downloads/windows/x86_64.html"; - } else { - downloadLink = L"https://docs.hmcl.net/downloads/windows/x86.html"; - } + if (isARM64) { + downloadLink = L"https://docs.hmcl.net/downloads/windows/arm64.html"; + } if (isX64) { + downloadLink = L"https://docs.hmcl.net/downloads/windows/x86_64.html"; } else { - downloadLink = L"https://docs.hmcl.net/downloads/java.html"; + downloadLink = L"https://docs.hmcl.net/downloads/windows/x86.html"; } if (IDOK == MessageBox(NULL, useChinese ? ERROR_PROMPT_ZH : ERROR_PROMPT, useChinese ? ERROR_TITLE_ZH : ERROR_TITLE, MB_ICONWARNING | MB_OKCANCEL)) { diff --git a/HMCLauncher/HMCL/targetver.h b/HMCLauncher/HMCL/targetver.h index 46161da10..e1306e323 100644 --- a/HMCLauncher/HMCL/targetver.h +++ b/HMCLauncher/HMCL/targetver.h @@ -1,8 +1,8 @@ #pragma once -// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 +// Windows 7 -// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将 -// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 +#define WINVER 0x0601 +#define _WIN32_WINNT 0x0601 #include