﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Monolight-随笔分类-VC++</title><link>http://www.cppblog.com/wbf1013/category/13739.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 06 May 2010 02:48:36 GMT</lastBuildDate><pubDate>Thu, 06 May 2010 02:48:36 GMT</pubDate><ttl>60</ttl><item><title>WinMain函数的错误</title><link>http://www.cppblog.com/wbf1013/archive/2010/05/06/114568.html</link><dc:creator>王冰锋</dc:creator><author>王冰锋</author><pubDate>Thu, 06 May 2010 02:42:00 GMT</pubDate><guid>http://www.cppblog.com/wbf1013/archive/2010/05/06/114568.html</guid><wfw:comment>http://www.cppblog.com/wbf1013/comments/114568.html</wfw:comment><comments>http://www.cppblog.com/wbf1013/archive/2010/05/06/114568.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wbf1013/comments/commentRss/114568.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wbf1013/services/trackbacks/114568.html</trackback:ping><description><![CDATA[
<p>很多时候在我们读一些英文编程资料的时候，经常会遇到写Windows主入口函数的问题，英文一般会这样写：</p> <p>// This is winmain, the main entry point for Windows applications <br>int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPTSTR lpCmdLine, int nCmdShow )</p> <p>不过照抄下来在VS2005或VS2008编译的时候总会说error C2731: &#8220;WinMain&#8221;: 无法重载函数 <br>其实因为WinMain函数的原始定义中lpCmdLine的类型是char *，但在中文系统的环境下因为启用了Unicode支持，LPTSTR代表的是WCHAR *。所以上述函数我们就应该这样来写：</p> <p>// This is winmain, the main entry point for Windows applications <br>int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPSTR lpCmdLine, int nCmdShow )</p> <p>自然也就不会有问题了。</p><img src ="http://www.cppblog.com/wbf1013/aggbug/114568.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wbf1013/" target="_blank">王冰锋</a> 2010-05-06 10:42 <a href="http://www.cppblog.com/wbf1013/archive/2010/05/06/114568.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>