??xml version="1.0" encoding="utf-8" standalone="yes"?>精品久久久无码中文字幕,色老头网站久久网,一级A毛片免费观看久久精品http://www.shnenglu.com/SpringSnow/category/8492.html雪化了,花开了,春天来了zh-cnTue, 25 Aug 2009 10:50:12 GMTTue, 25 Aug 2009 10:50:12 GMT60“没有找?MSVCR80D.dll”的解决Ҏhttp://www.shnenglu.com/SpringSnow/archive/2009/08/24/94295.htmlSandySandyMon, 24 Aug 2009 10:41:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/08/24/94295.htmlhttp://www.shnenglu.com/SpringSnow/comments/94295.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/08/24/94295.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/94295.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/94295.html
“没有扑ֈ MSVCR80D.dll,因此q个E序未能启动Q重新安装应用程序,可能会修复此问题?#8221;
在VS2005中,l常到q个问题Q怎么办呢Q是ȝ上下载一个dll么?我没有尝试过。但是网上提供的一U方法是q样的,我觉得挺便的?br>
如图Q?br>               
  

?Use FAT32 Work-around" 设ؓyes可以了?br>

Sandy 2009-08-24 18:41 发表评论
]]>
多线E程序中的调?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/08/21/94039.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Fri, 21 Aug 2009 09:19:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/08/21/94039.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/94039.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/08/21/94039.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/94039.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/94039.html</trackback:ping><description><![CDATA[<p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">今天看的调试的这一章主要是针对多线E程序的调试。多U程E序q行的不定性,使其调试h像抓蝴蝶一P你捉怸透它驻的位|?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">书中l了一些徏议和ҎQ?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一是有计划地对付错误?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对应用程序展开适当的调试,应该是远在你使用调试器之前就开始了。多多?/span><span lang=EN-US>ASSERT</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">调试措施。(</span><span lang=EN-US>ASSERT</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">背后的概忉|安全和速度之间的交换。程序运行因此运行得比较慢,但是</span><span lang=EN-US>Debug Build</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的制造就是ؓ了调试,所以可以理解)在每一个你的假设之处做验工作。进入一个函数时Q确认所有状态。不要只是检查指针是否合法;如果可能Q检查一下指针所指的l构中的数据是否一致?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">二是</span><span lang=EN-US>Bench Testing</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其实q种Ҏ是先撇开多线E的环境Q测试程序逻辑的正性。如?/span><span lang=EN-US>OK</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">了,然后再考虑与线E相关的东西?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">三是U程对话?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q里主要讨论了对一个特定的U程如何调试Q方法是挂v所有的U程——除了我们关注的那个。书中介l的Ҏ?/span><span lang=EN-US>vs 2005</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我没有找到?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">四是日志记录</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q里主要是在控制台窗口显CZ些运行信息,我们可以使用</span><span lang=EN-US>printf</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">{函数在控制台输Z些信息来查看U程的运行次序?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">五是内存记号</span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用内存记号的好处就是降低彼此干扰的可能性。但是也要注意它不是同步操作Q可能会因ؓ两个U程的同时写入引来问题?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">六是g调试寄存?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">前面的这六种Ҏ我也只用q三U,有一些还真是W一ơ见到。不q不怕下ơ搞不定问题的时候可以拿来进行尝试,来抓一抓隐藏在E序中的“臭虫?#8221;?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">成功消除多线E程序的“臭虫”Q作者说需要具备三U素养:军_、耐心、创造力。同时也不要蛮干Q要采用U学的方法:观察、预、测试?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">ȝ一下:借助ҎQ观察现象,大胆预测Q勇敢尝试,完备试?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目中也到了多U程的用。未来可能多U程的用会来多Q不能停留在完成功能和Q务上Q应该多思考多试。避免多U程的不可确定性带来的一些困扰?/span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">学习书籍Q?/span><span lang=EN-US>Win32 </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">多线E程序设计》侯捯</span></p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/94039.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-08-21 17:19 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/08/21/94039.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>? Windows Mobile下创建cmwap接入?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/04/21/80610.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 21 Apr 2009 06:54:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/04/21/80610.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/80610.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/04/21/80610.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/80610.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/80610.html</trackback:ping><description><![CDATA[? http://tech.ddvip.com/2008-09/122062103760957.html<br><br>E序中如果要<nobr oncontextmenu="return false" onmousemove=kwM(1) id=clickeyekey1 onmouseover="kwE(event,1, this)" style="COLOR: #6600ff; BORDER-BOTTOM: #6600ff 1px dotted; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" onclick='kwC(event,1,"")' onmouseout=kwL(event,this)>使用</nobr>http或socketq接服务器,需要先q接|络。ConnMgrEstablishConnectionSync函数中的CONNMGR_CONNECTIONINFO参数Q不论采用IID_DestNetWAPq是IID_DestNetInternetQ似乎都要依赖于<nobr oncontextmenu="return false" onmousemove=kwM(0) id=clickeyekey0 onmouseover="kwE(event,0, this)" style="COLOR: #6600ff; BORDER-BOTTOM: #6600ff 1px dotted; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" onclick='kwC(event,0,"")' onmouseout=kwL(event,this)>手机</nobr>上的接入点设|。都怪中国移动非要搞什么CMNET、CMWAPQ中国特色的通信公司?/clk> <p>  可以自行创徏一接入炏V以下代码创Z个CMWAP接入点:</p> <p><code>CString strFavoriteXml =<br>L"<wap-provisioningdoc>"<br>L"<characteristic type="CM_Networks">"<br>L"<characteristic type="Test_GPRS">"<br>L"<parm name="DestId" value="{D1D06580-C364-55ec-9421-6ACF34129C58}" />"<br>L"</characteristic>"<br>L"</characteristic>"<br>L"<characteristic type="CM_GPRSEntries">"<br>L"<characteristic type="Test_GPRS">"<br>L"<parm name="DestId" value="{D1D06580-C364-55ec-9421-6ACF34129C58}" />"<br>L"<characteristic type="DevSpecificCellular">"<br>L"<parm name="BearerInfoValid" value="1" />"<br>L"<parm name="GPRSInfoValid" value="1" />"<br>L"<parm name="GPRSInfoProtocolType" value="2" />"<br>L"<parm name="GPRSInfoL2ProtocolType" value="PPP" />"<br>L"<parm name="GPRSInfoAccessPointName" value="cmwap" />"<br>L"<parm name="GPRSInfoAddress" value="" />"<br>L"<parm name="GPRSInfoDataCompression" value="1" />"<br>L"<parm name="GPRSInfoHeaderCompression" value="1" />"<br>L"<parm name="GPRSInfoParameters" value="" />"<br>L"</characteristic>"<br>L"</characteristic>"<br>L"</characteristic>"<br>L"<characteristic type="CM_ProxyEntries">"<br>L"<characteristic type="WAP">"<br>L"<parm name="SrcId" value="{D1D06580-C364-55ec-9421-6ACF34129C58}" />"<br>L"<parm name="DestId" value="{436EF144-B4FB-4863-A041-8F905A62C572}" />"<br>L"<parm name="Proxy" value="10.0.0.172:80" />"<br>L"<parm name="Enable" value="1" />"<br>L"<parm name="Type" value="1" />"<br>L"</characteristic>"<br>L"</characteristic>"<br>L"</wap-provisioningdoc>";<br>  <br>LPWSTR pszwXMLout = NULL;<br>HRESULT hr = DMProcessConfigXML(strFavoriteXml, CFGFLAG_PROCESS, &pszwXMLout);<br>  <br>if ( pszwXMLout )<br>{<br> delete [] pszwXMLout;<br> pszwXMLout = NULL;<br>}</code></p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/80610.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-04-21 14:54 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/04/21/80610.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>?Windows Mobile 6 SDK 中的 Cellular Emulator http://www.shnenglu.com/SpringSnow/archive/2009/04/15/79967.htmlSandySandyWed, 15 Apr 2009 01:59:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/04/15/79967.htmlhttp://www.shnenglu.com/SpringSnow/comments/79967.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/04/15/79967.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/79967.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/79967.html
摘自: http://www.cnblogs.com/upto/archive/2007/02/14/649769.html 
         黎L老师的博?br>

Windows Mobile 6 SDK 中的 Cellular Emulator

现在?Windows Mobile 讑֤大多数都拥有电话和其他无UK信的功能。在许多情况下,你想让你的应用程序跟q些通信功能q行交互。例如,你想在电话响L时候,你的应用程序播N乐的声音调小Q或者需要直接对通信gq行各种操作。那么开发这U类型的应用E序往往比较困难Q最大的隄在于试应用E序?br>
Z解决试q种应用E序的困难,Windows Mobile 6 SDK 包含?Cellular EmulatorQ蜂H仿真器Q。Cellular Emulator 让你能够?Device Emulator 中,试你的应用E序在各U蜂H通信的情况下的行为?br>


Cellular Emulator 是一个强大的试工具Q它可以用于试你的应用E序在蜂H通信状况变化时的行ؓ。用 Cellular Emulator 可以执行一些简单的试Q如Q在仿真器中拨打电话Q接听来电和挂断电话Q发送和接收 SMS 信息{。ؓ了让开发h员可以测试更复杂的功能,Cellular Emulator q支持对 SIM 配置信息的修改,q有选择2G|络q是3G|络。所有这些测试工作都不需要用C台物理设备?/p>

要让 Cellular Emulator ?Device Emulator 可以一起配合用,首先你需要把他们兌h?br>1. C Cellular Emulator 左下角状态栏?COM 端口受如 COM5?br>2. ?Device Emulator 中选择“File-->Configure...”菜单,打开 Emulator Properties 对话框?br>3. ?Emulator Properties 对话框中选择 Peripherals 选项卡?br>4. 把刚才记下的 COM 端口可入到 Serial Port 0 文本框中。如果你在下拉列表中找不C的端口号Q可以自p入进厅R?br>5. 点击 OK 按钮保存讄Q关?Emulator Properties 对话框?br>6. 点击“File-->Reset-->Soft”菜单,对仿真器q行软重|操作?br>


待仿真器完成重置q程q新启动后Q你会看到仿真器的蜂窝|络已经可用了。如果还是不行,可能是安装了 Windows Mobile 6 SDK 之后Q没有重新启动系l的原因吧?br>
l仿真器拨打电话
打开 Cellular Emulator ?Call Manager 选项卡,?Phone Number 文本框中输入L一个电话号码,点击旁边?Dial 按钮Q仿真器的电话铃声将响vQƈ昄来自所输入的电话号码的来电。这时在 Active Calls 列表中将出现仿真器上的活动通话Q?strong>Status 昄?Incoming?br>?272024q个电话L向仿真器拨打电话Q?br>

仿真器收到电话号码ؓ7272024的来电:


从仿真器拨打电话
?Preset Number 列表中提供了4个可供测试的电话L?strong>Busy 表示U\忙,Reject 表示拒绝接听Q?strong>Hang Up After Connect 表示接听后再挂断Q?strong>No Answer 表示没有回应。尝试在仿真器中拨打7272021QCellular Emulator ?Active Calls 列表显CZ真器当前的活动通话。电话接通后持箋?0U钟Q然后挂断,也就?strong>Hang Up After Connect?br>



向仿真器发?SMS 信息
打开 Cellular Emulator ?SMS 选项卡,?Send to device 的多行文本框中输入短信内容,然后点击 Send 按钮短信发送至仿真器?br>

仿真器将收到新短信:


q可以设|重复发送。选中 Repeatly 查框Q设定好 IntervalQ间隔时_?Max CountQ最大数目)Q然后再点击 Send 按钮卛_。如果你在仿真器中回复了信息Q将会在 Cellular Emulator ?Receive from device 列表中看C回复的短信?br>

选择|络
打开 Cellular Emulator ?Network 选项卡,可以选择2G或?G|络Q断开 GPRS q接Q查看数据通道{?br>

执行和查?AT 命o
打开 Cellular Emulator ?nbsp;Injection 选项卡,q里可以向仿真器发?AT 命o或事件?br>

打开 Cellular Emulator ?nbsp;AT log 选项卡,可以看到刚才所有对仿真器的操作对应?AT 命o?br>

使用配置文g
q里可以选择使用哪一?SIM 配置文gQ文件内Ҏ XML 格式?br>

ȝ
有了 Cellular Emulator 的配合,Device Emulator 昑־更加强大。现?Windows Mobile 6 开发h员可以用仿真器q行开发和试Q而不需要购买各U真实设备。遗憄是,Cellular Emulator q不支持 Windows Mobile 5.0 ?Windows Mobile 2003 的仿真器。不q好?Windows Mobile 6 ?API ?Windows Mobile 5.0 的绝大部分一P所以你可以?Windows Mobile 6 的仿真器中开发和调试 Windows Mobile 5.0 的应用程序。对?Windows Mobile 2003 可能试效果没有那么一_你也可以自己试一下?br>
参考:
What's New for Developers in Windows Mobile 6



Sandy 2009-04-15 09:59 发表评论
]]>
工作ȝ:界面响应的问?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/04/14/79851.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 14 Apr 2009 01:10:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/04/14/79851.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/79851.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/04/14/79851.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/79851.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/79851.html</trackback:ping><description><![CDATA[        昨天一直在调一D代码,程是这LQ我在某个界面程序里先放|了一个对话框AQ用户选择是或否。选择是后Q会再弹Z个对话框BQƈ触发一个事Ӟ然后再启动一个对话框C。这些对话框是模态的?br><br>        逻辑感觉很对Q没有问题。但是界面的异常让我是头疹{A对话框选择是后QB对话框显CZ完全Q在CҎ框显C的时候,文字昄又有异常。检查了一下,原来EndDialog没有执行成功。用GetLastError获取的错误g是正的?br>  <br>        惆怅了……Q后来利用线E,L行那个事Ӟ界面也正怺?br><br>        q是Z么呢Q?br>         我个得是事g的执行媄响到了界面的hQ因为我的事件是在界面的E序里面执行的。它对界面消息进行了dQ导致界面不能刷新?br>          q个问题Q不是我W一ơ遇刎ͼ以前也遇到过q样的问题,没有ȝ。ȝ一下,不要再犯了?br>   <br> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/79851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-04-14 09:10 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/04/14/79851.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows Mobile 获取SIM卡联pMh信息http://www.shnenglu.com/SpringSnow/archive/2009/04/09/79344.htmlSandySandyThu, 09 Apr 2009 07:20:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/04/09/79344.htmlhttp://www.shnenglu.com/SpringSnow/comments/79344.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/04/09/79344.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/79344.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/79344.htmlWindows Mobile上联pMh的信息可分别存储在手机和SIM卡中。我试q从手机Q即所谓的Outlook联系Zd联系人的信息Q但是还没有试q从sim卡中d联系人的信息Q心里也一直默认ؓ隑֐。今天查了一下,发现竟然q么单,相比outlook的读取方式来_单很多?br>
我们先来定义个结?br>
typedef struct {
  TCHAR szName[32];
  TCHAR szTelNum[32];
}CONTACTSTRUCT;

要用SIM的相xӞ需要包含头文g simmgr.h

首先要初始化一?br>HSIM lphSim;  
 HRESULT hr = SimInitialize(0, NULL, 0, &lphSim);
if(FAILED(hr))  
 {
  return;
 }

其次获取d使用的多条记录与d可以容纳的记录条?nbsp; 
 DWORD dwUsed,dwTotal;  
 hr = SimGetPhonebookStatus(lphSim, SIM_PBSTORAGE_SIM, &dwUsed, &dwTotal);

然后我们d联系人的信息
定义一?br>std::vector<CONTACTSTRUCT> vContact;

 for(int i=0; i<dwTotal; i++)      
 {
  //对结构初始话以下  
  SIMPHONEBOOKENTRY phoneent;  
  memset(&phoneent,0,sizeof(phoneent));  
  phoneent.cbSize = sizeof(phoneent);

  if (SUCCEEDED(SimReadPhonebookEntry(lphSim, SIM_PBSTORAGE_SIM, i+1, &phoneent)))
  {
   CONTACTSTRUCT tempContact = {0};

   wcsncpy(tempContact.szName, phoneent.lpszText, 31); // 姓名
   wcsncpy(tempContact.szTelNum, phoneent.lpszAddress, 31); // 电话

   vContact.push_back(tempContact );
  }
 }

 //最后别忘了清理      
 SimDeinitialize(lphSim);
 lphSim = NULL;

q里d的时候用了dwTotalQ是因ؓ听有l验的h_sim卡的存储可能不连l,如果用dwUsed的话Q可能会有问题?br>
U篏一下,有时间再好好看一下outlook联系人的?br>
参考文章:
Pocket 中获取SIM卡中联系Z?br>http://blog.csdn.net/xulg1984/archive/2008/05/30/2497712.aspx



Sandy 2009-04-09 15:20 发表评论
]]>
vs 后缀名ȝhttp://www.shnenglu.com/SpringSnow/archive/2009/04/08/79257.htmlSandySandyWed, 08 Apr 2009 05:43:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/04/08/79257.htmlhttp://www.shnenglu.com/SpringSnow/comments/79257.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/04/08/79257.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/79257.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/79257.html

转自: http://www.cnblogs.com/dotnetearthworm/archive/2009/02/02/1382488.html

.sln
Q解x案文Ӟx案资源管理器提供昄理文g的图形接口所需的信息?

.csproj:目文gQ创建应用程序所需的引用、数据连接、文件夹和文件的信息?

.aspxQWeb H体는两部分组成:视觉元素QHTML、服务器控g和静态文本)和该늚~程逻辑。Visual Studio 这两个l成部分分别存储在一个单独的文g中。视觉元素在.aspx 文g中创建?

