Loop problem - unneeded extra characters
I have the following problem with loop. I would like to associate filetypes with MyProgram that are listed in an ini file.
The ini file contains file extensions, each of them is in a new row. The loop runs well but with an error
because it adds two extra characters to the end of the name of the registry key, so instead of
HKCR\MyProgram.mp3
it writes
HKCR\MyProgram.mp3
(if it cannot be seen, there's two extra square-like characters after MyProgram.mp3)
However, the last item in the ini file are written correctly into the registry (no extra chars).
I'm using NSIS 2.17.
Here is the corresponding section of the script:
Section "File Associations"
ClearErrors
FileOpen $2 "Settings\FileAssociations.ini" r
loop:
FileRead $2 $3
StrCmp $3 "" done
!define Index "Line${__LINE__}"
ReadRegStr $1 HKCR ".$3" ""
StrCmp $1 "" "${Index}-NoBackup"
StrCmp $1 "MyProgram.$3" "${Index}-NoBackup"
WriteRegStr HKCR ".$3" "backup_val" $1
"${Index}-NoBackup:"
WriteRegStr HKCR ".$3" "" "MyProgram.$3"
ReadRegStr $0 HKCR "MyProgram.$3" ""
StrCmp $0 "" 0 "${Index}-Skip"
WriteRegStr HKCR "MyProgram.$3" "" "MyProgram $3 file"
WriteRegStr HKCR "MyProgram.$3\shell" "" "open"
WriteRegStr HKCR "MyProgram.$3\DefaultIcon" "" "$EXEDIR\Settings\shell_icon.ico"
"${Index}-Skip:"
WriteRegStr HKCR "MyProgram.$3\shell\open\command" "" \
'"$EXEDIR\MyProgram.exe" "%1"'
!undef Index
Goto loop
done:
FileClose $2
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
SectionEnd
I hope you can help me solving this. Thanks for your answers in advance.