From: r_z_aret on 8 Apr 2010 15:05 On Thu, 8 Apr 2010 07:14:14 +0200, "Jean" <nosp-jean(a)free.fr> wrote: >Hello Friedel >Here is the code: > >int how_many_fichiers_unicode(char *rep) { >HANDLE hh; >wchar_t wrep[_MAX_PATH]; >char full_name[_MAX_PATH] >int nbFic=0; >WIN32_FIND_DATAW wfind; >int ret, sz; >LPSTR ansi; > >#define UNICODE >#define _UNICODE clip > >MessageBox(NULL,ansi,"",MB_OK); I'm surprised this line compiled. You have UNICODE and _UNICODE defined, so MessageBox should be defined as MessageBoxW. But you've passed an ANSI argument. clip > >#undef _UNICODE >#undef UNICODE > return nbFic; >} > >Jean ----------------------------------------- To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message). Robert E. Zaret, eMVP PenFact, Inc. 20 Park Plaza, Suite 400 Boston, MA 02116 www.penfact.com Useful reading (be sure to read its disclaimer first): http://catb.org/~esr/faqs/smart-questions.html
From: Friedel Jantzen on 8 Apr 2010 15:27 Hello Jean! Am Thu, 8 Apr 2010 11:17:47 +0200 schrieb Jean: >> if you are using MSVC > yes, i use MSVC6 and pure C SDK. > i set UNICODE in the project and got 34765 warnings :-)) > > using WCHAR is easy, thank you for the tip. > i suppose that i lust use _wsplitpath instead of _splitpath, swprintf > instead of wsprintf, wcscpy instead of strcpy etc... ? > Yes, the wcs CRT string functions must be used, if the strings are Unicode. This redesign can be a lot of work. However, it is possible to use both ANSI and Unicode APIs together in the exe, like in your original code posting. This is a mess, but possible (not on Win9x). If you want to to it that way, do not define UNICODE, but code the WideChar-API-functions explicitely, as you did. But when you must pass the strings to ANSI functions, you will run into problems with converting the Unicode cyrillic strings (wchar_t, WCHAR) to ANSI (char)... IMO there really is no way around Unicode, if e.g. Cyrillic must be supported. BTW, I suggest to provide a way for the user to select a font to ensure cyrillic support. Regards, Friedel
From: Ulrich Eckhardt on 9 Apr 2010 02:53 r_z_aret(a)pen_fact.com wrote: > On Thu, 8 Apr 2010 07:14:14 +0200, "Jean" <nosp-jean(a)free.fr> wrote: [...] >>LPSTR ansi; >> >>#define UNICODE >>#define _UNICODE > > clip > >> >>MessageBox(NULL,ansi,"",MB_OK); > > I'm surprised this line compiled. You have UNICODE and _UNICODE > defined, so MessageBox should be defined as MessageBoxW. But you've > passed an ANSI argument. He first included the according header, where the MessageBox macro is defined and only afterwards defined the UNICODE/_UNICODE macros. In other words, these simply didn't take effect and MessageBox still resolves to MessageBoxA. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
First
|
Prev
|
Pages: 1 2 3 4 Prev: Looking for Open XML SDK tutorial in C++ Next: OS x64 Identification |