.ascxQASP.NET的用hӞ也叫?#8220;pagelets”Q,是作ZU封装了特定功能和行为(q两者要被用在Web应用E序的各U页面上Q的Web面被开发的。一个用h件包含了HTML、代码和其他Web或者用h件的l合Qƈ在Web服务器上以自q文g格式保存Q其扩展名是*.ascx。ASP.NET里的~省配置q不允许Web客户端通过URL来访问这些文Ӟ但是q个|站的其他页面可以集成这些文仉所包含的功能?

.aspx.csQWeb H体늚~程逻辑位于一个单独的cL件中Q该文gUC代码隐藏cLӞ.aspx.csQ?

.csQ?cL块代码文件。业务逻辑处理层的代码?

.asaxQGlobal.asax 文gQ也叫做 ASP.NET 应用E序文gQ是一个可选的文gQ该文g包含响应 ASP.NET ?HTTP 模块引发的应用程序别事件的代码?

.configQWeb.config 文g向它们所在的目录和所有子目录提供配置信息?

.aspx.resx/.resxQ资源文Ӟ资源是在逻辑上由应用E序部v的Q何非可执行数据。通过在资源文件中存储数据Q无需重新~译整个应用E序卛_更改数据?51aspx.com

.XSD:XML schema的一U?从DTD,XDR发展到XSD

.pdb:PDBQ程序数据库Q文件保持着调试和项目状态信息,从而可以对E序的调试配|进行增量链接?

.suo:解决Ҏ用户选项,记录所有将与解x案徏立关联的选项Q以便在每次打开Ӟ它都包含您所做的自定义设|?

.asmxQ?asmx文g包含 WebService 处理指oQƈ用作 XML Web services 的可d入口?51aspx?

.vsdiscoQ项目发玎ͼ文g Z XML 的文Ӟ它包含ؓ Web 服务提供发现信息的资源的链接 (URL-51aspx )?

.htc:一个HTML文g,包含脚本和定义组件的一pdHTC特定元素.htc提供在脚本中implementlg的机?/p>

来源Q?.Net中文C֌Q?a >http://www.aspxcs.net/)

上面是我看到的一些介l?q里再补充一?
  .clw   支持ClassWizard  
  .ncb   支持ClassView  
  .opt   保存工作I间的配|?nbsp; 
  .aps   支持ResourceView  
  .bsc   览器信息文?nbsp; 
  .dsp   目文g  
  .dsw   工作I间文g  
  .mak   外部的创建文?nbsp; 
  .plg   建立日志文g 



Sandy 2009-04-08 13:43 发表评论
]]>
warning C4005: 'WINVER' : macro redefinition 的解x?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/04/07/79184.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 07 Apr 2009 07:22:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/04/07/79184.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/79184.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/04/07/79184.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/79184.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/79184.html</trackback:ping><description><![CDATA[ 对于warning C4005: 'WINVER' : macro redefinition的处?br><br> 在Windows.h中有如下定义Q?  <br>  #ifndef   WINVER   <br>  #define   WINVER   0x0400   <br>  #endif   <br>  如果你把#define   WINVER   0x500|于#include   <windows.h>之前,׃会出现警?   <br><br>摘自:http://topic.csdn.net/t/20020103/15/456195.html<br> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/79184.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-04-07 15:22 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/04/07/79184.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何在方框里打对?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/03/31/78463.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 31 Mar 2009 07:44:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/03/31/78463.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/78463.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/03/31/78463.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/78463.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/78463.html</trackback:ping><description><![CDATA[q个的确q是挺头疼的。前一阶段同学告诉我,很不q,今天又给忘了?br>查了一下,再根据模p记忆,q是把方框打上了对勾?br><br>可能你也有这L烦恼Q不妨我们来看一下:<br><br>在word字体中选择Wingdings2Q然后写一个大写RQ这样你q到方框打对勾了?br><br>好记性真不如烂笔_占此一角,记录一下?br><br> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/78463.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-03-31 15:44 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/03/31/78463.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>windows mobile 中的Database 对应?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/03/30/78378.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Mon, 30 Mar 2009 08:32:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/03/30/78378.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/78378.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/03/30/78378.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/78378.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/78378.html</trackback:ping><description><![CDATA[<p>Windows mobile ?outlook 中Q?U会,联系?在调用时,有相应的database oid<br>对应的database oid 不是很清?我通过实验,发现,d?3, U会?, 联系人是10.<br><br>那有没有专门的数值对应呢?查了一?发现q么个东?<br><br>typedef /* [v1_enum] */<br>enum OlDefaultFolders<br>    {   olFolderCalendar    = 9,<br>        olFolderContacts    = 10,<br>        olFolderTasks       = 13,<br>        olFolderCities      = 101,<br>        olFolderInfrared    = 102,<br>    } OlDefaultFolders;<br><br>和我们的实验数据一?<br><br>不错?</p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/78378.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-03-30 16:32 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/03/30/78378.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DATE和SYSTEMTIME的{?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/03/26/77906.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Thu, 26 Mar 2009 01:21:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/03/26/77906.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/77906.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/03/26/77906.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/77906.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/77906.html</trackback:ping><description><![CDATA[最q在搞一个小东东,<br>里面涉及CDATE和SYSTEMTIME的{?没有用到q?记录一?<br><br> <strong> DATE 转换成SYSTEMTIME</strong><br>  VariantTimeToSystemTime<br>  其原型ؓ:<br><strong>  INT VariantTimeToSystemTime( <br>  double </strong><em><a class=synParam onclick=showTip(this) href=""><font color=#006bad>vtime</font></a></em><strong>,              </strong><br><strong>  LPSYSTEMTIME </strong><em><a class=synParam onclick=showTip(this) href=""><font color=#006bad>lpSystemTime</font></a>  </em><br><strong>  );</strong><br>  <br><br>   <strong>SYSTEMTIME转换成DATE <br></strong>   SystemTimeToVariantTime<br>  其原型ؓ:<br>  <strong>INT SystemTimeToVariantTime(<br>  LPSYSTEMTIME </strong><em><a class=synParam onclick=showTip(this) href=""><font color=#006bad>lpSystemTime</font></a></em>,<em>  </em><br><strong>  double </strong><em>       *<a class=synParam onclick=showTip(this) href=""><font color=#006bad>pvtime</font></a>           </em><br><strong>  );</strong> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/77906.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-03-26 09:21 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/03/26/77906.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对话框的属性问?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/03/18/77048.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Wed, 18 Mar 2009 11:00:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/03/18/77048.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/77048.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/03/18/77048.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/77048.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/77048.html</trackback:ping><description><![CDATA[       今天调试安装文g的对话框Q横屏的时候,Edit框的昄QM随着滚动条往上移动,下面昄Z大片的空白?br><br>      很是郁闷?#8230;…<br><br>       在代码中修改了很长时_找不出原因,最后和别h代码比对的时候,发现我竟然是在资源文件中的对话框属性定义中比别人多一个WS_BORDER属性,问题q刃而解?br><br>         但究其原因,q不是很清楚?br><br>         WS_BORDER: Create a window that has a border.<br><br>          g也看不出来什么原因? <img src ="http://www.shnenglu.com/SpringSnow/aggbug/77048.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-03-18 19:00 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/03/18/77048.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows Mobile中Edit控g的滚动条问题http://www.shnenglu.com/SpringSnow/archive/2009/03/18/77046.htmlSandySandyWed, 18 Mar 2009 10:48:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/03/18/77046.htmlhttp://www.shnenglu.com/SpringSnow/comments/77046.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/03/18/77046.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/77046.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/77046.html        在Windows Mobile中,Edit控g在具有WS_VSCROLL的时候,无论昄文字的多,都会昄滚动条。如何在昄文字不到一늚情况下,让滚动条不显C呢Q?br>
         我是q样考虑的:判断昄文字的高度,xC文字的行数*单个文字的高度,判断其是否大于屏q高度,如果大于Q则改变Edit控g的属性,使其hWS_VSCROLL属性;如果于或等于,则改变Edit控g的属性,使其不具有WS_VSCROLL属性?br>
         代码CZQ?br>
         int height = GetSystemMetrics(SM_CYFULLSCREEN); // 此处C屏q高度,可自p?br>         
         HWND hEdit = GetDlgItem(hDlg, IDC_EDIT);
         DWORD dwLineCount = (DWORD)::SendMessage(hEdit, EM_GETLINECOUNT, 0, 0L);
         HDC hdc = GetDC(hDlg);
         TEXTMETRIC metric;
         GetTextMetrics(hdc, &metric);
         ReleaseDC(hDlg, hdc); 

          if (metric.tmHeight * dwLineCount <= height))
         {
               SetWindowLong(hEdit, GWL_STYLE, WS_VISIBLE | ES_MULTILINE | ES_READONLY);
           }
           else
           {
                SetWindowLong(hEdit,GWL_STYLE, WS_VISIBLE| WS_VSCROLL|   ES_MULTILINE  |ES_READONLY);
           }

           我在创徏Edit控g的时候,一开始没有设|WS_VSCROLL属性,发现加上WS_VSCROLL属性后Q对于按键的上下响应有些问题。后来就反其道而行之,先让其具有WS_VSCROLL属性,然后再判断其是否该显C滚动条?br>
            在Windows Mobile中涉及到横竖屏切换的问题Q比如说Q在竖屏的时候没有滚动条Q到横屏的时候又需要有滚动条,此时怎么办?
             在WMQSIZE中进行以上的属性判断,但是有一个问题需要注意:如果需要调整Edit控g的大,需要在属性判断置后进行?br>
              一点心得,大家可以试试哈!
          

        



Sandy 2009-03-18 18:48 发表评论
]]>
转:Teach Yourself Programming in Ten Years http://www.shnenglu.com/SpringSnow/archive/2009/03/14/76557.htmlSandySandySat, 14 Mar 2009 02:24:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/03/14/76557.htmlhttp://www.shnenglu.com/SpringSnow/comments/76557.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/03/14/76557.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/76557.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/76557.htmlWhy is everyone in such a rush?
Walk into any bookstore, and you'll see how to Teach Yourself Java in 7 Days alongside endless variations offering to teach Visual Basic, Windows, the Internet, and so on in a few days or hours. I did the following power search at Amazon.com:
pubdate: after 1992 and title: days and
(title: learn or title: teach yourself)
and got back 248 hits. The first 78 were computer books (number 79 was Learn Bengali in 30 days). I replaced "days" with "hours" and got remarkably similar results: 253 more books, with 77 computer books followed by Teach Yourself Grammar and Style in 24 Hours at number 78. Out of the top 200 total, 96% were computer books.
The conclusion is that either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days.

Let's analyze what a title like Learn Pascal in Three Days could mean:

Learn: In 3 days you won't have time to write several significant programs, and learn from your successes and failures with them. You won't have time to work with an experienced programmer and understand what it is like to live in that environment. In short, you won't have time to learn much. So they can only be talking about a superficial familiarity, not a deep understanding. As Alexander Pope said, a little learning is a dangerous thing.

