⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installer.nsi

📁 bittorrent source by python. please enjoy
💻 NSI
📖 第 1 页 / 共 2 页
字号:
; CloseBitTorrent: this will in a loop send the BitTorrent window the WM_CLOSE; message until it does not find a valid BitTorrent window;!macro CloseBitTorrent UNFunction ${UN}CloseBitTorrent  Push $0  IntFmt $R1 "%u" 0  goto skip  loop:         IntOp $R1 $R1 + 1    IntCmp $R1 5 done  skip:    DetailPrint "Looking for running copies of BitTorrent"    Push "wxWindowClassNR"   # the wcn    Push "BitTorrent"   # the known part of the wt    Call ${UN}EnhancedFindWindow    Pop  $0   # will contain the window's handle    Pop  $1   # will containg the full wcn              # both will containg "failed", if no matching wcn was found    StrCmp $0 "failed" done    StrCmp $0 "0" done    DetailPrint "Stopping BitTorrent"    SendMessage $0 16 0 0 # WM_CLOSE == 16    Sleep 1000    Goto loop  done:  IntFmt $R1 "%u" 0  Processes::FindProcess "bittorrent.exe"  StrCmp $R0 "1" loop reallydone  reallydone:  Pop $0FunctionEnd!macroend!macro CheckForIt UNFunction ${UN}CheckForIt    Processes::FindProcess $KILLEXENAME    StrCmp $R0 "1" foundit didntfindit  foundit:    MessageBox MB_OKCANCEL "You must quit ${APPNAME} ($KILLEXENAME) \    before installing this version.$\r$\nPlease quit it and press \    OK to continue." IDOK tryagain    Abort  tryagain:            Sleep 2000    Processes::FindProcess $KILLEXENAME    StrCmp $R0 "1" stillthere didntfindit  stillthere:    MessageBox MB_OKCANCEL "There is still a copy of ${APPNAME} \    ($KILLEXENAME) running.$\r$\nPress OK to force-quit the application, \    or Cancel to exit." IDOK killit    Abort  killit:    KillProcDLL::KillProc $KILLEXENAME    Sleep 1000  didntfindit:FunctionEnd!macroend!macro QuitIt UNFunction ${UN}QuitIt    # try nicely first    Call ${UN}CloseBitTorrent    # kill all the old ones        StrCpy $KILLEXENAME "btdownloadgui.exe"    Call ${UN}CheckForIt    StrCpy $KILLEXENAME "bittorrent.exe"    Call ${UN}CheckForIt    StrCpy $KILLEXENAME "btmaketorrentgui.exe"    Call ${UN}CheckForIt    StrCpy $KILLEXENAME "maketorrent.exe"    Call ${UN}CheckForIt    StrCpy $KILLEXENAME "choose_language.exe"    Call ${UN}CheckForIt    StrCpy $KILLEXENAME ""FunctionEnd!macroend!macro MagicUninstall UNFunction ${UN}MagicUninstall  ;; this would remove other associations / context menu items too  ; DeleteRegKey HKCR .torrent  ; DeleteRegKey HKCR "MIME\Database\Content Type\application/x-bittorrent"  ;; disassociate our missing Application manually, windows takes care of the rest  DeleteRegKey HKCR "Applications\${EXENAME}.exe"  DeleteRegKey HKLM "Software\Classes\Applications\${EXENAME}.exe"  ; just in case  DeleteRegKey HKCR "Applications\btdownloadgui.exe"  DeleteRegKey HKLM "Software\Classes\Applications\btdownloadgui.exe"  ;; be nice and put back what we removed  ReadRegStr $R1 HKCR "bittorrent\shell\open\command" "backup"  StrCmp $R1 "" delete restore restore:  WriteRegStr HKCR "bittorrent\shell\open\command" "" $R1  goto continue delete:  DeleteRegKey HKCR bittorrent continue:  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"  ;; we do not currently restore backups on torrent:// stuff  DeleteRegKey HKCR torrent    Call ${UN}GetOldPath  Pop $R0  StrCmp $R0 "" 0 remove  StrCpy $R0 $INSTDIR remove:       ; some users like to store important data in our directory  ; be nice to them  ;RMDir /r "$R0"  Delete "$R0\*.exe"  Delete "$R0\*.manifest"  Delete "$R0\*.pyd"  Delete "$R0\*.dll"  Delete "$R0\library.zip"  RMDir /r "$R0\images"  RMDir /r "$R0\lib"  RMDir /r "$R0\locale"  Delete "$R0\redirdonate.html"  Delete "$R0\credits.txt"  Delete "$R0\credits-l10n.txt"  Delete "$R0\LICENSE.txt"  Delete "$R0\README.txt"  Delete "$R0\TRACKERLESS.txt"  Delete "$R0\public.key"  ClearErrors  RMDir "$R0"    IfErrors 0 dontwarn  ; no need for a warning, it is just annoying  ;MessageBox MB_OK "Not deleting $R0,$\r$\nbecause there are extra files or directories in it, or it is in use."    dontwarn:      ;SetShellVarContext current  SetShellVarContext all  Delete "$SMSTARTUP\${APPNAME}.lnk"  SetShellVarContext all  Delete "$DESKTOP\${APPNAME}.lnk"  RMDir /r "$SMPROGRAMS\${APPNAME}"  FunctionEnd!macroend;awesome voodoo!insertmacro EnhancedFindWindow ""!insertmacro EnhancedFindWindow "un."!insertmacro CloseBitTorrent ""!insertmacro CloseBitTorrent "un."!insertmacro CheckForIt ""!insertmacro CheckForIt "un."!insertmacro QuitIt ""!insertmacro QuitIt "un." !insertmacro GetUninstallString ""!insertmacro GetUninstallString "un."!insertmacro GetOldPath ""!insertmacro GetOldPath "un." !insertmacro MagicUninstall ""!insertmacro MagicUninstall "un." Function .onInit    BringToFront        ;Language selection dialog    !insertmacro MUI_LANGDLL_DISPLAY    Call QuitIt    ClearErrors    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer.directory.ini"      ; check for an installed copy, and add the upgrade page if needed    Call GetOldPath    Pop $R0    StrCmp $R0 "" notupgrading    StrCpy $UPGRADE "yes"    StrCpy $INSTDIR $R0    !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer.upgrade.ini"    Goto done  notupgrading:    StrCpy $UPGRADE "no"  done:FunctionEndSection "Install" SecInstall  SectionIn 1 2  Call IsUserAdmin  Pop $R0  StrCmp $R0 "false" abortinstall continueinstall  abortinstall:  MessageBox MB_OK "You must have Administrator privileges to install ${APPNAME}."   Goto endofinstall  continueinstall:  SetOverwrite try    SetOutPath $INSTDIR  WriteUninstaller "$INSTDIR\uninstall.exe"  IntFmt $0 "%u" 0  goto skip files:       IntOp $0 $0 + 1  IntCmp $0 30 ohcrap  Sleep 1000 skip:  File dist\*.exe  IfErrors files  File dist\*.manifest  IfErrors files  File dist\*.pyd  IfErrors files  File dist\*.dll  IfErrors files  File dist\library.zip  IfErrors files  File /r dist\images  IfErrors files  File redirdonate.html  IfErrors files  File credits.txt  IfErrors files  File credits-l10n.txt  IfErrors files  File LICENSE.txt  IfErrors files  File README.txt  IfErrors files  File TRACKERLESS.txt  IfErrors files  File public.key  IfErrors files  goto success ohcrap:  MessageBox MB_OK "While installing BitTorrent, a critical timeout occured. Please reboot, and retry the installer."  Abort success:  ; registry entries  ; in super old versions of BitTorrent (2.x) some Bad Things were done.  ; if we don not clean them up before installing, users get "Invalid Menu Handle"  ; after upgrading.  DeleteRegKey HKCR "torrent_auto_file"  DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent\" "ProgId"  ; this guards against a reinstallation to a different directory  (like d:\...) causing Invalid Menu Handle  DeleteRegKey HKCR "Applications\btdownloadgui.exe"  DeleteRegKey HKCR "Applications\bittorrent.exe"  DeleteRegKey HKCR "Applications\${EXENAME}"  DeleteRegKey HKLM "Software\Classes\Applications\btdownloadgui.exe"  DeleteRegKey HKLM "Software\Classes\Applications\bittorrent.exe"  DeleteRegKey HKLM "Software\Classes\Applications\${EXENAME}"    ;; make us the default handler for BT files  WriteRegStr HKCR .torrent "" bittorrent  DeleteRegKey HKCR ".torrent\Content Type"  ;; This line maks it so that BT sticks around as an option   ;; after installing some other default handler for torrent files  WriteRegStr HKCR ".torrent\OpenWithProgids" "bittorrent" ""  ; this prevents user-preference from generating "Invalid Menu Handle" by looking for an app  ; that no longer exists, and instead points it at us.  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent\" Application "${EXENAME}"  WriteRegStr HKCR "Applications\${EXENAME}\shell" "" open  WriteRegStr HKCR "Applications\${EXENAME}\shell\open\command" "" `"$INSTDIR\${EXENAME}" "%1"`    ;; Add a mime type  WriteRegStr HKCR "MIME\Database\Content Type\application/x-bittorrent" Extension .torrent  ;; Add a shell command to match the 'bittorrent' handler described above  WriteRegStr HKCR bittorrent "" "TORRENT File"  WriteRegBin HKCR bittorrent EditFlags 00000100  ;; make us the default handler for bittorrent://  WriteRegBin HKCR bittorrent "URL Protocol" 0  WriteRegStr HKCR "bittorrent\Content Type" "" "application/x-bittorrent"  WriteRegStr HKCR "bittorrent\DefaultIcon" "" "$INSTDIR\${EXENAME},0"  WriteRegStr HKCR "bittorrent\shell" "" open  ReadRegStr $R1 HKCR "bittorrent\shell\open\command" ""  StrCmp $R1 "" continue  WriteRegStr HKCR "bittorrent\shell\open\command" "backup" $R1continue:  WriteRegStr HKCR "bittorrent\shell\open\command" "" `"$INSTDIR\${EXENAME}" "%1"`  ;; Add a shell command to handle torrent:// stuff  WriteRegStr HKCR torrent "" "TORRENT File"  WriteRegBin HKCR torrent EditFlags 00000100  ;; make us the default handler for torrent://  WriteRegBin HKCR torrent "URL Protocol" 0  WriteRegStr HKCR "torrent\Content Type" "" "application/x-bittorrent"  WriteRegStr HKCR "torrent\DefaultIcon" "" "$INSTDIR\${EXENAME},0"  WriteRegStr HKCR "torrent\shell" "" open  ReadRegStr $R1 HKCR "torrent\shell\open\command" ""  WriteRegStr HKCR "torrent\shell\open\command" "backup" $R1    WriteRegStr HKCR "torrent\shell\open\command" "" `"$INSTDIR\${EXENAME}" "%1"`  ;; Automagically register with the Windows Firewall  WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List" "$INSTDIR\${EXENAME}" `$INSTDIR\${EXENAME}:*:Enabled:${APPNAME}`  ;; Info about install/uninstall   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME} ${VERSION}"  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'  ; SHCNE_ASSOCCHANGED == 0x8000000  ; prevents a reboot where it would be needed in rare cases otherwise  System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'  ; Add items to start menu  ; newer versions of BT use the registry 'run' section  SetShellVarContext current  Delete "$SMSTARTUP\${APPNAME}.lnk"  SetShellVarContext all  ;CreateShortCut "$SMSTARTUP\${APPNAME}.lnk"                  "$INSTDIR\${EXENAME}"  CreateDirectory "$SMPROGRAMS\${APPNAME}"  CreateShortCut "$SMPROGRAMS\${APPNAME}\BitTorrent.lnk"      "$INSTDIR\${EXENAME}"  CreateShortCut "$SMPROGRAMS\${APPNAME}\Make Torrent.lnk"    "$INSTDIR\maketorrent.exe"  CreateShortCut "$SMPROGRAMS\${APPNAME}\Donate.lnk"          "$INSTDIR\redirdonate.html"  CreateShortCut "$SMPROGRAMS\${APPNAME}\Choose Language.lnk" "$INSTDIR\choose_language.exe"  IfSilent launch_anyway not_silent  launch_anyway:  ExecShell open "$INSTDIR\${EXENAME}"  not_silent:  BringToFront  endofinstall:SectionEndFunction un.onInit  ;; gets the stored language from install  !insertmacro MUI_UNGETLANGUAGEFunctionEndSection "Uninstall"  Call un.QuitIt  ; this should not go in MagicUninstall  ; because we want to keep the preference between upgrades  DeleteRegKey HKCU "Software\BitTorrent\Language"  Call un.MagicUninstallSectionEnd

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -