TCHAR is defined by including either <windows.h>(<windows.h>--><windef.h>--><winnt.h>) or <tchar.h>.
The problem is that in <tchar.h> it is defined as WCHAR if _UNICODE is defined, while in <winnt.h> it is defined as WCHAR if UNICODE is defined.
This means that if you do not have both of these symbols defined it depends on the order of your #includes whether you get a TCHAR which is one byte or two.
Code:
// Sample 1.
#define UNICODE
#include <tchar.h>
#include <windows.h>
...
Code:
// Sample 2.
#define UNICODE
#include <windows.h>
#include <tchar.h>
...
In sample one we get a single byte TCHAR because it is defined in <tchar.h> and _UNICODE is not defined. In sample two we get a two byte TCHAR because it is defined in <winnt.h> and UNICODE is defined.
If we define only _UNICODE then we can reverse the above samples.
The morals of this story are:
1. Always define both UNICODE and _UNICODE.
2. Something as simple as changing the order of #includes can introduce hard to diagnose bugs in to your program.
3. Make sure item no. 2 doesn't apply to your header files.
4. Always check for the boogie monster under your bed before going to sleep at night.