Archive: Adding one parameter to installer


Adding one parameter to installer
I'm having problems reading parameters in nsis.

I only need a number in the parameter. The number will then replace this number in my curent code. Hope this isn't do difficult to do :) .

Thanks in advance.


CURRENT CODE
...
SendMessage $0 ${WM_COMMAND} 40012 0
...
The number in bold will then be replaced with the parameter.
EX:
C:\myInstaller.exe 40012
will then do the same as my current code.

I've included my source code.


Use GetParameters which you can find in the NSIS documentation under Useful Scripts.

-Stu


Thanks for the help so far but I still need help getting it working. Here is the source:

!include WinMessages.nsh

Name "Alarm"
Caption "Alarm Notice"
OutFile "zzzz.exe"
Icon "..\Contrib\Graphics\Icons\llama-grey.ico"

silent by default.
; SilentInstall silent

Function CloseProgram
Exch $1
Push $0
FindWindow $0 $1
SendMessage $0 ${WM_COMMAND} 40012 0
Pop $0
Pop $1
FunctionEnd

Function .onInit
Push "Winamp v1.x"
Call CloseProgram
SetSilent silent
FunctionEnd

Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3

StrCpy $R2 1
StrLen $R3 $CMDLINE

;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "

loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop

get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2

Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd

Section
SectionEnd

..:: How do I get the int in the parameter to the 40012.

I will run the setup like this:

"C:\zzzz.exe 40012"

If the code look funny its because I don't know much about nsis. Can you maybe correct the above code?
Hope you can help me :) a a


Function CloseProgram
Exch $0
Exch
Exch $1
Push $2
FindWindow $2 $1
SendMessage $2 ${WM_COMMAND} $0 0
Pop $2
Pop $1
Pop $0
FunctionEnd

Function .onInit
Call GetParameters
Pop $0
IntOp $0 $0 * 1 # make sure int value
Push "Winamp v1.x"
Push $0
Call CloseProgram
SetSilent silent
FunctionEnd


-Stu

Thanks!!!!!!
I still can believe it's working! Finaly!

Thanks again, Afrow UK