📄 jpcapsetup.nsi
字号:
# Auto-generated by EclipseNSIS Script Wizard
# 2006/01/01 0:56:16
Name Jpcap
# Defines
!define REGKEY "SOFTWARE\$(^Name)"
# MUI defines
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
# Included files
!include Sections.nsh
!include MUI.nsh
# Reserved Files
# Variables
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ..\..\..\COPYING
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
# Installer languages
!insertmacro MUI_LANGUAGE English
;!insertmacro MUI_LANGUAGE Japanese
# Installer attributes
OutFile JpcapSetup.exe
InstallDir $PROGRAMFILES\Jpcap
CRCCheck on
XPStyle on
ShowInstDetails hide
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails hide
# Installer sections
Section "Jpcap for JRE" SEC0000
Call GetJRE
Pop $R0
SetOutPath $R0\bin
SetOverwrite on
File ..\..\c\win32\Release\Jpcap.dll
SetOutPath $R0\lib\ext
File ..\..\..\lib\jpcap.jar
WriteRegStr HKLM "${REGKEY}\Components" "Jpcap for JRE" 1
;Store JRE directory
WriteRegStr HKLM "${REGKEY}" JRE_DIR $R0
SectionEnd
Section /o "Jpcap for JDK" SEC0001
Call GetJDK
Pop $R0
SetOutPath $R0\bin
SetOverwrite on
File ..\..\c\win32\Release\Jpcap.dll
SetOutPath $R0\jre\lib\ext
File ..\..\..\lib\jpcap.jar
WriteRegStr HKLM "${REGKEY}\Components" "Jpcap for JDK" 1
;Store JRE directory
WriteRegStr HKLM "${REGKEY}" JDK_DIR $R0
SectionEnd
Section -post SEC0002
WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
SetOutPath $INSTDIR
WriteUninstaller $INSTDIR\uninstall.exe
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
; WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
; WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
SectionEnd
# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
Push $R0
ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
StrCmp $R0 1 0 next${UNSECTION_ID}
!insertmacro SelectSection "${UNSECTION_ID}"
Goto done${UNSECTION_ID}
next${UNSECTION_ID}:
!insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
Pop $R0
!macroend
# Uninstaller sections
Section /o "un.Jpcap for JRE" UNSEC0000
ReadRegStr $R0 HKLM "${REGKEY}" JRE_DIR
Delete /REBOOTOK $R0\bin\Jpcap.dll
Delete /REBOOTOK $R0\lib\ext\jpcap.jar
DeleteRegValue HKLM "${REGKEY}\Components" "Jpcap for JRE"
SectionEnd
Section /o "un.Jpcap for JDK" UNSEC0001
ReadRegStr $R0 HKLM "${REGKEY}" JDK_DIR
Delete /REBOOTOK $R0\bin\Jpcap.dll
Delete /REBOOTOK $R0\jre\lib\ext\jpcap.jar
DeleteRegValue HKLM "${REGKEY}\Components" "Jpcap for JDK"
SectionEnd
Section un.post UNSEC0002
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
Delete /REBOOTOK $INSTDIR\uninstall.exe
DeleteRegValue HKLM "${REGKEY}" Path
DeleteRegKey /ifempty HKLM "${REGKEY}\Components"
DeleteRegKey /ifempty HKLM "${REGKEY}"
RMDir /REBOOTOK $INSTDIR
SectionEnd
# Installer functions
Function .onInit
InitPluginsDir
FunctionEnd
Function .onMouseOverSection
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1043 ; description item (must be added to the UI)
StrCmp $0 0 "" +2
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This will install Jpcap onto the Java Runtime Environment (JRE) currently installed on your computer. If you want to run applications based on Jpcap, check this option."
StrCmp $0 1 "" +2
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This will install Jpcap onto the Java Development Kit (JDK) currently installed on your computer. If you want to develop applications based on Jpcap, check this option."
FunctionEnd
# Uninstaller functions
Function un.onInit
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
!insertmacro SELECT_UNSECTION "Jpcap for JRE" ${UNSEC0000}
!insertmacro SELECT_UNSECTION "Jpcap for JDK" ${UNSEC0001}
FunctionEnd
Function GetJRE
;
; Find JRE (Java.exe)
; //1 - in .\jre directory (JRE Installed with application)
; //2 - in JAVA_HOME environment variable
; 3 - in the registry
; 4 - assume java.exe in current dir or PATH
Push $R0
Push $R1
; ClearErrors
; StrCpy $R0 "$EXEDIR\jre\bin\java.exe"
; IfFileExists $R0 JreFound
; StrCpy $R0 ""
; ClearErrors
; ReadEnvStr $R0 "JAVA_HOME"
; StrCpy $R0 "$R0\bin\java.exe"
; IfErrors 0 JreFound
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome"
; StrCpy $R0 "$R0\bin\java.exe"
IfErrors 0 JreFound
Abort "Cannot find Java Runtime Environment (JRE) on your machine. Please download and install JRE from http://java.sun.com."
JreFound:
Pop $R1
Exch $R0
FunctionEnd
Function GetJDK
;
; Find JDK
; //1 - in .\jre directory (JRE Installed with application)
; //2 - in JAVA_HOME environment variable
; 3 - in the registry
; //4 - assume java.exe in current dir or PATH
Push $R0
Push $R1
; ClearErrors
; StrCpy $R0 "$EXEDIR\jre\bin\java.exe"
; IfFileExists $R0 JreFound
; StrCpy $R0 ""
; ClearErrors
; ReadEnvStr $R0 "JAVA_HOME"
; StrCpy $R0 "$R0\bin\java.exe"
; IfErrors 0 JdkFound
ClearErrors
ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Development Kit\$R1" "JavaHome"
; StrCpy $R0 "$R0\bin\java.exe"
IfErrors 0 JdkFound
Abort "Cannot find Java Development Kit (JDK) on your machine. Please download and install JDK from http://java.sun.com."
JdkFound:
Pop $R1
Exch $R0
FunctionEnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -