# 호출 예
# ${StrReplace} '반환' '찾을 문자열' '바꿀 문자열' '원본 문자열'
# ${StrReplace} $0 "like" "don't like" "I like cheese a lot!"
# $0 == I don't like cheese a lot!
!macro _StrReplace un
Function ${un}_StrReplace
Push $R0 # 원본 문자열
Exch
Pop $R0
Push $R1
Exch 2
Pop $R1 # 바꿀 문자열
Push $R2
Exch 3
Pop $R2
Push $R3
Push $R4
Push $R5
Push $R6
Push $R7
Push $R8
StrCpy $R3 -1
StrLen $R5 $R0
StrLen $R6 $R1
StrLen $R7 $R2
Loop:
IntOp $R3 $R3 + 1
StrCpy $R4 $R0 $R7 $R3
StrCmp $R3 $R5 End
StrCmp $R4 $R2 0 Loop
StrCpy $R4 $R0 $R3
IntOp $R8 $R3 + $R7
StrCpy $R8 $R0 "" $R8
StrCpy $R0 $R4 $R1 $R8
IntOp $R3 $R3 + $R6
IntOp $R3 $R3 - 1
IntOp $R5 $R5 - $R7
IntOp $R5 $R5 + $R6
Goto Loop
End:
Pop $R8
Pop $R7
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Push $R0
Exch
Pop $R0
Exch
Pop $R1
Exch
Pop $R2
FunctionEnd
!macroend
!insertmacro _StrReplace ""
!insertmacro _StrReplace "un."
!macro StrReplace OUTPUT str_find str_replace str_origin
Push "${str_find}"
Push "${str_replace}"
Push "${str_origin}"
!ifndef __UNINSTALL__
Call _StrReplace
!else
Call un._StrReplace
!endif
Pop "${OUTPUT}"
!macroend
!define StrReplace "!insertmacro StrReplace"
댓글
댓글 쓰기