Archive: DumpLog in Unicode script


DumpLog in Unicode script
So I needed to save the log in my unicode in the same way I did in ANSI one. I used the code from nsis web site:

FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1016
StrCmp $0 0 exit
SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6
DetailPrint "Item count: $6"
DetailPrint ${NSIS_MAX_STRLEN}
System::Alloc ${NSIS_MAX_STRLEN}
Pop $3
StrCpy $2 0
System::Call "*(i, i, i, i, i, i, i, i, i) i \
(0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"
loop: StrCmp $2 $6 done
System::Call "User32::SendMessageA(i, i, i, i) i \
($0, ${LVM_GETITEMTEXT}, $2, r1)"
System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)"
DetailPrint "Here's the string: $4"
IntOp $2 $2 + 1
Goto loop
done:
System::Free $1
System::Free $3
exit:


I edited it to the following:
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1016
StrCmp $0 0 exit
SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6
DetailPrint "Item count: $6"
DetailPrint ${NSIS_MAX_STRLEN}
System::StrAlloc ${NSIS_MAX_STRLEN}
Pop $3
StrCpy $2 0
System::Call "*(i, i, i, i, i, i, i, i, i) i \
(0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"
loop: StrCmp $2 $6 done
System::Call "User32::SendMessageA(i, i, i, i) i \
($0, ${LVM_GETITEMTEXTW}, $2, r1)"
System::Call "*$3(&w${NSIS_MAX_STRLEN} .r4)"
DetailPrint "Here's the string: $4"
IntOp $2 $2 + 1
Goto loop
done:
System::Free $1
System::Free $3
exit:


Surprisingly, the code works. Surprisingly, because I have no idea why if I'm creating the szString member of the structure as type "i":
System::Call "*(i, i, i, i, i, i, i, i, i) i \
(0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"

the thing still works. My understanding was that the type should be 'w' or 't'. But alas, specifying any of these types doesn't work at all. Just an empty string is returned...
Can anyone explain me why?

Why are you using SendMessageA in the unicode code?

i because t/m/w are special types used by the system plugin (It converts on the fly before calling the requested windows function). i (and p in 2.47) is used for pointers and the LVITEM struct needs a pointer to a string (LPTSTR winapi type)


oh, now I see, thank you! I was under the impression that 'i' stands for int and was therefore wondering.
well the SendMessageA was initially in the code before I started converting to Unicode, it worked, so I never paid attention that it's actually an ANSI function, thanks for pointing out, I'll replace it with SendMessageW.


It does stand for int, but pointers are the same size as an int (depending on the architecture mind).

Stu