LPWSTR wprintf 规格严格

因为LPWSTR指向的是一个宽字符串,而printf()是针对通常的字符串(非宽字符串)的,所以两者的类型不匹配,应该使用wprintf()

s String When used with printf functions, specifies a single-byte–character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached. 
S String When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte–character string. Characters are printed up to the first null character or until the precision value is reached. 

#define __T(x) L ## x
...
#define _T(x) __T(x)
#define _TEXT(x) __T(x)
...

MSDN98
mk:@MSITStore:C:\MSDN98\98VS\2052\vclang.chm::/html/_pluslang_c.2b2b_.string_literals.htm

C++ String Literals
A string literal consists of zero or more characters from the source character set surrounded by double quotation marks ("). A string literal represents a sequence of characters that, taken together, form a null-terminated string.

Syntax

string-literal :

"s-char-sequenceopt"
L"s-char-sequenceopt"

...
To specify a string of type wide-character (wchar_t[]), precede the opening double quotation mark with the character L. For example:

wchar_t wszStr[] = L"1a1g";

http://msdn.microsoft.com/en-us/library/ms686944(v=VS.85).aspx

原文地址:https://www.cnblogs.com/diyunpeng/p/2324358.html