2012-05-14 103 views
5

NSIS函数可以有多个参数吗?带有多个参数的NSIS函数

为什么不通过此代码编译?如果我的功能不能超过1个参数,我的其他选项是什么(不考虑使用宏)?

编译错误:

Function expects 1 parameters, got 4. Usage: Function function_name

Outfile "test.exe" 
Caption "" 
Name "" 

# Compile Error Here: "Function expects 1 parameters, got 4. Usage: Function function_name" 
Function MyFunction p1 p2 p3 
    DetailPrint "$p1, $p2, $p3" 
FunctionEnd 

Section 
    DetailPrint "Hello World" 
SectionEnd 

回答

8

你要通过和/或在stack寄存器参数:

Function onstack 
pop $0 
detailprint $0 
FunctionEnd 

Function reg0 
detailprint $0 
FunctionEnd 

Section 
push "Hello" 
call onstack 
strcpy $0 "World" 
call reg0 
SectionEnd 
+0

当你调用你允许通过一个函数参数它一致。它使用堆栈或注册表吗? – Ring

+0

@Ring不,你不能将它们内联。你可以在使用dll :: export插件语法时做到这一点,但编译器会将这些语法转换为推式... – Anders

+0

我正在查看以下函数之一的源代码:对于大多数库,它们包括!宏定义,允许用户提供参数内联。在(爆炸http://nsis.sourceforge.net/Explode)的情况下,参数被推入并且返回被弹出。 – Ring