Pascal: In 3 days you might be able to learn the syntax of Pascal (if you already knew a similar language), but you couldn't learn much about how to use the syntax. In short, if you were, say, a Basic programmer, you could learn to write programs in the style of Basic using Pascal syntax, but you couldn't learn what Pascal is actually good (and bad) for. So what's the point? Alan Perlis once said: "A language that doesn't affect the way you think about programming, is not worth knowing". One possible point is that you have to learn a tiny bit of Pascal (or more likely, something like Visual Basic or javascript) because you need to interface with an existing tool to accomplish a specific task. But then you're not learning how to program; you're learning to accomplish that task.

in Three Days: Unfortunately, this is not enough, as the next section shows.
Teach Yourself Programming in Ten Years
Researchers (Hayes, Bloom) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. There appear to be no real shortcuts: even Mozart, who was a musical prodigy at age 4, took 13 more years before he began to produce world-class music. In another genre, the Beatles seemed to burst onto the scene, appearing on the Ed Sullivan show in 1964. But they had been playing since 1957, and while they had mass appeal early on, their first great critical success, Sgt. Peppers, was released in 1967. Samuel Johnson thought it took longer than ten years: "Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price." And Chaucer complained "the lyf so short, the craft so long to lerne."
Here's my recipe for programming success:

Get interested in programming, and do some because it is fun. Make sure that it keeps being enough fun so that you will be willing to put in ten years.

Talk to other programmers; read other programs. This is more important than any book or training course.

Program. The best kind of learning is learning by doing. To put it more technically, "the maximal level of performance for individuals in a given domain is not attained automatically as a function of extended experience, but the level of performance can be increased even by highly experienced individuals as a result of deliberate efforts to improve." (p. 366) and "the most effective learning requires a well-defined task with an appropriate difficulty level for the particular individual, informative feedback, and opportunities for repetition and corrections of errors." (p. 20-21) The book Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life is an interesting reference for this viewpoint.

If you want, put in four years at a college (or more at a graduate school). This will give you access to some jobs that require credentials, and it will give you a deeper understanding of the field, but if you don't enjoy school, you can (with some dedication) get similar experience on the job. In any case, book learning alone won't be enough. "Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter" says Eric Raymond, author of The New Hacker's Dictionary. One of the best programmers I ever hired had only a High School degree; he's produced a lot of great software, has his own news group, and through stock options is no doubt much richer than I'll ever be.

Work on projects with other programmers. Be the best programmer on some projects; be the worst on some others. When you're the best, you get to test your abilities to lead a project, and to inspire others with your vision. When you're the worst, you learn what the masters do, and you learn what they don't like to do (because they make you do it for them).

Work on projects after other programmers. Be involved in understanding a program written by someone else. See what it takes to understand and fix it when the original programmers are not around. Think about how to design your programs to make it easier for those who will maintain it after you.

Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).

Remember that there is a "computer" in "computer science". Know how long it takes your computer to execute an instruction, fetch a word from memory (with and without a cache miss), read consecutive words from disk, and seek to a new location on disk. (Answers here.)

Get involved in a language standardization effort. It could be the ANSI C++ committee, or it could be deciding if your local coding style will have 2 or 4 space indentation levels. Either way, you learn about what other people like in a language, how deeply they feel so, and perhaps even a little about why they feel so.

Have the good sense to get off the language standardization effort as quickly as possible.
With all that in mind, its questionable how far you can get just by book learning. Before my first child was born, I read all the How To books, and still felt like a clueless novice. 30 Months later, when my second child was due, did I go back to the books for a refresher? No. Instead, I relied on my personal experience, which turned out to be far more useful and reassuring to me than the thousands of pages written by experts.
Fred Brooks, in his essay No Silver Bullets identified a three-part plan for finding great software designers:

Systematically identify top designers as early as possible.

Assign a career mentor to be responsible for the development of the prospect and carefully keep a career file.

Provide opportunities for growing designers to interact and stimulate each other.

This assumes that some people already have the qualities necessary for being a great designer; the job is to properly coax them along. Alan Perlis put it more succinctly: "Everyone can be taught to sculpt: Michelangelo would have had to be taught how not to. So it is with the great programmers".
So go ahead and buy that Java book; you'll probably get some use out of it. But you won't change your life, or your real overall expertise as a programmer in 24 hours, days, or even months.


References
Bloom, Benjamin (ed.) Developing Talent in Young People, Ballantine, 1985.

Brooks, Fred, No Silver Bullets, IEEE Computer, vol. 20, no. 4, 1987, p. 10-19.

Hayes, John R., Complete Problem Solver Lawrence Erlbaum, 1989.

Lave, Jean, Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life, Cambridge University Press, 1988.
http://www.norvig.com/



Sandy 2009-03-14 10:24 发表评论
]]>
Windows Mobile获取q程路径http://www.shnenglu.com/SpringSnow/archive/2009/03/11/76250.htmlSandySandyWed, 11 Mar 2009 09:52:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/03/11/76250.htmlhttp://www.shnenglu.com/SpringSnow/comments/76250.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/03/11/76250.html#Feedback2http://www.shnenglu.com/SpringSnow/comments/commentRss/76250.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/76250.html
开发的时候利用数字签名就可以解决?br>
开发的时候,在Project->Property->Configuration Properties->Authenticode Signing中需要加载开发安全证书?br>
q样我们可以很方便的获得进E的路径

TCHAR szPath[MAX_PATH];
HANDLE hProcess 
= OpenProcess(0, FALSE, pe.th32ProcessID);
   GetModuleFileName((HMODULE)hProcess, szPath, 
sizeof(szPath));
   CloseHandle(hProcess);

如果hProcess为NULL的话Q获取的是当前进E的路径?br>
所以开发SmartPhone旉要注意这炏V涉及特权API了,需要签名了?

Sandy 2009-03-11 17:52 发表评论
]]>
Windows Mobile 发送短信的问题http://www.shnenglu.com/SpringSnow/archive/2009/03/10/76107.htmlSandySandyTue, 10 Mar 2009 06:14:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/03/10/76107.htmlhttp://www.shnenglu.com/SpringSnow/comments/76107.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/03/10/76107.html#Feedback11http://www.shnenglu.com/SpringSnow/comments/commentRss/76107.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/76107.html最q在工作中遇C个比较怪异的现象,在某些省ZSP的短信交互存在问题,短信发送不出去。查了一下原因:SmsSendMessage参数讄的问题?/span>

?/span>Windows Mobile 5.0SDK?/span>HelloSMS例子中,发送短信的代码是这样写?/span>

void SendSMS(BOOL bSendConfirmation, BOOL bUseDefaultSMSC, LPCTSTR lpszSMSC, LPCTSTR lpszRecipient, LPCTSTR lpszMessage)
{
    SMS_HANDLE smshHandle;
    SMS_ADDRESS smsaSource;
    SMS_ADDRESS smsaDestination;
    TEXT_PROVIDER_SPECIFIC_DATA tpsd;
    SMS_MESSAGE_ID smsmidMessageID;

    
// try to open an SMS Handle
    if(FAILED(SmsOpen(SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL)))
    
{
        MessageBox(NULL,
                    (LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSOPEN, 
00), 
                    (LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 
00),
                    MB_OK 
| MB_ICONERROR);
        
return;
    }


    
// Create the source address
    if(!bUseDefaultSMSC)
    
{
        smsaSource.smsatAddressType 
= SMSAT_INTERNATIONAL;
        _tcsncpy(smsaSource.ptsAddress, lpszSMSC, SMS_MAX_ADDRESS_LENGTH);
    }


    
// Create the destination address
    smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
    _tcsncpy(smsaDestination.ptsAddress, lpszRecipient, SMS_MAX_ADDRESS_LENGTH);

    
// Set up provider specific data
    memset(&tpsd, 0sizeof(tpsd));
    tpsd.dwMessageOptions 
= bSendConfirmation ? PS_MESSAGE_OPTION_STATUSREPORT : PS_MESSAGE_OPTION_NONE;
    tpsd.psMessageClass 
= PS_MESSAGE_CLASS1;
    tpsd.psReplaceOption 
= PSRO_NONE;
    tpsd.dwHeaderDataSize 
= 0;

    
// Send the message, indicating success or failure
    if(SUCCEEDED(SmsSendMessage(smshHandle, ((bUseDefaultSMSC) ? NULL : &smsaSource), 
                                 
&smsaDestination, NULL, (PBYTE) lpszMessage, 
                                 _tcslen(lpszMessage) 
* sizeof(TCHAR), (PBYTE) &tpsd, 
                                 
sizeof(TEXT_PROVIDER_SPECIFIC_DATA), SMSDE_OPTIMAL, 
                                 SMS_OPTION_DELIVERY_NONE, 
&smsmidMessageID)))
    
{
        MessageBox(NULL,
                    (LPCTSTR)LoadString(ghInstance, IDS_SMSSENT, 
00), 
                    (LPCTSTR)LoadString(ghInstance, IDS_CAPTION_SUCCESS, 
00),
                    MB_OK);
    }

    
else
    
{
        MessageBox(NULL,
                    (LPCTSTR)LoadString(ghInstance, IDS_ERROR_SMSSEND, 
00), 
                    (LPCTSTR)LoadString(ghInstance, IDS_CAPTION_ERROR, 
00),
                    MB_OK 
| MB_ICONERROR);
    }


    
// clean up
    VERIFY(SUCCEEDED(SmsClose(smshHandle)));
}


q段代码在一般情况下是运行正的Q对于手Z手机的发送是不存在问题的Q但是与SP的交互在某些省区存在短信发送不出去的情c?span lang=EN-US>

Z更好的理解这D代码,我们先来熟悉一?span lang=EN-US style="COLOR: black">SmsSendMessage及各个参数?span lang=EN-US>

SmsSendMessage

功能Q?/span>Use the SmsSendMessage function to create and send an Short Message Service (SMS) message.Q创建和发送短信,但短信发送后q不保存到发件箱中)

原型Q?span lang=EN-US>

HRESULT SmsSendMessage (

const SMS_HANDLE smshHandle, // 调用SmsOpen时获得的短信句柄

const SMS_ADDRESS * const psmsaSMSCAddress, //指向短信中心L的地址

const SMS_ADDRESS * const psmsaDestinationAddress, // 发送的目的地址

const SYSTEMTIME * const pstValidityPeriod, // 发送时间的有效?span lang=EN-US>

const BYTE * const pbData, // 信息的内定w?span lang=EN-US>

const DWORD dwDataSize,// 信息内容的长?span lang=EN-US>

const BYTE * const pbProviderSpecificData, //q营商的附加数据

const DWORD dwProviderSpecificDataSize, // 附加数据的长?span lang=EN-US>

const SMS_DATA_ENCODING smsdeDataEncoding, // 短信~码

const DWORD dwOptions, // 其他选项

SMS_MESSAGE_ID * psmsmidMessageID); // 用于得到pȝ回执的信?span lang=EN-US>

Q具体介l可查看http://msdn.microsoft.com/en-us/library/aa455068.aspxQ?span lang=EN-US>

在实际应用中短信发送不出去Q但?span lang=EN-US>SmsSendMessage的返回值是S_OK倹{在一些文章中有hq样认ؓ是短信编码的问题造成的?span lang=EN-US>

如果~码格式不对可能造成短信中心|关把短信给吞掉的情况,E序虽然调用成功Q但是就是目标号码收不到短信。函数参C的后三个参数可以不用或设默认值都可以?span lang=EN-US>

起初我也是认个地斚w成的,很是兴奋。短信的回复内容Cؓ字母Q我误以为短信内Ҏ时是7-BIT的短消息Q短信网x短信l吞掉了Q造成目标L收不到短信。在l习中却也阴差阳错的成功了。很高兴的把理由归到了这个地斏Vƈq样ȝQ?/span>SmsSendMessage可以支持7-bit?span lang=EN-US>ASCII码的短消息,也支?span lang=EN-US>16-bit?span lang=EN-US>unicode的短消息。但内容?span lang=EN-US>ASCII的时候,短信~码?span lang=EN-US style="COLOR: black"> SMSDE_GSM?span lang=EN-US>SMSDE_OPTIMALQ当内容不全?/span>ASCII的时候,短信~码?span lang=EN-US style="COLOR: black">SMSDE_GSM?span lang=EN-US>SMSDE_OPTIMAL。所以回复内Ҏ为汉字即可?span lang=EN-US>

但是q样对么Qv初我认ؓ我的解释很合?span lang=EN-US>.但是我却发现我的一个参C原来的程序不一?span lang=EN-US>.

是我在尝试中无意修改了一个参?span lang=EN-US>,?span lang=EN-US>

tpsd.psMessageClass = PS_MESSAGE_CLASS1;

修改Z

tpsd.psMessageClass = PS_MESSAGE_CLASSUNSPECIFIED;

q是发送短信中的运营商的指定数?/span>TEXT_PROVIDER_SPECIFIC_DATA,它的参数psMessageClass是指

Text Short Message Service (SMS) messages with the appropriate flag can replace previously received notifications with a similar flag and originating address.

它有以下五个?/span>:

PS_MESSAGE_CLASS0: The message should be displayed immediately but not stored. The MS shall send an acknowledgement to the service center when the message has successfully reached the MS. Q被接受后立xCZ不存?/span>(UCؓ闪信)。需要向SMSC发送确认信息。)

PS_MESSAGE_CLASS1Q?/span>The message should be stored and an acknowledgement should be sent to the Service Center when it is stored.Q接收后被存储,一旦存储,需要向SMSC发送确认信息。)

PS_MESSAGE_CLASS2Q?/span>The message should be transferred to the SMS data field in the subscriber identity module (SIM) before an acknowledgement is sent to the Service Center.

PS_MESSAGE_CLASS3Q?/span>When the message has successfully reached the destination and can be stored, an acknowledgement is sent to the Service Center.

PS_MESSAGE_CLASSUNSPECIFIEDQ?/span>The message Class is not set in the outgoing or incoming message. Q对发出或收到的短信不进行设|)

 

分析以上五个|前四个值有一个共同的特点Q都需要向SMSC发送确认。而最后一个值没有设定?/span>

q个值的改动Q解决了我所遇到的问题。但I其原因,我有些想不通ؓ什?
    但是在实际应用中Q出C
tmail.exe的异常。不知道是这个值的变动带来的问题,q是实际模块中存在的问题。还需要l研I一下?br>
如果大家有知道的,l些?



