CreateWindowEx、CreateWindowExA、CreateWindowExW 之间有什么区别?

What is differnece between CreateWindowEx, CreateWindowExA, CreateWindowExW?

我阅读了有关 CreateWindowEx CreateWindowExA CreateWindowExW 的文档,它们似乎彼此相同。

如果没有区别,为什么它们都存在?

首先,CreateWindowEx是一个宏,它根据是否定义了UNICODE扩展为CreateWindowExACreateWindowExW。许多 WinAPI 函数都是这样工作的:它们有一个宏,可以根据 UNICODE 在适当的函数之间切换,然后有 AW 版本。

现在,AW 版本的区别非常简单。

The "A" version handles text based on Windows code pages, while the "W" version handles Unicode text.

-- 来源:https://docs.microsoft.com/en-us/windows/win32/intl/code-pages

来自 Microsoft documentation:

The winuser.h header defines CreateWindowEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.