Les fonctions de registre ne peuvent pas effectuer de manipulation de chaîne. Si vous avez besoin de manipuler une chaîne, vous pouvez jeter un oeil à certaines des macros d'aide fournies avec NSIS ou écrire les vôtres.
J'ai fini avec un hybride qui fait un peu des deux:
!include LogicLib.nsh
!include StrFunc.nsh
${StrLoc}
Section
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" "Windows"
${StrLoc} $7 $0 "SharedSection=" ">" ; Find "SharedSection="
StrCpy $R1 $0 $7 ; Save the stuff before "SharedSection="
StrCpy $R2 $0 "" $7
${StrLoc} $8 $R2 " " ">" ; Find the end of "SharedSection=#,#,#" by looking for a space
${IfThen} $8 = 0 ${|} StrLen $8 $R2 ${|}
StrCpy $R3 $R2 "" $8 ; Save the stuff after "SharedSection=#,#,#"
StrCpy $R2 $0 $8 $7 ; Save "SharedSection=#,#,#"
; We can now parse "SharedSection=#,#,#":
StrLen $8 $R2
findcomma:
IntOp $8 $8 - 1
StrCpy $1 $R2 1 $8
StrCmp $1 "," findcomma_end
StrCmp $1 "" findcomma_end findcomma
findcomma_end:
IntOp $9 $8 + 1
StrCpy $2 $R2 "" $9
${If} $1 != "" ; Only edit if we found the comma..
${AndIf} $2 != "" ; ..And there was something after the comma
StrCpy $R2 $R2 $8 ; Copy the first part of the string
StrCpy $R2 "$R2,1536" ; Append the final comma and number
${EndIf}
StrCpy $0 "$R1$R2$R3" ; Build the final string
DetailPrint Result=$0
# TODO: WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" "Windows" $0
SectionEnd
Vous devriez être très prudent lors de la modification de ces valeurs, si vous faites une erreur le système peut ne pas démarrer. – Anders