Skip to content

V1.1: Basically steady version

Latest
Compare
Choose a tag to compare
@Muyu-Chen Muyu-Chen released this 15 Jan 07:30
· 7 commits to main since this release

Auto-Update Checker Documentation

Overview

The Auto-Update Checker is a lightweight utility designed to check for updates and download the latest version of your application. This program ensures that your software remains up-to-date by comparing the current version with the version available at a specified URL.

Usage

Command-line Options

The program accepts the following command-line arguments:

English

Usage: Auto-Update-Checker.exe [options]
Options:
  -url <url>          Specify the URL to fetch version data.
  -version <version>  Specify the current version of the program.
  -showConfirm        Show confirmation dialog before updating (optional, default is true).
  -help               Show this help message. If used with other options, it will take precedence.

Example in C Language

To integrate the update checker into your application, use a system call to execute the .exe file:

Code Example (English)

// Define the current version and update URL.
const char* version = "3.2.1"; // Current program version (hardcoded).
const char* url = "http://xxx/xxx.json"; // Update URL.

// Construct the command.
char command[256];
snprintf(command, sizeof(command), "path\to\dic\Auto-Update-Checker.exe -version %s -url %s", version, url);

// Execute the command and handle the result.
int result = system(command);

if (result == 1) {
    // A new version has been downloaded.
    printf("Updating...\n");
    // Notify the user to close the main program.
    printf("Please close the main program within 5 seconds to avoid update failure.\n");
    return 0; // Exit the program to allow the update to proceed.
} else if (result == 0) {
    // The current version is up-to-date or the user refused to update.
    printf("No update performed.\n");
} else if (result == -1) {
    // The user agreed to update but the update failed.
    printf("Update failed.\n");
} else {
    // Handle other unexpected results.
    printf("An unknown error occurred while checking for updates.\n");
}

Supported Version Format

  • Now supports four-segment version numbers (e.g., 3.2.1.0).
  • If more segments are needed, modify the version number length in your application.
  • For compatibility, three-segment versions (e.g., 3.2.0) are also supported.

Return Values

  • 1: A new version has been downloaded successfully. The update will start after 5 seconds. The main program must close immediately to avoid conflicts.
  • 0: No update was performed (either the version is up-to-date, or the user declined the update).
  • -1: The user agreed to update, but the update failed.

Note

  • This tool is very simple to use. On your website, store a JSON file like the following:
{
    "version": "2.3.2.0",
    "download_url": "https://download.com/example.zip"
}
  • When downloading, remember to include the license file to comply with the Apache License terms.

Additional Features

  • A confirmation popup is now included before proceeding with updates, giving users the option to accept or decline the update.
  • If the -showConfirm option is omitted or specified with a value other than false, the program will default to showing the confirmation dialog.

自动更新检查工具文档

概述

Auto-Update Checker 是一个轻量级工具,用于检查更新并下载应用程序的最新版本。此程序通过比较当前版本和指定 URL 上的版本来确保您的软件保持最新。

使用说明

命令行选项

此程序接受以下命令行参数:

中文

用法: Auto-Update-Checker.exe [选项]
选项:
  -url <url>          指定用于获取版本数据的URL(可选,默认使用硬编码的url);
  -version <version>  指定程序的当前版本;
  -showConfirm        在更新前显示确认对话框(可选,默认显示);
  -help               显示此帮助消息,若同时与其他选项一起使用,会被忽略。

示例代码

要在您的应用程序中集成此更新检查工具,可以通过系统调用执行此 .exe 文件:

示例代码

// 定义当前版本号和更新的URL。
const char* version = "3.2.1"; // 当前程序的版本号(建议硬编码)。
const char* url = "http://xxx/xxx.json"; // 更新地址。

// 构造命令。
char command[256];
snprintf(command, sizeof(command), "path\to\dic\Auto-Update-Checker.exe -version %s -url %s", version, url);

// 执行命令并处理结果。
int result = system(command);

if (result == 1) {
    // 新版本已下载。
    printf("正在更新...\n");
    // 通知用户关闭主程序。
    printf("请在5秒内关闭主程序以避免更新失败。\n");
    return 0; // 退出程序以允许更新继续。
} else if (result == 0) {
    // 当前版本已是最新或用户拒绝更新。
    printf("未执行更新操作。\n");
} else if (result == -1) {
    // 用户同意更新但更新失败。
    printf("更新失败。\n");
} else {
    // 处理其他意外结果。
    printf("检查更新时发生未知错误。\n");
}

版本格式支持

  • 现在支持四段式版本号(例如 3.2.1.0)。
  • 如果需要更多段式版本号,可修改应用程序中的版本号长度。
  • 为兼容性,仍支持三段式版本号(例如 3.2.0)。

返回值

  • 1:新版本已成功下载。更新将在 5 秒后开始,主程序必须立即关闭以避免冲突。
  • 0:未执行更新操作(当前版本已是最新,或用户拒绝更新)。
  • -1:用户同意更新但更新失败。

注意

  • 此工具使用非常简单。在您的网站上存储一个如下所示的 JSON 文件即可:
{
    "version": "2.3.2.0",
    "download_url": "https://download.com/example.zip"
}
  • 下载时请记得包含许可证文件,以符合 Apache License 的规定。

附加功能

  • 现在已包含更新前的确认弹窗,用户可以选择接受或拒绝更新。
  • 如果省略 -showConfirm 参数或指定的值不是 false,程序默认显示确认对话框。

Full changelog:
V1.0...V1.1