NSIS版本号比较

NSIS打包脚本第二篇 NSIS 打包脚本 windows打包脚本 阅读详情

原地址:http://blog.csdn.net/debehe/article/details/3671142

  1. ;  From:http://nsis.sourceforge.net/Comparing_Two_Version_Numbers
  2. ;  Created 1/5/05 by Comperio
  3. ;
  4. ;   Usage:
  5. ;   ${VersionCheck} "Version1" "Version2" "outputVar"
  6. ;       Version1 = 1st version number
  7. ;       Version2 = 2nd version number
  8. ;       outputVar = Variable used to store the ouput
  9. ;
  10. ;   Return values:
  11. ;       0 = both versions are equal
  12. ;       1 = Version 1 is NEWER than version 2
  13. ;       2 = Version1 is OLDER than version 2
  14. ;   Rules for Version Numbers:
  15. ;       Version numbers must always be a string of numbers only.  (A dot
  16. ;       in the name is optional). 
  17. ;
  18. ;   [Variables]
  19. var P1  ; file pointer, used to "remember" the position in the Version1 string
  20. var P2  ; file pointer, used to "remember" the position in the Version2 string
  21. var V1  ;version number from Version1
  22. var V2  ;version number from Version2
  23. Var Reslt   ; holds the return flag
  24. ;   [Macros]
  25. !macro VersionCheck Ver1 Ver2 OutVar
  26.     ;   To make this work, one character must be added to the version string:
  27.     Push "x${Ver2}"
  28.     Push "x${Ver1}"
  29.     Call VersionCheckF
  30.     Pop ${OutVar}
  31. !macroend
  32. ;   [Defines]
  33. !define VersionCheck "!insertmacro VersionCheck"
  34. ;   [Functions]
  35. Function VersionCheckF
  36.     Exch $1 ; $1 contains Version 1
  37.     Exch
  38.     Exch $2 ; $2 contains Version 2
  39.     Exch
  40.     Push $R0
  41.     ;   initialize Variables
  42.     StrCpy $V1 ""
  43.     StrCpy $V2 ""
  44.     StrCpy $P1 ""
  45.     StrCpy $P2 ""
  46.     StrCpy $Reslt ""
  47.     ;   Set the file pointers:
  48.     IntOp $P1 $P1 + 1
  49.     IntOp $P2 $P2 + 1
  50.     ;  ******************* Get 1st version number for Ver1 **********************
  51.     V11:
  52.     ;   I use $1 and $2 to help keep identify "Ver1" vs. "Ver2"
  53.     StrCpy $R0 $1 1 $P1 ;$R0 contains the character at position $P1
  54.     IntOp $P1 $P1 + 1   ;increments the file pointer for the next read
  55.     StrCmp $R0 "" V11end 0  ;check for empty string
  56.     strCmp $R0 "." v11end 0
  57.     strCpy $V1 "$V1$R0"
  58.     Goto V11
  59.     V11End:
  60.     StrCmp $V1 "" 0 +2
  61.     StrCpy $V1 "0"  
  62.     ;  ******************* Get 1st version number for Ver2 **********************
  63.     V12:
  64.     StrCpy $R0 $2 1 $P2 ;$R0 contains the character at position $P1
  65.     IntOp $P2 $P2 + 1   ;increments the file pointer for the next read
  66.     StrCmp $R0 "" V12end 0  ;check for empty string
  67.     strCmp $R0 "." v12end 0
  68.     strCpy $V2 "$V2$R0"
  69.     Goto V12
  70.     V12End:
  71.     StrCmp $V2 "" 0 +2
  72.     StrCpy $V2 "0"  
  73.     ;   At this point, we can compare the results.  If the numbers are not
  74.     ;       equal, then we can exit
  75.     IntCmp $V1 $V2 cont1 older1 newer1
  76.     older1: ; Version 1 is older (less than) than version 2
  77.     StrCpy $Reslt 2
  78.     Goto ExitFunction
  79.     newer1: ; Version 1 is newer (greater than) Version 2
  80.     StrCpy $Reslt 1
  81.     Goto ExitFunction
  82.     Cont1: ;Versions are the same.  Continue searching for differences
  83.     ;   Reset $V1 and $V2
  84.     StrCpy $V1 ""
  85.     StrCpy $V2 ""
  86.     ;  ******************* Get 2nd version number for Ver1 **********************   
  87.     V21:
  88.     StrCpy $R0 $1 1 $P1 ;$R0 contains the character at position $P1
  89.     IntOp $P1 $P1 + 1   ;increments the file pointer for the next read
  90.     StrCmp $R0 "" V21end 0  ;check for empty string
  91.     strCmp $R0 "." v21end 0
  92.     strCpy $V1 "$V1$R0"
  93.     Goto V21
  94.     V21End:
  95.     StrCmp $V1 "" 0 +2
  96.     StrCpy $V1 "0"  
  97.     ;  ******************* Get 2nd version number for Ver2 **********************
  98.     V22:
  99.     StrCpy $R0 $2 1 $P2 ;$R0 contains the character at position $P1
  100.     IntOp $P2 $P2 + 1   ;increments the file pointer for the next read
  101.     StrCmp $R0 "" V22end 0  ;check for empty string
  102.     strCmp $R0 "." V22end 0
  103.     strCpy $V2 "$V2$R0"
  104.     Goto V22
  105.     V22End:
  106.     StrCmp $V2 "" 0 +2
  107.     StrCpy $V2 "0"  
  108.     ;   At this point, we can compare the results.  If the numbers are not
  109.     ;       equal, then we can exit
  110.     IntCmp $V1 $V2 cont2 older2 newer2
  111.     older2: ; Version 1 is older (less than) than version 2
  112.     StrCpy $Reslt 2 
  113.     Goto ExitFunction
  114.     newer2: ; Version 1 is newer (greater than) Version 2
  115.     StrCpy $Reslt 1
  116.     Goto ExitFunction
  117.     Cont2: ;Versions are the same.  Continue searching for differences
  118.     ;   Reset $V1 and $V2
  119.     StrCpy $V1 ""
  120.     StrCpy $V2 ""   
  121.     ;  ******************* Get 3rd version number for Ver1 **********************   
  122.     V31:
  123.     StrCpy $R0 $1 1 $P1 ;$R0 contains the character at position $P1
  124.     IntOp $P1 $P1 + 1   ;increments the file pointer for the next read
  125.     StrCmp $R0 "" V31end 0  ;check for empty string
  126.     strCmp $R0 "." v31end 0
  127.     strCpy $V1 "$V1$R0"
  128.     Goto V31
  129.     V31End:
  130.     StrCmp $V1 "" 0 +2
  131.     StrCpy $V1 "0"  
  132.     ;  ******************* Get 3rd version number for Ver2 **********************
  133.     V32:
  134.     StrCpy $R0 $2 1 $P2 ;$R0 contains the character at position $P1
  135.     IntOp $P2 $P2 + 1   ;increments the file pointer for the next read
  136.     StrCmp $R0 "" V32end 0  ;check for empty string
  137.     strCmp $R0 "." V32end 0
  138.     strCpy $V2 "$V2$R0"
  139.     Goto V32
  140.     V32End:
  141.     StrCmp $V2 "" 0 +2
  142.     StrCpy $V2 "0"  
  143.     ;   At this point, we can compare the results.  If the numbers are not
  144.     ;       equal, then we can exit
  145.     IntCmp $V1 $V2 cont3 older3 newer3
  146.     older3: ; Version 1 is older (less than) than version 2
  147.     StrCpy $Reslt 2
  148.     Goto ExitFunction
  149.     newer3: ; Version 1 is newer (greater than) Version 2
  150.     StrCpy $Reslt 1
  151.     Goto ExitFunction
  152.     Cont3: ;Versions are the same.  Continue searching for differences
  153.     ;   Reset $V1 and $V2
  154.     StrCpy $V1 ""
  155.     StrCpy $V2 ""
  156.     ;  ******************* Get 4th version number for Ver1 **********************   
  157.     V41:
  158.     StrCpy $R0 $1 1 $P1 ;$R0 contains the character at position $P1
  159.     IntOp $P1 $P1 + 1   ;increments the file pointer for the next read
  160.     StrCmp $R0 "" V41end 0  ;check for empty string
  161.     strCmp $R0 "." v41end 0
  162.     strCpy $V1 "$V1$R0"
  163.     Goto V41
  164.     V41End:
  165.     StrCmp $V1 "" 0 +2
  166.     StrCpy $V1 "0"  
  167.     ;  ******************* Get 4th version number for Ver2 **********************
  168.     V42:
  169.     StrCpy $R0 $2 1 $P2 ;$R0 contains the character at position $P1
  170.     IntOp $P2 $P2 + 1   ;increments the file pointer for the next read
  171.     StrCmp $R0 "" V42end 0  ;check for empty string
  172.     strCmp $R0 "." V42end 0
  173.     strCpy $V2 "$V2$R0"
  174.     Goto V42
  175.     V42End:
  176.     StrCmp $V2 "" 0 +2
  177.     StrCpy $V2 "0"  
  178.     ;   At this point, we can compare the results.  If the numbers are not
  179.     ;       equal, then we can exit
  180.     IntCmp $V1 $V2 cont4 older4 newer4
  181.     older4: ; Version 1 is older (less than) than version 2
  182.     StrCpy $Reslt 2
  183.     Goto ExitFunction
  184.     newer4: ; Version 1 is newer (greater than) Version 2
  185.     StrCpy $Reslt 1
  186.     Goto ExitFunction
  187.     Cont4: 
  188.     ;Versions are the same.  We've reached the end of the version
  189.     ;   strings, so set the function to 0 (equal) and exit
  190.     StrCpy $Reslt 0
  191.     ExitFunction:
  192.     Pop $R0
  193.     Pop $1
  194.     Pop $2
  195.     Push $Reslt
  196. FunctionEnd

