Repository navigation
Releases: Muyu-Chen/Lite-Update-Checker
Release list
V1.1: Basically steady version
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
-showConfirmoption is omitted or specified with a value other thanfalse, 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
V1.0: Initial Version
Initial Version V1.0 | 初始V1.0版本
How to use?
In your application that requires updates, use a system call to invoke this .exe file. For example, in C language:
// The first parameter "3.2.1" represents the current version of the program. It's recommended to hardcode this in your program.
// The second parameter is your URL, which can be stored in a configuration file or hardcoded.
path = "path\\to\\dic\\Auto-Update-Checker.exe 3.2.1 \"http://xxx/xxx.json\""
// .data is used to pass a pointer
int result = system(path.data());
if(result == 1){
// This software will directly update. In the future, a popup will be added to confirm the update.
// When the result is returned, the file has already been downloaded,
// and the update will begin after 5 seconds. Please close the main program in time to avoid update failure.
printf("Updating...");
return 0; // Exit the program to avoid file occupation causing the update to fail.
}
Only three-segment version numbers are supported. If you only need two-segment version numbers, you can set the last segment to 0.
Return Values:
1: A new version has been downloaded. The update will start after 5 seconds. Please close all processes within 5 seconds.
0: The version is already up-to-date.
Note:
When downloading, remember to include the license file to comply with the Apache License terms.
How to use?
在你需要更新的应用程序中,使用系统的调用命令调用此exe,例如在C语言中:
// 第一个参数 3.2.1 为目前程序的版本号,建议硬编码进入程序
// 第二个参数为你的网址,可以放入配置文件中,或硬编码
path = "path\\to\\dic\\Auto-Update-Checker.exe 3.2.1 \"http://xxx/xxx.json\""
// .data为传递指针
int result = system(path.data());
if(result == 1){
// 本软件会直接更新,未来将加入弹窗来确认是否更新;
// 在result结果出来的时候,文件已经下载好,
// 并在5s后开始覆盖文件,请及时关闭主程序,避免更新失败。
printf("正在更新...");
return 0; //退出程序,避免占用导致更新失败
}
其中仅支持三位版本号,若仅使用两位版本号,可以直接把最后一位写为0即可。
返回值为1:新版本下载完成,5s后更新,请在5s内退出所有占用;
返回值为0:版本是最新版。