gpt4 book ai didi

windows - NSIS 获取参数

转载 作者:可可西里 更新时间:2023-11-01 11:22:11 26 4
gpt4 key购买 nike

要将 -n 0 值作为字符串(不需要选项)传递给安装程序,我不太明白这个函数的作用是什么?

; 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 获取 a 的值参数。

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

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

关于windows - NSIS 获取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4133962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com