Le lundi 28 février 2005 à 09:10 +0800, Dmitry Timoshkov a écrit :
"Jonathan Ernst" Jonathan@ErnstFamily.ch wrote:
With some help I'll be able to improve it (more unicodification, etc.) when I'll come back.
You can't really convert to unicode partially, you have to do it in one go. That not only will simplify things a lot, but also will save you a lot of time.
Ok, I will continue to work on it then. I'm sorry to require that much help, but my first idea was just to add internationalization to the uninstaller, then I was asked to move from window to dialog and then from ascii to unicode and that's another cup of tea ;-)
- for (i=0; i < numentries; i++)
- {
len = WideCharToMultiByte(CP_UNIXCP, 0, entries[i].descr, -1, NULL, 0, NULL, NULL);
descr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
WideCharToMultiByte(CP_UNIXCP, 0, entries[i].descr, -1, descr, len, NULL, NULL);
printf("%s|||%s\n", entries[i].key, descr);
There is no need to allocate len * sizeof(WCHAR) bytes, len works just fine.
Ok Fixed.
+int wmain(int argc, char *argv[])
wmain takes 'WCHAR *argv[]' list.
Fixed as well.
All remaining problems are caused by the fact that now argv[] array is passed in unicode but you still handle argv[] strings as ASCII and pass them around to internal functions which accept 'char *' not 'WCHAR *' strings.
I tried to fix every char->WCHAR I though was worth it; please have a second look at it.
The problem now with unicode is that when I try to strstr my token with the element of the list (entries[i].descr) it works only with the first letter (before to use unicode it was working very well). You can see the same problem (one letter .descr) when using the unintaller with --list.
The second problem is that since I use unicode for the argvs, whatever argv I give I get the --list branch.
Thanks everyone for your help.