Unicode programming under Windows or supports Unicode, the general trend, the underlying system after WINDOW 2K is Unicode, even if you call ANSI's API (End, such as setwidowstexta), the system will also be in your process Dynamically assigned a memory, store the converted Unicode string, then pass the converted string to the API, if the return value is an ANSI string, Windows will conversion in the background, more waste Time !! Even if you don't consider efficiency problems, don't you want your software internationalization? Do you want to face half of Chinese characters?
In fact, Unicode programming in VC is not bother, probably as follows:
1. Add a Unicode and _unicode preprocessing options for the project, which is items in VC.NET -> Properties -> C / C -> Preprocessors Add these two macro definitions in the Pre-Processing Definition (Project in VC6 " -> Settings -> C / C -> Preprocessor definitions in General.
2.NClude
(Generally in stdafx.h) and then replace all places using char * to define variables to LPTSTR / TCHAR * or LPCTSTSTSTSTSTSTSTSTSTSTSTST TCHAR * (corresponding to const char *).
3. Pack all the string constants, such as tchar * sztext = _t ("My Text");
4. All C library string operation functions are also replaced, such as
Strlen -> _ TCSLEN
STRCAT -> _ TCSCAT
strcmp -> _ tcscmp
......
Note that "text length" in these functions is the number of characters, not the number of CHARs to see MSDN.
5. API calls generally do not need special processing, and after unicode and _genicode are defined, all APIs will be macro the version of the end (not defined, pointing to the end of A).
In fact, the above is not to force you to use Unicode, if you want to go back to use ANSI, there is no problem, take the two macros defined in the first step to get off, continue our ANSI program! !
:)