我的修改

  1. (cur) (last)  12:35, 31 December 2008 219.131.237.209 (Talk) (6,929 bytes) (→if have not initialized the variables, the second call will be not correct.如果不初始化,之后的调用结果将是错误的) (undo)
  2. (→Description)
    Current revision (12:35, 31 December 2008) (edit) (undo)
    (→if have not initialized the variables, the second call will be not correct.如果不初始化,之后的调用结果将是错误的)
     
    Line 55: Line 55:
    Exch
    Exch
    Push $R0
    Push $R0
     +
    ; initialize Variables
     +
    StrCpy $V1 ""
     +
    StrCpy $V2 ""
     +
    StrCpy $P1 ""
     +
    StrCpy $P2 ""
     +
    StrCpy $Reslt ""
    ; Set the file pointers:
    ; Set the file pointers:
    IntOp $P1 $P1 + 1
    IntOp $P1 $P1 + 1
还不是很懂,再看看.懂了再说.
NSIS生成安装程序 基于PyQt5写成的界面py程序转换成的exe文件,介绍的NSIS程序打包成可安装的程序 阅读详情

相关推荐

NSIS打包

以下是一篇详细的 NSIS 打包 EXE 的入门教程:NSIS(Nullsoft Scriptable Install System)是一款开源的 Windows 安装包制作工具,支持脚本化定制安装流程。本教程将带你从零开始,创建一个简单的 EXE 安装程序。安装完成后,桌面会生成两个图标:假设你要打包以下文件: 2.2 编写 NSIS 脚本

