mainWCRTStartup 与 wmain

11 篇文章 0 订阅

The C Run-Time Libraries for Windows CE (CRT) provide many useful functions that can make programming much easier.

The CRT resides in two core libraries, COREDLL.DLL and CORELIBC.LIB.

  • You can link to the portion of the CRT in COREDLL.DLL by linking with COREDLL.LIB, the import library for COREDLL.DLL.
  • CORELIBC.LIB contains the CRT startup routines. In addition, it contains other CRT routines that you must link to statically, primarily to ensure optimum performance.

When you link your image, you explicitly or implicitly specify an entry point that the operating system will call into after loading the image.

For a DLL, the default entry point is _DllMainCRTStartup.

For an EXE, the default entry is wWinMainCRTStartup, the Unicode entry point for an EXE that defines the wWinMain function, orWinMainCRTStartup otherwise.

You can rely on the default entry point that the linker chooses, but the best practice is usually to override the default choice. Instead, specify an entry point with the /ENTRY linker option.

Windows CE supports the following CRT entry points:

  • mainACRTStartup for applications that define the main function
  • mainWCRTStartup for applications that define the wmain function
  • WinMainCRTStartup for applications that define the WinMain function
  • wWinMainCRTStartup for applications that define the wWinMain function
  • _DllMainCRTStartup for DLLs

For more information, see the linker topic /ENTRY (Entry-Point Symbol).

Note   If you want to use  mainACRTStartup or  mainWCRTStartup, you must explicitly state that when you specify the  /ENTRYoption.

_tmain:
1. main是所有C或C++的程序执行的起点,_tmain是main为了支持unicode所使用的main的别名。
2. _tmain需要一个返回值,而main默认为void。
3. _tmain的定义在<tchar.h>可以找到,如#define _tmain main,所以要加 #include <tchar.h> 才能用。
4. _tmain()是个宏,如果定义了UNICODE,则他是wmain(),否则他是main()。
5. _tmain这个符号多见于VC++创建的控制台工程中,这个是为了保证移植unicode而加入的。
6. 一般_t、_T、T()这些东西都是宏都和unicode有关系。
7. 对于使用非unicode字符集的工程来说,实际上_tmain和main没有差别。
8. 因此_tmain编译后后仍为main,所以都可以执行。
9. main()是WINDOWS的控制台程序(32BIT)或DOS程序(16BIT)。
10.WinMain()是WINDOWS的GUI程序。
11.另外,wmain也是main的另一个别名,是为了支持二个字节的Unicode语言环境。
  -----------------------
  int main( int argc, char *argv[ ], char *envp[ ])
  wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )
  int _tmain(int argc, _TCHAR* argv[ ])


参考文章:

http://msdn.microsoft.com/en-us/library/ms859584.aspx

http://blog.sina.com.cn/s/blog_48a45b950100ykwl.html



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值