Sandy 2009-03-10 14:14 发表评论
]]>
关于mobile的内存释?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/03/05/75612.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Thu, 05 Mar 2009 05:56:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/03/05/75612.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/75612.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/03/05/75612.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/75612.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/75612.html</trackback:ping><description><![CDATA[<p>前阶D在调研mobile上的内存释放问题Q根据大家的试了一些,但是没有什么效果?br>于是跑到MSDN上去问相关的问题Q得C一些解{?br><br>As far as I know, I don't think there is other way to meet your requirement.  Since each mobile application has 32M memory limitation, we have to do the performance manually, like deleting object which is not used and allocating Large Memory Blocks in Large memory Area.<br><br>For more information:<br><a target=_blank><font color=#0072bc>Windows CE .NET Advanced Memory Management</font></a><br><a target=_blank><font color=#0072bc>How the Windows Mobile 5.0 Shell Handles Low Memory Situations</font></a><br><br>我看了一部分Q在<a target=_blank><font color=#0072bc><u>How the Windows Mobile 5.0 Shell Handles Low Memory Situations</u></font></a>中提刎ͼ<br></p> <div> <p> </p> <p><a target=_blank><img src="http://blogs.msdn.com/photos/wmshell/images/607242/original.aspx" border=0></a></p> <p> </p> <p><strong>Hibernate</strong></p> <p>This is the amount of memory the shell tries to keep free at all times. If the amount of free memory falls below this value then the low memory check routine will try to free up memory. It will do this by first sending <a >WM_HIBERNATE</a> to all <a >valid</a> applications. When an application receives this message it should try to free as many resources as possible. When the low memory check routine runs again and the amount of free memory is still below the hibernate level then the shell will try to close the least recently used (LRU) application by sending a <a >WM_CLOSE</a> message. If the low memory check routine runs yet again and the amount of free memory is still below the hibernate level then the shell will call <a >TerminateProcess</a> on the LRU application that it last sent the WM_CLOSE message to.</p> </div> <p><br>我对q段话的理解是:当空闲内存小于HibernateӞpȝ便会试释放内存。首先他会向所有有效的E序发送WM_HIBERNATE。应用程序收到该消息后,会尽量释放资源来释放内存。如果还低于q个值的话,发送WM_CLOSE消息l最q很用的E序。如果还低于该值的Q就关闭该程序了?br><br>q个Ҏg有效Q但是用户再hE序的话Q还是一L效果Qƈ不是辑ֈ了什么释攑ֆ存的效果。如何记录最q很用的E序Q这个是不是有什么方法获得呢Q?br><br>可以像pȝ提示的那P内存不Q请释放一些内存。手工做一些比较好?br><br>也看了一些相q的E序的做法,g效果也没有大家说的那么好?br><br>?a target=_blank><font color=#0072bc><u>How the Windows Mobile 5.0 Shell Handles Low Memory Situations</u></font></a>的最后,q样写的<br></p> <p class=MsoNormal style="MARGIN: 0in 0in 0pt"><strong>What can my Application do?</strong></p> <p class=MsoNormal style="MARGIN: 0in 0in 0pt">The best thing your application can do when faced with a low memory situation is to play nicely with the rest of the device. <br><br>1、If your application receives a <a >WM_HIBERNATE</a> message free up any resources not absolutely required. <br>2、If you are planning on allocating a large amount of memory (or if a large allocation fails) you should call <a >SHCloseApps</a>, which will invoke the shell low memory check routine and will try to ensure that enough free memory exists. See below for an example:<o:p><span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-weight: bold"><font size=2></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> MIN_MEMORY_TO_RUN 2*1024*1024</span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>MEMORYSTATUS mst;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>mst.dwLength  </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(MEMORYSTATUS);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>GlobalMemoryStatus(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">mst);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>If (mst.dwAvailPhys </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> MIN_MEMORY_TO_RUN)<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img id=Codehighlighter1_166_349_Open_Image onclick="this.style.display='none'; Codehighlighter1_166_349_Open_Text.style.display='none'; Codehighlighter1_166_349_Closed_Image.style.display='inline'; Codehighlighter1_166_349_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_166_349_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_166_349_Closed_Text.style.display='none'; Codehighlighter1_166_349_Open_Image.style.display='inline'; Codehighlighter1_166_349_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_166_349_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_166_349_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Try to free memory by asking Shell to shutdown apps</span><span style="COLOR: #008000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">SHCloseApps(MIN_MEMORY_TO_RUN))<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img id=Codehighlighter1_275_349_Open_Image onclick="this.style.display='none'; Codehighlighter1_275_349_Open_Text.style.display='none'; Codehighlighter1_275_349_Closed_Image.style.display='inline'; Codehighlighter1_275_349_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_275_349_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_275_349_Closed_Text.style.display='none'; Codehighlighter1_275_349_Open_Image.style.display='inline'; Codehighlighter1_275_349_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_275_349_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_275_349_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Handle the case where memory could not be freed</span><span style="COLOR: #008000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        …<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span></div> <p></span></span></font></span></o:p><o:p></p> <br>专门查了一?a >SHCloseApps</a>的用?br><strong>原型QBOOL <font style="BACKGROUND-COLOR: #3399fe" color=#ffffff>SHCloseApps</font>(</strong><strong>  DWORD </strong><em><a class=synParam onclick=showTip(this) href=""><u><font color=#0000ff>dwMemSought</font></u></a></em><strong>);<br>功能Q?/strong>This function tries to free up memory for an application. If necessary, the shell closes down other applications by sending <a href="http://www.shnenglu.com/SpringSnow/admin/href_cetemp=" ?><u><font color=#0000ff>dwMemSought</font></u></a></em><strong>);<br>功能Q?/strong>This function tries to free up memory for an application. If necessary, the shell closes down other applications by sending <a href="mk:@MSITStore:F:\保存资料\Magneto%20Documentation%20September%2027,%202005.chm::/html/wce50lrfwmclose.htm">WM_CLOSE</a> messages.<br>参数Q?a class=synParam onclick=showTip(this) href=""><u><font color=#0000ff><em>dwMemSought</em></font></u></a> Specifies, in bytes, the amount of memory to be freed.<br><br>通过了解<a href="http://www.shnenglu.com/SpringSnow/admin/href_cetemp=" ?><u><font color=#0000ff><em>dwMemSought</em></font></u></a> Specifies, in bytes, the amount of memory to be freed.<br><br>通过了解<a >SHCloseApps</a>Q我们就明白了上面那D代码什么意思了?br><br>看来Q内存释攑ƈ不是真正意义上的内存整理Q看来我有的地方误解了!</o:p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/75612.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-03-05 13:56 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/03/05/75612.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>wcsicmp 字符串比?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/03/03/75443.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 03 Mar 2009 10:49:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/03/03/75443.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/75443.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/03/03/75443.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/75443.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/75443.html</trackback:ping><description><![CDATA[今天在写的程序的时?遇到字符串比?<br><br>但是字符串可能会有大写的区?此时怎么办呢?忽略大小写进行比?<br><br>利用wcsicmp比较好, 它将字符串{换成写字符串进行比?q样忽略了大小写的情况. <img src ="http://www.shnenglu.com/SpringSnow/aggbug/75443.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-03-03 18:49 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/03/03/75443.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>疑问: 如何释放内存??http://www.shnenglu.com/SpringSnow/archive/2009/02/23/74694.htmlSandySandyMon, 23 Feb 2009 11:18:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/02/23/74694.htmlhttp://www.shnenglu.com/SpringSnow/comments/74694.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/02/23/74694.html#Feedback6http://www.shnenglu.com/SpringSnow/comments/commentRss/74694.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/74694.html
q里,我不是简单的new后要delete.是对于系l而言,我怎么做到释放内存?让系l的可用内存变大.从网上也看到了许多释攑ֆ存的软g,很惊异它们是如何做到的呢?

有h我申请一大块控g,pȝ不够分配?会引起它自己L理内?试了一?g效果不是很好.
q有人徏?q么?向所有窗口发送一个WM_HIBERNAT消息.
PostMessage(HWND_BROADCAST, WM_HIBERNATE, 0, 0);
g效果也不是很?

有没有很好的Ҏ处理q个问题?

大家知道的话,指点一下啊!

万分感谢!

Sandy 2009-02-23 19:18 发表评论
]]>
Windows核心~程Q第一章错误处理学习笔?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/02/20/74350.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Thu, 19 Feb 2009 16:24:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/02/20/74350.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/74350.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/02/20/74350.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/74350.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/74350.html</trackback:ping><description><![CDATA[<p>      q年前,从china-pub买的。一直也没有安下心来诅R看今年扑ַ作的境况Q也不得不抓把紧了。也愿与c++博客的各位朋友分享我的学习心得?br>       步入主题?br><br>         q一章开介l了windows函数的几U返回|VOIDQBOOLQHANDLEQPVOIDQLONG/DWORD。让我们明白Q仅仅通过q回|我们是不能清楚函数调用ؓ什么会p|的?br><br>         windows内部Q函数检到错误会采用什么机制呢Q它是采?#8220;U程本地存储?#8221;的机制来讲相应的错误代码?#8220;主调U程”兌C赗它可以使不同的U程能独立运行,不会出现怺q扰Ҏ的错误代码的情况?br><br>         函数q回的时候,其返回g指出已发生的一个错误?br><br>         我们查看具体是什么错误,在相应的函数执行完成后调用GetLastError()卛_?br><br>         windows中,错误有三U表C:<br>         一个消息IDQ如ERROR_PATH_NOT_FOUNDQ?br>            消息文本Q如the system cannot find the path specifiedQ?br>         一个编P量避免使用Q?br><br>         调试E序的时候,我们可以配置watchH口Q让它始l显C线E的上一个错误代码和错误的文本描q。如$err,hr。hr是要昄错误代码的消息文本。不q我在windows mobile的环境下没有成功Q没有弄清楚Z么?br><br>         那么我们怎么在自qE序中显C消息文本呢Q文章介l了利用FormatMessage函数。这里我也介l一下这个函数的用法Q?br>         Q下面的介绍摘自Q?a href="http://www.shnenglu.com/bidepan2023/archive/2008/02/03/42433.html">http://www.shnenglu.com/bidepan2023/archive/2008/02/03/42433.html</a>Q?br>         <span style="COLOR: #2000ff">DWORD FormatMessage(</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             DWORD dwFlags,</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             LPCVOID lpSource,</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             DWORD dwMessageId,</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             DWORD dwLanguageId,</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             LPTSTR lpBuffer,</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             DWORD nSize,</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             va_list* Arguments</span><br style="COLOR: #2000ff"><span style="COLOR: #2000ff">             );</span><br><br><span style="FONT-WEIGHT: bold">         dwFlags:</span><br>         # FORMAT_MESSAGE_ALLOCATE_BUFFER // 此函C分配内存以包含描q字丌Ӏ?br>         # FORMAT_MESSAGE_FROM_SYSTEM,  // 在系l的id映射表中L描述字串<br>         # FORMAT_MESSAGE_FROM_HMODULE  // 在其他资源模块中L描述字串<br>         # FORMAT_MESSAGE_FROM_STRING   // 消息ID是个字串Q不是个DWORD<br>         #FORMAT_MESSAGE_IGNORE_INSERTS // 允许我们获得含有%占位W的消息Q不传递这个标志,必dArguments参数中提供这些占位符的信?br>         通常为:FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM<br><br><span style="FONT-WEIGHT: bold">         lpSource:</span><br>         # 指定了FORMAT_MESSAGE_FROM_HMODULE的话Q此参数表示模块的HANDLE<br>         # 指定了FORMAT_MESSAGE_FROM_STRING的话Q此参数表示id字串<br>         通常为:NULL<br><br><span style="FONT-WEIGHT: bold">         dwMessageId:</span><br>         消息ID;如果指定FORMAT_MESSAGE_FROM_STRINGQ将被忽略?br><br style="FONT-WEIGHT: bold"><span style="FONT-WEIGHT: bold">         dwLanguageId:</span><br>         消息描述所用的语言<br>         通常为:0表示自动选择<br><br><span style="FONT-WEIGHT: bold">         lpBuffer:</span><br>         #如果未指定FORMAT_MESSAGE_ALLOCATE_BUFFERQ则己提供的~冲?br>         #否则为系lLocalAlloc分配Q需要被用户LocalFree<br><br><span style="FONT-WEIGHT: bold">         nSize:</span><br>         #如果未指定FORMAT_MESSAGE_ALLOCATE_BUFFERQ则己提供的~冲区大?br>         #否则为系lLocalAlloc分配之最缓冲区大小<br><br><span style="FONT-WEIGHT: bold">         Arguments:</span><br>         通常不?</p> <p><br>例子Q?br></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> ShowError()<br><img id=Codehighlighter1_17_942_Open_Image onclick="this.style.display='none'; Codehighlighter1_17_942_Open_Text.style.display='none'; Codehighlighter1_17_942_Closed_Image.style.display='inline'; Codehighlighter1_17_942_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_17_942_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_17_942_Closed_Text.style.display='none'; Codehighlighter1_17_942_Open_Image.style.display='inline'; Codehighlighter1_17_942_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_17_942_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_17_942_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    DWORD dwError </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> GetLastError();<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    HLOCAL hlocal </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> NULL;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Use the default system locale since we look for Windows messages.<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Note: this MAKELANGID combination has 0 as value</span><span style="COLOR: #008000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    DWORD systemLocale </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    BOOL fOk </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> FormatMessage(<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        FORMAT_MESSAGE_FROM_SYSTEM </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> FORMAT_MESSAGE_IGNORE_INSERTS </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        FORMAT_MESSAGE_ALLOCATE_BUFFER, <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        NULL, dwError, systemLocale, <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        (PTSTR) </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">hlocal, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, NULL);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img id=Codehighlighter1_464_833_Open_Image onclick="this.style.display='none'; Codehighlighter1_464_833_Open_Text.style.display='none'; Codehighlighter1_464_833_Closed_Image.style.display='inline'; Codehighlighter1_464_833_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_464_833_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_464_833_Closed_Text.style.display='none'; Codehighlighter1_464_833_Open_Image.style.display='inline'; Codehighlighter1_464_833_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">fOk) </span><span id=Codehighlighter1_464_833_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_464_833_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Is it a network-related error?</span><span style="COLOR: #008000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">        HMODULE hDll </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> LoadLibraryEx(TEXT(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">netmsg.dll</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">), NULL, <br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            DONT_RESOLVE_DLL_REFERENCES);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img id=Codehighlighter1_614_830_Open_Image onclick="this.style.display='none'; Codehighlighter1_614_830_Open_Text.style.display='none'; Codehighlighter1_614_830_Closed_Image.style.display='inline'; Codehighlighter1_614_830_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_614_830_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_614_830_Closed_Text.style.display='none'; Codehighlighter1_614_830_Open_Image.style.display='inline'; Codehighlighter1_614_830_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (hDll </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> NULL) </span><span id=Codehighlighter1_614_830_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_614_830_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            fOk </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> FormatMessage(<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                FORMAT_MESSAGE_FROM_HMODULE </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"> FORMAT_MESSAGE_IGNORE_INSERTS </span><span style="COLOR: #000000">|</span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                FORMAT_MESSAGE_ALLOCATE_BUFFER,<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                hDll, dwError, systemLocale,<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>                (PTSTR) </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">hlocal, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, NULL);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>            FreeLibrary(hDll);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (fOk </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> (hlocal </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> NULL))<br><img id=Codehighlighter1_867_940_Open_Image onclick="this.style.display='none'; Codehighlighter1_867_940_Open_Text.style.display='none'; Codehighlighter1_867_940_Closed_Image.style.display='inline'; Codehighlighter1_867_940_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_867_940_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_867_940_Closed_Text.style.display='none'; Codehighlighter1_867_940_Open_Image.style.display='inline'; Codehighlighter1_867_940_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_867_940_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_867_940_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        OutputDebugString((PCTSTR) LocalLock(hlocal));<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        LocalFree(hlocal);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div> <p><br><br>      q个是书中的例子的代码,我只是将它归lؓ了一个函数ErrorShow。这h们在一个函数的后面调用Q直接可以知道错误的原因。不q环境我是在smart device 的DEBUG环境下调时的QOutputDebugString会输出相应的字符丌Ӏ?br><br>      q个例子中同时展CZFormatMessage的两U用法。观察一下第二个参数明白了?br><br>      visual studio 也提供了一个查询错误的工P为Error Lookup。通过以上的示例,我们q道其相应的工作原理呢?br><br>      q本书的源码的下载地址Q?a >http://wintellect.com/Books.aspx</a> <br>      大家如果对windows ~程感兴的话,不妨下来看看?br></p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/74350.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-02-20 00:24 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/02/20/74350.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>文g映射的学?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/02/17/74017.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 17 Feb 2009 03:55:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/02/17/74017.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/74017.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/02/17/74017.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/74017.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/74017.html</trackback:ping><description><![CDATA[最q在调研文g相关的东?如MD5?但是文g有可能很?所以我们不能一ơ读出文?有h用文件映?查了一下文件映的内容.记录下来.<br> 摘自:http://www.yesky.com/405/1756405.shtml<br><br><strong>        摘要Q?/strong> 本文通过内存映射文g的用来对大寸文gq行讉K操作Q同时也对内存映文件的相关概念和一般编E过E作了较l的介绍?br><br>  关键词: 内存映射文gQ大文g处理Q分配粒?<br><br>  <strong>引言</strong><br><br>  文g操作是应?a class=bluekey target=_blank><font color=#204890>E序</font></a>最为基本的功能之一QWin32 API和MFC均提供有支持文g处理的函数和c,常用的有Win32 API的CreateFile()、WriteFile()、ReadFile()和MFC提供的CFilecȝ。一般来_以上q些函数可以满大多数场合的要求Q但是对于某些特D应用领域所需要的动辄几十GB、几百GB、乃臛_TB的v量存储,再以通常的文件处理方法进行处理显然是行不通的。目前,对于上述q种大文件的操作一般是以内存映文件的方式来加以处理的Q本文下面将针对q种Windows核心~程技术展开讨论?br><br>  <strong>内存映射文g概述</strong><br><br>  内存文g映射也是Windows的一U内存管理方法,提供了一个统一的内存管理特征,使应用程序可以通过内存指针对磁盘上的文件进行访问,其过E就如同对加载了文g的内存的讉K。通过文g映射q种使磁盘文件的全部或部分内容与q程虚拟地址I间的某个区域徏立映关联的能力Q可以直接对被映的文gq行讉KQ而不必执行文件I/O操作也无需Ҏ件内容进行缓冲处理。内存文件映的q种Ҏ是非常适合于用来管理大寸文g的?br><br>  在用内存映文件进行I/O处理ӞpȝҎ据的传输按页面来q行。至于内部的所有内存页面则是由虚拟内存理器来负责理Q由其来军_内存面何时被分到盘Q哪些页面应该被释放以便为其它进E提供空闲空_以及每个q程可以拥有出实际分配物理内存之外的多个面I间{等。由于虚拟内存管理器是以一U统一的方式来处理所有磁盘I/O的(以页面ؓ单位对内存数据进行读写)Q因此这U优化其有能力以够快的速度来处理内存操作?br><br>  使用内存映射文g时所q行的Q何实际I/O交互都是在内存中q行q以标准的内存地址形式来访问。磁盘的周期性分也是由<a class=bluekey target=_blank><font color=#204890>操作pȝ</font></a>在后台隐蔽实现的Q对应用E序而言是完全透明的。内存映文件的q种Ҏ在q行大文件的盘事务操作时将获得很高的效益?br><br>  需要说明的是,在系l的正常的分|作过E中Q内存映文件ƈ非一成不变的Q它被定期更新。如果系l要使用的页面目前正被某个内存映文件所占用Q系l将释放此页面,如果面数据未保存Q系l将在释N面之前自动完成页面数据到盘的写入?br><br>  对于使用虚拟存储管理的Windows操作pȝQ内存映文件是其内部已有的内存理lg的一个扩充。由可执行代码页面和数据面l成的应用程序可Ҏ需要由操作pȝ来将q些面换进或换出内存。如果内存中的某个页面不再需要,操作pȝ撤消此面原拥用者对它的控制权,q放该面以供其它q程使用。只有在该页面再ơ成为需求页面时Q才会从盘上的可执行文仉新读入内存。同样地Q当一个进E初始化启动Ӟ内存的页面将用来存储该应用程序的静态、动态数据,一旦对它们的操作被提交Q这些页面也被备䆾至系l的面文gQ这与可执行文g被用来备份执行代码页面的q程是很cM的。图1展示了代码页面和数据面在磁盘存储器上的备䆾q程Q?br><br><img onerror="this.src='http://www.yesky.com/image20010518/95741.jpg';" hspace=3 src="http://www.yesky.com/image20010518/95741.jpg" align=center vspace=1 border=1><br>? q程的代码页、数据页在磁盘存储器上的备䆾<br><br>  昄Q如果可以采取同一U方式来处理代码和数据页面,无疑会提高E序的执行效率,而内存映文件的使用恰恰可以满此需求?br><strong>对大文g的管?br><br></strong>  内存映射文g对象在关闭对象之前ƈ没有必要撤销内存映射文g的所有视图。在对象被释放之前,所有的脏页面将自动写入盘。通过CloseHandleQ)关闭内存映射文g对象Q只是释放该对象Q如果内存映文件代表的是磁盘文Ӟ那么q需要调用标准文件I/O函数来将其关闭。在处理大文件处理时Q内存映文件将表示出卓的优势Q只需要消耗极的物理资源Q对pȝ的媄响微乎其微。下面先l出内存映射文g的一般编E流E框图:<br><br><img onerror="this.src='http://www.yesky.com/image20010518/95743.jpg';" hspace=3 src="http://www.yesky.com/image20010518/95743.jpg" align=center vspace=1 border=1><br>? 使用内存映射文g的一般流E?br><br>  而在某些Ҏ行业Q经常要面对十几GB乃至几十GB定w的巨型文Ӟ而一?2位进E所拥有的虚拟地址I间只有232 = 4GBQ显然不能一ơ将文g映像全部映射q来。对于这U情况只能依ơ将大文件的各个部分映射到进E中的一个较的地址I间。这需要对上面的一般流E进行适当的更改:<br><br>  1Q映文件开头的映像?br><br>  2Q对该映像进行访问?br><br>  3Q取消此映像<br><br>  4Q映一个从文g中的一个更q位移开始的新映像?br><br>  5Q重复步?Q直到访问完全部的文件数据?br><br>  下面l出一D|据此描述而写出的对大?GB的文件的处理代码Q?br><br> <table width="100%" bgColor=#ffffff> <tbody> <tr> <td>// 选择文g<br>CFileDialog fileDlg(TRUE, "*.txt", "*.txt", NULL, "文本文g (*.txt)|*.txt||", this);<br>fileDlg.m_ofn.Flags |= OFN_FILEMUSTEXIST;<br>fileDlg.m_ofn.lpstrTitle = "通过内存映射文gd数据";<br>if (fileDlg.DoModal() == IDOK)<br>{<br> // 创徏文g对象<br> HANDLE hFile = CreateFile(fileDlg.GetPathName(), GENERIC_READ | GENERIC_WRITE,<br>   0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);<br> if (hFile == INVALID_HANDLE_VALUE)<br> {<br>  TRACE("创徏文g对象p|,错误代码:%d\r\n", GetLastError());<br>  return;<br> }<br> // 创徏文g映射对象<br> HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);<br> if (hFileMap == NULL)<br> {<br>  TRACE("创徏文g映射对象p|,错误代码:%d\r\n", GetLastError());<br>  return;<br> }<br> // 得到pȝ分配_度<br> SYSTEM_INFO SysInfo;<br> GetSystemInfo(&SysInfo);<br> DWORD dwGran = SysInfo.dwAllocationGranularity;<br> // 得到文g寸<br> DWORD dwFileSizeHigh;<br> __int64 qwFileSize = GetFileSize(hFile, &dwFileSizeHigh);<br> qwFileSize |= (((__int64)dwFileSizeHigh) << 32);<br> // 关闭文g对象<br> CloseHandle(hFile);<br> // 偏移地址 <br> __int64 qwFileOffset = 0;<br> // 块大?br> DWORD dwBlockBytes = 1000 * dwGran;<br> if (qwFileSize < 1000 * dwGran)<br>  dwBlockBytes = (DWORD)qwFileSize;<br>  while (qwFileOffset > 0)<br>  {<br>   // 映射视图<br>   LPBYTE lpbMapAddress = (LPBYTE)MapViewOfFile(hFileMap,FILE_MAP_ALL_ACCESS, <br>      (DWORD)(qwFileOffset >> 32), (DWORD)(qwFileOffset & 0xFFFFFFFF),<br>      dwBlockBytes);<br>   if (lpbMapAddress == NULL)<br>   {<br>    TRACE("映射文g映射p|,错误代码:%d\r\n", GetLastError());<br>    return;<br>   }<br>   // Ҏ的视图q行讉K<br>   for(DWORD i = 0; i < dwBlockBytes; i++)<br>    BYTE temp = *(lpbMapAddress + i);<br>    // 撤消文g映像<br>    UnmapViewOfFile(lpbMapAddress);<br>    // 修正参数<br>    qwFileOffset += dwBlockBytes;<br>    qwFileSize -= dwBlockBytes;<br>  }<br>  // 关闭文g映射对象句柄<br>  CloseHandle(hFileMap);<br>  AfxMessageBox("成功完成Ҏ件的讉K");<br>}</td> </tr> </tbody> </table> <br>  在本例中Q首先通过GetFileSizeQ)得到被处理文仉度(64位)的高32位和?2位倹{然后在映射q程中设定每ơ映的块大ؓ1000倍的分配_度Q如果文仉度小?000倍的分配_度时则块大小讄为文件的实际长度。在处理q程中由映射、访问、撤消映构成了一个@环处理。其中,每处理完一个文件块后都通过关闭文g映射对象来对每个文g块进行整理。CreateFileMappingQ)、MapViewOfFileQ){函数是专门用来q行内存文g映射处理用的?br><br> 下面分别对这些关键函数进行说明:<br><br>  <strong>1QCreateFileQ)Q?/strong>CreateFileQ)函数是一个用途非常广泛的函数Q?在这里的用法q没有什么特D的地方Q但有几炚w要注意:一是访问模式参数dwDesiredAccess。该参数讄了对文g内核对象的访问类型,其允许设|的权限可以权限GENERIC_READ、写权限GENERIC_WRITE、读写权限GENERIC_READ | GENERIC_WRITE和设备查询权?。在使用映射文gӞ只能打开那些h可读讉K权限的文Ӟ卛_能应用GENERIC_READ和GENERIC_READ | GENERIC_WRITEq两U组合;另一炚w要注意的是共享模式参数dwShareMode。该参数定义了对文g内核对象的共享方式,其可能的讄为FILE_SHARE_READ、FILE_SHARE_WRITE?Qƈ可对其组合用。其中,讄?时不允许׃n对象QFILE_SHARE_READ和FILE_SHARE_WRITE分别为在要求只读、只写访问的情况下才允许对象的共享?br><br>  ׃通过内存映射文g可以在多个进E间׃n数据Q因此在q行q种应用时应当考虑dwShareMode参数讄对运行结果的影响?br><br>  <strong>2QCreateFileMappingQ)Q?/strong>该函数的作用是创Z个文件映内核对象,以告知系l文件映对象需要多大的物理存储器。创建内存映文件对象对pȝ资源几乎没有什么媄响,也不会媄响进E的虚拟地址I间。除了需要用来表C对象的内部资源之外通常q不用ؓ其分配虚拟内存,但是如果内存映射文g对象是作׃n内存之用的话Q就要在创徏对象时由pȝ为内存映文件的使用在系l页文g中保留够的I间?br><br>  函数W一个参数hFile为标识要映射到进E的地址I间的文件的句柄。虽然由于内存映文件的物理存储器是来自于磁盘上的文Ӟ而非pȝ的页文gQ创徏内存映射文g像保留一个地址I间区域q将物理存储器提交给该区域一栗第二个参数为指向文件映内核对象的SECURITY_ATTRIBUTESl构的指针,由此来决定子q程能否l承得到q回的句柄。通常为其传递NULL|以默认的<a class=bluekey target=_blank><font color=#204890>安全</font></a>属性来止q回句柄的被l承?br><br>  接下来的参数用于文g被映后讑֮文g映像的保护属性。其可能的取gؓPAGE_READONLY、PAGE_READWRITE和PAGE_WRITECOPY。虽然在创徏文g映射对象Ӟpȝq不为其保留地址I间区域Q也不将文g的存储器映射到该区域。但是,在系l将存储器映到q程的地址I间中去Ӟpȝ必须切知道应赋予物理存储器面的保护属性。在讄保护属性时Q必M用CreateFileQ)函数打开文g时所指定的访问标识相匚wQ否则将DCreateFileMappingQ)的执行失败。因此这里设|PAGE_READWRITE属性。除了上qC个页面保护属性外Q还?个区QSectionQ保护属性也可以一L合用:<br><br> <table cellSpacing=0 width="100%" border=1> <tbody> <tr> <td>Z护属?/td> <td>说明</td> </tr> <tr> <td>SEC_COMMIT</td> <td>为区中的所有页面在内存中或盘面文g中分配物理存储器</td> </tr> <tr> <td>SEC_IMAGE</td> <td>告知pȝQ映的文g是一个可UL的EXE文g映像</td> </tr> <tr> <td>SEC_NOCACHE</td> <td>告知pȝQ未文件的M内存映射文g攑օ高速缓存,多供<a class=bluekey target=_blank><font color=#204890>g</font></a>讑֤驱动<a class=bluekey target=_blank><font color=#204890>E序</font></a>开发h员?/td> </tr> <tr> <td>SEC_RESERVE</td> <td>对一个区的所有页面进行保留而不分配物理存储?/td> </tr> </tbody> </table> <br>  后面的两个参数指定了要创建的文g映射对象的最大字节数的高32位值和?2位|实际也就讑֮了文件的最大字节数Q最大可以处?6EB的文Ӟ。这两个参数可以满保文g映射对象能够得到_的物理存储器q一基本条g。在参数讄的大小于文件实际大时Q系l将从文件映指定的字节数。这里将其设|ؓ0Q将使所创徏的文件映对象将为文件的当前大小Q以上两U情况均无法改变文g的大。如果设|的参数大于文g的实际大,pȝ会在CreateFileMappingQ)函数q回前扩展该文g。需要指出的是,文g映射对象的大是静态的Q一旦创建完毕后无法更攏V如果设|的文g映射对象寸偏小导致无法对文gq行全面的访问?br><br>  在本节开始也曾提到过Q创建文件映对象是不需要花费什么系l资源的Q因此遵?宁多勿缺"的原则,一般应文件映对象的大小讄为文件大的相同倹{函数最后的参数可以ؓ映射对象命名。如果想打开一个已存在的文件映对象,该对象必要命名。对该名字字W串的要求仅限于未被其它对象使用q的名字卛_?br><br>  CreateFileMappingQ)在成功执行后返回一个指向文件映对象的句柄。如果对一个已l存在的文g映射对象调用了CreateFileMappingQ)函数Q进E将得到一个指向现有映对象的句柄。通过调用GetLastErrorQ)可以得到q回值ERROR_ALREADY_EXISTQ由此可以判断当前得到的内存映射对象句柄是新创徏的还是打开已经存在的。如果系l无法创建文件映对象,导致CreateFileMappingQ)的执行失败,q回N U L L句柄倹{?br><br><strong>3QMapViewOfFileQ)Q?/strong>当创Z一个内存映文件对象ƈ得到其有效句柄后Q该句柄卛_用来在进E的虚拟地址I间中映文件的一个映像。在内存映射文g对象已经存在的情况下Q映像可被Q意映或取消映射。在文g映像被映时Q仍然必ȝpȝ来ؓ文g的数据保留一个地址I间区域Qƈ文件的数据作ؓ映射到该区域的物理存储器q行提交。在q程的地址I间中,一个够大的连l地址I间Q通常以覆盖整个文g映像Q将被指定给此文件映像。尽如此,内存的物理页面还是根据在实际使用中的需求而进行分配的。真正分配一个对应于内存映射文g映像面的物理内存页面是在发生该늚~页中断时进行的Q这在W一ơ读写内存页面中的Q一地址时自动完成。MapViewOfFileQ)卌责映内存映文件的一个映像,<br><br>  函数的第一个参CؓCreateFileMappingQ)所q回的内存映文件对象句柄,W二个参数指定了Ҏ件映像的讉KcdQ可能取值有FILE_MAP_WRITE、FILE_MAP_READ、FILE_MAP_ALL_ACCESS和FILE_MAP_COPY{几U,具体的设|要Ҏ文g映射对象允许的保护模式而定。根据前面代码的讄Q这里应该用FILE_MAP_ALL_ACCESS参数。这U机制ؓ对象的创提供了Ҏ此对象的方式进行控制的能力。接下来?个参数分别指定了内存映射文g?4位偏Ud址的低32位和?2位地址Q该地址是从内存映射文g头位|到映像开始位|的距离。最后的参数指定了视囄大小Q如果设|ؓ0Q前面的偏移地址被忽略Q系l将会把整个文g映射Z个映像。MapViewOfFileQ)如果成功执行Q将q回一个指向文件映像在q程的地址I间中的起始地址的指针。如果失败,则返回NULL。在q程中,可以为同一个文件映对象创建多个文件映像,q些映像可以在系l中共存和重叠,也可以与对应的文件映对象大不怸_但不能大于文件映对象的大小?br><br>  <strong>4QUnmapViewOfFileQ)Q?/strong>当不再需要保留映到q程地址I间区域中的文g映像数据Ӟ可通过调用UnmapViewOfFileQ)函数其释放。该函数l构非常单,只需要提供映像在q程中的起始地址Q区域的基地址Q作为参数即可。该函数的输入参Cؓ调用MapViewOfFileQ)时所q回的指向文件映像在q程的地址I间中的起始地址的指针。在调用MapViewOfFileQ)后,必须保在进E退Z前能够执行UnmapViewOfFileQ)函数Q否则在q程l止之后先前保留的区域将得不到释放,即再次启动q程重复调用MapViewOfFileQ)pȝ也L在进E的地址I间中保留一个新的区域,而此前保留的所有区域将得不到释放?br><br>  一U比较特D的情况是,对同一个内存映文件映了两个相同的映像的撤消。前面曾l提到过Q对于同一个内存映文件可以有多个映像Q这些映像也可以重叠Q因此这U情늚存在是合法的。对于这U情况,虽然从表面看上去在单q程的地址I间内是不可能存在两个基地址完全相同的映像的Q这导致无法对q它们的区分。但是事实上Q由MapViewOfFileQ)所q回得到的基地址只是文g映像在进E地址I间中的起始基地址Q因此在映射同一内存映射文g的两个相同映像时会产生对内存映文件同一部分的两个不同基地址的相同映像,可以用同LҎ调用UnmapViewOfFileQ)其从进E的地址I间中予以撤消?br><br>  <strong>5QCloseHandleQ)Q?/strong> 与Win32的大多数对象一P在用完毕之后L要通过CloseHandleQ)函数已打开的内核对象关闭。如果忘记关闭对象,在程序l运行时会出现资源泄漏。虽然在E序退行时Q操作系l会自动关闭在进E中已经打开但未关闭的Q何对象。但是在q程的运行过E中Q势必会U篏q多的资源句柄。因此在不再需要用对象的时候通过CloseHandleQ)其予以关闭是有意义的?br><br>  <strong>结</strong><br><br>  本文对内存映文件在大文件处理中的应用作了较l的阐述。经实际试Q内存映文件在处理大数据量文g时表现出了良好的性能Q比通常使用CFilecdReadFile()和WriteFile(){函数的文g处理方式h明显的优ѝ本文所q程序代码在Windows 2000 Professional下由Microsoft Visual C++ 6.0~译通过?br><br> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/74017.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-02-17 11:55 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/02/17/74017.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>文g操作QCreateFile和WriteFile的学?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/02/09/73334.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Mon, 09 Feb 2009 14:14:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/02/09/73334.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/73334.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/02/09/73334.html#Feedback</comments><slash:comments>9</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/73334.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/73334.html</trackback:ping><description><![CDATA[  <p align=left><span>今天的Q务是要保存一个文件。^常看别h怎么写,自己q只是看Q没有动手去写过Q对各个<span>API</span>相应的参C是很了解。今天在q用的时候,q真是遇见了一些问题?span><br><br></span>我们先来说说问题Q?span><br></span>W一个问题:使用<span>WriteFile</span>的时候,我直接将宽字W串写进了文Ӟ文g昄如大家所惻I掺杂了很多ؕ码。但是很有规则。所以我很快明白了q需要将宽字W串转换?span>ASCII</span>码?span><br></span>W二个问题:是我将文g打开后,又进行了写文件的操作Q此时失败。所以对q种情况Q还没有惛_办法Q是׃<span>CreateFile</span>的参数的某些限制么?<span><br><br></span>׃q两个问题,所以我也好好看了一?span>SDK</span>文?span><br></span>我们先来看一?span>CreateFile</span>?span>WriteFile</span>的原型和参数介绍Q?span><br><br><strong>HANDLE</strong> <strong><span>CreateFile</span>(</strong><br>  <strong>LPCTSTR</strong> <em><span><u><span>lpFileName</span></u></span></em><strong>,  // </strong></span><strong>文g?/strong><span><br>  <strong>DWORD</strong> <em><span><u><span>dwDesiredAccess</span></u></span></em><strong>,  // </strong></span><strong>讉K方式</strong><span><br>  <strong>DWORD</strong> <em><span><u><span>dwShareMode</span></u></span></em><strong>,  // </strong></span><strong>׃n模式</strong><span><br>  <strong>LPSECURITY_ATTRIBUTES</strong> <em><span><u><span>lpSecurityAttributes</span></u></span></em><strong>,  // </strong></span><strong>设ؓ<span>NULL</span></strong><span><br>  <strong>DWORD</strong> <em><span><u><span>dwCreationDisposition</span></u></span></em><strong>,  /// </strong></span><strong>创徏方式</strong><span><br>  <strong>DWORD</strong> <em><span><u><span>dwFlagsAndAttributes</span></u></span></em><strong>,  // </strong></span><strong>属?/strong><span><br>  <strong>HANDLE</strong> <em><span><u><span>hTemplateFile</span></u></span></em><br><strong>);</strong> </span></span></p> <p align=left><strong><span>BOOL</span></strong><span> <strong><span>WriteFile</span>( </strong></span></p> <p align=left><span> <strong>HANDLE</strong> <em><span><u><span>hFile</span></u></span></em><strong>, // </strong></span><strong><span>文g句柄</span></strong></p> <p align=left><span> <strong>LPCVOID</strong> <em><span><u><span>lpBuffer</span></u></span></em><strong>, // </strong></span><strong><span>包含写向文g的数?/span></strong></p> <p align=left><span> <strong>DWORD</strong> <em><span><u><span>nNumberOfBytesToWrite</span></u></span></em><strong>, // </strong></span><strong><span>数据包含的字W串的个?/span></strong></p> <p align=left><span> <strong>LPDWORD</strong> <em><span><u><span>lpNumberOfBytesWritten</span></u></span></em><strong>, </strong></span></p> <p align=left><span> <strong>LPOVERLAPPED</strong> <em><span><u><span>lpOverlapped</span></u></span></em></span></p> <p align=left><strong><span>);</span></strong><span> </span></p> <p align=left><span>W一ơ我写的E序很简?/span></p> <p align=left><span>BOOL WriteOwnFile(TCHAR* pFileName, TCHAR* pBuffer, DWORD dwLen)</span></p> <p align=left><span>{</span></p> <p align=left><span><span>        </span>HANDLE hFile = CreateFile(pFileName,</span></p> <p align=left><span><span>                       </span></span><span>GENERIC_WRITE,</span></p> <p align=left><span><span>                                              </span>FILE_SHARE_WRITE,</span></p> <p align=left><span><span>                                              </span>NULL,</span></p> <p align=left><span><span>                                              </span>CREATE_ALWAYS,</span></p> <p align=left><span><span>                                              </span>FILE_ATTRIBUTE_NORMAL,</span></p> <p align=left><span><span>                                              </span>NULL</span></p> <p align=left><span><span>                                              </span></span><span>Q;</span></p> <p align=left> </p> <p align=left><span><span>                 </span>if (INVALID_HANDLE_VALUE != hFile)</span></p> <p align=left><span><span>               </span>{</span></p> <p align=left><span><span>                                              </span>DWORD dwSize = 0;</span></p> <p align=left><span><span>                                              </span>WriteFile(hFile, pBuffer, dwLen, &dwSize, NULL );</span></p> <p align=left><span><span>                                              </span>CloseHandle(hFile);</span></p> <p align=left><span><span>                                              </span>return TRUE;</span></p> <p align=left><span><span>               </span>}</span></p> <p align=left><span><span>               </span>return FALSE;</span></p> <p align=left><span>}</span></p> <p align=left> </p> <p align=left><span>q样是完成了Q但是写出来的文件是q。所以没有进行字W的转换Q我们需要将<span>pBuffer</span>q行转换。这p用到?span>WideCharToMultiByte.</span>如何用呢Q?/span></p> <p align=left><span>首先我的Ҏ比较W,我是q么用的Q?/span></p> <p align=left><span>char* pchBuffer = new char[dwLen+1];</span></p> <p align=left><span>WideCharToMultiByte(</span><span>CP_ACP, NULL, pBuffer, -1, pchBuffer, dwLen+1, NULL, FALSE </span><span>);</span></p> <p align=left><span>WriteFile(hFile, pBuffer, <span>dwLen+1</span>, &dwSize, NULL );</span></p> <p align=left><span> Delete[] pchBuffer;</span></p> <p align=left> </p> <p align=left><span>此时注意Q我?span>WriteFile</span>中用?span>dwLen+1</span>。结果就是在文g的末ևCqQ正好多一个ؕ码出来。所?span>WriteFile</span>?span><span>nNumberOfBytesToWrite</span></span>是写的字W串的数目,是不包括<span>’\<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="0" UnitName="’">0’</st1:chmetcnv></span>的?/span></p> <p align=left> </p> <p align=left><span>q个ҎW,是因为我们的函数可以~减Z个参数。是因ؓ如下q么写时Q?span>dwLen</span>是所要{换的字符串的个数Q此时{换的字符串是包括<span>’\<st1:chmetcnv w:st="on" TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="0" UnitName="’">0’</st1:chmetcnv></span>的?/span></p> <p align=left><span>DWORD dwLen = WideCharToMultiByte(</span><span>CP_ACP, NULL, pBuffer, -1, NULL, NULL, NULL, FALSE </span><span>);</span></p> <p align=left> </p> <p align=left><span>所以我们再来看一下改写以后的代码</span></p> <p align=left><span>BOOL WriteOwnFile(TCHAR* pFileName, TCHAR* pBuffer)</span></p> <p align=left><span>{</span></p> <p align=left><span><span>        </span>HANDLE hFile = CreateFile(pFileName,</span></p> <p align=left><span><span>                       </span></span><span>GENERIC_WRITE,</span></p> <p align=left><span><span>                                              </span>FILE_SHARE_WRITE,</span></p> <p align=left><span><span>                                              </span>NULL,</span></p> <p align=left><span><span>                                              </span>CREATE_ALWAYS,</span></p> <p align=left><span><span>                                              </span>FILE_ATTRIBUTE_NORMAL,</span></p> <p align=left><span><span>                                              </span>NULL</span></p> <p align=left><span><span>                                              </span></span><span>Q;</span></p> <p align=left> </p> <p align=left><span><span>                               </span>if (INVALID_HANDLE_VALUE != hFile)</span></p> <p align=left><span><span>               </span>{</span></p> <p align=left><span><span>                                              </span>DWORD dwSize = 0;</span></p> <p align=left><span><span>                                              </span>DWORD dwLen = WideCharToMultiByte(CP_ACP, NULL, pBuffer, -1, NULL, NULL, NULL, FALSE );</span></p> <p align=left><span><span>                                              </span>char* pchBuffer = new char[dwLen];</span></p> <p align=left><span><span>                                              </span>WideCharToMultiByte(CP_ACP, NULL, pBuffer, -1, pchBuffer, dwLen, NULL, FALSE );</span></p> <p align=left><span><span>                                              </span>WriteFile(hFile, pBuffer, dwLen+1, &dwSize, NULL );</span></p> <p align=left><span><span>                                              </span> delete[] pchBuffer;</span></p> <p align=left><span><span>                                              </span>CloseHandle(hFile);</span></p> <p align=left><span><span>                                              </span>return TRUE;</span></p> <p align=left><span><span>               </span>}</span></p> <p align=left><span><span>               </span>return FALSE;</span></p> <p align=left><span>}</span></p> <p align=left> </p> <p align=left> </p> <p align=left><span>q样感觉代码好看多了?/span></p> <p align=left> </p> <p align=left><span>对于W二个问题,文g打开的时候文件创建失败,q没有想好办法解冟뀂我在想是不是我的某些认知存在问题,文g打开的时候,是否可以?/span><span>CreateFile</span><span>来打开呢?<br></span></p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/73334.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-02-09 22:14 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/02/09/73334.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mobile上监控文件的操作http://www.shnenglu.com/SpringSnow/archive/2009/02/08/73221.htmlSandySandySun, 08 Feb 2009 08:20:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/02/08/73221.htmlhttp://www.shnenglu.com/SpringSnow/comments/73221.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/02/08/73221.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/73221.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/73221.html今天完成了一个Q?/span>,是?/span>mobile上如何监控文件的操作。这?/span>SDK中有相应的例子,?/span>FileChangeNotif?/span>

 
如何实现文g监控Q?/span>
         
首先要在H口注册Q这个要用到SHChangeNotifyRegisterQ这个函数的主要功能是列D一个窗口来接收change notifications.
         
在这个注册的H口中,响应WM_FILECHANGEINFOq个消息Q来q行我们响应的操作?/span>
         
如何我们不想监控了,则可以?/span>SHChangeNotifyDeregisterQ来U除相应的注册窗口?/span>

q样我们可以实现对一个文件夹内文件的生成Q删除,改名{等操作的监控?/span>

下面我们再具体来谈谈每一步如何操作?/span>
1
?/span>SHChangeNotifyRegister的运?/span>
   SHChangeNotifyRegister
的原型ؓ
  BOOL WINAPI SHChangeNotifyRegister(

HWND hwnd,

SHCHANGENOTIFYENTRY * pshcne

);

  其中,hwnd,为接?/span>change notification的窗?/span>;

pshcne是一个指?/span>SHCHANGENOTIFYENTRYl构的指?/span>,它用来指明窗口接收的change notification的类?/span>.如果设ؓNULL,H口接?/span>all file system, network ?/span> mediacd?/span>notifications.

SHCHANGENOTIFYENTRY是什么样的一个结?/span>,我们看一下它的定?/span>

typedef  struct  tagSHCHANGENOTIFYENTRY {
   DWORD dwEventMask;
   LPTSTR pszWatchDir;
 BOOL fRecursive;

} SHCHANGENOTIFYENTRY;

dwEventMask 指定发生什么时间来发?/span>notification 消息

pszWatchDir 指定监控路径Q该gؓNULL的情况下Q是监控所有的文g?/span>

fRecursive指定是否只监控指定\径还是监控指定\径及其子文g夏V?/span>

 

知道了这些,我们不妨写一个这L函数Q来启动文g监控?/span>

代码如下Q?/span>

BOOL StartFileMonitor(HWND hWnd, LPTSTR lpFilePath)

{

     SHCHANGENOTIFYENTRY schneNotifyEntry;

     schneNotifyEntry.dwEventMask = SHCNE_ALLEVENTS;

     schneNotifyEntry.pszWatchDir = lpFilePath;

     schneNotifyEntry.fRecursive = TRUE;

 

     return SHChangeNotifyRegister(hWnd, &schneNotifyEntry);

}

2、如何处?/span>WM_FILECHANGEINFO消息

WM_FILECHANGEINFO 中的参数lParamQ指?/span>FILECHANGENOTIFYQ含有相关的数据。所以我们在收到该消息后Q先作的一部操作就?/span>

FILECHANGENOTIFY *lpfcn = (FILECHANGENOTIFY*)lParam;

FILECHANGENOTIFY的结构ؓQ?/span>

typedef struct tagFILECHANGENOTIFY {

 DWORD dwRefCount;

 FILECHANGEINFO fci;

} FILECHANGENOTIFY;

我们主要用到了其中的fci参数?/span>

FILECHANGEINFO的结构ؓQ?/span>

struct _FILECHANGEINFO {

 DWORD cbSize;

 LONG wEventId;

 ULONG uFlags;

 DWORD dwItem1;

 DWORD dwItem2;

 DWORD dwAttributes;

 FILETIME ftModified;

 ULONG nFileSize;

} FILECHANGEINFO, *LPFILECHANGEINFO;

dwEventId ?/span>SHCHANGENOTIFYENTRYl构中的dwEventMask对应?/span>

dwItem1,dwItem2是事件依赖的|里面包括了我们需要的文g的完整\径。如果是q行创徏文g的操作,?/span>dwItem1是创建后文g的完整\径,如果是对文gq行重新命名操作的话Q则dwItem2是修改后文g的完整\径。此处对其他参数不做介绍Q大安要的话,可以查看一下?/span>

 

我们做完相应的操作后Q要知道释放Q此时要用到SHChangeNotifyFree。这个用hq单很多,?/span>SHChangeNotifyFreeQ?/span>lpfcnQ?/span>

 

下面l大家一段CZ代码Q如?/span>

case WM_FILECHANGEINFO:

     {  

FILECHANGENOTIFY    *lpfcn;

          FILECHANGEINFO        *lpfci;   

lpfcn = (FILECHANGENOTIFY *)lParam;

         if (NULL == lpfcn)

         {

             break;

         }

         // see if the pointer to the file change info structure

         lpfci = &(lpfcn->fci);

         if (NULL == lpfci)

         {

             break;

         }

           else

           {

               switch (lpfci->wEventId) 

                     {

                     case SHCNE_RENAME:

                            {

                                   //……

                            }

                            break;

                     }    

           }

           SHChangeNotifyFree(lpfcn);

}

break;

 

3、如何停止文件监?/span>

   停止文g监控比较单,只要使该H口不接?/span>WM_FILECHANGEINFO消息卛_。?/span>SHChangeNotifyDeregister(hWnd)卛_?/span>

 

以上是我今天学习的一些ȝQ此外需要注意的一个小地方Q在mobile上,把一个文件从一个文件夹拷到另一个文件夹Q此时响应的事g?/span>SHCNE_CREATEQ二从电脑上拯一个文件到mobile上,响应的消息ؓSHCNE_RENAME。我注意C电脑上拷贝的话,mobile会先生成一?/span>Temp文g夹内生成一个时文Ӟ然后再在我们指定的文件夹内生成一个文件。这个机制我q不是很清楚Z么?/span>



Sandy 2009-02-08 16:20 发表评论
]]>
mobile数据库遇到的问题 http://www.shnenglu.com/SpringSnow/archive/2009/02/04/72972.htmlSandySandyWed, 04 Feb 2009 05:20:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2009/02/04/72972.htmlhttp://www.shnenglu.com/SpringSnow/comments/72972.htmlhttp://www.shnenglu.com/SpringSnow/archive/2009/02/04/72972.html#Feedback0http://www.shnenglu.com/SpringSnow/comments/commentRss/72972.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/72972.html今天在加数据库的相关操作?遇到了一些问?提示

error C3861: 'CeMountDBVolEx': identifier not found
error C3861: 'CeMountDBVolEx': identifier not found
error C3861: 'CeCreateDatabaseWithProps': identifier not found
error C3861: 'CeCreateSession': identifier not found
error C3861: 'CeOpenDatabaseInSession': identifier not found

我在.cpp文g的开头加入了

#define EDB
#include <windows.h>
#include <windbase.h>

但是错误q依然存?/p>

从网上搜索了一些方?/p>

在博文《mobile数据库遇到的问题?/font>

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

它里面徏议?/p>

extern "C"
{
  #include <windbase_edb.h>
}

但是使用后,问题变成了lnk的错?/p>

error LNK2019: unresolved external symbol

有h在论坛里

#include Windbase_edb.h

也是同样的问?/p>

最后,我问了一下我的同?/p>

他徏议我?/p>

stdafx.h 头文件中d

#define EDB
#include <windows.h>
#include <windbase.h>

q样的确解决了问题?/p>

Sandy 2009-02-04 13:20 发表评论
]]>
?q程间通信?1U方?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/02/03/72928.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 03 Feb 2009 10:53:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/02/03/72928.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/72928.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/02/03/72928.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/72928.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/72928.html</trackback:ping><description><![CDATA[<p>先粘q来,备以后细?br>链接地址:http://www.bsdlover.cn/index.php?action/viewnews/itemid/1611/page/1/php/1<br><br></p> <p><a onclick="javascript:tagshow(event, '%E8%BF%9B%E7%A8%8B');" href="javascript:;" target=_self><u><strong><font color=#656d77>q程</font></strong></u></a>?a onclick="javascript:tagshow(event, '%E9%80%9A%E4%BF%A1');" href="javascript:;" target=_self><u><strong><font color=#656d77>通信</font></strong></u></a>有以下方?br>Using named objects<br>Waiting for multiple objects<br>Waiting in a message loop<br>Using mutex objects<br>Using semaphore objects<br>Using event objects<br>Using critical section objects<br>Using timer queues<br>Using waitable timer objects<br><strong> <span id=ArticleTitle1_ArticleTitle1_lblTitle>q程间的通讯<a onclick="javascript:tagshow(event, '%E5%AE%9E%E7%8E%B0');" href="javascript:;" target=_self><u><strong><font color=#656d77>实现</font></strong></u></a>QIPCQ的11U方?/span></strong>    <p>q程通常被定义ؓ一个正在运行的E序的实例,它由两个部分l成Q?br>一个是操作pȝ用来理q程?a onclick="javascript:tagshow(event, '%E5%86%85%E6%A0%B8');" href="javascript:;" target=_self><u><strong><font color=#656d77>内核</font></strong></u></a>对象。内核对象也是系l用来存攑օ于进E的l计信息的地?br> 另一个是地址I间Q它包含所有的可执行模块或DLL模块的代码和数据。它q包含动态分配的I间。如U程堆栈和堆分配I间。每个进E被赋予它自q虚拟地址I间Q当q程中的一个线E正在运行时Q该U程可以讉K只属于它的进E的<a onclick="javascript:tagshow(event, '%E5%86%85%E5%AD%98');" href="javascript:;" target=_self><u><strong><font color=#656d77>内存</font></strong></u></a>。属于其它进E的内存则是隐藏的,q不能被正在q行的线E访问?br>   Z能在两个q程之间q行通讯Q由以下几种Ҏ可供参考:</p> <p>?6位时代常使用的方式,CWnd中提供支?br>1。窗口消?标准的Windows消息以及专用的WM_COPYDATA消息 SENDMESSAGE()接收端必L一个窗?/p> <p>2。用共享内存方式(Shared Memory)<br>a.讑֮一块共享内存区?nbsp;      <br>     HANDLE CreateFileMapping(HANDLE,LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD,  LPCSTR)<br>     产生一个file-mapping核心对象<br>     LPVOID MapViewOfFile(<br>         HANDLE hFileMappingObject,<br>        DWORD  dwDesiredAcess,<br>         DWORD  dwFileOffsetHigh,<br>         DWORD  dwFileOffsetLow,<br>          DWORD  dwNumberOfBytesToMap<br>     );<br>得到׃n内存?a onclick="javascript:tagshow(event, '%E6%8C%87%E9%92%88');" href="javascript:;" target=_self><u><strong><font color=#656d77>指针</font></strong></u></a><br>   b.扑և׃n内存<br>    军_q块内存要以点对点(peer to peer)的Ş式呈?br>每个q程都必L相同的能力,产生׃n内存q将它初始化。每个进E?br>都应该调用CreateFileMapping(),然后调用GetLastError().如果传回的错误代码是ERROR_ALREADY_EXISTS,那么q程可以假设这一׃n内存?        域已l被别的q程打开q初始化了,否则该进E就可以合理的认?排在W一位,q接下来共享内存初始化。还是要使用client/server架构中只有serverq程才应该生ƈ初始化共享内存。所有的q程都应该?br>HANDLE OpenFileMapping(DWORD dwDesiredAccess,<br>                                   BOOL bInheritHandle,<br>                                   LPCTSTR lpName);<br>        再调用MapViewOfFile(),取得׃n内存的指?br>   c.同步处理(Mutex)<br>   d.清理(Cleaning up) BOOL UnmapViewOfFile(LPCVOID lpBaseAddress);<br>    CloseHandle()</p> <p>3。动态数据交换(DDEQ通过l护全局分配内存使的应用E序间传递成为可?br>   其方式是再一块全局内存中手工放|大量的数据Q然后用窗口消息传递内?nbsp;   指针.q是16位WIN时代使用的方式,因ؓ在WIN32下已l没有全局和局部内?nbsp;   了,现在的内存只有一U就是虚存?nbsp; </p> <p>4。消息管?Message Pipe)<br>   用于讄应用E序间的一条永久通讯通道Q通过该通道可以象自q应用E序<br>   讉K一个^?a onclick="javascript:tagshow(event, '%E6%96%87%E4%BB%B6');" href="javascript:;" target=_self><u><strong><font color=#656d77>文g</font></strong></u></a>一栯写数据?br>   名管?Anonymous Pipes)<br>    单向动Qƈ且只能够在同一电脑上的各个q程之间动?br>   命名道(Named Pipes)<br>   双向Q跨|络QQ何进E都可以L的抓住,放进道的数据有固定的格式,而用ReadFile()只能d该大的倍数。可以被使用于I/O Completion Ports</p> <p>5邮g?Mailslots)<br>    q播式通信,?2pȝ中提供的新方法,可以在不同主机间交换数据Q在        WIN9X下只支持邮g槽客?/p> <p>6Windows套接?Windows Socket)<br>   它具备消息管道所有的功能Q但遵守一套通信标准使的不同操作pȝ之上的应    用程序之间可以互盔R信?/p> <p>7Internet通信 它让应用E序从Internet地址上蝲?a onclick="javascript:tagshow(event, '%E4%B8%8B%E8%BD%BD');" href="javascript:;" target=_self><u><strong><font color=#656d77>下蝲</font></strong></u></a>文g</p> <p>8。RPCQ远E过E调用,很少使用Q因其与UNIX的RPC不兼宏V?/p> <p>9。串?q行通信(Serial/Parallel Communication)<br>   它允许应用程序通过串行或ƈ行端口与其他的应用程序通信</p> <p>10。COM/DCOM<br>     通过COMpȝ的代理存Ҏ式进行进E间数据交换Q但只能够表现在Ҏ?nbsp;    <a onclick="javascript:tagshow(event, '%E5%87%BD%E6%95%B0');" href="javascript:;" target=_self><u><strong><font color=#656d77>函数</font></strong></u></a>的调用时传送数据,通过DCOM可以在不同主机间传送数据?/p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/72928.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-02-03 18:53 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/02/03/72928.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>pȝ出现q?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/01/13/71905.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 13 Jan 2009 08:10:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/01/13/71905.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/71905.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/01/13/71905.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/71905.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/71905.html</trackback:ping><description><![CDATA[<p>昨天q在感叹落后了好几年,装了一个MSN,一下子p了一?.0?可以跟上时代了吧,美的加了一番好?今天打开电脑,发现我的开始就昄为我不认识的文字?<br><br>中毒?q是我的W一个反?不会?看来q个q是问题?x昨天p了一个msn,g也安安分分的写写E序,那肯定是我的msnE序出问题了.于是折腾了半?把msn都卸掉了,发现原来pȝq是坏的.<br><br>莫非因ؓ我是盗版,׃让我用么?<br><br>先不那么多?上网搜搜,有h说是注册表中涉及font的一些值有所改变,认认真真的对比了一下和同事的区?好像没有什么差?q是怎么回事?<br><br>杀?扫木?g都进行了,好像没有什么反?此时,我试着更换了一些主??好了.<br><br>问题是解决了,但是不明白是什么原因造成?呵呵,默认了?<br><br>症状q是比较ȝ,只是对话框的标题什么的,一些快hC是q,文gq是好好?否则我估计要哭残?</p> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/71905.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-01-13 16:10 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/01/13/71905.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>windows mobile中如何调用无U发送界?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/01/06/71367.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Tue, 06 Jan 2009 11:04:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/01/06/71367.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/71367.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/01/06/71367.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/71367.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/71367.html</trackback:ping><description><![CDATA[<br>如何调用无线发送界?<br>pȝ?我ؓ什么要自己写呢?qq样一U态度,查找调用无线发送界面的方式,在一遍遍苦苦搜寻?没有扑ֈ{案.攑ּ,自己写了.但是今天再调试的时?效果达不到系l那么好.不清楚系l怎么d?<br><br>但突然想看看英文pȝ中无U发送是怎么写的,查了一?Beam File",Z么我没有试一下用q个来查查呢?<br><br>果然有了新发?<br><br>通过下面一个简单的语句,我们可以在PPC上调用系l的无线发送界面了.<br>    CreateProcess(_T("<a href="file://Windows//Beam.exe">\\Windows\\Beam.exe</a>"), _T("<a href="file://My/">\\My</a> Documents\\Birthday_gift.gif"),  NULL, NULL, FALSE, 0,<br>                            NULL, NULL, NULL, NULL);<br><br>很是不错?<br><br>但是q个只是在PPC上适用.在smartphone上是怎样?在windows目录?我发Cq样一个执行文件BeamSP.exe,但是如何执行我还没有惛_?用上面的Ҏ是行不通的. 如果你要知道的话,告诉我一声啊.<br><br><br>好东西一起分? <img src ="http://www.shnenglu.com/SpringSnow/aggbug/71367.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-01-06 19:04 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/01/06/71367.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于debug和release的一点疑?/title><link>http://www.shnenglu.com/SpringSnow/archive/2009/01/05/71244.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Mon, 05 Jan 2009 11:16:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2009/01/05/71244.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/71244.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2009/01/05/71244.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/71244.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/71244.html</trackback:ping><description><![CDATA[<p>疑惑Q很是疑惑的一个问题?br><br>下午我遇到这么一个问题,我在E序里静态加载一个dllQ这个dll是我自己写的。我把dll在release环境下编译,UCؓA吧,另一个程序是在debug环境下进行编译的Q简UCؓB吧。B会调用AQ但是在调用中就出错了?br><br>A 中调用B的代码如下:<br></p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">std::vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">ITEMDATA</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> vcData;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>GetValue(vcData);</span></div> <p><br><br>B 中的代码?br>    </p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> GetValue(std::vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">ITEMDATA</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">vcData)<br><img id=Codehighlighter1_45_113_Open_Image onclick="this.style.display='none'; Codehighlighter1_45_113_Open_Text.style.display='none'; Codehighlighter1_45_113_Closed_Image.style.display='inline'; Codehighlighter1_45_113_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_45_113_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_45_113_Closed_Text.style.display='none'; Codehighlighter1_45_113_Open_Image.style.display='inline'; Codehighlighter1_45_113_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_45_113_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_45_113_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>   ……<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    ITEMDATA item;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>   ……<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    vcData.push_back(item);<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    ……<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div> <br>但是E序每走完GetValue后就抛异怺?br><br>但是如果两个环境都ؓdebugQ或都ؓrelease的话Q都正常Q但是如果不同的话,׃出错?br><br>比较郁闷了? <img src ="http://www.shnenglu.com/SpringSnow/aggbug/71244.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2009-01-05 19:16 <a href="http://www.shnenglu.com/SpringSnow/archive/2009/01/05/71244.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Z么Microsoft code sample們֐使用ZeroMemory而不是{0}? http://www.shnenglu.com/SpringSnow/archive/2008/12/20/69905.htmlSandySandySat, 20 Dec 2008 07:04:00 GMThttp://www.shnenglu.com/SpringSnow/archive/2008/12/20/69905.htmlhttp://www.shnenglu.com/SpringSnow/comments/69905.htmlhttp://www.shnenglu.com/SpringSnow/archive/2008/12/20/69905.html#Feedback1http://www.shnenglu.com/SpringSnow/comments/commentRss/69905.htmlhttp://www.shnenglu.com/SpringSnow/services/trackbacks/69905.htmlZ么Microsoft code sample們֐使用ZeroMemory而不是{0}?

q是最q看的一片短文的titleQ当时就很好奇?br>l常查阅MSDN的程序员都会有这个印象,微Ycode sample中常见的是ZeroMemoryQ而不是语a提供?#8220;{0}”清零功能Q不q,我一直也没有问个whyQ。c++语法中声明对数组或纯l构QstructQ,可以使用例如SPerson sTest = {0}; 来将所有成员置0.

那篇文章的解释是QMicrosoft使用ZeroMemory会更clearQ因?#8220;= {0}” q样的语法有些生僻,不是所有h都可以一下子明白?/p>

实际上,两者还是有一些区别?br>其一QZeroMemory会将l构所有字节置0Q?{0}只会成员置0Q其中padding字节不变?/p>

其二Q但一个struct有构造函数或虚函数时QZeroMemory可以Q?{0}会编译不q。显Ӟ后者vC一些保护作用,因ؓ对一个有虚函数的对象使用ZeroMemoryӞ会将其虚函数的指针置0Q这是非常危险的Q因用虚函数ӞE序昄会crash。参看如下代码:

struct SPerson
{
    
//SPerson(){    }
    char c;
    
float s;
}
;

class CTestVirtual
{
public:
    CTestVirtual()
    
{
    }


    
virtual int Draw()
    
{
        
return 10;
    }


    
int a;
}
;

void Test() 
{
    
char sztmp[20];
    ZeroMemory(sztmp, 
sizeof(sztmp));

    SPerson sTest 
= {0};
    
int i = sizeof(SPerson);

    
//CTestVirtual otv = {0};    //Compire error
    CTestVirtual tv;
    ZeroMemory(
&tv, sizeof(tv));
    tv.Draw();        
//As it is an object, don't use the virtual function pointer, so don't crash.
    CTestVirtual *pTv = &tv;
    pTv
->Draw();    //Crash!!!
}

因此Q在windowsq_下,对于数组或纯l构使用ZeroMemory是安全的Q对于classQ则使用构造函敎ͼ不要调用ZeroMemory。如果有跨^台要求,使用Q{0}则可以减一些工作?

Sandy 2008-12-20 15:04 发表评论
]]>
LPTSTR的认?/title><link>http://www.shnenglu.com/SpringSnow/archive/2008/12/19/69865.html</link><dc:creator>Sandy</dc:creator><author>Sandy</author><pubDate>Fri, 19 Dec 2008 13:10:00 GMT</pubDate><guid>http://www.shnenglu.com/SpringSnow/archive/2008/12/19/69865.html</guid><wfw:comment>http://www.shnenglu.com/SpringSnow/comments/69865.html</wfw:comment><comments>http://www.shnenglu.com/SpringSnow/archive/2008/12/19/69865.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/SpringSnow/comments/commentRss/69865.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/SpringSnow/services/trackbacks/69865.html</trackback:ping><description><![CDATA[原谅我无?对LPTSTR不是很熟?管用了半年的WIN32,今天才想h考LPTSTRq个变量.<br><br>例如:<br>LPTSTR lpStr = _T("Hello");<br>int len1 = wcslen(lpStr); // gؓ5<br>int len2 = sizeof(lpStr); // gؓ4<br><br>原来是这L?今天我终于弄明白?<br><br>lpStr 是一个指?它的用法应该与指针同.<br><br>犯了一个很低的错?记录下来.<br> <img src ="http://www.shnenglu.com/SpringSnow/aggbug/69865.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/SpringSnow/" target="_blank">Sandy</a> 2008-12-19 21:10 <a href="http://www.shnenglu.com/SpringSnow/archive/2008/12/19/69865.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.adu123.cn" target="_blank">þ</a>| <a href="http://www.vzxu.cn" target="_blank">þþþþþþ˳</a>| <a href="http://www.xiazb.cn" target="_blank">Ʒ99þþƷ</a>| <a href="http://www.crs24.cn" target="_blank">94þù׾Ʒ</a>| <a href="http://www.sjsgsl.net.cn" target="_blank">޹Ʒľþþ</a>| <a href="http://www.ccco.org.cn" target="_blank">Ʒþһ</a>| <a href="http://www.taozhenyuan.cn" target="_blank">þþƷѹۿ</a>| <a href="http://www.atzkw.cn" target="_blank">ƷŮþþ</a>| <a href="http://www.niugu6.cn" target="_blank">þô㽶</a>| <a href="http://www.hdv1p7.cn" target="_blank">þþƷѹۿͬ</a>| <a href="http://www.ldzx.sh.cn" target="_blank">þۺϸϾþù</a>| <a href="http://www.3xspace.cn" target="_blank">޹һɾþþƷۺ </a>| <a href="http://www.splh.net.cn" target="_blank">2020þþƷۺһ</a>| <a href="http://www.zazhui.cn" target="_blank">պŷþ</a>| <a href="http://www.2046film.cn" target="_blank">þþƷһ</a>| <a href="http://www.huadublog.cn" target="_blank">avttþþƷ</a>| <a href="http://www.drxt.com.cn" target="_blank">þþþþùƷ</a>| <a href="http://www.sjz114.net.cn" target="_blank">91þ㽶Ů߿</a>| <a href="http://www.yzx777.cn" target="_blank">Ļ뾫ƷԴþ</a>| <a href="http://www.mxylzc.cn" target="_blank">2021ھƷþþþþӰԺ</a>| <a href="http://www.e8ux.cn" target="_blank">99Ʒþ</a>| <a href="http://www.ghbo.cn" target="_blank">þþþþ˸߳ӰԺ</a>| <a href="http://www.sehinix.cn" target="_blank">99þþƷѿ</a>| <a href="http://www.0717zf.cn" target="_blank">þþþþҹƷƷ</a>| <a href="http://www.gakr.cn" target="_blank">þ</a>| <a href="http://www.dabage.cn" target="_blank">޾Ʒһþ</a>| <a href="http://www.ndj2.cn" target="_blank">þҹ³Ƭ</a>| <a href="http://www.7cfw.cn" target="_blank">ĻӰӾþþ</a>| <a href="http://www.szltw.cn" target="_blank">ԭۺϾþô</a>| <a href="http://www.nba592.cn" target="_blank">þۺϾþۺϾþۺ</a>| <a href="http://www.itmr.com.cn" target="_blank">ĻѾþ</a>| <a href="http://www.qpvm.cn" target="_blank">ҹƷþþþþþþ</a>| <a href="http://www.jiangyuyun.cn" target="_blank">þþƷһ </a>| <a href="http://www.shxxwxx.cn" target="_blank">þþþ뾫Ʒapp</a>| <a href="http://www.mfsdrj.com.cn" target="_blank">þþƷһպ </a>| <a href="http://www.njvwt.cn" target="_blank">aþ</a>| <a href="http://www.sjz114.net.cn" target="_blank">þ91ƷۺϹҳ</a>| <a href="http://www.yingongshe.cn" target="_blank">պŮ18վþþƷ</a>| <a href="http://www.xzij.cn" target="_blank">þþþۺþ</a>| <a href="http://www.4fro.cn" target="_blank">þۺ</a>| <a href="http://www.tmsystem888.cn" target="_blank">þþþAVվ </a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>