mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-06 16:10:42 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11081dd56b | ||
|
|
005e3f7536 | ||
|
|
1997abe601 | ||
|
|
9b1c74a6a1 | ||
|
|
5ad3d8ae9f | ||
|
|
8019c29abb | ||
|
|
1b7048d570 | ||
|
|
bba99d800f | ||
|
|
4831af1f69 | ||
|
|
f4e871e80e | ||
|
|
43f4be4a0f | ||
|
|
cedfe32b15 | ||
|
|
1a31b70fbb | ||
|
|
8805b12223 | ||
|
|
70534c06db | ||
|
|
9e11e66e03 | ||
|
|
4b8283574a | ||
|
|
de48557786 | ||
|
|
aa739e8d9e | ||
|
|
924684918c | ||
|
|
76bb4d1b50 | ||
|
|
94fafdb3ed | ||
|
|
b09175550e | ||
|
|
c3b5e3fe66 | ||
|
|
1cad6573e2 | ||
|
|
d01b7a4b5a | ||
|
|
7d393aa817 | ||
|
|
f28ec55eaf | ||
|
|
cbf4a2bc2d |
@@ -51,7 +51,7 @@ namespace AppStore
|
|||||||
|
|
||||||
// 初始化并添加应用信息
|
// 初始化并添加应用信息
|
||||||
infoLabel = new Label();
|
infoLabel = new Label();
|
||||||
infoLabel.Text = "kortapp-z\n版本: 1.3.4\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
infoLabel.Text = "kortapp-z\n版本: 1.3.9\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
||||||
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
||||||
infoLabel.AutoSize = false;
|
infoLabel.AutoSize = false;
|
||||||
infoLabel.Width = 300;
|
infoLabel.Width = 300;
|
||||||
@@ -125,7 +125,7 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保留原AboutForm作为容器(可选)
|
// 保留原AboutForm作为容器
|
||||||
public class AboutForm : Form
|
public class AboutForm : Form
|
||||||
{
|
{
|
||||||
public AboutForm()
|
public AboutForm()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ namespace AppStore
|
|||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public int Progress { get; set; }
|
public int Progress { get; set; }
|
||||||
public string Status { get; set; } = string.Empty;
|
public string Status { get; set; } = string.Empty;
|
||||||
|
public Process? DownloadProcess { get; set; }
|
||||||
|
|
||||||
public DownloadItem()
|
public DownloadItem()
|
||||||
{
|
{
|
||||||
@@ -123,9 +125,26 @@ namespace AppStore
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// 1. 先取消下载
|
||||||
DownloadManager.Instance.CancelDownload(this);
|
DownloadManager.Instance.CancelDownload(this);
|
||||||
|
|
||||||
|
// 2. 更新状态为已取消
|
||||||
Status = "已取消";
|
Status = "已取消";
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
|
|
||||||
|
// 3. 延迟100ms后移除控件,确保UI更新完成
|
||||||
|
var timer = new System.Windows.Forms.Timer { Interval = 100 };
|
||||||
|
timer.Tick += (s, args) =>
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
timer.Dispose();
|
||||||
|
if (this.Parent != null)
|
||||||
|
{
|
||||||
|
this.Parent.Controls.Remove(this);
|
||||||
|
this.Dispose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
timer.Start();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ namespace AppStore
|
|||||||
private static DownloadManager instance = null!;
|
private static DownloadManager instance = null!;
|
||||||
public static DownloadManager Instance => instance ??= new DownloadManager();
|
public static DownloadManager Instance => instance ??= new DownloadManager();
|
||||||
|
|
||||||
private Process? currentProcess;
|
|
||||||
public List<DownloadItem> DownloadItems { get; } = new List<DownloadItem>();
|
public List<DownloadItem> DownloadItems { get; } = new List<DownloadItem>();
|
||||||
|
|
||||||
public event Action<DownloadItem> DownloadAdded = delegate { };
|
public event Action<DownloadItem> DownloadAdded = delegate { };
|
||||||
@@ -78,6 +77,8 @@ namespace AppStore
|
|||||||
Status = "准备下载"
|
Status = "准备下载"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 创建进程并关联到下载项
|
||||||
|
downloadItem.DownloadProcess = new Process();
|
||||||
DownloadItems.Add(downloadItem);
|
DownloadItems.Add(downloadItem);
|
||||||
DownloadAdded?.Invoke(downloadItem);
|
DownloadAdded?.Invoke(downloadItem);
|
||||||
|
|
||||||
@@ -137,18 +138,15 @@ namespace AppStore
|
|||||||
var arguments = $"--out=\"{originalFileName}\" --dir=\"{downloadsDir}\" --split=16 --max-connection-per-server=16 {url}";
|
var arguments = $"--out=\"{originalFileName}\" --dir=\"{downloadsDir}\" --split=16 --max-connection-per-server=16 {url}";
|
||||||
|
|
||||||
|
|
||||||
currentProcess = new Process
|
downloadItem.DownloadProcess.StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo
|
FileName = aria2cPath,
|
||||||
{
|
Arguments = arguments,
|
||||||
FileName = aria2cPath,
|
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
|
||||||
Arguments = arguments,
|
UseShellExecute = false,
|
||||||
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
|
CreateNoWindow = true,
|
||||||
UseShellExecute = false,
|
RedirectStandardOutput = true,
|
||||||
CreateNoWindow = true,
|
RedirectStandardError = true
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取目标文件路径
|
// 获取目标文件路径
|
||||||
@@ -170,7 +168,7 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
currentProcess.OutputDataReceived += (sender, e) =>
|
downloadItem.DownloadProcess.OutputDataReceived += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(e.Data))
|
if (!string.IsNullOrEmpty(e.Data))
|
||||||
{
|
{
|
||||||
@@ -211,7 +209,7 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
currentProcess.ErrorDataReceived += (sender, e) =>
|
downloadItem.DownloadProcess.ErrorDataReceived += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(e.Data))
|
if (!string.IsNullOrEmpty(e.Data))
|
||||||
{
|
{
|
||||||
@@ -221,9 +219,9 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
currentProcess.Exited += (sender, e) =>
|
downloadItem.DownloadProcess.Exited += (sender, e) =>
|
||||||
{
|
{
|
||||||
var process = currentProcess;
|
var process = downloadItem.DownloadProcess;
|
||||||
if (process == null) return;
|
if (process == null) return;
|
||||||
|
|
||||||
var result = GetProcessResult(process);
|
var result = GetProcessResult(process);
|
||||||
@@ -292,10 +290,8 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (process != null)
|
// 清理资源
|
||||||
{
|
downloadItem.DownloadProcess = null;
|
||||||
currentProcess = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制更新显示
|
// 强制更新显示
|
||||||
@@ -304,13 +300,13 @@ namespace AppStore
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!currentProcess.Start())
|
if (!downloadItem.DownloadProcess.Start())
|
||||||
{
|
{
|
||||||
throw new Exception("进程启动失败");
|
throw new Exception("进程启动失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentProcess.BeginOutputReadLine();
|
downloadItem.DownloadProcess.BeginOutputReadLine();
|
||||||
currentProcess.BeginErrorReadLine();
|
downloadItem.DownloadProcess.BeginErrorReadLine();
|
||||||
progressTimer.Start();
|
progressTimer.Start();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -333,7 +329,7 @@ namespace AppStore
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var process = currentProcess;
|
var process = item.DownloadProcess;
|
||||||
if (process?.StartInfo == null || process.HasExited)
|
if (process?.StartInfo == null || process.HasExited)
|
||||||
{
|
{
|
||||||
item.Status = "已取消";
|
item.Status = "已取消";
|
||||||
@@ -343,7 +339,7 @@ namespace AppStore
|
|||||||
|
|
||||||
process.Kill();
|
process.Kill();
|
||||||
process.Dispose();
|
process.Dispose();
|
||||||
currentProcess = null;
|
item.DownloadProcess = null;
|
||||||
|
|
||||||
item.Status = "已取消";
|
item.Status = "已取消";
|
||||||
DownloadProgressChanged?.Invoke(item);
|
DownloadProgressChanged?.Invoke(item);
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 zsyg
|
Copyright (c) 2025 zs-yg
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
111
MainForm.cs
111
MainForm.cs
@@ -147,6 +147,8 @@ namespace AppStore
|
|||||||
|
|
||||||
// 软件下载按钮
|
// 软件下载按钮
|
||||||
private Button btnApps = null!;
|
private Button btnApps = null!;
|
||||||
|
// 网站推荐按钮
|
||||||
|
private Button btnWebsites = null!;
|
||||||
// 下载进度按钮
|
// 下载进度按钮
|
||||||
private Button btnDownloads = null!;
|
private Button btnDownloads = null!;
|
||||||
// 设置按钮
|
// 设置按钮
|
||||||
@@ -155,6 +157,8 @@ namespace AppStore
|
|||||||
private Button btnAbout = null!;
|
private Button btnAbout = null!;
|
||||||
// 内容显示面板
|
// 内容显示面板
|
||||||
private Panel contentPanel = null!;
|
private Panel contentPanel = null!;
|
||||||
|
// 网站卡片流式布局面板
|
||||||
|
private FlowLayoutPanel websitesFlowPanel = new FlowLayoutPanel();
|
||||||
// 系统托盘图标
|
// 系统托盘图标
|
||||||
private NotifyIcon trayIcon = null!;
|
private NotifyIcon trayIcon = null!;
|
||||||
// 托盘右键菜单
|
// 托盘右键菜单
|
||||||
@@ -372,10 +376,21 @@ namespace AppStore
|
|||||||
};
|
};
|
||||||
buttonPanel.Controls.Add(btnAbout);
|
buttonPanel.Controls.Add(btnAbout);
|
||||||
|
|
||||||
|
// 网站推荐按钮
|
||||||
|
btnWebsites = new Button();
|
||||||
|
btnWebsites.Text = "网站推荐";
|
||||||
|
btnWebsites.Location = new Point(590, 0);
|
||||||
|
styleButton(btnWebsites);
|
||||||
|
btnWebsites.Click += (s, e) => {
|
||||||
|
Logger.Log("用户点击了'网站推荐'按钮");
|
||||||
|
ShowWebsitesView();
|
||||||
|
};
|
||||||
|
buttonPanel.Controls.Add(btnWebsites);
|
||||||
|
|
||||||
// 内置工具按钮
|
// 内置工具按钮
|
||||||
var btnTools = new Button();
|
var btnTools = new Button();
|
||||||
btnTools.Text = "内置工具";
|
btnTools.Text = "内置工具";
|
||||||
btnTools.Location = new Point(590, 0);
|
btnTools.Location = new Point(730, 0);
|
||||||
styleButton(btnTools);
|
styleButton(btnTools);
|
||||||
btnTools.Click += (s, e) => {
|
btnTools.Click += (s, e) => {
|
||||||
Logger.Log("用户点击了'内置工具'按钮");
|
Logger.Log("用户点击了'内置工具'按钮");
|
||||||
@@ -783,6 +798,43 @@ namespace AppStore
|
|||||||
};
|
};
|
||||||
flowPanel.Controls.Add(imageConverterCard);
|
flowPanel.Controls.Add(imageConverterCard);
|
||||||
|
|
||||||
|
// 哈希提取器工具卡片
|
||||||
|
var hashExtractorCard = new ToolCard();
|
||||||
|
hashExtractorCard.ToolName = "哈希提取器";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string iconPath = Path.Combine(Application.StartupPath, "img", "resource", "png", "hash_value_extractor.png");
|
||||||
|
if (File.Exists(iconPath))
|
||||||
|
{
|
||||||
|
hashExtractorCard.ToolIcon = Image.FromFile(iconPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hashExtractorCard.ToolIcon = SystemIcons.Shield.ToBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
hashExtractorCard.ToolIcon = SystemIcons.Shield.ToBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
hashExtractorCard.UpdateDisplay();
|
||||||
|
hashExtractorCard.ToolCardClicked += (s, e) => {
|
||||||
|
try {
|
||||||
|
string toolPath = Path.Combine(Application.StartupPath, "resource", "hash_value_extractor.exe");
|
||||||
|
if (File.Exists(toolPath)) {
|
||||||
|
Process.Start(toolPath);
|
||||||
|
} else {
|
||||||
|
MessageBox.Show("哈希提取器工具未找到,请确保已正确安装", "错误",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
MessageBox.Show($"启动哈希提取器失败: {ex.Message}", "错误",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
flowPanel.Controls.Add(hashExtractorCard);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -793,6 +845,37 @@ namespace AppStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowWebsitesView()
|
||||||
|
{
|
||||||
|
contentPanel.Controls.Clear();
|
||||||
|
websitesFlowPanel.Dock = DockStyle.Fill;
|
||||||
|
websitesFlowPanel.AutoScroll = true;
|
||||||
|
websitesFlowPanel.WrapContents = false;
|
||||||
|
websitesFlowPanel.Padding = new Padding(20);
|
||||||
|
contentPanel.Controls.Add(websitesFlowPanel);
|
||||||
|
|
||||||
|
var card1 = new WebSiteCards();
|
||||||
|
card1.WebSiteName = "GitHub";
|
||||||
|
card1.WebSiteIconPath = "img/jpg/github.jpg";
|
||||||
|
card1.Description = "全球最大的代码托管平台,支持Git版本控制";
|
||||||
|
card1.WebSiteUrl = "https://github.com";
|
||||||
|
websitesFlowPanel.Controls.Add(card1);
|
||||||
|
|
||||||
|
var card2 = new WebSiteCards();
|
||||||
|
card2.WebSiteName = "Stack Overflow";
|
||||||
|
card2.WebSiteIconPath = "img/png/StackOverflow.png";
|
||||||
|
card2.Description = "程序员问答社区,解决各种编程问题";
|
||||||
|
card2.WebSiteUrl = "https://stackoverflow.com";
|
||||||
|
websitesFlowPanel.Controls.Add(card2);
|
||||||
|
|
||||||
|
var card3 = new WebSiteCards();
|
||||||
|
card3.WebSiteName = "果核剥壳";
|
||||||
|
card3.WebSiteIconPath = "img/png/gkbk.png";
|
||||||
|
card3.Description = "互联网的净土,分享互联网的精神与价值";
|
||||||
|
card3.WebSiteUrl = "https://www.ghxi.com/";
|
||||||
|
websitesFlowPanel.Controls.Add(card3);
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowAboutView()
|
private void ShowAboutView()
|
||||||
{
|
{
|
||||||
contentPanel.Controls.Clear();
|
contentPanel.Controls.Clear();
|
||||||
@@ -1129,6 +1212,12 @@ namespace AppStore
|
|||||||
"img/png/godot.png",
|
"img/png/godot.png",
|
||||||
"Godot - 免费开源的由社区驱动的游戏引擎"));
|
"Godot - 免费开源的由社区驱动的游戏引擎"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"luanti游戏引擎",
|
||||||
|
"https://www.ghproxy.cn/https://github.com/luanti-org/luanti/releases/download/5.12.0/luanti-5.12.0-win64.zip",
|
||||||
|
"img/png/Luanti.png",
|
||||||
|
"Luanti - Luanti(以前称为 Minetest)是一个开源体素游戏创建平台,具有简单的模组和游戏创建功能"));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"7-Zip",
|
"7-Zip",
|
||||||
"https://objects.githubusercontent.com/github-production-release-asset-2e65be/466446150/1645817e-3677-4207-93ff-e62de7e147be?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250613T035936Z&X-Amz-Expires=300&X-Amz-Signature=5e02d5fc34f45bd8308029c9fc78052007e9475ce0e32775619921cb8f3b83ea&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D7z2409-x64.exe&response-content-type=application%2Foctet-stream",
|
"https://objects.githubusercontent.com/github-production-release-asset-2e65be/466446150/1645817e-3677-4207-93ff-e62de7e147be?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250613T035936Z&X-Amz-Expires=300&X-Amz-Signature=5e02d5fc34f45bd8308029c9fc78052007e9475ce0e32775619921cb8f3b83ea&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3D7z2409-x64.exe&response-content-type=application%2Foctet-stream",
|
||||||
@@ -1544,12 +1633,30 @@ namespace AppStore
|
|||||||
"img/ico/Sumatra PDF.ico",
|
"img/ico/Sumatra PDF.ico",
|
||||||
"Sumatra PDF - 轻量级的PDF阅读器"));
|
"Sumatra PDF - 轻量级的PDF阅读器"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"LiveRecorder",
|
||||||
|
"https://ghproxy.net/https://github.com/auqhjjqdo/LiveRecorder/releases/download/v2.35/LiveRecorder_Windows_v2.35.zip",
|
||||||
|
"",
|
||||||
|
"LiveRecorder - 基于Streamlink的全自动直播录制工具"));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"Freeplane",
|
"Freeplane",
|
||||||
"https://ghproxy.net/https://github.com/zs-yg/package/releases/download/v0.5/Freeplane-Setup-1.12.11.exe.7z",
|
"https://ghproxy.net/https://github.com/zs-yg/package/releases/download/v0.5/Freeplane-Setup-1.12.11.exe.7z",
|
||||||
"img/png/Freeplane.png",
|
"img/png/Freeplane.png",
|
||||||
"Freeplane - 思维导图软件,帮助组织思路"));
|
"Freeplane - 思维导图软件,帮助组织思路"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"Win11Debloat",
|
||||||
|
"https://ghproxy.net/https://github.com/Raphire/Win11Debloat/releases/download/2025.06.12/Get.ps1",
|
||||||
|
"img/png/powershell.png",
|
||||||
|
"Win11Debloat - 这是一个简单易用的PowerShell脚本,可用于删除预装应用程序、禁用遥测以及执行各种其他更改,以自定义、整理和改善您的Windows体验。Win11Debloat适用于Windows 10和Windows 11。"));
|
||||||
|
|
||||||
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
|
"keycloak",
|
||||||
|
"https://ghproxy.net/https://github.com/keycloak/keycloak/releases/download/26.3.2/keycloak-26.3.2.zip",
|
||||||
|
"img/png/keycloak.png",
|
||||||
|
"keycloak - 现代应用程序和服务的开源身份和访问管理"));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"Motrix",
|
"Motrix",
|
||||||
"https://dl.motrix.app/release/Motrix-Setup-1.8.19.exe",
|
"https://dl.motrix.app/release/Motrix-Setup-1.8.19.exe",
|
||||||
@@ -1662,7 +1769,7 @@ namespace AppStore
|
|||||||
"BongoCat",
|
"BongoCat",
|
||||||
"https://ghproxy.net/https://github.com/ayangweb/BongoCat/releases/download/v0.5.0/BongoCat_0.5.0_x64-setup.exe",
|
"https://ghproxy.net/https://github.com/ayangweb/BongoCat/releases/download/v0.5.0/BongoCat_0.5.0_x64-setup.exe",
|
||||||
"img/png/BongoCat.png",
|
"img/png/BongoCat.png",
|
||||||
"BongoCat - 让b你的桌面多一个同步操作的可爱的桌宠"));
|
"BongoCat - 让你的桌面多一个同步操作的可爱的桌宠"));
|
||||||
|
|
||||||
flowPanel.Controls.Add(CreateAppCard(
|
flowPanel.Controls.Add(CreateAppCard(
|
||||||
"GalaceanEngine(code)",
|
"GalaceanEngine(code)",
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ Copyright (c) 2025 zsyg
|
|||||||
|
|
||||||
## 其他网站
|
## 其他网站
|
||||||
|
|
||||||
gitee镜像仓库:https://gitee.com/chr_super/kortapp-z (目前已经停止维护)
|
gitee镜像仓库:https://gitee.com/chr_super/kortapp-z (目前已经停止维护,仅镜像代码)
|
||||||
|
|
||||||
|
sourceforge镜像仓库:https://sourceforge.net/projects/kortapp-z/ (提供releases镜像)
|
||||||
|
|
||||||
## 维护
|
## 维护
|
||||||
|
|
||||||
|
|||||||
196
WebSiteCards.cs
Normal file
196
WebSiteCards.cs
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace AppStore
|
||||||
|
{
|
||||||
|
public class WebSiteCards : UserControl
|
||||||
|
{
|
||||||
|
private PictureBox iconBox;
|
||||||
|
private Label nameLabel;
|
||||||
|
private Label descriptionLabel;
|
||||||
|
private Button visitBtn;
|
||||||
|
private ToolTip toolTip;
|
||||||
|
private Color borderColor = SystemColors.ControlDark;
|
||||||
|
|
||||||
|
public string WebSiteName { get; set; } = string.Empty;
|
||||||
|
private Image _webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
public Image WebSiteIcon
|
||||||
|
{
|
||||||
|
get { return _webSiteIcon; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
_webSiteIcon = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
UpdateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string WebSiteIconPath
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = value;
|
||||||
|
if (!Path.IsPathRooted(path))
|
||||||
|
{
|
||||||
|
path = Path.Combine(Application.StartupPath, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
_webSiteIcon = Image.FromFile(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_webSiteIcon = SystemIcons.Application.ToBitmap();
|
||||||
|
}
|
||||||
|
UpdateDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string WebSiteUrl { get; set; } = string.Empty;
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public WebSiteCards()
|
||||||
|
{
|
||||||
|
iconBox = new PictureBox() { SizeMode = PictureBoxSizeMode.StretchImage };
|
||||||
|
nameLabel = new Label() { Text = string.Empty };
|
||||||
|
descriptionLabel = new Label() { Text = string.Empty };
|
||||||
|
visitBtn = new Button() { Text = "访问" };
|
||||||
|
toolTip = new ToolTip();
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.Size = new Size(400, 150); // 更宽的卡片以适应横向布局
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.Padding = new Padding(10);
|
||||||
|
|
||||||
|
// 网站名称标签 - 顶部
|
||||||
|
nameLabel.Font = new Font("Microsoft YaHei", 10, FontStyle.Bold);
|
||||||
|
nameLabel.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
|
nameLabel.Location = new Point(10, 10);
|
||||||
|
nameLabel.Size = new Size(Width - 20, 20);
|
||||||
|
this.Controls.Add(nameLabel);
|
||||||
|
|
||||||
|
// 网站图标 - 左侧
|
||||||
|
iconBox.Size = new Size(80, 80);
|
||||||
|
iconBox.Location = new Point(10, 40);
|
||||||
|
this.Controls.Add(iconBox);
|
||||||
|
|
||||||
|
// 网站描述 - 右侧
|
||||||
|
descriptionLabel.Font = new Font("Microsoft YaHei", 9);
|
||||||
|
descriptionLabel.TextAlign = ContentAlignment.TopLeft;
|
||||||
|
descriptionLabel.AutoSize = false;
|
||||||
|
descriptionLabel.Size = new Size(Width - 110, 80);
|
||||||
|
descriptionLabel.Location = new Point(100, 40);
|
||||||
|
descriptionLabel.MaximumSize = new Size(Width - 110, 0); // 允许自动换行
|
||||||
|
this.Controls.Add(descriptionLabel);
|
||||||
|
|
||||||
|
// 访问按钮 - 右下角
|
||||||
|
visitBtn.Size = new Size(80, 30);
|
||||||
|
visitBtn.Location = new Point(Width - 90, Height - 40);
|
||||||
|
visitBtn.Click += VisitBtn_Click;
|
||||||
|
this.Controls.Add(visitBtn);
|
||||||
|
|
||||||
|
// 工具提示
|
||||||
|
toolTip.AutoPopDelay = 5000;
|
||||||
|
toolTip.InitialDelay = 500;
|
||||||
|
toolTip.ReshowDelay = 500;
|
||||||
|
toolTip.ShowAlways = true;
|
||||||
|
toolTip.SetToolTip(visitBtn, "在浏览器中打开网站");
|
||||||
|
|
||||||
|
UpdateDisplay();
|
||||||
|
UpdateLabelTheme();
|
||||||
|
ThemeManager.ThemeChanged += (theme) => UpdateLabelTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLabelTheme()
|
||||||
|
{
|
||||||
|
if (ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Dark)
|
||||||
|
{
|
||||||
|
this.BackColor = Color.FromArgb(45, 45, 48);
|
||||||
|
nameLabel.ForeColor = Color.White;
|
||||||
|
descriptionLabel.ForeColor = Color.White;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
nameLabel.ForeColor = Color.Black;
|
||||||
|
descriptionLabel.ForeColor = Color.Black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateDisplay()
|
||||||
|
{
|
||||||
|
nameLabel.Text = WebSiteName;
|
||||||
|
iconBox.Image = WebSiteIcon;
|
||||||
|
descriptionLabel.Text = Description;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void VisitBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(WebSiteUrl))
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = WebSiteUrl,
|
||||||
|
UseShellExecute = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"打开网站失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaint(e);
|
||||||
|
|
||||||
|
// 绘制圆角边框
|
||||||
|
using (var pen = new Pen(borderColor, 1))
|
||||||
|
{
|
||||||
|
int radius = 10;
|
||||||
|
var rect = new Rectangle(0, 0, Width - 1, Height - 1);
|
||||||
|
e.Graphics.DrawPath(pen, GetRoundedRectPath(rect, radius));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.Drawing.Drawing2D.GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
|
||||||
|
{
|
||||||
|
var path = new System.Drawing.Drawing2D.GraphicsPath();
|
||||||
|
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
|
||||||
|
path.AddArc(rect.X + rect.Width - radius, rect.Y, radius, radius, 270, 90);
|
||||||
|
path.AddArc(rect.X + rect.Width - radius, rect.Y + rect.Height - radius, radius, radius, 0, 90);
|
||||||
|
path.AddArc(rect.X, rect.Y + rect.Height - radius, radius, radius, 90, 90);
|
||||||
|
path.CloseFigure();
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
img/png/Luanti.png
Normal file
BIN
img/png/Luanti.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
img/png/StackOverflow.png
Normal file
BIN
img/png/StackOverflow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 690 B |
BIN
img/png/gkbk.png
Normal file
BIN
img/png/gkbk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
img/png/keycloak.png
Normal file
BIN
img/png/keycloak.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
BIN
img/resource/png/hash_value_extractor.png
Normal file
BIN
img/resource/png/hash_value_extractor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 889 KiB |
@@ -2,7 +2,7 @@
|
|||||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||||
|
|
||||||
#define MyAppName "kortapp-z"
|
#define MyAppName "kortapp-z"
|
||||||
#define MyAppVersion "1.3.4"
|
#define MyAppVersion "1.3.9"
|
||||||
#define MyAppPublisher "zsyg"
|
#define MyAppPublisher "zsyg"
|
||||||
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
||||||
#define MyAppExeName "kortapp-z.exe"
|
#define MyAppExeName "kortapp-z.exe"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||||
|
|
||||||
#define MyAppName "kortapp-z"
|
#define MyAppName "kortapp-z"
|
||||||
#define MyAppVersion "1.3.4"
|
#define MyAppVersion "1.3.9"
|
||||||
#define MyAppPublisher "zsyg"
|
#define MyAppPublisher "zsyg"
|
||||||
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
||||||
#define MyAppExeName "kortapp-z.exe"
|
#define MyAppExeName "kortapp-z.exe"
|
||||||
|
|||||||
55
others/C/hash_value_extractor/CMakeLists.txt
Normal file
55
others/C/hash_value_extractor/CMakeLists.txt
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(hash_value_extractor)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# 静态编译选项
|
||||||
|
option(BUILD_STATIC "Build with static linking" ON)
|
||||||
|
|
||||||
|
# 查找OpenSSL
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
|
# 设置Windows子系统
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows")
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||||
|
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
|
||||||
|
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
|
||||||
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
|
||||||
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 包含目录
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
# 添加可执行文件
|
||||||
|
add_executable(hash_value_extractor
|
||||||
|
src/main.c
|
||||||
|
src/md5.c
|
||||||
|
src/sha256.c
|
||||||
|
src/sha512.c
|
||||||
|
src/string_util.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# 链接OpenSSL库
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
# 显式指定静态库路径和名称
|
||||||
|
find_library(OPENSSL_SSL_STATIC_LIBRARY NAMES ssl libssl.a PATHS ${OPENSSL_ROOT_DIR}/lib)
|
||||||
|
find_library(OPENSSL_CRYPTO_STATIC_LIBRARY NAMES crypto libcrypto.a PATHS ${OPENSSL_ROOT_DIR}/lib)
|
||||||
|
|
||||||
|
target_link_libraries(hash_value_extractor
|
||||||
|
${OPENSSL_SSL_STATIC_LIBRARY}
|
||||||
|
${OPENSSL_CRYPTO_STATIC_LIBRARY}
|
||||||
|
-lcrypt32
|
||||||
|
-lws2_32
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(hash_value_extractor
|
||||||
|
OpenSSL::SSL
|
||||||
|
OpenSSL::Crypto
|
||||||
|
)
|
||||||
|
endif()
|
||||||
37
others/C/hash_value_extractor/include/hash_calculator.h
Normal file
37
others/C/hash_value_extractor/include/hash_calculator.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef HASH_CALCULATOR_H
|
||||||
|
#define HASH_CALCULATOR_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
HASH_MD5,
|
||||||
|
HASH_SHA256,
|
||||||
|
HASH_SHA512
|
||||||
|
} HashAlgorithm;
|
||||||
|
|
||||||
|
// 各算法计算函数
|
||||||
|
int calculate_md5(const char* filename, char* output);
|
||||||
|
int calculate_sha256(const char* filename, char* output);
|
||||||
|
int calculate_sha512(const char* filename, char* output);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算文件的哈希值
|
||||||
|
* @param filename 文件路径
|
||||||
|
* @param algorithm 哈希算法
|
||||||
|
* @param output 输出缓冲区(必须足够大)
|
||||||
|
* @return 成功返回0,失败返回-1
|
||||||
|
*/
|
||||||
|
static inline int calculate_file_hash(const char* filename, HashAlgorithm algorithm, char* output) {
|
||||||
|
switch (algorithm) {
|
||||||
|
case HASH_MD5:
|
||||||
|
return calculate_md5(filename, output);
|
||||||
|
case HASH_SHA256:
|
||||||
|
return calculate_sha256(filename, output);
|
||||||
|
case HASH_SHA512:
|
||||||
|
return calculate_sha512(filename, output);
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HASH_CALCULATOR_H
|
||||||
21
others/C/hash_value_extractor/include/string_util.h
Normal file
21
others/C/hash_value_extractor/include/string_util.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef STRING_UTIL_H
|
||||||
|
#define STRING_UTIL_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
// 快速分配字符串内存
|
||||||
|
char* str_alloc(size_t size);
|
||||||
|
|
||||||
|
// 快速释放字符串内存
|
||||||
|
void str_free(char* str);
|
||||||
|
|
||||||
|
// 快速字符串复制
|
||||||
|
char* str_copy(const char* src);
|
||||||
|
|
||||||
|
// 快速字符串连接
|
||||||
|
char* str_concat(const char* str1, const char* str2);
|
||||||
|
|
||||||
|
// 二进制转十六进制字符串
|
||||||
|
char* bin_to_hex(const unsigned char* data, size_t len);
|
||||||
|
|
||||||
|
#endif // STRING_UTIL_H
|
||||||
53
others/C/hash_value_extractor/src/hash_calculator.c
Normal file
53
others/C/hash_value_extractor/src/hash_calculator.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include "hash_calculator.h"
|
||||||
|
#include <openssl/md5.h>
|
||||||
|
#include <openssl/sha.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int calculate_file_hash(const char* filename, HashAlgorithm algorithm, char* output) {
|
||||||
|
FILE* file = fopen(filename, "rb");
|
||||||
|
if (!file) return -1;
|
||||||
|
|
||||||
|
const EVP_MD* md = NULL;
|
||||||
|
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||||
|
unsigned char hash[EVP_MAX_MD_SIZE];
|
||||||
|
unsigned int hash_len = 0;
|
||||||
|
|
||||||
|
switch (algorithm) {
|
||||||
|
case HASH_MD5:
|
||||||
|
md = EVP_md5();
|
||||||
|
break;
|
||||||
|
case HASH_SHA256:
|
||||||
|
md = EVP_sha256();
|
||||||
|
break;
|
||||||
|
case HASH_SHA512:
|
||||||
|
md = EVP_sha512();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fclose(file);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||||
|
|
||||||
|
unsigned char buffer[1024];
|
||||||
|
size_t bytes_read;
|
||||||
|
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
|
||||||
|
EVP_DigestUpdate(mdctx, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
|
||||||
|
EVP_MD_CTX_free(mdctx);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
hash_to_hex(hash, hash_len, output);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hash_to_hex(const unsigned char* hash, size_t hash_len, char* output) {
|
||||||
|
for (size_t i = 0; i < hash_len; i++) {
|
||||||
|
sprintf(output + (i * 2), "%02x", hash[i]);
|
||||||
|
}
|
||||||
|
output[hash_len * 2] = '\0';
|
||||||
|
}
|
||||||
|
</fitten_content>
|
||||||
204
others/C/hash_value_extractor/src/main.c
Normal file
204
others/C/hash_value_extractor/src/main.c
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
// 确保使用Unicode字符集
|
||||||
|
#define UNICODE
|
||||||
|
#define _UNICODE
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <commdlg.h>
|
||||||
|
#include "hash_calculator.h"
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#define IDC_ALGORITHM_COMBO 1001
|
||||||
|
#define IDC_FILE_EDIT 1002
|
||||||
|
#define IDC_HASH_EDIT 1003
|
||||||
|
#define IDC_BROWSE_BUTTON 1004
|
||||||
|
#define IDC_CALCULATE_BUTTON 1005
|
||||||
|
#define IDC_COPY_BUTTON 1006
|
||||||
|
|
||||||
|
// 中文UI字符串定义
|
||||||
|
static const wchar_t* APP_TITLE = L"哈希值提取器";
|
||||||
|
static const wchar_t* ALGORITHMS[] = {L"MD5", L"SHA-256", L"SHA-512"};
|
||||||
|
static const wchar_t* CALCULATE_BTN = L"计算哈希";
|
||||||
|
static const wchar_t* BROWSE_BTN = L"浏览...";
|
||||||
|
static const wchar_t* COPY_BTN = L"复制哈希值";
|
||||||
|
static const wchar_t* CALC_FAILED = L"计算哈希值失败";
|
||||||
|
|
||||||
|
// 全局变量
|
||||||
|
HWND g_hAlgorithmCombo, g_hFileEdit, g_hHashEdit;
|
||||||
|
|
||||||
|
// 初始化控件
|
||||||
|
void InitControls(HWND hWnd) {
|
||||||
|
// 算法选择下拉框
|
||||||
|
g_hAlgorithmCombo = CreateWindowW(L"COMBOBOX", NULL,
|
||||||
|
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL,
|
||||||
|
10, 10, 200, 200, hWnd, (HMENU)IDC_ALGORITHM_COMBO, NULL, NULL);
|
||||||
|
|
||||||
|
// 添加算法选项
|
||||||
|
SendMessageW(g_hAlgorithmCombo, CB_ADDSTRING, 0, (LPARAM)L"MD5");
|
||||||
|
SendMessageW(g_hAlgorithmCombo, CB_ADDSTRING, 0, (LPARAM)L"SHA-256");
|
||||||
|
SendMessageW(g_hAlgorithmCombo, CB_ADDSTRING, 0, (LPARAM)L"SHA-512");
|
||||||
|
SendMessageW(g_hAlgorithmCombo, CB_SETCURSEL, 0, 0);
|
||||||
|
|
||||||
|
// 文件路径编辑框
|
||||||
|
g_hFileEdit = CreateWindowW(L"EDIT", NULL,
|
||||||
|
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,
|
||||||
|
10, 40, 300, 25, hWnd, (HMENU)IDC_FILE_EDIT, NULL, NULL);
|
||||||
|
|
||||||
|
// 浏览按钮
|
||||||
|
CreateWindowW(L"BUTTON", L"浏览...",
|
||||||
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
||||||
|
320, 40, 80, 25, hWnd, (HMENU)IDC_BROWSE_BUTTON, NULL, NULL);
|
||||||
|
|
||||||
|
// 计算按钮
|
||||||
|
CreateWindowW(L"BUTTON", L"计算哈希",
|
||||||
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
||||||
|
10, 75, 100, 30, hWnd, (HMENU)IDC_CALCULATE_BUTTON, NULL, NULL);
|
||||||
|
|
||||||
|
// 哈希结果显示框
|
||||||
|
g_hHashEdit = CreateWindowW(L"EDIT", NULL,
|
||||||
|
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,
|
||||||
|
10, 115, 380, 100, hWnd, (HMENU)IDC_HASH_EDIT, NULL, NULL);
|
||||||
|
|
||||||
|
// 复制按钮
|
||||||
|
CreateWindowW(L"BUTTON", L"复制哈希值",
|
||||||
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
||||||
|
10, 225, 100, 30, hWnd, (HMENU)IDC_COPY_BUTTON, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择文件
|
||||||
|
void BrowseFile(HWND hWnd) {
|
||||||
|
OPENFILENAMEW ofn;
|
||||||
|
WCHAR szFile[MAX_PATH] = {0};
|
||||||
|
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.hwndOwner = hWnd;
|
||||||
|
ofn.lpstrFile = szFile;
|
||||||
|
ofn.nMaxFile = sizeof(szFile)/sizeof(szFile[0]);
|
||||||
|
ofn.lpstrFilter = L"所有文件\0*.*\0";
|
||||||
|
ofn.nFilterIndex = 1;
|
||||||
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||||
|
|
||||||
|
if (GetOpenFileNameW(&ofn)) {
|
||||||
|
SetWindowTextW(g_hFileEdit, szFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算哈希值
|
||||||
|
void CalculateHash() {
|
||||||
|
WCHAR wszFile[MAX_PATH];
|
||||||
|
char szFile[MAX_PATH];
|
||||||
|
char szHash[EVP_MAX_MD_SIZE * 2 + 1];
|
||||||
|
|
||||||
|
GetWindowTextW(g_hFileEdit, wszFile, MAX_PATH);
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, wszFile, -1, szFile, MAX_PATH, NULL, NULL);
|
||||||
|
|
||||||
|
int algorithm = SendMessageW(g_hAlgorithmCombo, CB_GETCURSEL, 0, 0);
|
||||||
|
|
||||||
|
if (calculate_file_hash(szFile, algorithm, szHash) == 0) {
|
||||||
|
WCHAR wszHash[EVP_MAX_MD_SIZE * 2 + 1];
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, szHash, -1, wszHash, EVP_MAX_MD_SIZE * 2 + 1);
|
||||||
|
SetWindowTextW(g_hHashEdit, wszHash);
|
||||||
|
} else {
|
||||||
|
SetWindowTextW(g_hHashEdit, L"计算哈希值失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制哈希值到剪贴板
|
||||||
|
void CopyHashToClipboard() {
|
||||||
|
if (OpenClipboard(NULL)) {
|
||||||
|
EmptyClipboard();
|
||||||
|
|
||||||
|
int len = GetWindowTextLengthW(g_hHashEdit) + 1;
|
||||||
|
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (hMem) {
|
||||||
|
WCHAR* pszMem = (WCHAR*)GlobalLock(hMem);
|
||||||
|
GetWindowTextW(g_hHashEdit, pszMem, len);
|
||||||
|
GlobalUnlock(hMem);
|
||||||
|
|
||||||
|
SetClipboardData(CF_UNICODETEXT, hMem);
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 窗口过程
|
||||||
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||||
|
switch (message) {
|
||||||
|
case WM_CREATE:
|
||||||
|
InitControls(hWnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
switch (LOWORD(wParam)) {
|
||||||
|
case IDC_BROWSE_BUTTON:
|
||||||
|
BrowseFile(hWnd);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_CALCULATE_BUTTON:
|
||||||
|
CalculateHash();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_COPY_BUTTON:
|
||||||
|
CopyHashToClipboard();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 程序入口
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||||
|
// 注册窗口类
|
||||||
|
WNDCLASSEXW wcex;
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = WndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
|
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||||
|
wcex.lpszMenuName = NULL;
|
||||||
|
wcex.lpszClassName = L"HashValueExtractor";
|
||||||
|
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
|
||||||
|
if (!RegisterClassExW(&wcex)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建窗口
|
||||||
|
HWND hWnd = CreateWindowW(
|
||||||
|
L"HashValueExtractor", L"哈希值提取器",
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT, 420, 300,
|
||||||
|
NULL, NULL, hInstance, NULL);
|
||||||
|
|
||||||
|
if (!hWnd) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示窗口
|
||||||
|
ShowWindow(hWnd, nCmdShow);
|
||||||
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
|
// 消息循环
|
||||||
|
MSG msg;
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)msg.wParam;
|
||||||
|
}
|
||||||
35
others/C/hash_value_extractor/src/md5.c
Normal file
35
others/C/hash_value_extractor/src/md5.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "hash_calculator.h"
|
||||||
|
#include "string_util.h"
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int calculate_md5(const char* filename, char* output) {
|
||||||
|
FILE* file = fopen(filename, "rb");
|
||||||
|
if (!file) return -1;
|
||||||
|
|
||||||
|
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||||
|
const EVP_MD* md = EVP_md5();
|
||||||
|
unsigned char hash[EVP_MAX_MD_SIZE];
|
||||||
|
unsigned int hash_len = 0;
|
||||||
|
|
||||||
|
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||||
|
|
||||||
|
unsigned char buffer[1024];
|
||||||
|
size_t bytes_read;
|
||||||
|
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
|
||||||
|
EVP_DigestUpdate(mdctx, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
|
||||||
|
EVP_MD_CTX_free(mdctx);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
char* hex = bin_to_hex(hash, hash_len);
|
||||||
|
if (hex) {
|
||||||
|
strcpy(output, hex);
|
||||||
|
str_free(hex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
35
others/C/hash_value_extractor/src/sha256.c
Normal file
35
others/C/hash_value_extractor/src/sha256.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "hash_calculator.h"
|
||||||
|
#include "string_util.h"
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int calculate_sha256(const char* filename, char* output) {
|
||||||
|
FILE* file = fopen(filename, "rb");
|
||||||
|
if (!file) return -1;
|
||||||
|
|
||||||
|
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||||
|
const EVP_MD* md = EVP_sha256();
|
||||||
|
unsigned char hash[EVP_MAX_MD_SIZE];
|
||||||
|
unsigned int hash_len = 0;
|
||||||
|
|
||||||
|
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||||
|
|
||||||
|
unsigned char buffer[1024];
|
||||||
|
size_t bytes_read;
|
||||||
|
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
|
||||||
|
EVP_DigestUpdate(mdctx, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
|
||||||
|
EVP_MD_CTX_free(mdctx);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
char* hex = bin_to_hex(hash, hash_len);
|
||||||
|
if (hex) {
|
||||||
|
strcpy(output, hex);
|
||||||
|
str_free(hex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
35
others/C/hash_value_extractor/src/sha512.c
Normal file
35
others/C/hash_value_extractor/src/sha512.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "hash_calculator.h"
|
||||||
|
#include "string_util.h"
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int calculate_sha512(const char* filename, char* output) {
|
||||||
|
FILE* file = fopen(filename, "rb");
|
||||||
|
if (!file) return -1;
|
||||||
|
|
||||||
|
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||||
|
const EVP_MD* md = EVP_sha512();
|
||||||
|
unsigned char hash[EVP_MAX_MD_SIZE];
|
||||||
|
unsigned int hash_len = 0;
|
||||||
|
|
||||||
|
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||||
|
|
||||||
|
unsigned char buffer[1024];
|
||||||
|
size_t bytes_read;
|
||||||
|
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
|
||||||
|
EVP_DigestUpdate(mdctx, buffer, bytes_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
|
||||||
|
EVP_MD_CTX_free(mdctx);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
char* hex = bin_to_hex(hash, hash_len);
|
||||||
|
if (hex) {
|
||||||
|
strcpy(output, hex);
|
||||||
|
str_free(hex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
120
others/C/hash_value_extractor/src/string_util.c
Normal file
120
others/C/hash_value_extractor/src/string_util.c
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
#include "string_util.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
// 内存池块大小
|
||||||
|
#define MEMORY_BLOCK_SIZE 4096
|
||||||
|
|
||||||
|
// 内存池结构
|
||||||
|
typedef struct MemoryBlock {
|
||||||
|
char* buffer;
|
||||||
|
size_t used;
|
||||||
|
struct MemoryBlock* next;
|
||||||
|
} MemoryBlock;
|
||||||
|
|
||||||
|
static MemoryBlock* memory_pool = NULL;
|
||||||
|
|
||||||
|
// 初始化内存池
|
||||||
|
static void init_memory_pool() {
|
||||||
|
if (memory_pool == NULL) {
|
||||||
|
memory_pool = malloc(sizeof(MemoryBlock));
|
||||||
|
memory_pool->buffer = malloc(MEMORY_BLOCK_SIZE);
|
||||||
|
memory_pool->used = 0;
|
||||||
|
memory_pool->next = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从内存池分配
|
||||||
|
static char* pool_alloc(size_t size) {
|
||||||
|
init_memory_pool();
|
||||||
|
|
||||||
|
MemoryBlock* block = memory_pool;
|
||||||
|
while (block != NULL) {
|
||||||
|
if (MEMORY_BLOCK_SIZE - block->used >= size) {
|
||||||
|
char* ptr = block->buffer + block->used;
|
||||||
|
block->used += size;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
if (block->next == NULL) {
|
||||||
|
block->next = malloc(sizeof(MemoryBlock));
|
||||||
|
block = block->next;
|
||||||
|
block->buffer = malloc(MEMORY_BLOCK_SIZE);
|
||||||
|
block->used = 0;
|
||||||
|
block->next = NULL;
|
||||||
|
} else {
|
||||||
|
block = block->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* str_alloc(size_t size) {
|
||||||
|
// 小内存从池分配,大内存直接分配
|
||||||
|
if (size <= MEMORY_BLOCK_SIZE / 4) {
|
||||||
|
char* ptr = pool_alloc(size + 1); // +1 for null terminator
|
||||||
|
if (ptr != NULL) {
|
||||||
|
ptr[size] = '\0';
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char* ptr = malloc(size + 1);
|
||||||
|
if (ptr != NULL) {
|
||||||
|
ptr[size] = '\0';
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void str_free(char* str) {
|
||||||
|
// 池分配的内存不单独释放
|
||||||
|
if (str == NULL) return;
|
||||||
|
|
||||||
|
// 检查是否在内存池中
|
||||||
|
MemoryBlock* block = memory_pool;
|
||||||
|
while (block != NULL) {
|
||||||
|
if (str >= block->buffer && str < block->buffer + MEMORY_BLOCK_SIZE) {
|
||||||
|
return; // 池内存不释放
|
||||||
|
}
|
||||||
|
block = block->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* str_copy(const char* src) {
|
||||||
|
if (src == NULL) return NULL;
|
||||||
|
|
||||||
|
size_t len = strlen(src);
|
||||||
|
char* dest = str_alloc(len);
|
||||||
|
if (dest != NULL) {
|
||||||
|
memcpy(dest, src, len);
|
||||||
|
}
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* str_concat(const char* str1, const char* str2) {
|
||||||
|
if (str1 == NULL) return str_copy(str2);
|
||||||
|
if (str2 == NULL) return str_copy(str1);
|
||||||
|
|
||||||
|
size_t len1 = strlen(str1);
|
||||||
|
size_t len2 = strlen(str2);
|
||||||
|
char* result = str_alloc(len1 + len2);
|
||||||
|
if (result != NULL) {
|
||||||
|
memcpy(result, str1, len1);
|
||||||
|
memcpy(result + len1, str2, len2);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* bin_to_hex(const unsigned char* data, size_t len) {
|
||||||
|
if (data == NULL || len == 0) return NULL;
|
||||||
|
|
||||||
|
char* hex = str_alloc(len * 2);
|
||||||
|
if (hex != NULL) {
|
||||||
|
static const char hex_chars[] = "0123456789abcdef";
|
||||||
|
for (size_t i = 0; i < len; i++) {
|
||||||
|
hex[i * 2] = hex_chars[(data[i] >> 4) & 0x0F];
|
||||||
|
hex[i * 2 + 1] = hex_chars[data[i] & 0x0F];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hex;
|
||||||
|
}
|
||||||
BIN
resource/hash_value_extractor.exe
Normal file
BIN
resource/hash_value_extractor.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user