“APIENTRY _tWinMain"和“WINAPI WinMain"不同之处

2021-12-18 00:00:00 windows winapi c++ winmain

这两个函数有什么区别?:

What are the difference from these 2 function?:

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)

int WINAPI WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)

推荐答案

_tWinMain 只是 tchar.h 中相应版本的 #define 快捷方式WinMain.

_tWinMain is just a #define shortcut in tchar.h to the appropriate version of WinMain.

如果定义了_UNICODE,则_tWinMain 扩展为wWinMain.否则,_tWinMainWinMain 相同.

If _UNICODE is defined, then _tWinMain expands to wWinMain. Otherwise, _tWinMain is the same as WinMain.

相关的宏看起来是这样的(其实还有很多其他的代码穿插):

The relevant macro looks something like this (there's actually a lot of other code interspersed):

#ifdef  _UNICODE
#define _tWinMain  wWinMain
#else
#define _tWinMain  WinMain
#endif

相关文章