NSIS脚本制作windows软件安装包

简介

本文是10年前做windows开发时,做安装包是留下的一点关于用NSIS打包安装程序的技术文档。虽然不全面,但是勉强够用。

有兴趣的同学可以到 这里 下载全部脚本(共11个小例子),里面还有一个简单的ppt讲解。写的比较差,勉强可以参考。

实例一 弹出提示框

OutFile "1.exe"
ShowInstDetails show

# create a default section.
section
# create a popup box, with an OK button and the text "Hello world!"
messageBox MB_OK "Hello world!"
sectionEnd

运行结果

在这里插入图片描述

点击确定后

在这里插入图片描述

实例二 设置变量和显示变量

OutFile "2.exe"
ShowInstDetails show

!define APPNAME "TASS_CSP"
Var /GLOBAL version

Section

DetailPrint ${APPNAME}
StrCpy $version "2.0.0.0"
DetailPrint $version

SectionEnd

运行结果

在这里插入图片描述

实例三 函数及控制

OutFile "3.exe"
ShowInstDetails show

Var /GLOBAL str1
Var /GLOBAL str2

Var /GLOBAL strResult

/*
char *para1
char *para2

char *result
*/
Function ConnStrForReg
	Pop $1
	DetailPrint $1

	Pop $0
	DetailPrint $0

	StrCpy $2 $0$1
	
	Push $2
	
FunctionEnd

Function ConnStrForVar
	StrCpy $strResult $str1$str2
FunctionEnd

section "Main"
	StrCpy $str1 "0123456789"
	Push $str1

	StrCpy $str2 "abcdef"
	Push $str2

	Call ConnStrForReg
	Pop $strResult
	
	DetailPrint '"Reg=====>"$strResult'
	
	StrCpy $str1 "0123456789"
	StrCpy $str2 "abcdef"
	
	Call ConnStrForVar
	
	DetailPrint '"Var=====>"$strResult'
sectionEnd

运行结果

在这里插入图片描述

实例四 调用动态库功能

OutFile "4.exe"
ShowInstDetails show

Var /GLOBAL strSource

section

StrCpy $strSource "1234567890"
DetailPrint $strSource

md5dll::GetMD5String $strSource
Pop $R0

DetailPrint $R0

StrCpy $0 $strSource
DetailPrint $0

System::Call "user32::MessageBox(i $HWNDPARENT, t r0, t 'Test', i 0)"

sectionEnd

运行结果

在这里插入图片描述

点击确定后

在这里插入图片描述

实例五 宏

OutFile "5.exe"
ShowInstDetails show

!macro Hello What
  DetailPrint "Hello ${What}"
!macroend

Section Test
  !insertmacro Hello "World"
  !insertmacro Hello "Tree"
  !insertmacro Hello "Flower"
SectionEnd

运行结果

在这里插入图片描述

实例六 插入欢迎页,licence页,安装页,完成页

OutFile "6.exe"
ShowInstDetails show

!include "MUI.nsh"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "lic.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "SimpChinese"

# create a default section.
Section "Main"
# create a popup box, with an OK button and the text "Hello world!"
MessageBox MB_OK "Install section is running!"
SectionEnd

欢迎页

在这里插入图片描述

licence页

在这里插入图片描述

安装页

在这里插入图片描述

完成页

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

化妖成魔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值