tderouin, do the MBCS characters come right if you copy byte by byte? Afrow UK's code should help you test that.
Copying single multibyte characters with StrCpy
36 posts
I'm just getting around to testing this now, SubdirsAmount doesn't actually record how many directories are going to be created. It should probably be changed to check to see if a directory exists, if it doesn't exist then increment the number of subdirs, if it doesn't exist don't increment but continue copying.
I'll play with it and post new code if I find a better way.
Ex:
SubdirsAmount C:\Documents and Settings\user\Start Menu\Programs\Product
returns 6
but only one dir is being created, so in the uninstall log you see:
rmdir C:\Documents and Settings\user\Start Menu\Programs\Product
rmdir C:\Documents and Settings\user\Start Menu\Programs
rmdir C:\Documents and Settings\user\Start Menu
rmdir C:\Documents and Settings\user
rmdir C:\Documents and Settings
rmdir C:
Which wouldn't look to pleasant to the user.
I'll play with it and post new code if I find a better way.
Ex:
SubdirsAmount C:\Documents and Settings\user\Start Menu\Programs\Product
returns 6
but only one dir is being created, so in the uninstall log you see:
rmdir C:\Documents and Settings\user\Start Menu\Programs\Product
rmdir C:\Documents and Settings\user\Start Menu\Programs
rmdir C:\Documents and Settings\user\Start Menu
rmdir C:\Documents and Settings\user
rmdir C:\Documents and Settings
rmdir C:
Which wouldn't look to pleasant to the user.
I found this was a good way for finding the numbeof subdirs that had to be created:
Function SubdirsAmount
Exch $R0 ;input string
Push $R1
Push $R2
Push $R3
Push $R4
Push $R5
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
StrCpy $R5 $R0 -$R1
StrCpy $R3 $R0 1 -$R1
StrCmp $R1 $R2 exit
StrCmp $R3 "\" 0 loop
IfFileExists "$R5\*.*" loop ; don't increment if the directory exists
IntOp $R4 $R4 + 1
Goto loop
exit:
StrCpy $R0 $R4
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0 ;output
FunctionEnd So when installing I would do: Push "$INSTDIR"
Call SubdirsAmount
Pop $R0
WriteRegStr HKCU "${REGISTRY_LOC}" "UninstallTopLevelFolder" "$R0" When uninstalling: ; remove folders
ReadRegStr $R0 HKCU "${REGISTRY_LOC}" "UninstallTopLevelFolder"
Push $R0
Push "$INSTDIR"
call un.UninstallDirs What about the MBCS characters? Do they come out right?
Yes, this seems to work for multibyte characters.
I have updated the GetParent function, so it should support MBCS now. Can you please test this one? Thanks 🙂
Function GetParent
Exch $R0 ; old $R0 is on top of stack
Push $R1
Push $R2
Push $R3
StrLen $R3 $R0
loop:
IntOp $R1 $R1 - 1
IntCmp $R1 -$R3 exit exit
StrCpy $R2 $R0 1 $R1
StrCmp $R2 "\" exit
Goto loop
exit:
StrCpy $R0 $R0 $R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0 ; put $R0 on top of stack, restore $R0 to original value
FunctionEnd