﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-雪域佛国-随笔分类-转贴</title><link>http://www.cppblog.com/dfghj44444/category/14884.html</link><description>什么都懂一点，生活就有趣一些</description><language>zh-cn</language><lastBuildDate>Wed, 06 Oct 2010 09:11:21 GMT</lastBuildDate><pubDate>Wed, 06 Oct 2010 09:11:21 GMT</pubDate><ttl>60</ttl><item><title>ZEND公司的产品线</title><link>http://www.cppblog.com/dfghj44444/archive/2010/10/06/128724.html</link><dc:creator>叫我老王吧</dc:creator><author>叫我老王吧</author><pubDate>Tue, 05 Oct 2010 16:10:00 GMT</pubDate><guid>http://www.cppblog.com/dfghj44444/archive/2010/10/06/128724.html</guid><wfw:comment>http://www.cppblog.com/dfghj44444/comments/128724.html</wfw:comment><comments>http://www.cppblog.com/dfghj44444/archive/2010/10/06/128724.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/dfghj44444/comments/commentRss/128724.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/dfghj44444/services/trackbacks/128724.html</trackback:ping><description><![CDATA[<h2 class="entry-title" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; font-weight: bold; font-family: 微软雅黑; "><abbr title="星期一, 十一月 9th, 2009" class="published" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-variant: normal; font-size: 12px; color: rgb(153, 153, 153); font-weight: normal; margin-left: 5px; ">11/09/2009</abbr></h2><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">大名鼎鼎的<a href="http://www.zend.com/" target="_blank" style="color: rgb(0, 68, 170); text-decoration: none; ">Zend</a>公司在IT界的知名度是一路飙升啊，她是php的商业公司，随着php在编程语言中越来越多的被使用，据本人不灵通的消息，自9月以来，<a href="http://www.cnbeta.com/articles/94992.htm" target="_blank" style="color: rgb(0, 68, 170); text-decoration: none; ">php已经超越C++排名第三了</a>，这真是一个振奋人心的消息，当初选择做php，此时此刻，也让我感到值了！尽管如此，你不得不承认，php能拿到第三名的好成绩，一定是有我的贡献的~!!那么有没有一天，php能做到编程语言中的头把交椅呢？我想不会的，如果你在哪里看到这个排行榜，那它一定是不权威的。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">OK，言归正传，出于很多同学认为<a href="http://www.zendstudio.net/" style="color: rgb(0, 68, 170); text-decoration: none; ">zend studio</a>是官方网站的不正确认知（主要表现就是向我索取zend server,zend Guard的注册码），我就来说说这个zend公司她到底是个什么东西，或许我把标题改成《<span style="text-decoration: underline; ">zend公司的那些事儿</span>》，大概更能符合中国人的阅读习惯。顺便说一下，<strong>zend studio是公益性民间站点</strong>。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">由于zend公司的产品和php有着绝对的关系，然而其每个产品之间竟然也有这千丝万缕的联系，这就是一个很值得称道的事情了，甚至和金庸的武侠小说有异曲同工之妙。下面我们一一絮叨（排名不分先后，但zend studio排第一个）。<span id="more-833"></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>1、Zend Stduio</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">这是我认为zend公司唯一还有必要存在的真正原因，我厌烦了媒体一提到zend studio就照本宣科的道比&#8220;一个屡获大奖的专业 PHP 集成开发环境，具备功能强大的专业编辑工具和调试工具&#8230;&#8230;&#8221;，虽然事实上确实是这么回事，zend studio确实是一个强大的php集成开发环境，我选择，我喜欢！但这里我想提醒下大家，zend studio是商业软件。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>2、Zend Debugger</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">总是介绍一个商业公司的商业产品，难免有打商业广告之嫌，虽然我根本就不是一个商人，所以接下来我就马上搬出zend debugger（我前不久刚好写了一篇<a href="http://www.zendstudio.net/archives/zend-debugger-and-zend-optimizer-are-peaceful/" style="color: rgb(0, 68, 170); text-decoration: none; ">zend debugger的终极安装教程</a>），zend debugger是zend公司为数不多的免费产品，体积不大，安装方便，功能也很强大，一般需要调试php程序的时候，装上它就够用了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>3、Zend Server</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">实际上我并没有搞清楚zend server的真正意图，据说针对php做了专门的优化，并且是商业软件，但其不全是收费的，只是部分组件（我大约在3个月前试用过zend server，记忆有些模糊），内置的是apache服务器（当然你可以不选择内置），虽然她集成了Zend Optimizer、Zend Guard Loader、Zend Data Cache、Zend Debugger、Zend Framework，但在我看来这和免费的<a href="http://www.apachefriends.org/zh_cn/index.html" style="color: rgb(0, 68, 170); text-decoration: none; ">xampp</a>没有实质性区别。很多同学问我&#8220;<em>安装了zend studio是否一定要安装zend server？</em>&#8221;，回答是&#8220;<strong>安装zend studio不一定要安装zend server，因为他们之间没有必然的联系</strong>&#8221;。我想，问这个问题的同学，大概看了很早的zend studio介绍，那时候的zde还有分zend studio client和zend studio server，然后同学将zend studio server和zend server搞混了。<span style="text-decoration: underline; ">你看，这篇日志的意义就显现出来了。</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>4、Zend Optimizer</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">这又是zend 公司的免费产品之一，Zend Optimizer的最大作用是<span style="text-decoration: line-through; ">解密</span>解析被zend Guard加密了的php源文件，兼顾优化php性能的作用，因此，您在部署服务器的时候将zend Optimizer顺便安装上没有任何的坏处，当然，如果你购买了一份Zend Guard加密过的php源码，那你就必须安装她了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>5、Zend Guard</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">Zend Guard是一个非常有用的产品，当然她也是一个商业软件，如果你不打算将你的php代码开源，那么可以选择Zend Guard来保护你的研究成果，最新版的宝马5系，据说强度不是一般的大，能够在保护期内安全不被破解。值得一提的是，用Zend Guard加密过了的php源代码，在你的服务器环境中必须安装Zend Optimizer来&#8220;正常运行&#8221;之（<em>看！金庸的大师风范就彰显出来了</em>）。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>6、Zend Framework</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">这又是zend 公司近年来的重要产品，php界Framework的兴起，无疑的简化开发，提高效率，即&#8220;敏捷高效&#8221;四字方针，这个仅仅是程序员在开发工作上的描述，而php的运行效率性能上却并非有质的飞跃。因此，本人也不是非常崇尚框架，尽管国内的qeephp,thinkphp等著名框架发展的如火如荼，框架的追捧者也是如潮水一般，有个人依然我行我素的&#8220;坐以待毙&#8221;，他是——gently。然而Zend Framework并非一无是处，她是一个伟大的框架产品，发展稳健，现在的用户群也是蛮庞大的（中国人比较迷信官方，当然也因为她确实不错）。<strong>Zend studio</strong>从宝马7系开始，已经完美的支持zend Framework的开发、调试运行一条龙了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>7、Zend Core</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">直译过来是<em>zend核心</em>，乍听起来，你一定觉得这是个了不起的产品。实际上，你的感觉是对的，zend core是zend官方又一个为数不多的优秀的免费产品，她的存在必要性是能够帮助大家快速的安装部署php运行环境，简约而不简单，甚至还提供了一个web管理配置php.ini的功能，这是很优秀的，更多有趣的功能等着大家去发现了。它与zend studio也是有着千丝万缕的关系，比如我用zend studio开发了一个系统，借由zend core就能很快的上线运行。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><strong>8、Zend Platform</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; ">更准确的说她是一整套的企业服务器解决方案，企业级应用从来都是和大型联系在一起的，因此，什么集群啊、阵列啊、控制中心啊、等等等等对zend platform来说全都不在话下，她能够跟踪Php运行中的错误，监控php运行的性能，精确的找出瓶颈，这是多么牛逼的产品啊。那么，需要多少钱呢？只要998，全球限量30套，赶紧拿起电话订购吧！&#8230;&#8230;抽风了一下，依我看，zend server正要逐步替代掉zend platform，不止是做嫁衣，zend 还要生产新娘！因此，Zend Server风头正劲。Zend Platform与zend studio的关系就是前者能够提供给后者非常强大的服务端支持，当然这个强大是zend debugger无法企及的，当大多数时候，我们个人开发者用不着这么强大，官方可以下载到Zend Platform的30天试用版（就是说她是商业软件），抱歉，我也没有Zend Platform的注册码或者注册机。她与zend server的关系呢，就是Zend Server在嫁衣里面包了个新娘。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 13px; "><a href="http://www.zend.com/" style="color: rgb(0, 68, 170); text-decoration: none; ">Zend公司</a>是一个有潜力的公司，与各界的合作正纷纷展开，也祝zend越走越远。</p>
<img src ="http://www.cppblog.com/dfghj44444/aggbug/128724.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/dfghj44444/" target="_blank">叫我老王吧</a> 2010-10-06 00:10 <a href="http://www.cppblog.com/dfghj44444/archive/2010/10/06/128724.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC++ ini文件操作</title><link>http://www.cppblog.com/dfghj44444/archive/2010/09/27/127890.html</link><dc:creator>叫我老王吧</dc:creator><author>叫我老王吧</author><pubDate>Mon, 27 Sep 2010 10:14:00 GMT</pubDate><guid>http://www.cppblog.com/dfghj44444/archive/2010/09/27/127890.html</guid><wfw:comment>http://www.cppblog.com/dfghj44444/comments/127890.html</wfw:comment><comments>http://www.cppblog.com/dfghj44444/archive/2010/09/27/127890.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/dfghj44444/comments/commentRss/127890.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/dfghj44444/services/trackbacks/127890.html</trackback:ping><description><![CDATA[<span  style="line-height: 23px; color: rgb(40, 71, 85); font-family: Verdana, Arial, Helvetica, 宋体, sans-serif; font-size: 13px; "><div class="item-body" style="line-height: 15px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); "><div class="item-title revoArtlabel" style="line-height: 15px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 10px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); border-left-color: rgb(216, 231, 238); height: 22px; ">原帖：<a href="http://leapfish.blog.sohu.com/60685388.html">http://leapfish.blog.sohu.com/60685388.html</a></div><div class="item-content" id="main-content" style="line-height: 23px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); font-size: 13px; overflow-x: hidden; overflow-y: hidden; border-left-color: rgb(216, 231, 238); "><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">用Visual C++操作INI文件</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">在我们写的程序当中,总有一些配置信息需要保存下来,以便完成程序的功能,最简单的办法就是将这些信息写入INI文件中,程序初始化时再读入.具体应用如下:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">一.将信息写入.INI文件中.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">1.所用的WINAPI函数原型为:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL WritePrivateProfileString(<br style="line-height: 23px; ">LPCTSTR lpAppName,<br style="line-height: 23px; ">LPCTSTR lpKeyName,<br style="line-height: 23px; ">LPCTSTR lpString,<br style="line-height: 23px; ">LPCTSTR lpFileName<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">其中各参数的意义:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　LPCTSTR lpAppName 是INI文件中的一个字段名.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp; LPCTSTR lpKeyName 是lpAppName下的一个键名,通俗讲就是变量名.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　LPCTSTR lpString 是键值,也就是变量的值,不过必须为LPCTSTR型或CString型的.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　LPCTSTR lpFileName 是完整的INI文件名.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">2.具体使用方法:设现有一名学生,需把他的姓名和年龄写入 c:\stud\student.ini 文件中.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString strName,strTemp;<br style="line-height: 23px; ">int nAge;<br style="line-height: 23px; ">strName="张三";<br style="line-height: 23px; ">nAge=12;<br style="line-height: 23px; ">::WritePrivateProfileString("StudentInfo","Name",strName,"c:\\stud\\student.ini");</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">此时c:\stud\student.ini文件中的内容如下:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">[StudentInfo]<br style="line-height: 23px; ">Name=张三</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">3.要将学生的年龄保存下来,只需将整型的值变为字符型即可:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">strTemp.Format("%d",nAge);<br style="line-height: 23px; ">::WritePrivateProfileString("StudentInfo","Age",strTemp,"c:\\stud\\student.ini");</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">二.将信息从INI文件中读入程序中的变量.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">1.所用的WINAPI函数原型为:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">DWORD GetPrivateProfileString(<br style="line-height: 23px; ">LPCTSTR lpAppName,&nbsp;<br style="line-height: 23px; ">LPCTSTR lpKeyName,&nbsp;<br style="line-height: 23px; ">LPCTSTR lpDefault,&nbsp;<br style="line-height: 23px; ">LPTSTR lpReturnedString,&nbsp;<br style="line-height: 23px; ">DWORD nSize,&nbsp;<br style="line-height: 23px; ">LPCTSTR lpFileName&nbsp;<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">其中各参数的意义:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">前二个参数与 WritePrivateProfileString中的意义一样.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp; lpDefault : 如果INI文件中没有前两个参数指定的字段名或键名,则将此值赋给变量.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　lpReturnedString : 接收INI文件中的值的CString对象,即目的缓存器.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　nSize : 目的缓存器的大小.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　lpFileName : 是完整的INI文件名.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">2.具体使用方法:现要将上一步中写入的学生的信息读入程序中.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString strStudName;<br style="line-height: 23px; ">int nStudAge;&nbsp;<br style="line-height: 23px; ">GetPrivateProfileString("StudentInfo","Name","默认姓名",strStudName.GetBuffer(MAX_PATH),MAX_PATH,"c:\\stud\\student.ini");</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　执行后 strStudName 的值为:"张三",若前两个参数有误,其值为:"默认姓名".</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">3.读入整型值要用另一个WINAPI函数:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">UINT GetPrivateProfileInt(<br style="line-height: 23px; ">LPCTSTR lpAppName,&nbsp;<br style="line-height: 23px; ">LPCTSTR lpKeyName,&nbsp;<br style="line-height: 23px; ">INT nDefault,&nbsp;<br style="line-height: 23px; ">LPCTSTR lpFileName&nbsp;<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">这里的参数意义与上相同.使用方法如下:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">nStudAge=GetPrivateProfileInt("StudentInfo","Age",10,"c:\\stud\\student.ini");</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">三.循环写入多个值,设现有一程序,要将最近使用的几个文件名保存下来,具体程序如下:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">1.写入:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString strTemp,strTempA;<br style="line-height: 23px; ">int i;<br style="line-height: 23px; ">int nCount=6;<br style="line-height: 23px; ">file://共有6个文件名需要保存<br style="line-height: 23px; ">for(i=0;i&lt;nCount;i++)&nbsp;<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; strTemp.Format("%d",i);<br style="line-height: 23px; ">&nbsp; strTempA=文件名;<br style="line-height: 23px; ">&nbsp; //文件名可以从数组,列表框等处取得.<br style="line-height: 23px; ">&nbsp; ::WritePrivateProfileString("UseFileName","FileName"+strTemp,strTempA,"c:\\usefile\\usefile.ini");<br style="line-height: 23px; ">}<br style="line-height: 23px; ">strTemp.Format("%d",nCount);<br style="line-height: 23px; ">::WritePrivateProfileString("FileCount","Count",strTemp,"c:\\usefile\\usefile.ini");<br style="line-height: 23px; ">//将文件总数写入,以便读出.</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">2.读出:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">nCount=::GetPrivateProfileInt("FileCount","Count",0,"c:\\usefile\\usefile.ini");<br style="line-height: 23px; ">for(i=0;i&lt;nCount;i++)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; strTemp.Format("%d",i);<br style="line-height: 23px; ">&nbsp; strTemp="FileName"+strTemp;<br style="line-height: 23px; ">&nbsp; ::GetPrivateProfileString("CurrentIni",strTemp,"default.fil", strTempA.GetBuffer(MAX_PATH),MAX_PATH,"c:\\usefile\\usefile.ini");<br style="line-height: 23px; ">&nbsp; //使用strTempA中的内容.<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">补充四点:<br style="line-height: 23px; ">　1.INI文件的路径必须完整,文件名前面的各级目录必须存在,否则写入不成功,该函数返回 FALSE 值.<br style="line-height: 23px; ">　2.文件名的路径中必须为 \\ ,因为在VC++中, \\ 才表示一个 \ .<br style="line-height: 23px; ">　3.也可将INI文件放在程序所在目录,此时 lpFileName 参数为: ".\\student.ini".</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">//----------------------------------------------------------------------------------<br style="line-height: 23px; ">/*<br style="line-height: 23px; ">类名：CIni<br style="line-height: 23px; ">版本：v2.0<br style="line-height: 23px; ">加入高级操作的功能<br style="line-height: 23px; ">v1.0<br style="line-height: 23px; ">梦小孩于2003年某日<br style="line-height: 23px; ">一般操作完成</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">类描述：<br style="line-height: 23px; ">本类可以于.ini文件进行操作<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">文件 1:<br style="line-height: 23px; ">#pragma once<br style="line-height: 23px; ">#include "afxTempl.h"</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">class CIni<br style="line-height: 23px; ">{<br style="line-height: 23px; ">private:<br style="line-height: 23px; ">CString m_strFileName;<br style="line-height: 23px; ">public:<br style="line-height: 23px; ">CIni(CString strFileName):m_strFileName(strFileName)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">}<br style="line-height: 23px; ">public:<br style="line-height: 23px; ">//一般性操作：<br style="line-height: 23px; ">BOOL SetFileName(LPCTSTR lpFileName);&nbsp; //设置文件名<br style="line-height: 23px; ">CString GetFileName(void); //获得文件名<br style="line-height: 23px; ">BOOL SetValue(LPCTSTR lpSection, LPCTSTR lpKey, LPCTSTR lpValue,bool bCreate=true); //设置键值，bCreate是指段名及键名未存在时，是否创建。<br style="line-height: 23px; ">CString GetValue(LPCTSTR lpSection, LPCTSTR lpKey); //得到键值.<br style="line-height: 23px; ">BOOL DelSection(LPCTSTR strSection);&nbsp; //删除段名<br style="line-height: 23px; ">BOOL DelKey(LPCTSTR lpSection, LPCTSTR lpKey);&nbsp; //删除键名</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">public:<br style="line-height: 23px; ">//高级操作：<br style="line-height: 23px; ">int GetSections(CStringArray&amp; arrSection);&nbsp; //枚举出全部的段名<br style="line-height: 23px; ">int GetKeyValues(CStringArray&amp; arrKey,CStringArray&amp; arrValue,LPCTSTR lpSection);&nbsp; //枚举出一段内的全部键名及值</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL DelAllSections();</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">};</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">文件 2:</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">#include "StdAfx.h"<br style="line-height: 23px; ">#include "ini.h"</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">#define MAX_ALLSECTIONS 2048&nbsp; //全部的段名<br style="line-height: 23px; ">#define MAX_SECTION 260&nbsp; //一个段名长度<br style="line-height: 23px; ">#define MAX_ALLKEYS 6000&nbsp; //全部的键名<br style="line-height: 23px; ">#define MAX_KEY 260&nbsp; //一个键名长度</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL CIni::SetFileName(LPCTSTR lpFileName)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; CFile file;<br style="line-height: 23px; ">&nbsp; CFileStatus status;<br style="line-height: 23px; ">&nbsp; if(!file.GetStatus(lpFileName,status))<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; return TRUE;<br style="line-height: 23px; ">&nbsp; m_strFileName=lpFileName;<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; return FALSE;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString CIni::GetFileName(void)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; return m_strFileName;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL CIni::SetValue(LPCTSTR lpSection, LPCTSTR lpKey, LPCTSTR lpValue,bool bCreate)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">TCHAR lpTemp[MAX_PATH] ={0};</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">//以下if语句表示如果设置bCreate为false时，当没有这个键名时则返回TRUE（表示出错）<br style="line-height: 23px; ">//!*&amp;*none-value*&amp;!* 这是个垃圾字符没有特别意义，这样乱写是防止凑巧相同。<br style="line-height: 23px; ">if (!bCreate)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; GetPrivateProfileString(lpSection,lpKey,"!*&amp;*none-value*&amp;!*",lpTemp,MAX_PATH,m_strFileName);<br style="line-height: 23px; ">&nbsp; if(strcmp(lpTemp,"!*&amp;*none-value*&amp;!*")==0)<br style="line-height: 23px; ">&nbsp; return TRUE;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">if(WritePrivateProfileString(lpSection,lpKey,lpValue,m_strFileName))<br style="line-height: 23px; ">&nbsp; return FALSE;<br style="line-height: 23px; ">else<br style="line-height: 23px; ">&nbsp; return GetLastError();<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString CIni::GetValue(LPCTSTR lpSection, LPCTSTR lpKey)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; DWORD dValue;<br style="line-height: 23px; ">&nbsp; TCHAR lpValue[MAX_PATH] ={0};</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp; dValue=GetPrivateProfileString(lpSection,lpKey,"",lpValue,MAX_PATH,m_strFileName);<br style="line-height: 23px; ">&nbsp; return lpValue;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL CIni::DelSection(LPCTSTR lpSection)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; if(WritePrivateProfileString(lpSection,NULL,NULL,m_strFileName))<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; return FALSE;<br style="line-height: 23px; ">&nbsp; else<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; return GetLastError();<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL CIni::DelKey(LPCTSTR lpSection, LPCTSTR lpKey)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">if(WritePrivateProfileString(lpSection,lpKey,NULL,m_strFileName))<br style="line-height: 23px; ">&nbsp; return FALSE;<br style="line-height: 23px; ">else<br style="line-height: 23px; ">&nbsp; return GetLastError();<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">int CIni::GetSections(CStringArray&amp; arrSection)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">/*<br style="line-height: 23px; ">本函数基础：<br style="line-height: 23px; ">GetPrivateProfileSectionNames - 从 ini 文件中获得 Section 的名称<br style="line-height: 23px; ">如果 ini 中有两个 Section: [sec1] 和 [sec2]，则返回的是 'sec1',0,'sec2',0,0 ，当你不知道&nbsp;&nbsp;<br style="line-height: 23px; ">ini 中有哪些 section 的时候可以用这个 api 来获取名称&nbsp;<br style="line-height: 23px; ">*/<br style="line-height: 23px; ">int i;&nbsp;&nbsp;<br style="line-height: 23px; ">int iPos=0;&nbsp;&nbsp;<br style="line-height: 23px; ">int iMaxCount;<br style="line-height: 23px; ">TCHAR chSectionNames[MAX_ALLSECTIONS]={0}; //总的提出来的字符串<br style="line-height: 23px; ">TCHAR chSection[MAX_SECTION]={0}; //存放一个段名。<br style="line-height: 23px; ">GetPrivateProfileSectionNames(chSectionNames,MAX_ALLSECTIONS,m_strFileName);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">//以下循环，截断到两个连续的0<br style="line-height: 23px; ">for(i=0;i&lt;MAX_ALLSECTIONS;i++)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; if (chSectionNames[i]==0)<br style="line-height: 23px; ">&nbsp; if (chSectionNames[i]==chSectionNames[i+1])<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; break;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">iMaxCount=i+1; //要多一个0号元素。即找出全部字符串的结束部分。<br style="line-height: 23px; ">arrSection.RemoveAll();//清空原数组</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">for(i=0;i&lt;iMaxCount;i++)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; chSection[iPos++]=chSectionNames[i];<br style="line-height: 23px; ">&nbsp; if(chSectionNames[i]==0)<br style="line-height: 23px; ">&nbsp; {&nbsp;&nbsp;<br style="line-height: 23px; ">&nbsp; arrSection.Add(chSection);<br style="line-height: 23px; ">&nbsp; memset(chSection,0,MAX_SECTION);<br style="line-height: 23px; ">&nbsp; iPos=0;<br style="line-height: 23px; ">&nbsp; }<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">return (int)arrSection.GetSize();<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">int CIni::GetKeyValues(CStringArray&amp; arrKey,CStringArray&amp; arrValue, LPCTSTR lpSection)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">/*<br style="line-height: 23px; ">本函数基础：<br style="line-height: 23px; ">GetPrivateProfileSection- 从 ini 文件中获得一个Section的全部键名及值名<br style="line-height: 23px; ">如果ini中有一个段，其下有 "段1=值1" "段2=值2"，则返回的是 '段1=值1',0,'段2=值2',0,0 ，当你不知道&nbsp;&nbsp;<br style="line-height: 23px; ">获得一个段中的所有键及值可以用这个。&nbsp;<br style="line-height: 23px; ">*/<br style="line-height: 23px; ">int i;&nbsp;&nbsp;<br style="line-height: 23px; ">int iPos=0;<br style="line-height: 23px; ">CString strKeyValue;<br style="line-height: 23px; ">int iMaxCount;<br style="line-height: 23px; ">TCHAR chKeyNames[MAX_ALLKEYS]={0}; //总的提出来的字符串<br style="line-height: 23px; ">TCHAR chKey[MAX_KEY]={0}; //提出来的一个键名</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">GetPrivateProfileSection(lpSection,chKeyNames,MAX_ALLKEYS,m_strFileName);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">for(i=0;i&lt;MAX_ALLKEYS;i++)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; if (chKeyNames[i]==0)<br style="line-height: 23px; ">&nbsp; if (chKeyNames[i]==chKeyNames[i+1])<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; break;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">iMaxCount=i+1; //要多一个0号元素。即找出全部字符串的结束部分。<br style="line-height: 23px; ">arrKey.RemoveAll();//清空原数组<br style="line-height: 23px; ">arrValue.RemoveAll();</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">for(i=0;i&lt;iMaxCount;i++)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; chKey[iPos++]=chKeyNames[i];<br style="line-height: 23px; ">&nbsp; if(chKeyNames[i]==0)<br style="line-height: 23px; ">&nbsp; {<br style="line-height: 23px; ">&nbsp; strKeyValue=chKey;<br style="line-height: 23px; ">&nbsp; arrKey.Add(strKeyValue.Left(strKeyValue.Find("=")));<br style="line-height: 23px; ">&nbsp; arrValue.Add(strKeyValue.Mid(strKeyValue.Find("=")+1));<br style="line-height: 23px; ">&nbsp; memset(chKey,0,MAX_KEY);<br style="line-height: 23px; ">&nbsp; iPos=0;<br style="line-height: 23px; ">&nbsp; }</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">return (int)arrKey.GetSize();<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL CIni::DelAllSections()<br style="line-height: 23px; ">{<br style="line-height: 23px; ">int nSection;<br style="line-height: 23px; ">CStringArray arrSection;<br style="line-height: 23px; ">nSection=GetSections(arrSection);<br style="line-height: 23px; ">for(int i=0;i&lt;nSection;i++)<br style="line-height: 23px; ">{<br style="line-height: 23px; ">&nbsp; if(DelSection(arrSection[i]))<br style="line-height: 23px; ">&nbsp; return GetLastError();<br style="line-height: 23px; ">}<br style="line-height: 23px; ">return FALSE;<br style="line-height: 23px; ">}</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; "><br style="line-height: 23px; ">使用方法：<br style="line-height: 23px; ">CIni ini("c:\\a.ini");<br style="line-height: 23px; ">int n;</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*获得值<br style="line-height: 23px; ">TRACE("%s",ini.GetValue("段1","键1"));<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*添加值<br style="line-height: 23px; ">ini.SetValue("自定义段","键1","值");<br style="line-height: 23px; ">ini.SetValue("自定义段2","键1","值",false);<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*枚举全部段名<br style="line-height: 23px; ">CStringArray arrSection;<br style="line-height: 23px; ">n=ini.GetSections(arrSection);<br style="line-height: 23px; ">for(int i=0;i&lt;n;i++)<br style="line-height: 23px; ">TRACE("%s\n",arrSection[i]);<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*枚举全部键名及值<br style="line-height: 23px; ">CStringArray arrKey,arrValue;<br style="line-height: 23px; ">n=ini.GetKeyValues(arrKey,arrValue,"段1");<br style="line-height: 23px; ">for(int i=0;i&lt;n;i++)<br style="line-height: 23px; ">TRACE("键：%s\n值：%s\n",arrKey[i],arrValue[i]);<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*删除键值<br style="line-height: 23px; ">ini.DelKey("段1","键1");<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*删除段<br style="line-height: 23px; ">ini.DelSection("段1");<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">/*删除全部<br style="line-height: 23px; ">ini.DelAllSections();<br style="line-height: 23px; ">*/</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">操作配置文件ini<br style="line-height: 23px; ">1.基础知识<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp; INI文件（Initialization file ，又称为初始化文件）是用来保存应用程序设置和选项的一种特殊的ASCII文件，以&#8220;.ini&#8221;作为文件扩展名，也被称做配置文件或概要文件（Profile）。除了各个应用程序可以拥有自己私有的初始化文件外，Windows系统还提供有一个系统的初始化文件Win.ini，并由此对当前的Windows系统进行配置，同时也可以在其内记录系统内其他应用程序在运行时的选项。</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　　通常为应用程序所私有的初始化文件比较小，这样可以减少程序在初始化时所读取的信息量，从而提高程序的启动速度。而系统初始化文件Win.ini由于除了记录有关系统的大量信息外，还存储着许多其他应用软件的初始化数据，因此其通常比较庞大，访问的数据量要远比私有的配置文件大得多。如没有必要，一般不建议对Win.ini文件进行操作，但如果待存取的信息涉及到Windows系统环境或是其他应用程序时, 就必须对Win.ini进行读写访问，并在访问的同时发送WM_WININICHANGE消息给所有的顶层窗口，通知其他进程系统初始化文件已被更改。</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　　配置文件里的信息之所以能为系统和众多不同类型的应用程序读取并识别，是由于其内部对数据的存取采用了预先约定的&#8220;项-值对（Entry-value pairs）&#8221;存储结构, 并对待存取的数据分门别类地进行存储。下面是系统目录下Win.ini文件的部分内容：</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">[windows]&nbsp;<br style="line-height: 23px; ">load=&nbsp;<br style="line-height: 23px; ">run=&nbsp;<br style="line-height: 23px; ">NullPort=None&nbsp;<br style="line-height: 23px; ">[Desktop]&nbsp;<br style="line-height: 23px; ">WallpaperStyle=2&nbsp;<br style="line-height: 23px; ">Pattern=(无)&nbsp;</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp;&nbsp; 在此，配置文件将信息分为若干&#8220;节&#8221;，节标题放在方括号中，如&#8220;[Desktop]&#8221;就是Desktop节，在每一个节中包含了一些与之相关的&#8220;项&#8221;，并通过等号对其进行赋值。一般形式如下：</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">[SECTION]&nbsp;<br style="line-height: 23px; ">ENTRY=VALUE&nbsp;</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　　在初始化文件中，VALUE值只能有两种数据类型：数值和字符串。Windows分别为这两种数据类型提供了两套API函数对初始化文件进行数据读取，在写入初始化文件时则只支持对字符串的写入，数值等类型必须先进行数据类型的转换，然后才能写入到初始化文件。私有初始化文件的访问　　对私有初始化文件的数据存取是由GetPrivateProfileInt（）、GetPrivateProfileString（）和WritePrivateProfileString（）等三个API函数来完成的。其函数说明如下：</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">UINT GetPrivateProfileInt(LPCTSTR lpAppName, // 节名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpKeyName, // 项名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT nDefault,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 在项名没有找到时返回的缺省值<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpFileName // 初始化文件名地址<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">DWORD GetPrivateProfileString(LPCTSTR lpAppName, // 节名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpKeyName, // 项名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpDefault, // 缺省字符串<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPTSTR lpReturnedString, // 存放字符串的缓冲区地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DWORD nSize, // 缓冲区大小<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpFileName // 初始化文件名地址<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL WritePrivateProfileString(LPCTSTR lpAppName, // 节名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpKeyName, // 项名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpString,&nbsp; // 要写入的字符串地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpFileName // 初始化文件名地址<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 其中，GetPrivateProfileInt（）返回的是初始化文件lpFileName中lpAppName节内lpKeyName项的整数值，如果没有找到该项则返回缺省值nDefault。如果此项目存在，但值不为整数，则返回0。如果某项目的值中含有非数字字符则只返回第一个非数字前的字符，例如对于&#8220;Value = 21century&#8221;则只返回数值21。初始化文件名lpFileName可以是全路径也可以只是文件名，如果不指定具体路径，Windows系统将在系统目录对文件进行寻找。GetPrivateProfileString（）和WritePrivateProfileString（）的用法基本与之类似，只是处理对象的数据类型不同。</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">2 知识应用<br style="line-height: 23px; ">　　私有初始化文件主要用来保存同应用程序当前状态相关的一些信息，当程序退出后，这些信息由于已写入到初始化文件而得以保留，当程序再次运行时，可以通过对此初始化文件各项数据的读取而得知此应用程序在上次运行期间的相关信息。下面这段代码即通过对私有初始化文件的访问而对程序的运行次数和上一次的运行日期进行记录：</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString sPath,sMsg,sTime,sDate;<br style="line-height: 23px; ">char buffer[255];</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 获取当前应用程序全路径<br style="line-height: 23px; ">GetModuleFileName(NULL, buffer, MAX_PATH);<br style="line-height: 23px; ">sPath = CString(buffer);<br style="line-height: 23px; ">sPath = sPath.Left(sPath.ReverseFind('\\'));</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 得到初始化文件的全路径<br style="line-height: 23px; ">sPath += "\\Sample04.ini";</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 得到程序累计运行次数<br style="line-height: 23px; ">UINT Time = GetPrivateProfileInt("PROGRAM", "RUNTIME", 0, sPath);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 得到上次运行日期<br style="line-height: 23px; ">GetPrivateProfileString("DATE", "LAST", "2002-11-1", buffer, 1000, sPath);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 显示从初始化文件获取到的文件信息<br style="line-height: 23px; ">sMsg.Format("本软件共运行过%d次,上次运行日期为%s", Time, CString(buffer));<br style="line-height: 23px; ">AfxMessageBox(sMsg);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 累加运行次数,并保存到初始化文件<br style="line-height: 23px; ">Time++;<br style="line-height: 23px; ">sTime.Format("%d", Time);<br style="line-height: 23px; ">WritePrivateProfileString("PROGRAM", "RUNTIME", sTime, sPath);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 获取当前日期,并保存到初始化文件<br style="line-height: 23px; ">CTime tm = CTime::GetCurrentTime();<br style="line-height: 23px; ">sDate.Format("%d-%d-%d", tm.GetYear(), tm.GetMonth(), tm.GetDay());<br style="line-height: 23px; ">WritePrivateProfileString("DATE", "LAST", sDate, sPath);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">在程序执行后，初始化文件Sample04.ini的内容为：<br style="line-height: 23px; ">[DATE]<br style="line-height: 23px; ">LAST =2002-11-12<br style="line-height: 23px; ">[PROGRAM]<br style="line-height: 23px; ">RUNTIME =1</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp;　　系统目录下的Win.ini是一种特殊的初始化文件，主要为系统提供初始化服务，在系统启动时将被系统所访问，并根据其所保存的参数值对系统进行配置。Windows专门提供了三个API函数GetProfileInt（）、GetProfileString（）和WriteProfileString（）对Win.ini进行读写访问，其函数用法同访问私有初始化文件的那几个函数非常类似，只是不必再去指定初始化文件名。下面是这三个函数的原型声明：</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">UINT GetProfileInt(LPCTSTR lpAppName, // 节名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpKeyName, // 项名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT nDefault // 在项名没有找到时返回的缺省值<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">DWORD GetProfileString(LPCTSTR lpAppName, // 节名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpKeyName, // 项名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpDefault, // 缺省字符串地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPTSTR lpReturnedString, // 存放字符串的缓存的地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DWORD nSize // 缓存的大小<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">BOOL WriteProfileString(LPCTSTR lpAppName, // 节名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpKeyName, // 项名地址<br style="line-height: 23px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPCTSTR lpString&nbsp;&nbsp; // 要写入字符串的地址<br style="line-height: 23px; ">);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp;</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">　　只要对前面对私有初始化文件进行访问的代码稍加改动即可将程序的配置信息添加到Win.ini中，改动后的代码如下：</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">CString sPath,sMsg,sTime,sDate;</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 得到程序累计运行次数<br style="line-height: 23px; ">UINT Time = GetProfileInt("PROGRAM", "RUNTIME", 0);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 得到上次运行日期<br style="line-height: 23px; ">GetProfileString("DATE", "LAST", "2002-11-1", buffer, 1000);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 显示从初始化文件获取到的文件信息<br style="line-height: 23px; ">sMsg.Format("本软件共运行过%d次,上次运行日期为%s", Time, CString(buffer));<br style="line-height: 23px; ">AfxMessageBox(sMsg);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 累加运行次数,并保存到初始化文件<br style="line-height: 23px; ">Time++;<br style="line-height: 23px; ">sTime.Format("%d", Time);<br style="line-height: 23px; ">WriteProfileString("PROGRAM", "RUNTIME", sTime);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">// 获取当前日期,并保存到初始化文件<br style="line-height: 23px; ">CTime tm = CTime::GetCurrentTime();<br style="line-height: 23px; ">sDate.Format("%d-%d-%d", tm.GetYear(), tm.GetMonth(), tm.GetDay());<br style="line-height: 23px; ">WriteProfileString("DATE", "LAST", sDate);</p><p style="line-height: 23px; color: rgb(40, 71, 85); margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; ">&nbsp;&nbsp; 由于Win.ini文件是系统初始化文件，在程序没有运行前文件内不含&#8220;DATE&#8221;和&#8220;PROGRAM&#8221;等自定义的节以及其下各项，因此在程序第一次执行后，将由WriteProfileString（）函数向Win.ini文件末尾创建相关节、项，并完成数据的写入。<br style="line-height: 23px; "></p><div style="line-height: 23px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); "><div class="shareToTblog" style="line-height: 21px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); width: 128px; height: 33px; overflow-x: hidden; overflow-y: hidden; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 12px; float: right; "><a href="http://leapfish.blog.sohu.com/60685388.html" entrytitle="VC++ ini文件操作" data-sharetype="31" data-title="#{@entryTitle}" data-url="http://leapfish.blog.sohu.com/60685388.html" data-abstracts="#{#main-content@innerText&lt;51}" data-ext="{v:'1',xpt:'#{$_xpt}'}" id="shareMenuButton1" style="line-height: 12px; color: rgb(51, 51, 51); font: normal normal normal 12px/normal Verdana, Arial, Helvetica, 宋体, sans-serif; text-decoration: none; background-image: url(http://js2.pp.sohu.com.cn/ppp/blog/themes_ppp_v_100827/def/i/tblog-icon.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; padding-top: 12px; padding-right: 0px; padding-bottom: 0px; padding-left: 36px; display: block; float: left; width: 96px; height: 20px; background-position: 0px 0px; background-repeat: no-repeat no-repeat; ">分享到搜狐微博</a></div></div><div class="clear" style="line-height: 23px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); clear: both; visibility: hidden; "></div><div class="pn_na" style="line-height: 23px; margin-top: 0px; margin-right: auto; margin-bottom: 15px; margin-left: auto; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); height: 15px; "><div class="previous" style="line-height: 23px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; border-style: initial; border-color: initial; color: rgb(40, 71, 85); float: left; height: 15px; text-align: left; "></div></div></div></div></span>
<img src ="http://www.cppblog.com/dfghj44444/aggbug/127890.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/dfghj44444/" target="_blank">叫我老王吧</a> 2010-09-27 18:14 <a href="http://www.cppblog.com/dfghj44444/archive/2010/09/27/127890.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Doxygen+Graphviz 帮助</title><link>http://www.cppblog.com/dfghj44444/archive/2010/09/08/126164.html</link><dc:creator>叫我老王吧</dc:creator><author>叫我老王吧</author><pubDate>Wed, 08 Sep 2010 07:45:00 GMT</pubDate><guid>http://www.cppblog.com/dfghj44444/archive/2010/09/08/126164.html</guid><wfw:comment>http://www.cppblog.com/dfghj44444/comments/126164.html</wfw:comment><comments>http://www.cppblog.com/dfghj44444/archive/2010/09/08/126164.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/dfghj44444/comments/commentRss/126164.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/dfghj44444/services/trackbacks/126164.html</trackback:ping><description><![CDATA[<div class="tit" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 20px !important; background-image: url(http://imgsrc.baidu.com/css/pic/item/365aa007813ec5e17a894706.jpg); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; padding-left: 30px; font-weight: bold; overflow-x: hidden; overflow-y: hidden; background-repeat: no-repeat no-repeat; ">Doxygen+Graphviz 帮助</div><div class="date" style="font-family: Georgia; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 11px; line-height: 20px !important; margin-top: 10px; margin-right: 20px; margin-bottom: 10px; margin-left: 0px; color: rgb(157, 157, 157); text-align: right; ">2010-02-02 10:33</div><table style="line-height: 20px !important; table-layout: fixed; font-family: Arial; font-size: 12px; width: 927px; "><tbody style="line-height: 20px !important; "><tr style="line-height: 20px !important; "><td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: 20px !important; "><div id="blog_text" class="cnt" style="font-family: Tahoma; word-wrap: break-word; word-break: normal; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: 20px; color: rgb(85, 85, 85); overflow-x: hidden; overflow-y: hidden; position: static; "><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@class 声明一个类</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@fn 声明一个函数</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@brief 简要说明</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">/**<br style="line-height: normal; ">@file RenderMgr.h<br style="line-height: normal; ">@brief 渲染管理类<br style="line-height: normal; ">@date 3/16/2006<br style="line-height: normal; ">@author lethean<br style="line-height: normal; ">*/</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@param 声明一个参数</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@note 注解</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@par paragraph，自定义一个段落标题，类似html中&lt;p&gt;</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@code 代码示例，需要用@endcode封闭，代码段中不需要加前置*号</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "><br style="line-height: normal; ">/**<br style="line-height: normal; ">@brief 读取bmp文件<br style="line-height: normal; ">@remarks 测试一下<br style="line-height: normal; ">@param [in] dc 传入一个dc用于临时操作<br style="line-height: normal; ">@param [in] filename bmp文件名<br style="line-height: normal; ">@note 屏幕dc只能在一处被使用，请确保传入屏幕dc后其他地方不会操作该dc<br style="line-height: normal; ">@par 代码示例:<br style="line-height: normal; ">@code<br style="line-height: normal; ">&nbsp;&nbsp; //使用<br style="line-height: normal; ">&nbsp;&nbsp; CDC* dc = AfxGetMainWindow()-&gt;GetDC();<br style="line-height: normal; ">&nbsp;&nbsp; Bitmap bmp( dc , "test.bmp");<br style="line-height: normal; ">&nbsp;&nbsp; AfxGetMainWindow()-&gt;ReleaseDC( dc );<br style="line-height: normal; ">@endcode<br style="line-height: normal; ">*/</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">对于单行的前置注释可以用///，或者/** blahblah */ 样式</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">///我是一个变量</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">int index;</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">对于单行的后置注释，需要加一个"&lt;"符号</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">int count; ///&lt; 我也是</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">/** 协议标识 */<br style="line-height: normal; ">enum ProtoId {&nbsp;<br style="line-height: normal; ">PROTOID_LOGIN, /**&lt; 登陆协议*/<br style="line-height: normal; ">PROTOID_BROWSE, /**&lt; 浏览协议*/<br style="line-height: normal; ">};</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@defgroup是用来定义新模块的</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">集中在某个头文件中定义所有的模块，然后在属于这个模块的类定义处使用@ingroup</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">EnginePrerequisite.h中</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">/**&nbsp;<br style="line-height: normal; ">@defgroup Render Render渲染模块<br style="line-height: normal; ">@defgroup Resource Resource管理模块<br style="line-height: normal; ">@defgroup Sound Sound声音模块<br style="line-height: normal; ">@defgroup Anim Anim动画模块<br style="line-height: normal; ">@defgroup Math Math数学库模块<br style="line-height: normal; ">@defgroup Script Script脚本模块<br style="line-height: normal; ">*/</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">RenderMgr.h中</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">/**</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@class RenderMgr</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">@ingroup Render</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; ">*/</div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "></div><div style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; "><p style="line-height: normal; "><strong style="line-height: normal; "><span style="line-height: normal; color: blue; ">JavaDoc</span></strong><strong style="line-height: normal; "><span style="line-height: normal; ">类型：</span><span style="line-height: normal; color: blue; "></span></strong></p><p style="line-height: normal; "><span style="line-height: normal; ">/**</span></p><p style="line-height: normal; "><span style="line-height: normal; ">* ...&nbsp;</span><span style="line-height: normal; ">程序注释</span><span style="line-height: normal; ">&nbsp;...</span></p><p style="line-height: normal; "><span style="line-height: normal; ">*/</span></p><p style="line-height: normal; "><strong style="line-height: normal; "><span style="line-height: normal; color: blue; ">Qt</span></strong><strong style="line-height: normal; "><span style="line-height: normal; ">类型：</span><span style="line-height: normal; color: blue; "></span></strong></p><p style="line-height: normal; "><span style="line-height: normal; ">/*!</span></p><p style="line-height: normal; "><span style="line-height: normal; ">* ...&nbsp;</span><span style="line-height: normal; ">程序注释</span><span style="line-height: normal; ">...</span></p><p style="line-height: normal; "><span style="line-height: normal; ">*/<span style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></span></p><p style="line-height: normal; "><strong style="line-height: normal; "><span style="line-height: normal; ">单行型式：</span><span style="line-height: normal; color: blue; "></span></strong></p><p style="line-height: normal; "><span style="line-height: normal; ">///&nbsp;</span><span style="line-height: normal; ">这是一个简洁型的注释</span></p><p style="line-height: normal; "><span style="line-height: normal; ">//!&nbsp;</span><span style="line-height: normal; ">这也是一个简洁型的注释</span></p><p style="line-height: normal; "><span style="line-height: normal; ">用</span><span style="line-height: normal; ">Doxygen</span><span style="line-height: normal; ">的这几种基本注释类型就可以建立足以建立文档了，如果需要更多复杂功能，</span><span style="line-height: normal; ">Doxygen</span><span style="line-height: normal; ">还可以提供高级格式如组（</span><span style="line-height: normal; ">group</span><span style="line-height: normal; ">）和列表。</span></p><p style="line-height: normal; "><span style="line-height: normal; ">Doxygen</span><span style="line-height: normal; ">的常用注释参数：</span></p><p style="line-height: normal; "></p><table border="1" cellspacing="0" cellpadding="0" align="left" style="line-height: normal; table-layout: auto; border-bottom-width: medium; border-bottom-style: none; border-bottom-color: initial; border-left-width: medium; border-left-style: none; border-left-color: initial; border-collapse: collapse; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-width: medium; border-right-style: none; border-right-color: initial; width: 921px; "><tbody style="line-height: normal; "><tr style="line-height: normal; "><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-color: windowtext; border-left-width: 0.5pt; border-left-style: solid; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-color: windowtext; border-top-width: 0.5pt; border-top-style: solid; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@file</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-width: medium; border-left-style: none; border-left-color: initial; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-color: windowtext; border-top-width: 0.5pt; border-top-style: solid; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; ">档案的批注说明。</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td></tr><tr style="line-height: normal; "><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-color: windowtext; border-left-width: 0.5pt; border-left-style: solid; padding-bottom: 0cm; padding-left: 1.5pt; width: 272px; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@author</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-width: medium; border-left-style: none; border-left-color: initial; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; ">作者的信息</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td></tr><tr style="line-height: normal; "><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-color: windowtext; border-left-width: 0.5pt; border-left-style: solid; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@brief</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-width: medium; border-left-style: none; border-left-color: initial; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; ">用于</span><span style="line-height: normal; font-size: 9pt; ">class&nbsp;</span><span style="line-height: normal; ">或</span><span style="line-height: normal; font-size: 9pt; ">function</span><span style="line-height: normal; ">的批注中，后面为</span><span style="line-height: normal; font-size: 9pt; ">class&nbsp;</span><span style="line-height: normal; ">或</span><span style="line-height: normal; font-size: 9pt; ">function</span><span style="line-height: normal; ">的简易说明。</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td></tr><tr style="line-height: normal; "><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-color: windowtext; border-left-width: 0.5pt; border-left-style: solid; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@param</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-width: medium; border-left-style: none; border-left-color: initial; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; ">格式为</span><span style="line-height: normal; font-size: 9pt; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@param arg_name&nbsp;</span><span style="line-height: normal; ">参数说明</span><span style="line-height: normal; font-size: 9pt; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "><span style="line-height: normal; ">主要用于函式说明中，后面接参数的名字，然后再接关于该参数的说明。</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td></tr><tr style="line-height: normal; "><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-color: windowtext; border-left-width: 0.5pt; border-left-style: solid; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@return</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-width: medium; border-left-style: none; border-left-color: initial; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; ">后面接函数传回值的说明。用于</span><span style="line-height: normal; font-size: 9pt; ">function</span><span style="line-height: normal; ">的批注中。说明该函数的传回值。</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td></tr><tr style="line-height: normal; "><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-color: windowtext; border-left-width: 0.5pt; border-left-style: solid; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@retval</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td><td valign="top" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: normal; border-bottom-color: windowtext; border-bottom-width: 0.5pt; border-bottom-style: solid; border-left-width: medium; border-left-style: none; border-left-color: initial; padding-bottom: 0cm; padding-left: 1.5pt; padding-right: 1.5pt; border-top-width: medium; border-top-style: none; border-top-color: initial; border-right-color: windowtext; border-right-width: 0.5pt; border-right-style: solid; padding-top: 0cm; "><p style="line-height: normal; "><span style="line-height: normal; ">格式为</span><span style="line-height: normal; font-size: 9pt; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "><span style="line-height: normal; font-size: 9pt; ">@retval value&nbsp;</span><span style="line-height: normal; ">传回值说明</span><span style="line-height: normal; font-size: 9pt; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "><span style="line-height: normal; ">主要用于函式说明中，说明特定传回值的意义。所以后面要先接一个传回值。然后在放该传回值的说明。</span><span style="line-height: normal; "></span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p></td></tr></tbody></table><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "><span style="line-height: normal; ">Doxygen</span><span style="line-height: normal; ">的使用，如下：</span></p><p style="line-height: normal; "><span style="line-height: normal; ">E:\&gt;xstring</span><span style="line-height: normal; ">目录包含下列文件：</span></p><p style="line-height: normal; "><span style="line-height: normal; ">Xstring.cpp</span></p><p style="line-height: normal; "><span style="line-height: normal; ">Xstring.h</span></p><p style="line-height: normal; "><span style="line-height: normal; ">其中</span><span style="line-height: normal; ">xstring.h</span><span style="line-height: normal; ">里对</span><span style="line-height: normal; ">xstring</span><span style="line-height: normal; ">类的</span><span style="line-height: normal; ">StrToInt</span><span style="line-height: normal; ">方法的注释如下：</span></p><p style="line-height: normal; "><span style="line-height: normal; "><span style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>/**</span></p><p style="line-height: normal; "><span style="line-height: normal; "><span style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>*</span></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; "></p><p style="line-height: normal; ">0. 序言<br style="line-height: normal; ">为代码写注释一直是大多数程序员有些困扰的事情。当前程序员都能接受为了程序的可维护性、可读性编码的同时写注释的说法，但对哪些地方应该写注释，注释如何写，写多少等这些问题，很多程序员仍然没有答案。更头痛的是写文档，以及维护文档的问题，开发人员通常可以忍受编写或者改动代码时编写或者修改对应的注释，但之后需要修正相应的文档却比较困难。如果能从注释直接转化成文档，对开发人员无疑是一种福音。而doxygen就能把遵守某种格式的注释自动转化为对应的文档。</p><p style="line-height: normal; ">Doxygen是基于GPL的开源项目，是一个非常优秀的文档系统，当前支持在大多数unix（包括linux），windows家族，Mac系统上运行，完全支持C++, C, Java, IDL（Corba和Microsoft 家族）语言，部分支持PHP和C#语言，输出格式包括HTML、latex、RTF、ps、PDF、压缩的HTML和unix manpage。有很多开源项目（包括前两篇文章介绍的log4cpp和CppUnit）都使用了doxygen文档系统。而国内的开发人员却使用的不多，这里从开发人员使用的角度介绍这个工具，使开发人员用最少的代价尽快掌握这种技术，并结合这个工具探讨如何撰写注释的问题。以下以linux下的C++语言为例进行介绍，以下讨论基于doxygen1.3.3。</p><p style="line-height: normal; ">1. doxygen使用步骤<br style="line-height: normal; ">由于只是工具的使用，这里不介绍它的原理，直接从使用步骤开始。Doxygen的使用步骤非常简单。主要可以分为：<br style="line-height: normal; ">1）第一次使用需要安装doxygen的程序<br style="line-height: normal; ">2）生成doxygen配置文件<br style="line-height: normal; ">3）编码时，按照某种格式编写注释<br style="line-height: normal; ">4）生成对应文档<br style="line-height: normal; ">doxygen的安装非常简单， linux下可以直接下载安装包运行即可，下载源代码编译安装也是比较通用的编译安装命令。请参考其安装文档完成安装。</p><p style="line-height: normal; ">Doxygen在生成文档时可以定义项目属性以及文档生成过程中的很多选项，使用下面命令能够产生一个缺省的配置文件：<br style="line-height: normal; ">doxygen -g [配置文件名]<br style="line-height: normal; ">可以根据项目的具体需求修改配置文件中对应的项，具体的修改过程在下面介绍。修改过的配置文件可以作为以后项目的模板。</p><p style="line-height: normal; ">让doxygen自动产生文档，平常的注释风格可不行，需要遵循doxygen自己的格式。具体如何写doxygen认识的注释在第3节详细介绍。</p><p style="line-height: normal; ">OK，代码编完了，注释也按照格式写好了，最后的文档是如何的哪？非常简单，运行下面的命令，相应的文档就会产生在指定的目录中。<br style="line-height: normal; ">&nbsp;&nbsp; doxygen [配置文件名]</p><p style="line-height: normal; ">需要注意的是doxygen并不处理所有的注释，doxygen重点关注与程序结构有关的注释，比如：文件、类、结构、函数、变量、宏等注释，而忽略函数内变量、代码等的注释。</p><p style="line-height: normal; ">2. doxygen配置文件<br style="line-height: normal; ">doxygen配置文件的格式是也是通常的unix下配置文件的格式：注释'#'开始；tag = value [,value2&#8230;]；对于多值的情况可以使用 tag += value [,value2&#8230;]。</p><p style="line-height: normal; ">对doxygen的配置文件的修改分为两类：一种就是输出选项，控制如何解释源代码、如何输出；一种就是项目相关的信息，比如项目名称、源代码目录、输出文档目录等。对于第一种设置好后，通常所有项目可以共用一份配置，而后一种是每个项目必须设置的。下面选择重要的，有可能需要修改的选项进行解释说明，其他选项在配置文件都有详细解释。</p><p style="line-height: normal; ">TAG 缺省值 含义<br style="line-height: normal; ">PROJECT_NAME&nbsp;&nbsp; 项目名称<br style="line-height: normal; ">PROJECT_NUMBER&nbsp;&nbsp; 可以理解为版本信息<br style="line-height: normal; ">OUTPUT_DIRECTORY&nbsp;&nbsp; 输出文件到的目录，相对目录（doxygen运行目录）或者绝对目录<br style="line-height: normal; ">INPUT&nbsp;&nbsp; 代码文件或者代码所在目录，使用空格分割<br style="line-height: normal; ">FILE_PATTERNS *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp *.h++ *.idl *.odl 指定INPUT的目录中特定文件，如：*.cpp *.c *.h&nbsp;<br style="line-height: normal; ">RECURSIVE NO 是否递归INPUT中目录的子目录<br style="line-height: normal; ">EXCLUDE&nbsp;&nbsp; 在INPUT目录中需要忽略的子目录<br style="line-height: normal; ">EXCLUDE_PATTERNS&nbsp;&nbsp; 明确指定的在INPUT目录中需要忽略的文件，如：FromOut*.cpp<br style="line-height: normal; ">&nbsp;&nbsp;<br style="line-height: normal; ">OUTPUT_LANGUAGE English 生成文档的语言，当前支持2、30种语言，国内用户可以设置为Chinese<br style="line-height: normal; ">USE_WINDOWS_ENCODING YES（win版本）<br style="line-height: normal; ">NO（unix版本） 编码格式，默认即可。<br style="line-height: normal; ">EXTRACT_ALL NO 为NO，只解释有doxygen格式注释的代码；为YES，解析所有代码，即使没有注释。类的私有成员和所有的静态项由EXTRACT_PRIVATE和 EXTRACT_STATIC控制<br style="line-height: normal; ">EXTRACT_PRIVATE NO 是否解析类的私有成员<br style="line-height: normal; ">EXTRACT_STATIC NO 是否解析静态项<br style="line-height: normal; ">EXTRACT_LOCAL_CLASSES YES 是否解析源文件（cpp文件）中定义的类<br style="line-height: normal; ">SOURCE_BROWSER NO 如果为YES，源代码文件会被包含在文档中<br style="line-height: normal; ">INLINE_SOURCES NO 如果为YES，函数和类的实现代码被包含在文档中<br style="line-height: normal; ">ALPHABETICAL_INDEX NO 生成一个字母序的列表，有很多类、结构等项时建议设为YES<br style="line-height: normal; ">GENERATE_HTML YES 是否生成HTML格式文档<br style="line-height: normal; ">GENERATE_HTMLHELP NO 是否生成压缩HTML格式文档（.chm）<br style="line-height: normal; ">GENERATE_LATEX YES 是否乘车latex格式的文档<br style="line-height: normal; ">GENERATE_RTF NO 是否生成RTF格式的文档<br style="line-height: normal; ">GENERATE_MAN NO 是否生成man格式文档<br style="line-height: normal; ">GENERATE_XML NO 是否生成XML格式文档<br style="line-height: normal; ">&nbsp;&nbsp;</p><p style="line-height: normal; ">3. doxygen注释<br style="line-height: normal; ">3.1 注释风格<br style="line-height: normal; ">下面是工作量最大部分，安装doxygen格式写注释。通常代码可以附上一个注释块来对代码进行解释，一个注释块由一行或者多行组成。通常一个注释块包括一个简要说明（brief）和一个详细说明（detailed），这两部分都是可选的。可以有多种方式标识出doxygen可识别的注释块。<br style="line-height: normal; ">1）JavaDoc类型的多行注释。<br style="line-height: normal; ">/**<br style="line-height: normal; ">* &#8230;.text&#8230;.<br style="line-height: normal; ">*/<br style="line-height: normal; ">2）QT样式的多行注释。<br style="line-height: normal; ">/*!<br style="line-height: normal; ">&#8230;.text&#8230;.<br style="line-height: normal; ">*/<br style="line-height: normal; ">3） /// &#8230;text&#8230;.<br style="line-height: normal; ">4） //! &#8230;text&#8230;.<br style="line-height: normal; ">简要说明有多种方式标识，这里推荐使用@brief命令强制说明，例如：<br style="line-height: normal; ">/**<br style="line-height: normal; ">* @brief [some brief description ]<br style="line-height: normal; ">*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [ brief description more. ]<br style="line-height: normal; ">*&nbsp;<br style="line-height: normal; ">* [some more detailed description&#8230;]<br style="line-height: normal; ">*/<br style="line-height: normal; ">以上这些注释格式用来对紧跟其后的代码进行注释。doxygen也允许把注释放到代码后面，具体格式是放一个'&lt;'到注释开始部分。例如：<br style="line-height: normal; ">int var1 ; /**&lt; &#8230;.text&#8230;. */<br style="line-height: normal; ">int var2; ///&lt; &#8230;.text&#8230;.</p><p style="line-height: normal; ">注释和代码完全分离，放在其他地方也是允许的，但需要使用特殊的命令加上名称或者声明进行标识，比如：class、struct、union、enum、fn、var、def、file、namespace、package、interface（这些也就是doxygen关注的注释类型）。这里不推荐使用，建议注释尽量放在代码前后。具体使用方式参见doxygen手册。</p><p style="line-height: normal; ">3.2 doxygen常用注释格式<br style="line-height: normal; ">通常的选择上面的一、两种注释风格，遇到头文件中各种类型定义，关键变量、宏的定义，在其前或者后使用 @brief 定义其简要说明，空一行后继续写其详细的注释即可。</p><p style="line-height: normal; ">对函数的注释，是比较常常需要注释的部分。除了定义其简要说明以及详细注释，还可以使用param命令对其各个参数进行注释，使用return命令对返回值进行注释。常见的格式如下：<br style="line-height: normal; ">/**<br style="line-height: normal; "><a href="mailto:*@brief" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">*@brief</font></a>&nbsp;func's brief comment.<br style="line-height: normal; ">*<br style="line-height: normal; ">* Some detailed comment.<br style="line-height: normal; "><a href="mailto:*@param" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">*@param</font></a>&nbsp;a [param a 's comment.]<br style="line-height: normal; "><a href="mailto:*@param" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">*@param</font></a>&nbsp;b [param b 's comment.]<br style="line-height: normal; "><a href="mailto:*@exception" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">*@exception</font></a>&nbsp;std::out_of_range [exception's comment.]<br style="line-height: normal; "><a href="mailto:*@return" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">*@return</font></a>&nbsp;[return's comment.]<br style="line-height: normal; ">*/<br style="line-height: normal; ">int func1(int a, int b);</p><p style="line-height: normal; ">进行设计时，通常有模块的概念，一个模块可能有多个类或者函数组成，完成某个特定功能的代码的集合。如何对这个概念进行注释？doxygen提供了group的概念，生成的模块的注释会单独放在一个模块的页面中。使用下面的格式定义一个group。<br style="line-height: normal; ">/** [group_name] [brief group description ]<br style="line-height: normal; ">* detailed group description ]<br style="line-height: normal; ">* @{<br style="line-height: normal; ">*/<br style="line-height: normal; ">code<br style="line-height: normal; ">/** @} */<br style="line-height: normal; ">group中的代码可以有自己的注释。单纯定义一个模块，去除{ 和}命令即可。任何其他代码项（比如类、函数、甚至文件）如果要加入到某个模块，可以在其doxygen注释中使用ingroup命令即可。Group之间使用ingroup命令，可以组成树状关系。<br style="line-height: normal; ">/** @file util.cpp&nbsp;<br style="line-height: normal; ">* @ingroup [group_name]<br style="line-height: normal; ">* @brief file's brief info.<br style="line-height: normal; ">*/<br style="line-height: normal; ">把多个代码项一起添加到某个模块中可以使用addtogroup命令，格式和defgroup相似。</p><p style="line-height: normal; ">对于某几个功能类似的代码项（比如类、函数、变量）等，如果希望一起添加注释，而又不想提升到模块的概念，可以通过下面的方式：<br style="line-height: normal; ">//@{<br style="line-height: normal; ">/** Comments for all below code. */<br style="line-height: normal; ">code&#8230;<br style="line-height: normal; ">//@}<br style="line-height: normal; ">对这种组进行命名可以使用name命令。此时中间代码可以有自己的注释。如：<br style="line-height: normal; ">/** @name group_name<br style="line-height: normal; ">* description for group.<br style="line-height: normal; ">*/<br style="line-height: normal; ">//@{<br style="line-height: normal; ">code&#8230;<br style="line-height: normal; ">//@}</p><p style="line-height: normal; ">3.3 doxygen常用注释命令<br style="line-height: normal; ">doxygen通过注释命令识别注释中需要特殊处理的注释，比如函数的参数、返回值进行突出显示。上面也提到了一些注释命令（如：brief、param、return、以及group相关的命令），下面对其他一些常用的注释命令进行解释说明。<br style="line-height: normal; ">@exception &lt;exception-object&gt; {exception description} 对一个异常对象进行注释。<br style="line-height: normal; ">@warning {warning message } 一些需要注意的事情<br style="line-height: normal; ">@todo { things to be done } 对将要做的事情进行注释<br style="line-height: normal; ">@see {comment with reference to other items } 一段包含其他部分引用的注释，中间包含对其他代码项的名称，自动产生对其的引用链接。<br style="line-height: normal; ">@relates &lt;name&gt; 通常用做把非成员函数的注释文档包含在类的说明文档中。<br style="line-height: normal; ">@since {text} 通常用来说明从什么版本、时间写此部分代码。<br style="line-height: normal; ">@deprecated<br style="line-height: normal; ">@pre { description of the precondition } 用来说明代码项的前提条件。<br style="line-height: normal; ">@post { description of the postcondition } 用来说明代码项之后的使用条件。<br style="line-height: normal; ">@code 在注释中开始说明一段代码，直到@endcode命令。<br style="line-height: normal; ">@endcode 注释中代码段的结束。</p><p style="line-height: normal; ">到此为止，常用的doxygen的注释格式讨论完毕，我们能够按照一定的格式撰写doxygen认识的注释，并能够使用doxygen方便快捷的生成对应的文档，不过注释中应该写些什么，如何撰写有效的注释可能是困扰开发人员的一个更深层次的问题。</p><p style="line-height: normal; ">4. 注释的书写<br style="line-height: normal; ">注释应该怎么写，写多还是写少。过多的注释甚至会干扰对代码的阅读。写注释的一个总的原则就是注释应该尽量用来表明作者的意图，至少也应该是对一部分代码的总结，而不应该是对代码的重复或者解释。对代码的重复或者解释的代码，看代码可能更容易理解。反映作者意图的注释解释代码的目的，从解决问题的层次上进行注释，而代码总结性注释则是从问题的解答的层次上进行注释。</p><p style="line-height: normal; ">推荐的写注释的过程是首先使用注释勾勒出代码的主要框架，然后根据注释撰写相应的代码。对各种主要的数据结构、输出的函数、多个函数公用的变量进行详细地注释。对代码中控制结构，单一目的的语句集进行注释。下面是一些写注释时需要注意的要点：<br style="line-height: normal; ">&nbsp;&nbsp; 避免对单独语句进行注释；<br style="line-height: normal; ">&nbsp;&nbsp; 通过注释解释为什么这么做、或者要做什么，使代码的读者可以只阅读注释理解代码；<br style="line-height: normal; ">&nbsp;&nbsp; 对读者可能会有疑问的地方进行注释；<br style="line-height: normal; ">&nbsp;&nbsp; 对数据定义进行注释，而不是对其使用过程进行注释；<br style="line-height: normal; ">&nbsp;&nbsp; 对于难于理解的代码，进行改写，而不要试图通过注释加以说明；<br style="line-height: normal; ">&nbsp;&nbsp; 对关键的控制结构进行注释；<br style="line-height: normal; ">&nbsp;&nbsp; 对数据和函数的边界、使用前提等进行注释；</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 虽然使用各种IDE或者Source Insight 可以方便地在windows下阅读和分析C/C++代码，但是一步步Go to Definetion 实在令人痛苦。Doxygen能够生成函数调用关系图，所有的函数调用关系可以一目了然，另外他还能统计文档中所有的类，成员变量，成员函数等。总的来说，Doxygen不但能从局部把握代码，还能从全局审视代码，后者是一般IDE和Source Insight 不能做到的。所以，使用doxygen阅读分析代码可以达到事半功倍的效果。</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doxygen的安装很简单，到官方网站下载doxygen的windows安装程序即可。除了安装doxygen外，还需要安装graphviz，因为doxygen需要使用graphviz的dot.exe生成调用图。graphviz在它的官方网站上也可以下载到安装程序。不过我下载的安装程序在安装时老是报cab文件错误。最后我下载了graphviz的release文件，即安装程序下面的zip压缩文件，下载完成后解压缩即可。</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 安装完doxygen后即可进行适当的配置，然后运行doxyfile生成文档。基本的配置前人早有说明，不再赘述。需要注意的是：</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.要勾选Dot选项卡下面的HAVE_DOT、CALL_GRAPH 、CALLER_GRAPH 选项。并在DOT_PATH下面填入dot.exe的路径，也就是graphviz安装目录下的bin文件夹。</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.勾选Wizard-&gt;Project选项卡下面的Scan recursively！</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.勾选Build选项卡下面的EXTRACT_ALL、EXTRACT_PRIVATE、EXTRACT_STATIC、EXTRACT_LOCAL_CLASSES、EXTRACT_LOCAL_METHODS选项</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.如果程序里面有中文，将Project选项卡下的DOXYFILE_ENCODING和Input选项卡下面的INPUT_ENCODING改为GBK</p><p style="line-height: normal; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.可以勾掉LATEX输出，这样节省编译时间</p><p style="line-height: normal; ">5. 参考资料<br style="line-height: normal; ">1. doxygen homepage<br style="line-height: normal; "><a href="http://www.stack.nl/~dimitri/doxygen/" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">http://www.stack.nl/~dimitri/doxygen/</font></a></p><p style="line-height: normal; ">2. doxygen manual&nbsp;<br style="line-height: normal; "><a href="http://www.stack.nl/~dimitri/doxygen/manual.html" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">http://www.stack.nl/~dimitri/doxygen/manual.html</font></a></p><p style="line-height: normal; ">3. Code Complete: A Practical Handbook of Software Construction. Redmond, Wa.: Microsoft Press, 880 pages, 1993. ISBN: 1-55615-484-4.&nbsp;<br style="line-height: normal; "><br style="line-height: normal; ">4. 简介doxygen<br style="line-height: normal; "><a href="http://www.stack.nl/~dimitri/doxygen/doxygen_intro_cn.html" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">http://www.stack.nl/~dimitri/doxygen/doxygen_intro_cn.html</font></a><br style="line-height: normal; "><br style="line-height: normal; ">5. 10 Minutes to document your code<br style="line-height: normal; "><a href="http://www.codeproject.com/tips/doxysetup.asp" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">http://www.codeproject.com/tips/doxysetup.asp</font></a></p><p style="line-height: normal; ">6. 使用doxygen<br style="line-height: normal; "><a href="http://www.csdn.net/Develop/article/16/16383.shtm" style="text-decoration: none; font-weight: bold; line-height: 20px; color: rgb(68, 95, 136); font-size: 12px; font-family: Georgia; "><font color="#ae0405" size="2" style="line-height: normal; ">http://www.csdn.net/Develop/article/16%5C16383.shtm</font></a></p></div></div></td></tr></tbody></table>
<img src ="http://www.cppblog.com/dfghj44444/aggbug/126164.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/dfghj44444/" target="_blank">叫我老王吧</a> 2010-09-08 15:45 <a href="http://www.cppblog.com/dfghj44444/archive/2010/09/08/126164.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DOXYGEN简明实用教程</title><link>http://www.cppblog.com/dfghj44444/archive/2010/09/08/126161.html</link><dc:creator>叫我老王吧</dc:creator><author>叫我老王吧</author><pubDate>Wed, 08 Sep 2010 07:15:00 GMT</pubDate><guid>http://www.cppblog.com/dfghj44444/archive/2010/09/08/126161.html</guid><wfw:comment>http://www.cppblog.com/dfghj44444/comments/126161.html</wfw:comment><comments>http://www.cppblog.com/dfghj44444/archive/2010/09/08/126161.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/dfghj44444/comments/commentRss/126161.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/dfghj44444/services/trackbacks/126161.html</trackback:ping><description><![CDATA[
<div class="postbody" style="padding-top: 1em; padding-right: 1.5em; padding-left: 1.5em; padding-bottom: 2em; line-height: 19px; font-size: 1em; color: rgb(255, 255, 255); font-family: Verdana, Arial, Helvetica, sans-serif; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; line-height: 19px; font-size: 1em; text-indent: 0px; "><font color="#009999" face="'trebuchet ms', 'lucida grande', verdana, arial, sans-serif" size="5"><span style="font-size: 17px; letter-spacing: 1px; line-height: normal; text-transform: uppercase;"><strong><span style="color: rgb(255, 255, 255); font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; letter-spacing: normal; text-transform: none; font-size: 13px; "></span></strong></span></font></p><font color="#009999" face="'trebuchet ms', 'lucida grande', verdana, arial, sans-serif" size="5"><strong><div class="posthead" style="padding-top: 2px; padding-right: 1em; padding-bottom: 2px; padding-left: 1em; font-size: 0.9em; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><h2 style="margin-top: 0px; font-size: 1.2em; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.5em; padding-right: 0em; padding-bottom: 0em; padding-left: 0em; letter-spacing: 1px; text-transform: uppercase; "><a id="ctl03_TitleUrl" class="singleposttitle" href="http://www.cnblogs.com/wswqwps/archive/2009/03/04/1403376.html" style="text-decoration: none; color: rgb(255, 153, 0); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">DOXYGEN简明实用教程</a></h2>Posted on 2009-03-04 21:31&nbsp;<a href="http://www.cnblogs.com/wswqwps/" style="text-decoration: none; color: rgb(255, 153, 0); ">活着就是幸福</a>&nbsp;阅读(507)&nbsp;<a href="http://www.cnblogs.com/wswqwps/archive/2009/03/04/1403376.html#commentform" style="text-decoration: none; color: rgb(255, 153, 0); ">评论(0)</a>&nbsp;<a href="http://www.cnblogs.com/wswqwps/archive/2009/03/04/1403376.html#" style="text-decoration: none; color: rgb(255, 153, 0); ">编辑</a>&nbsp;<a href="http://www.cnblogs.com/wswqwps/archive/2009/03/04/1403376.html#" style="text-decoration: none; color: rgb(255, 153, 0); ">收藏</a>&nbsp;所属分类:&nbsp;<a href="http://www.cnblogs.com/wswqwps/category/178930.html" style="text-decoration: none; color: rgb(255, 153, 0); ">Project Management</a><img src="http://www.cnblogs.com/wswqwps/aggbug/1403376.html?type=1&amp;webview=1" width="1px" height="1px" alt="" style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-style: initial; border-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(102, 102, 102); border-right-color: rgb(102, 102, 102); border-bottom-color: rgb(102, 102, 102); border-left-color: rgb(102, 102, 102); margin-right: 5px; margin-bottom: 5px; margin-left: 5px; "></div><div class="postbody" style="padding-top: 1em; padding-right: 1.5em; padding-left: 1.5em; padding-bottom: 2em; line-height: 19px; font-size: 1em; "><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; line-height: 19px; font-size: 1em; text-indent: 0px; ">代码写多了难免需要做文档，给自己还是给别人看都需要如此，这次XBOX360制作，前期没怎么写注释，回头改Bug都要猜半天自己写的代码是什么意思。更别提别人写的东西，100行代码也没有一句注释，幸好不是我维护，否则要疯掉了。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; line-height: 19px; font-size: 1em; text-indent: 0px; ">花了一天功夫尝试了一下Doxygen的使用，还好不难，但是有些磕磕绊绊，它自己的文档也说不清楚，网上搜出来的教程也只是给出样子，遇到的问题还是靠自己尝试了几十次才搞定。</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; line-height: 19px; font-size: 1em; text-indent: 0px; ">不管如何，常用的东西都可以弄出来了。贴在下面：<br></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; line-height: 19px; font-size: 1em; text-indent: 0px; ">&nbsp;-----------------------------------------------------------------------------------</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; line-height: 19px; font-size: 1em; text-indent: 0px; ">1.所有注释都可以使用///开始(C++风格)。<br><br>2.类体前必须加上///描述，否则会产生警告【Compound 类名 is not documented】<br>&nbsp; 描述中最好不要带有此类的类名，否则会产生两个链接(但指向同一个文件)影响美观。<br><br>3.public和protected会自动生成，但是private要在Expert的Build选项里勾中EXTRACT_PRIVATE，static成员也是如此。<br><br>4.函数注释方式<br>&nbsp;&nbsp; &nbsp;/// Constructor【函数描述】<br>&nbsp;&nbsp; &nbsp;/// @param [in] pos&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; The position of Camera in world coordinate&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 【参数描述1】<br>&nbsp;&nbsp; &nbsp;/// @param [in] lookat&nbsp;&nbsp;&nbsp; The point Camera looks at in world coordinate&nbsp;&nbsp; &nbsp;【参数描述2】<br>&nbsp;&nbsp; &nbsp;BaseCamera( const D3DXVECTOR3&amp; pos, const D3DXVECTOR3&amp; lookat );<br><br>5.变量注释方式<br>&nbsp;&nbsp; &nbsp;D3DXVECTOR3 m_Position;&nbsp;&nbsp; &nbsp;/*!&lt; Camera position point in world coordinate */&nbsp;&nbsp; 或<br>&nbsp;&nbsp; &nbsp;D3DXVECTOR3 m_Position;&nbsp;&nbsp; &nbsp;///&lt; Camera position point in world coordinate<br>两种方式产生的结果不同。前者会单独产生一块Member Data Documentation注释，后者会在Pubilc/Protected/Private Attributes变量描述后紧跟注释。<br><br>6.@参数和\参数相同<br><br>7.产生描述顺序和注释顺序相同，一般风格为<br><br>&nbsp;&nbsp; &nbsp;/// 函数描述<br>&nbsp;&nbsp; &nbsp;/// @param &nbsp;&nbsp; &nbsp;参数描述<br>&nbsp;&nbsp; &nbsp;/// @return &nbsp;&nbsp; &nbsp;返回值描述<br>&nbsp;&nbsp; &nbsp;/// @retval &nbsp;&nbsp; &nbsp;返回值1 &nbsp;&nbsp; &nbsp;返回值1描述<br>&nbsp;&nbsp; &nbsp;/// @retval &nbsp;&nbsp; &nbsp;返回值2 &nbsp;&nbsp; &nbsp;返回值2描述<br>&nbsp;&nbsp; &nbsp;/// @remarks &nbsp;&nbsp; &nbsp;注意事项<br>&nbsp;&nbsp; &nbsp;/// @note&nbsp;&nbsp; &nbsp;注意事项，功能同@remarks,显示字样不同<br>&nbsp;&nbsp; &nbsp;/// @par&nbsp;&nbsp; &nbsp;自定义图块，后面可跟示例代码之类<br>&nbsp;&nbsp; &nbsp;/// @code(必须使用@endcode结束)<br>&nbsp;&nbsp; &nbsp;/// 示例代码(无需缩进)&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;/// @endcode<br>&nbsp;&nbsp; &nbsp;/// @see &nbsp;&nbsp; &nbsp;其他参考项【产生指向参考的链接】<br>&nbsp;&nbsp; &nbsp;函数代码声明<br><br>8.特殊符号<br>&nbsp;&nbsp; &nbsp;/// -&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;产生一个黑色圆点<br><br>9.定义在类体里面的enum<br>&nbsp;&nbsp; &nbsp;/// Camera types<br>&nbsp;&nbsp; &nbsp;enum CAMERA_TYPE<br>&nbsp;&nbsp; &nbsp;{<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CAMERA_FIRST_VIEW,/*!&lt; Camera that looks from the first view */<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CAMERA_MODEL_VIEW,///&lt; Camera that looks from the third view<br>&nbsp;&nbsp; &nbsp;};<br>&nbsp;&nbsp; &nbsp;两种风格相同。<br><br>以下开始的项都是全局非类内定义，在文件最开始(我尝试是在include之前) 必须加上【/// \file 文件名】，否则不会生成注释【没有File Member页】。<br><br>10. 定义在文件里面的宏<br>&nbsp;&nbsp;&nbsp; &nbsp;#define CAMERA_TYPE_NUMBER&nbsp;&nbsp;&nbsp;&nbsp; ///&lt; The number of camera types.&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 或<br>&nbsp;&nbsp; &nbsp; #define CAMERA_TYPE_NUMBER&nbsp;&nbsp;&nbsp;&nbsp; /*!&lt; The number of camera types. */<br>风格说明见5。<br><br>11. 非类内enum定义同10.&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;两种风格相同。见9。<br>12. 非类内typedef定义同10. &nbsp;&nbsp; &nbsp;风格说明见5。</p></div></strong></font><p>&nbsp;</p></div><img src ="http://www.cppblog.com/dfghj44444/aggbug/126161.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/dfghj44444/" target="_blank">叫我老王吧</a> 2010-09-08 15:15 <a href="http://www.cppblog.com/dfghj44444/archive/2010/09/08/126161.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>