最新消息:

nsRandom是NSIS生成随机数的插件

nsis 永恒心锁 1895浏览 0评论
/*
nsRandom是NSIS生成随机数的插件
nsRandom想要生成100以内的数需要先Push 100到栈里,浮点数需要Push -1到栈里即可.
*/
Name "nsRandom Test"
OutFile "nsRandom Test.exe"
ShowInstDetails show
Section "Get Random"
 DetailPrint "nsRandom example by Leon Zandman"
 DetailPrint "------------------------------------"
 DetailPrint "Getting 10 random numbers in range 0 <= random < 100:"
 StrCpy $1 10
 loop1:
 ; Use range 0 <= Random < 100
 Push "100"
 ; Get the random number
 nsRandom::GetRandom
 Pop $2
 DetailPrint "$2"
 IntOp $1 $1 - 1
 IntCmp $1 0 exit_loop1
 Goto loop1
 exit_loop1:
 DetailPrint "------------------------------------------"
 DetailPrint "Getting 10 random numbers between 0 and 1:"
 StrCpy $1 10
 loop2:
 ; Use range 0 <= Random < 1 (floating numbers!)
 Push "-1"
 ; Get the random number
 nsRandom::GetRandom
 Pop $2
 DetailPrint "$2"
 IntOp $1 $1 - 1
 IntCmp $1 0 exit_loop2
 Goto loop2
 exit_loop2:
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » nsRandom是NSIS生成随机数的插件

您必须 登录 才能发表评论!