5

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

为什么这段代码不能编译?如果我不能为一个函数提供超过 1 个参数,那么我的其他选项是什么(不考虑使用宏)?

编译错误:

函数需要 1 个参数,得到 4 个。用法:函数 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
4

1 回答 1

8

您必须在寄存器和/或堆栈中传递参数:

Function onstack
pop $0
detailprint $0
FunctionEnd

Function reg0
detailprint $0
FunctionEnd

Section
push "Hello"
call onstack
strcpy $0 "World"
call reg0
SectionEnd
于 2012-05-14T01:06:26.540 回答