jaroslav_adamec
23rd October 2001 11:41 UTC
How to parse string?
I write some values to common RegistryString:
ReadRegStr $1 HKEY_LOCAL_MACHINE "Software\Microsoft\Java VM" Classpath
StrCpy $1 "$INSTDIR\myApp\pakage.jar;$1"
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Java VM" "Classpath" "$1"
On Uninstall I want to remove only my part from this RegistryString.
Can somebody help me?
Jarda
justin
24th October 2001 02:21 UTC
Here you go:
; removes $9 from $1. keep $9 intact.
Function removeFromString
Push $2
Push $3
Push $4
StrCpy $2 0 ; search start
StrLen $3 $9 ; get length of string to remove
loop:
StrCpy $4 $1 $3 $2 ; copy substring of string starting at $2
StrCmp $4 "" done
StrCmp $4 $9 found
IntOp $2 $2 + 1
Goto loop
found:
StrCpy $4 $1 $2 ; $4 is start of string
IntOp $2 $2 + $3
StrCpy $3 $1 "" $2 ; $3 is end of string
StrCpy $1 $4$3 ; $1 is new string
done:
Pop $4
Pop $3
Pop $2
FunctionEnd
Section add
ReadRegStr $1 HKLM "Software\Microsoft\Java VM" Classpath
StrCpy $9 "$INSTDIR\myapp\pakage.jar;"
Call removeFromString
StrCpy $1 "$9$1"
WriteRegStr HKLM "Software\Microsoft\Java VM" Classpath $1
SectionEnd
Section del
ReadRegStr $1 HKLM "Software\Microsoft\Java VM" Classpath
StrCpy $9 "$INSTDIR\myapp\pakage.jar;"
call removeFromString
WriteRegStr HKLM "Software\Microsoft\Java VM" Classpath $1
SectionEnd
Note: if you use removeFromString in both the installer and uninstaller, you will need two copies, one named un.removeFromString (for the uninstaller), and the uninstaller will need to call un.removeFromString.
I tested this briefly, and it seemed to work.
-Justin
jaroslav_adamec
24th October 2001 12:07 UTC
Thanks
I used old version of NSIS and there wasn't the fourth argument in StrCpy so I found it impossible.
Thanks once more for your work Justin :)
Jarda