正确设置文件版本号

This commit is contained in:
zqm
2026-04-28 17:03:01 +08:00
parent 4f338363c7
commit d1fae575f3
3 changed files with 10 additions and 4 deletions

View File

@@ -6,16 +6,20 @@ fn main() {
{
let mut res = WindowsResource::new();
// 设置 FileVersion = 1.0.0.0
// 编码方式高32位 = (major << 16 | minor)低32位 = (patch << 16 | build)
// 1.0.0.0 => 0x0001_0000_0000_0000
// 1.0.0.0 => major=1, minor=0, patch=0, build=0 => 0x0001_0000_0000_0000
res.set_version_info(winres::VersionInfo::FILEVERSION, 0x0001_0000_0000_0000);
res.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0001_0000_0000_0000);
// 关键:显式设置字符串版本字段,与二进制版本保持一致
// 不设置的话PowerShell/.NET/Explorer 可能从不同字段读取,导致不一致
res.set("FileVersion", "1.0.0.1");
res.set("ProductVersion", "1.0.0.1");
// 设置产品名和公司名
res.set("ProductName", "BootLoader");
res.set("CompanyName", "JoyD");
res.set("FileDescription", "BootLoader Application");
res.set("FileDescription", "应用程序启动器");
res.set("LegalCopyright", "Copyright JoyD");
if let Err(e) = res.compile() {