|
In fact, all the runtime library functions, the string operation functions printf and sprintf that we are used to have their corresponding unicode version and tchar version
Most of the tchar version can do this, for example, strlen, change to _tcslen(), which means that str becomes _tcs
printf can be changed to _tprintf, most can be handled in this way
Involved parameters contain string constants like printf(""), all become _tprintf(_T("...")) like this,
All of the above are done for compatibility with previous runtime functions
For some standard API functions, such as MessageBoxA and MessageBoxW, macros are replaced by MessageBox automatic recognition environment. Try to use _T() in the parameter to contain the string constant, if it is a pointer to a variable string
LPTSTR is used to replace unsigned char *
LPCTSTR is used to replace const unsigned char *
What about arrays is TCHAR[]
When calculating the size of a byte, pay attention to that the correct number of TCHAR[100] is 100*sizeof(TCHAR) instead of just 100
The program written in this way can cope with compilation in two environments |
|