码迷,mamicode.com
首页 > Windows程序 > 详细

WinMain函数无法重载(转)

时间:2014-12-12 18:49:02      阅读:350      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   sp   for   strong   on   div   

学习DX,用VS2010生成了一个简单的WIN32。

看着是_tWinMain()很不舒服,就改为WinMain()发现提示这个错误。

就百度一下,找到解决方案,实验可行。

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

 

照抄下来,在VS2005或VS2008或 VS2010编译的时候总会说error C2731: “WinMain”: 无法重载函数。

其实因为WinMain函数的原始定义中lpCmdLine的类型是char *,但在中文系统的环境下因为启用了Unicode支持,LPTSTR代表的是WCHAR *。所以上述函数我们就应该这样来写:

函数我们就应该这样来写:

 

  1. // This is winmain, the main entry point for Windows applications  
  2. int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow )  

WinMain函数无法重载(转)

标签:blog   http   io   ar   sp   for   strong   on   div   

原文地址:http://www.cnblogs.com/arthurLeo/p/4160180.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!