Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows NSIS get参数_Windows_Nsis - Fatal编程技术网

Windows NSIS get参数

Windows NSIS get参数,windows,nsis,Windows,Nsis,要将-n0值作为字符串(无需选项)传递给安装程序,我不太了解此函数的工作原理 ; 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

要将
-n0
值作为字符串(无需选项)传递给安装程序,我不太了解此函数的工作原理

; 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”将为您提供“/foo/bar”等),它基本上只去除第一个标记(带有引号处理)使用GetOptions获取参数值

!include "FileFunc.nsh"
!include "LogicLib.nsh"

function .onInit
${GetParameters} $0
ClearErrors
${GetOptions} $0 "-n" $1
${IfNot} ${Errors}
    MessageBox mb_ok $1
${EndIf}
functionend

GetParameters只获取参数(“yourapp.exe/foo/bar”将为您提供“/foo/bar”等),它基本上只去除第一个标记(带有引号处理)使用GetOptions获取参数值

!include "FileFunc.nsh"
!include "LogicLib.nsh"

function .onInit
${GetParameters} $0
ClearErrors
${GetOptions} $0 "-n" $1
${IfNot} ${Errors}
    MessageBox mb_ok $1
${EndIf}
functionend