NSIS查找文本中是否包含某个字串

!include "textfunc.nsh"
!include "logiclib.nsh"
OutFile "find.exe"
#文本文件a.txt内其中一行包含字串kb234783
#编写 水晶石
#查找文本中是否包含某个字串

Var found


Section
  StrCpy
$found 0
    
${LineFind} "a.txt" "/NUL" "1:-1" "GrepFunc"
    ${if} $found 1
          
MessageBox MB_OK "找到了"
    
${else}
          
MessageBox MB_OK "没找到"
    
${endIf}
SectionEnd

Function
GrepFunc
    
${TrimNewLines} '$R9$R9
    
System::Call "Shlwapi::StrStr(tR9, t`kb234783`)i .r0"
    ${if} $0 != 0
         
StrCpy $found 1
         
Push "StopLineFind"
    
${else}
         
Push 0
   
${endIf}
FunctionEnd

posted @ 2022-08-12 19:30  水晶石  阅读(292)  评论(0编辑  收藏  举报