2194

NSIS版本号比较-VersionCompare Bug

问题:今天发现自己之前写的NSIS脚本中有个BUG,BUG的来源正是NSIS的版本号比较函数:VersionCompare这个函数在比较"2008.3.15.1"和"2008.05.1.10"返回的不是期待的2,却是1于是,可怕的事情发生了……  解决:同类的几个函数,经过一番测试,采用下面这个函数。http://nsis.sourceforge.net/Compa

I Habit I DO 5870

NSIS 使用指南

Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4 <! /* Style

Franken Zeng的专栏 3791

NSIS打包软件,${VersionCompare}命令报错

用NSIS 打包软件,想在软件安装前检测当前环境是否已经安装过了该软件,若已经有软件安装,比较已经安装软件的版本和待安装软件的版本,若待安装软件版本比较高,则提示用户原有软件版本比较低,请更新程序.    修改scrip.nsi,增加内容如下;   添加头文件 !include "WordFunc.nsh"   添加代码:   Function  .onInit   XXXXXXXX;此

fang20277的专栏 1788

[NSIS] 用NSIS做一个软件升级安装包

在《NSIS使用心得 I》这篇中简要介绍了一下NSIS的脚本编写,通过文章中的介绍相信各位高手很快就做了一个有特色的程序安装包了。但相信不是每个人写的软件都只发布一次就可以了,肯定要有修改和维护的情况发生。在这种情况下,您可能就需要一个程序的升级安装包了。 下面介绍一个简单的升级安装包的制作。(如果有更好的升级方法,希望各位高手能发表评论,我也好学习学习) /* ---------------

doublecells的专栏 6295

[NSIS] NSIS使用心得Ⅰ

NSIS(Nullsoft Scriptable Install System)适用于Windows下的一款安装程序制作工具。虽然它的功能不如InstallShield和 InstallAnyWhere 的功能强大,也不象InstallWise 那么易用,但它的确是一个值得了解的工具软件。 首先NSIS是一款免费软件,使用的时候不存在盗版或正版的问题。这也给了我们这些穷孩子以学习的机会。(感谢

doublecells的专栏 6247

NSIS安装打包程序的版本比较方便做后续逻辑处理

因为当时公司的项目打包卸载前期出现了一些问题,只能做个补丁来弥补,考虑到不影响后期的项目,分隔版本号,以1.0.12为分割线,判断new or old,然后分别做出不同的卸载逻辑。 1.VersionCompare: *比较版本数字 语法: ${VersionCompare} "[Version1]" "[Version2]" $var "[Vers

Android丶Ren 1682

Unity面试题总结

Unity面试题

sinat_34014668的博客 1万+

NSIS判断系统版本

Function "GetWinVer" /* ;Push $R0 ;Push $R1 ClearErrors ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion IfErrors 0 lbl_winnt ; we are not NT ReadRegStr $R0 HK

非鱼 5311

Utrust4701F与Utrust2700R读写器在银河麒麟系统的安装及测试步骤说明

Utrust4701F与Utrust2700R读写器支持银河麒麟系统,广泛应用会员管理、支付管理等领域。本文将重点介绍Utrust4701F与Utrust2700R读写器在银河麒麟系统的安装及测试步骤说明。以上方法适用于主流国产操作系统,如 优麒麟(UbuntuKylin)/ 中标麒麟(NeoKylin) / UOS(统信操作系统)/ 中兴新支点 / 红旗 linux(redflag linux)/ 普华 Linux(I-soft OS) / 威科乐恩 Linux(WiOS)等

华翔天诚科技 1843

2026零成本私有化:OpenClaw一键搭建Discord/Telegram智能机器人,数据不出本地,永久免费替代ChatGPT

如果内置的功能不能满足你的需求,你可以很容易地添加自己的自定义工具。public string Description => "查询指定城市的天气";// 调用天气API获取天气信息return $"city今天的天气是晴,温度25度";// 注册工具今天北京的天气怎么样?大模型的选择很重要:不要盲目追求大参数的模型。对于大多数场景来说,7B参数的模型已经足够用了,而且速度快,内存占用低。上下文长度不要设置太大:上下文长度越大,内存占用越高,推理速度越慢。

2601_94871597的博客 267

【源码】编写的NSIS脚本示例分享

使用nsis脚本制作windows安装包程序,自己编写的源码分享,涵盖了进程检测,版本提示,源文件备份,程序卸载,注册表记录等功能,仅供参考

打不死的小五 2792

企业微信审批流开发避坑指南:从零搭建自定义审批模板(含完整代码)

本文为企业微信审批流开发提供了从零搭建自定义审批模板的完整指南。通过对比内置模板与自建引擎的优劣,详细阐述了利用企业微信开放API和自建应用实现高度灵活审批流程的方案。文章重点解析了前端JS-SDK安全调用、后端签名生成与回调处理的核心代码,并分享了流程引擎设计、安全加固及性能监控等实战经验,帮助企业开发者避开常见陷阱,构建贴合业务的自定义审批系统。

weixin_28358083的博客 995

NSIS 检测程序版本号、注册表的写入与读取实例 (学习二)

!define PRODUCT_NAME "pkpm" !define PRODUCT_VERSION "1.0" !define PRODUCT_PUBLISHER "My company, Inc." !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_

yimengchenxi的专栏 7673

NI-HIL学习开篇

自我介绍下,四年零部件厂工作经验,一年(至今)主机厂工作经验,负责BMS/VCU方向软硬件测试。 学习目的:把握新能源汽车的测试发展趋势,顺应历史的洪流。 学习目标:1.掌握HIL开发测试流程中的IO配置、开环验证、闭环模型开发及调试、自动化测试 2.掌握第三方模型的搭建及simulink关联仿真(2019.05.21新增:需巩固练习matlab基础——2...

masonson的专栏 4185

【SABRE 3D, SABRE 3DxT,LAM设备】2025年9月10日

前文:SABRE 3D系列机台简介本章节详细阐述了在维护期间锁定电气、机械、热力学及重力组件以及化学管线输入的锁定操作流程,旨在降低人员受伤风险。p42~p55。

weixin_46735260的博客 1645

2020-10-20

Page for NSIS 2.07 and below users You can use the latest version of headers (recommended) or the following function code (put the function code in your script before calling it) Function Description VersionCompare v1.0 Thanks Af

qq_42826610的博客 193

【YOLO11改进 - C3k2融合】C3k2融合DWRSeg二次创新C3k2_DWR:扩张式残差分割网络,提高特征提取效率和多尺度信息获取能力,助力小目标检测

【YOLO11改进 - C3k2融合】C3k2DWRSeg二次创新C3k2_DWR:扩张式残差分割网络,提高特征提取效率和多尺度信息获取能力,助力小目标检测

专注于图像领域,主要研究内容包括计算机视觉和深度学习,特别是在图像分类、目标检测和图像生成等方面有深入的研究和实践经验。 1062

NSIS大杂烩

点击这里进入链接

我房间 386

构建高效的LLM应用测试框架

《构建高效的LLM应用测试框架》 关键词:LLM,测试框架,应用测试,效率优化,测试原理 摘要:本文将深入探讨构建高效LLM应用测试框架的必要性、方法与步骤,旨在为开发者提供一套系统化、可操作的测试解决方案,从而提升LLM

AI天才研究院 1054

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Winform打包-NSIS 检测.NetFramework版本(亲测可用)

首先介绍下,HM NIS Edit工具,是一款已非常简洁好用的winform打包工具,功能强大,插件丰富,还有丰富的第三方界面库支持。 随着C/S模式开发的越来越少,这方面的资料,尤其是NSIS的资料都极其稀少。翻了很多文章,进行整合,终于找到比较满意的.NetFramework检测,并安装的实现方式。 进入正题,网上查了很多资料遇到问题:版本号对比一直无效,后来改为了用内置的版本号对比函数。...

weixin_30291791的博客 550

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Inno Setup与NSIS的比较

Inno Setup 和NSIS 都很有名气、很不错的开源安装包制作工具。1. 入门难度 ,说实话两者都不难学,文档都挺齐全的,而且都有现成的例子供学习参考。再不济,可以在网上找到相应的社区论坛上寻求帮助。相对而言,Inno Setup更容易上手一些。2. 脚本语言 ,两者都支持。NSIS脚本语言是它独有的,类似于宏汇编,语法有些怪异难懂。不过,功能还算强大,能调用Windows API,支持用动...

Blasting_expert的博客 3806

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

0003__NSIS添加版本号

转载:http://blog.sina.com.cn/s/blog_6cd65f450101cr0j.html 问: 添加版本号 VIProductVersion "1.2.3.4" VIAddVersionKeyLANG=${LANG_ENGLISH} "ProductName" "Test Application" VIAddVersionKeyLANG=${LANG_E...

行潇 485

NSIS打包教程

NSIS简介 NSIS是"Nullsoft 脚本安装系统"(Nullsoft scriptable Installation System)的缩写,它是是一个免费的win32安装、卸载系统,可以很方便的打包windows应用程序。它的特点:脚本简洁高效;系统开销少;支持安装、卸载、系统设置、解压文件等功能。 打包步骤 1.下载NSIS脚本安装系统,启动NSIS Edit,在“文件”菜单中“新建脚本...

急支糖浆的博客 1万+

NSIS安装包开发笔记(一):NSIS介绍、使用NSIS默认向导脚本制作Windows安装包

做产品时,定制的自定义安装界面常有的,使用NSIS + Qt可以完美的定制基于QT的安装界面,先从纯NSIS开始,制作常规的安装包。

长沙红胖子 Qt・西安|省级科研团队从业背景,深耕双一流体系高精尖技术配套研发|剥离高精尖机理,沉淀高端特种行业领域 Qt 工程化落地经验|博文仅分享通用技术总结,输出公开普适工程思路。 4万+

NSIS安装包开发笔记(二):NSIS使用NSIS+Qt界面制作安装包流程

Nsis可以使用duilib也可以使用qt界面,笔者主要qt,本文章梳理nsis+qt制作安装包的基本流程。

长沙红胖子 Qt・西安|省级科研团队从业背景,深耕双一流体系高精尖技术配套研发|剥离高精尖机理,沉淀高端特种行业领域 Qt 工程化落地经验|博文仅分享通用技术总结,输出公开普适工程思路。 4万+
下一篇: VIAddversionKey
yandede
博客等级 码龄16年 0粉丝 4原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值