本文介绍了NSIS 获取参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了让 -n 0
值作为字符串(不需要选项)传递给安装程序,我不太明白这个函数的作用是什么?
to get -n 0
value passing as a string (no need option) to the installer, I don't quite understand what this function work?
; GetParameters
; input, none
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
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
推荐答案
GetParameters 只是获取参数 ("yourapp.exe/foo/bar" will give you "/foo/bar" etc) 它基本上只是去掉第一个令牌(带引号处理)使用 GetOptions 获取参数的值.
GetParameters just gets the parameters ("yourapp.exe /foo /bar" will give you "/foo /bar" etc) It basically just strips away the first token (with quote handling) Use GetOptions to get the value of a parameter.
!include "FileFunc.nsh"
!include "LogicLib.nsh"
function .onInit
${GetParameters} $0
ClearErrors
${GetOptions} $0 "-n" $1
${IfNot} ${Errors}
MessageBox mb_ok $1
${EndIf}
functionend
这篇关于NSIS 获取参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!