Archive: variable functionname in Getfunctionaddress


variable functionname in Getfunctionaddress
Hello,
I need to pass function name as a variable to getfunctionaddress,
e.g. if I have a function named myFunction:

StrCpy $1 myFunction
GetFunctionAddress $0 $1

but this does not work, is this too difficult to implement in NSIS?


The second paramater for GetFunctionAddress has to be a compile-time value. $1 is a run-time variable and so you'll be telling it your function is called "$1" not "myFunction".
You could get around this though by checking the value of $1 and get the right function address from there.

E.g.
StrCmp $1 "myFunction" 0 +2
GetFunctionAddress $0 "myFunction"

-Stu


if you can use that inside a macro you could try something similar to:

(note _FUNC and '${_FUNC}' )


Function RegSearch
!define RegSearch `!insertmacro RegSearchCall`

!macro RegSearchCall _PATH _OPTIONS _FUNC
Push $0
Push `${_PATH}`
Push `${_OPTIONS}`
GetFunctionAddress $0 `${_FUNC}`
Push `$0`
Call RegSearch
Pop $0
!macroend
.
.
.

from http://nsis.sourceforge.net/wiki/RegSearch