最新消息:

EnumINI为NSIS提供检索INI文件操作

nsis 永恒心锁 1763浏览 0评论
/*
EnumINI为NSIS提供检索INI文件操作
可以迭代遍历INI文件的键和值,可以查询特定的键值是否存在
*/
; EnumINI plug-in example
!AddPluginDir "../../Plugins"
Name "EnumINI Example"
OutFile "EnumINI.exe"
ShowInstDetails show
Section ""
 InitPluginsDir
 DetailPrint "EnumINI plug-in v0.13"
 DetailPrint ""
 DetailPrint "Let's enumerate keys in $"EXAMPLE_ONE$" section"
 EnumINI::Section "enumtest.ini" "EXAMPLE_ONE"
 Pop $R0
 DetailPrint "Keys in stack: $R0"
 StrCmp $R0 "error" done
 loop:
 IntCmp $R0 "0" done done 0
 Pop $R1
 DetailPrint "$R1"
 IntOp $R0 $R0 - 1
Goto loop
 done:
 DetailPrint ""
 DetailPrint "Let's enumerate sections in .ini file"
 EnumINI::SectionNames "enumtest.ini"
 Pop $R0
 DetailPrint "Sections in stack: $R0"
 StrCmp $R0 "error" done2
 loop2:
 IntCmp $R0 "0" done2 done2 0
 Pop $R1
 DetailPrint "$R1"
 IntOp $R0 $R0 - 1
Goto loop2
 done2:
 DetailPrint ""
 DetailPrint "Let's find out if key $"fairlight$" exist in $"EXAMPLE_ONE$" section"
 EnumINI::KeyExist "enumtest.ini" "EXAMPLE_ONE" "fairlight"
 Pop $R0
 DetailPrint "In stack we have: $R0"
 StrCmp $R0 "1" 0 +3
 DetailPrint "And the key exist :)"
 Goto +3
 StrCmp $R0 "0" +2
 DetailPrint "And key doesn't exist :("
 DetailPrint ""
 DetailPrint "Let's find out if section $"EXAMPLE_TWO$" exist in .ini file"
 EnumINI::SectionExist "enumtest.ini" "EXAMPLE_TWO"
 Pop $R0
 DetailPrint "In stack we have: $R0"
 StrCmp $R0 "1" 0 +3
 DetailPrint "And the section exist :)"
 Goto +3
 StrCmp $R0 "0" +2
 DetailPrint "And section doesn't exist :("
 DetailPrint ""
 DetailPrint "Let's test stuff ;)"
 EnumINI::Section "enumtest.ini" "TEST STUFF"
 Pop $R2
 StrCmp $R2 "error" done3
 loop3:
 IntCmp $R2 "0" done3 done3 0
 Pop $R3
 ReadINIStr $R4 "$EXEDIRenumtest.ini" "TEST STUFF" "$R3"
 DetailPrint ">$R3< = >$R4<"
 IntOp $R2 $R2 - 1
 Goto loop3
 done3:
 DetailPrint ""
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » EnumINI为NSIS提供检索INI文件操作

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