System.nsi 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ; This is just an example of System Plugin
  2. ;
  3. ; (c) brainsucker, 2002
  4. ; (r) BSForce
  5. Name "System Plugin Example"
  6. OutFile "System.exe"
  7. !include "SysFunc.nsh"
  8. Section "ThisNameIsIgnoredSoWhyBother?"
  9. SetOutPath $TEMP
  10. ; ----- Sample 1 ----- Message box with custom icon -----
  11. ; there are no default beeps for custom message boxes, use sysMessageBeep
  12. ; in case you need it (see next message box example)
  13. !insertmacro smMessageBox "i 0" "Message box with custom icon!" "System Example 1a" ${MB_OK} "i 103"
  14. ; i 0 - installer exe as module
  15. ; i 103 - icon ID
  16. ; The same example but using icon from resource.dll.
  17. ; You could use this dll for storing your resources, just replace FAR icon
  18. ; with something you really need.
  19. File "Resource.dll"
  20. System::Call '${sysMessageBeep} (${MB_ICONHAND})' ; custom beep
  21. !insertmacro smMessageBox "`$TEMP\resource.dll`" "Message box with custom icon from resource.dll!" "System Example 1b" ${MB_OKCANCEL} "i 103"
  22. Delete $TEMP\resource.dll
  23. ; ----- Sample 2 ----- Fixed disks size/space -----
  24. StrCpy $7 ' Disk, Size, Free, Free for user:$\n$\n'
  25. ; Memory for paths
  26. System::Alloc 1024
  27. Pop $1
  28. ; Get drives
  29. System::Call '${sysGetLogicalDriveStrings}(1024, r1)'
  30. enumok:
  31. ; One more drive?
  32. System::Call '${syslstrlen}(i r1) .r2'
  33. IntCmp $2 0 enumex
  34. ; Is it DRIVE_FIXED?
  35. System::Call '${sysGetDriveType} (i r1) .r3'
  36. StrCmp $3 ${DRIVE_FIXED} 0 enumnext
  37. ; Drive space
  38. System::Call '${sysGetDiskFreeSpaceEx}(i r1, .r3, .r4, .r5)'
  39. ; Pretty KBs will be saved on stack
  40. System::Int64Op $3 / 1048576
  41. System::Int64Op $5 / 1048576
  42. System::Int64Op $4 / 1048576
  43. ; Get pretty drive path string
  44. System::Call '*$1(&t1024 .r6)'
  45. System::Call '${syswsprintf} (.r7, "%s%20s %20s mb %20s mb %20s mb$\n", tr7, tr6, ts, ts, ts)'
  46. enumnext:
  47. ; Next drive path
  48. IntOp $1 $1 + $2
  49. IntOp $1 $1 + 1
  50. goto enumok
  51. enumex: ; End of drives or user cancel
  52. ; Free memory for paths
  53. System::Free $1
  54. ; Message box
  55. System::Call '${sysMessageBox}($HWNDPARENT, s, "System Example 2", ${MB_OKCANCEL})' "$7"
  56. ; ----- Sample 3 ----- Direct proc defenition -----
  57. ; Direct specification demo
  58. System::Call 'user32::MessageBoxA(i $HWNDPARENT, t "Just direct MessageBoxA specification demo ;)", t "System Example 3", i ${MB_OK}) i.s'
  59. Pop $0
  60. ; ----- Sample 4 ----- Int64, mixed definition demo -----
  61. ; Long int demo
  62. StrCpy $2 "12312312"
  63. StrCpy $3 "12345678903"
  64. System::Int64Op $2 "*" $3
  65. Pop $4
  66. ; Cdecl demo (uses 3 defenitions (simple example))
  67. System::Call "${syswsprintf}(.R1, s,,, t, ir0) .R0 (,,tr2,tr3,$4_)" "Int64 ops and strange defenition demo, %s x %s == %s, and previous msgbox result = %d"
  68. MessageBox MB_OKCANCEL "Cool: '$R1'"
  69. ; ----- Sample 5 ----- Small structure example -----
  70. ; Create & Fill structure
  71. System::Call "*(i 123123123, &t10 'Hello', &i1 0x123dd, &i2 0xffeeddccaa) i.s"
  72. Pop $1
  73. ; Read data from structure
  74. System::Call "*$1(i .r2, &t10 .r3, &i1 .r4, &i2 .r5, &l0 .r6)"
  75. ; Show data and delete structure
  76. MessageBox MB_OK "Structure example: $\nint == $2 $\nstring == $3 $\nbyte == $4 $\nshort == $5 $\nsize == $6"
  77. System::Free $1
  78. ; ----- Sample 6 ----- systemGetFileSysTime demo -----
  79. Call GetInstallerExeName
  80. pop $0
  81. !insertmacro smGetFileSysTime $0
  82. System::Call '*$R0${stSYSTEMTIME}(.r1, .r2, .r3, .r4, .r5, .r6, .r7, .r8)'
  83. MessageBox MB_OK "GetFileSysTime example: file '$0', year $1, month $2, dow $3, day $4, hour $5, min $6, sec $7, ms $8"
  84. ; free memory from SYSTEMTIME
  85. System::Free $R0
  86. ; ----- Sample 7 ----- systemSplash -> Callbacks demonstration -----
  87. ; Logo
  88. File /oname=spltmp.bmp "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp"
  89. ; File /oname=spltmp.wav "d:\Windows\Media\tada.wav"
  90. ; I. systemSplash variant
  91. !insertmacro smSystemSplash 2000 "$TEMP\spltmp"
  92. ; II. Splash Plugin variant
  93. ; splash::show 2000 $TEMP\spltmp
  94. ; Pop $R0 ; $R0 has '1' if the user closed the splash screen early,
  95. ; remove logo
  96. Delete $TEMP\spltmp.bmp
  97. ; Delete $TEMP\spltmp.wav
  98. ; Display splash result
  99. pop $0
  100. MessageBox MB_OK "Splash (callbacks) demo result $R0"
  101. SectionEnd
  102. ; eof