example.nsi 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;VPatch example
  2. ;Written by Joost Verburg
  3. ;--------------------------------
  4. ; The name of the installer
  5. Name "VPatch Test"
  6. ; The file to write
  7. OutFile "vpatchtest.exe"
  8. ; The default installation directory
  9. InstallDir "$PROGRAMFILES\VPatch Test"
  10. ; The text to prompt the user to enter a directory
  11. DirText "Choose a folder in which to install the VPatch Test!"
  12. ; Show details
  13. ShowInstDetails show
  14. ;--------------------------------
  15. ; The normal way to use VPatch
  16. ;--------------------------------
  17. !include "VPatchLib.nsh"
  18. Section "Update file"
  19. ; Set output path to the installation directory
  20. SetOutPath $INSTDIR
  21. ; Extract the old file under name 'updatefile.txt'
  22. File /oname=updatefile.txt oldfile.txt
  23. ; Update the file - it will be replaced with the new version
  24. DetailPrint "Updating updatefile.txt using patch..."
  25. !insertmacro VPatchFile "patch.pat" "$INSTDIR\updatefile.txt" "$INSTDIR\temporaryfile.txt"
  26. SectionEnd
  27. ;-------------------------------
  28. ; The hard way to use VPatch
  29. ;-------------------------------
  30. Section "New version in separate file"
  31. ; Set output path to the installation directory
  32. SetOutPath $INSTDIR
  33. ; Extract the old file
  34. File oldfile.txt
  35. ; Extract the patch to the plug-ins folder (temporary)
  36. InitPluginsDir
  37. File /oname=$PLUGINSDIR\patch.pat patch.pat
  38. ; Update the old file to the new file using the patch
  39. DetailPrint "Updating oldfile.txt using patch to newfile.txt..."
  40. vpatch::vpatchfile "$PLUGINSDIR\patch.pat" "$INSTDIR\oldfile.txt" "$INSTDIR\newfile.txt"
  41. ; Show result
  42. Pop $R0
  43. DetailPrint "Result: $R0"
  44. SectionEnd