Because the code is using System::String. Similar to how the _T() and TEXT() macros map a literal to the data type used by the C runtime's _TCHAR and Win32 API's TCHAR data types, respectively, the _D() macro maps a literal to the data type used by the System::String and System::Char data types. Prior to CB2009, that was Ansi 'char'. In CB2009 onwards, that is now UTF-16 'wchar_t' (Windows) and 'char16_t' (other platforms). Who knows what it will be in the future.

ingalime wrote:3. What is the real difference?

On Windows, there is currently no difference, since L"" and _D("") both map to the same 'wchar_t' data type. On other platforms, though, there is a difference, since 'wchar_t' is 32bit instead of 16bit on some platforms. That is why 'char16_t' is used instead on those platforms, to ensure 16bit since System::String is currently UTF-16 on all platforms. L"" does not produce a 16bit literal on those platforms, u"" does. So _D() maps to either L"" or u"" as needed.

Last edited by rlebeau on Thu Feb 15, 2018 8:17 pm, edited 2 times in total.