NSIS求助!!!,如有大佬知道怎么办,请留言回复!!!感谢!!!

NSIS求助!!!,如有大佬知道怎么办,请留言回复!!!感谢!!!
本人初学NSIS,最近接触到给自己用NSIS制作的程序安装包加上注册码序列号(类似Windos激活码)的博客,非常喜欢,便想着自己也制作一回,但由于初学,根本做不出,所以,来此求助.

编译显示错误的代码:

## 注册码输入框
Function InputBoxPageShow

 !insertmacro MUI_HEADER_TEXT "注册码输入" "请输入您的注册码!"

 RegisterCode::getSeq $R1
 Pop $R1
 PassDialog::InitDialog /NOUNLOAD InputBox /HEADINGTEXT "请输入注册码" /BOX "注册码:" "$R2" 29 /BOXRO "序列号:" "$R1" 0
  Pop $R3 # Page HWND
 PassDialog::Show
  Pop $R0 # success, back, cancel or error

FunctionEnd

## Validate input
Function InputBoxPageLeave

 ## Pop details from stack
 Pop $R2

 ## Validate entered string to encrypt
 StrCmp $R2 "" 0 +3
  MessageBox MB_OK|MB_ICONEXCLAMATION "请输入注册码."
  Abort

 RegisterCode::getReg $R5
 Pop $R5

 StrCmp $R5 $R2 Good Bad

 Bad:
 MessageBox MB_OK|MB_ICONEXCLAMATION "注册码错误请重新输入!"
 Abort

 Good:

FunctionEnd

Function ComponentsPageShow

 ## Disable the Back button
 GetDlgItem $R0 $HWNDPARENT 3
 EnableWindow $R0 0

FunctionEnd

编译成功但没有效果的代码:

; 该脚本使用 HM VNISEdit 脚本编辑器向导产生

; 安装程序初始定义常量
!define PRODUCT_NAME "XJJZZ"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "XJJZZBCL"
!define PRODUCT_WEB_SITE "XJJZZ"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\BLCL的简陋答复.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

SetCompressor lzma

; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"

; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
## Pages
Page Custom InputBoxPageShow InputBoxPageLeave
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ComponentsPageShow
; 许可协议页面
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "G:\XJJZZ\XJJZZ条例详见.txt"
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!define MUI_FINISHPAGE_RUN "$INSTDIR\BLCL的简陋答复.exe"
!insertmacro MUI_PAGE_FINISH

; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES

; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"

; 安装预释放文件
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\XJJZZ"
InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
ShowInstDetails show
ShowUnInstDetails show
BrandingText "版权归XJJZZ"

Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "F:\IN-QQ\19-11-05-Pioneer\BLCL的简陋答复.exe"
  CreateDirectory "$SMPROGRAMS\XJJZZ"
  CreateShortCut "$SMPROGRAMS\XJJZZ\XJJZZ.lnk" "$INSTDIR\BLCL的简陋答复.exe"
  CreateShortCut "$DESKTOP\XJJZZ.lnk" "$INSTDIR\BLCL的简陋答复.exe"
SectionEnd

Section -AdditionalIcons
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateShortCut "$SMPROGRAMS\XJJZZ\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\XJJZZ\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\BLCL的简陋答复.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\BLCL的简陋答复.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

/******************************
 *  以下是安装程序的卸载部分  *
 ******************************/

Section Uninstall
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\BLCL的简陋答复.exe"

  Delete "$SMPROGRAMS\XJJZZ\Uninstall.lnk"
  Delete "$SMPROGRAMS\XJJZZ\Website.lnk"
  Delete "$DESKTOP\XJJZZ.lnk"
  Delete "$SMPROGRAMS\XJJZZ\XJJZZ.lnk"

  RMDir "$SMPROGRAMS\XJJZZ"

  RMDir "$INSTDIR"

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  SetAutoClose true
SectionEnd

#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
  Abort
FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
FunctionEnd

## 注册码输入框
Function InputBoxPageShow

 !insertmacro MUI_HEADER_TEXT "注册码输入" "请输入您的注册码!"

 Pop $R1
 PassDialog::InitDialog /NOUNLOAD InputBox /HEADINGTEXT "请输入注册码" /BOX "注册码:" "$R2" 29 /BOXRO "序列号:" "$R1" 0
  Pop $R3 # Page HWND
 PassDialog::Show
  Pop $R0 # success, back, cancel or error

FunctionEnd

## Validate input
Function InputBoxPageLeave

 ## Pop details from stack
 Pop $R2

 ## Validate entered string to encrypt
 StrCmp $R2 "" 0 +3
  MessageBox MB_OK|MB_ICONEXCLAMATION "请输入注册码."
  Abort

 Pop $R5

 StrCmp $R5 $R2 Good Bad

 Bad:
 MessageBox MB_OK|MB_ICONEXCLAMATION "注册码错误请重新输入!"
 Abort

 Good:

FunctionEnd

Function ComponentsPageShow

 ## Disable the Back button
 GetDlgItem $R0 $HWNDPARENT 3
 EnableWindow $R0 0

FunctionEnd

效果图:
在这里插入图片描述


  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 1024 设计师:白松林 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值