You must know they are all related to unicode but how to use them?
UNICODE definition is used in Windows SDK source code. If it is defined, functions like RegSetValueEx will be defined as RegSetValueExW, else it is defined as RegSetValueExA.
The definition _UNICODE is used in C/C++ library source code such as in tchar.h so it is at a lower level than UNICODE. If defined, the macro _T(or _TEXT) will be defined as L, if not defined, _T(or _TEXT) will be defined as empty.
L is neither a function nor macro. It is prefixed before a string literal (like L”name”) to tell the compiler(such as g++) to compile the following string(“name”) as WCHARs(a character uses two bytes).
These definitions/macro/prefix are used to control whether to build a unicode version of app or an ansi version of app from a single version of source code. The following is how to use them in a source code to achieve this aim:
//at the beginning of source code #ifdef UNICODE #define _UNICODE #endif #include <tchar.h> ..... ...... ..... RegSetValueEx(key, _T("name"), 0, REG_SZ, (BYTE*)xx, strlen(xx));
When building with gcc or a framework such as Qt, you only need to use UNICODE instead of _UNICODE like:
g++ -DUNICODE yoursource.cpp
This will build a unicode version of your app.
If you don’t define UNICODE like
g++ yoursource.cpp
It will build an ansi version of your app.
Reference: https://stackoverflow.com/questions/7953025/why-both-unicode-and-unicode