﻿<?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++博客-随感而发-随笔分类-windows相关</title><link>http://www.cppblog.com/shongbee2/category/10033.html</link><description>杂七杂八</description><language>zh-cn</language><lastBuildDate>Thu, 24 Sep 2009 10:20:53 GMT</lastBuildDate><pubDate>Thu, 24 Sep 2009 10:20:53 GMT</pubDate><ttl>60</ttl><item><title>【转】MFC使用CTreeCtrl控件</title><link>http://www.cppblog.com/shongbee2/archive/2009/09/24/97096.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Thu, 24 Sep 2009 01:47:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/09/24/97096.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/97096.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/09/24/97096.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/97096.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/97096.html</trackback:ping><description><![CDATA[<table style="width: 100%; table-layout: fixed;">
    <tbody>
        <tr>
            <td>
            <div id="blog_text" class="cnt">
            <p>转自：忘记具体网址了。。。。。</p>
            <p style="line-height: 18pt; margin-top: 5pt; margin-bottom: 15pt;" class="p0"><span style="color: #353535; font-size: 10.5pt;">首先<font face="Times New Roman">,</font><font face="宋体">我们要创建一个</font></span><span><a  href="http://action.utops.cc/click.jsp?adsId=168&amp;adsLeagueId=5&amp;adsUserId=1&amp;siteId=406&amp;siteLeagueId=5&amp;siteUserId=384&amp;scId=2&amp;adsType=6&amp;prices=1.31&amp;checkCode=b7081fe123&amp;click=1&amp;url=http://www.totole.com.cn&amp;v=0&amp;keyword=%u57FA%u672C&amp;s=http://www.6to23.com/tech/btkf/kfpt/vbmfc/200604/44208.html&amp;rn=795387"><span style="color: #353535; font-size: 10.5pt;">基本</span></a></span><span style="color: #353535; font-size: 10.5pt;">对话框的<font face="Times New Roman">MFC</font></span><span><a  href="http://action.utops.cc/click.jsp?adsId=249&amp;adsLeagueId=5&amp;adsUserId=188&amp;siteId=406&amp;siteLeagueId=5&amp;siteUserId=384&amp;scId=2&amp;adsType=2&amp;prices=1.12&amp;checkCode=b0c779f1a3&amp;click=1&amp;url=http://www.sasacity.com/sports-brand-60.html/?utm_source=hp_banner&amp;v=0&amp;keyword=%u5DE5%u7A0B&amp;s=http://www.6to23.com/tech/btkf/kfpt/vbmfc/200604/44208.html&amp;rn=357592"><span style="color: #353535; font-size: 10.5pt;">工程</span></a></span><span style="color: #353535; font-size: 10.5pt;">MFC_TreeCRTL<font face="宋体">（名字随便给一个）。然后在资源视图中插入两个</font><font face="Times New Roman">Dialog</font><font face="宋体">，</font><font face="Times New Roman">ID</font><font face="宋体">分别为</font><font face="Times New Roman">IDD_DIALOG11</font><font face="宋体">和</font><font face="Times New Roman">IDD_DIALOG211</font><font face="宋体">，都更改</font><font face="Times New Roman">Style</font><font face="宋体">属性为</font><font face="Times New Roman">Child,Border</font><font face="宋体">属性为</font><font face="Times New Roman">None,</font><font face="宋体">为它们建立两个类，分别命名为</font><font face="Times New Roman">Cdialog11</font><font face="宋体">和</font><font face="Times New Roman">Cdialog211</font><font face="宋体">，并在</font><font face="Times New Roman">MFC_TreeCRTLDlg.CPP</font><font face="宋体">文件中包含</font><font face="Times New Roman">dialog11.h</font><font face="宋体">和</font><font face="Times New Roman">dialog211.h</font><font face="宋体">两个头文件。再导入几个资源图标作为树形控件节点的图标及装饰面板。最后在主面板上添加一个</font><font face="Times New Roman">CTreeCtrl</font><font face="宋体">控件</font><font face="Times New Roman">,ID</font><font face="宋体">为</font></span><span><a  href="http://action.utops.cc/click.jsp?adsId=166&amp;adsLeagueId=5&amp;adsUserId=1&amp;siteId=406&amp;siteLeagueId=5&amp;siteUserId=384&amp;scId=2&amp;adsType=7&amp;prices=1.3&amp;checkCode=e13a3de176&amp;click=1&amp;url=http://www.totole.com.cn&amp;v=0&amp;keyword=%u9ED8%u8BA4&amp;s=http://www.6to23.com/tech/btkf/kfpt/vbmfc/200604/44208.html&amp;rn=110619"><span style="color: #353535; font-size: 10.5pt;">默认</span></a></span><span style="color: #353535; font-size: 10.5pt;">，并在<font face="Times New Roman">ClassWizard</font><font face="宋体">中添加它的一个变量，命名为</font><font face="Times New Roman">m_mytree</font><font face="宋体">。</font></span><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">　　接着，我们进行具体代码编写。</span><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">　　我们必须在<font face="Times New Roman">CMFC_TreeCRTLDlg</font><font face="宋体">类中加入这些变量和函数</font></span><span style="color: #353535; font-size: 10.5pt;"><br></span></p>
            <p>
            <table style="padding: 0pt 5.4pt; border-collapse: collapse;" class="FCK__ShowTableBorders" align="center">
                <tbody>
                    <tr>
                        <td style="padding: 0pt 5.4pt; background: #e3e3e3 none repeat scroll 0% 0%; width: 366.9pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" width="489" valign="center">
                        <p style="background: #e3e3e3 none repeat scroll 0% 0%; line-height: 18pt; margin-top: 0pt; margin-bottom: 0pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="p0"><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">CDialog
                        * m_treePages[2];</span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">CString
                        node_name;</span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">BOOL
                        InitMytree();</span></p>
                        </td>
                    </tr>
                </tbody>
            </table>
            </p>
            <p style="line-height: 18pt; margin-top: 5pt; margin-bottom: 15pt;" class="p0"><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">　　我们还要在<font face="Times New Roman">CMFC_TreeCRTLDlg</font><font face="宋体">类的构造函数中为</font><font face="Times New Roman">m_treePages[2]</font><font face="宋体">分配空间， </font><font face="Times New Roman">m_treePages[0]=new Cdialog11;</font></span><span style="color: #353535; font-size: 10.5pt;"><br></span></p>
            <p>
            <table style="padding: 0pt 5.4pt; border-collapse: collapse;" class="FCK__ShowTableBorders" align="center">
                <tbody>
                    <tr>
                        <td style="padding: 0pt 5.4pt; background: #e3e3e3 none repeat scroll 0% 0%; width: 432.4pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" width="576" valign="center">
                        <p style="background: #e3e3e3 none repeat scroll 0% 0%; line-height: 18pt; margin-top: 0pt; margin-bottom: 0pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="p0"><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">m_treePages[1]=new
                        Cdialog211;</span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">InitMytree()<font face="宋体">函数为</font><font face="Times New Roman">m_mytree</font><font face="宋体">的初始化过程 </font><font face="Times New Roman">BOOL
                        CMFC_TreeCRTLDlg::InitMytree()</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">{</span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">节点的图标</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">int i=0;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">int i_count=2;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">载入图标</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">HICON icon[4];</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">icon[0]=AfxGetApp()-&gt;LoadIcon
                        (IDI_ICON6);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">icon[1]=AfxGetApp()-&gt;LoadIcon
                        (IDI_ICON7);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">创建图像列表控件</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">CImageList *m_imagelist=new
                        CImageList;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_imagelist-&gt;Create(16,16,0,7,7);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_imagelist-&gt;SetBkColor
                        (#ffffff);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">for(int n=0;n&lt;i_count;n++)</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">{</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　　<font face="Times New Roman">m_imagelist-&gt;Add(icon[n]); //</font><font face="宋体">把图标载入图像列表控件</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">}</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_mytree.SetImageList(m_imagelist,TVSIL_NORMAL);
                        //</font><font face="宋体">为</font><font face="Times New Roman">m_mytree</font><font face="宋体">设置一个图像列表，使</font><font face="Times New Roman">CtreeCtrl</font><font face="宋体">的节点显示不同的图标</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_mytree.SetBkColor(#00faff);//</font><font face="宋体">设置</font><font face="Times New Roman">m_mytree</font><font face="宋体">的背景色</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">创建节点</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">父节点</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">HTREEITEM
                        root0=m_mytree.InsertItem("Dialog1",0,1,TVI_ROOT,TVI_LAST);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">HTREEITEM
                        root1=m_mytree.InsertItem("Dialog2",0,1,TVI_ROOT,TVI_LAST);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">一层子节点</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">HTREEITEM sub_son0=m_mytree.InsertItem("Dialog
                        1-1",0,1,root0,TVI_LAST);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">HTREEITEM sub_son1=m_mytree.InsertItem("Dialog
                        2-1",0,1,root1,TVI_LAST);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">二层孙子节点</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">HTREEITEM sub_m_son0=m_mytree.InsertItem("Dialog
                        2-1-1",0,1,sub_son1,TVI_LAST);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">建立节点对应的</font><font face="Times New Roman">Dialog</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_treePages[0]-&gt;Create(IDD_DIALOG11,this);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_treePages[1]-&gt;Create(IDD_DIALOG211,this);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_treePages[0]-&gt;ShowWindow(SW_SHOW);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_treePages[1]-&gt;ShowWindow(SW_HIDE);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">把</font><font face="Times New Roman">Dialog</font><font face="宋体">移到合适位置</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">CRect m_rect;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">GetClientRect(m_rect);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_rect.left=200;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_treePages[0]-&gt;MoveWindow(m_rect);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">m_treePages[1]-&gt;MoveWindow(m_rect);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">return true;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">}</span></p>
                        </td>
                    </tr>
                </tbody>
            </table>
            </p>
            <p style="line-height: 18pt; margin-top: 5pt; margin-bottom: 15pt;" class="p0"><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">　　始初化完成后，我们要添加<font face="Times New Roman">CTreeCtrl</font><font face="宋体">的消息响应事件，这样才能让它按我们的要求起作用。我们打开</font><font face="Times New Roman">Class
            Wizard</font><font face="宋体">点选</font><font face="Times New Roman">IDC_TREE1</font><font face="宋体">添加</font><font face="Times New Roman">TVN_SELCHANGED</font><font face="宋体">消息，并在消息响应函数中写入代码。</font></span><span style="color: #353535; font-size: 10.5pt;"><br></span></p>
            <p>
            <table style="padding: 0pt 5.4pt; border-collapse: collapse;" class="FCK__ShowTableBorders" align="center">
                <tbody>
                    <tr>
                        <td style="padding: 0pt 5.4pt; background: #e3e3e3 none repeat scroll 0% 0%; width: 399.15pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" width="532" valign="center">
                        <p style="background: #e3e3e3 none repeat scroll 0% 0%; line-height: 18pt; margin-top: 0pt; margin-bottom: 0pt; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="p0"><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">void
                        CMFC_TreeCRTLDlg::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)</span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">{</span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">NM_TREEVIEW* pNMTreeView =
                        (NM_TREEVIEW*)pNMHDR;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">// TODO: Add your control notification handler code
                        here</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">UpdateData(true);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">node_name=m_mytree.GetItemText(pNMTreeView-&gt;itemNew.hItem);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">在标题栏显示节点信息</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">SetWindowText(node_name);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">//</font><font face="宋体">切换面板</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">if(node_name=="Dialog 1-1"){</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　　<font face="Times New Roman">m_treePages[0]-&gt;ShowWindow(SW_SHOW);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　　<font face="Times New Roman">m_treePages[1]-&gt;ShowWindow(SW_HIDE);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">}</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">else if(node_name=="Dialog 2-1-1"){</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　　<font face="Times New Roman">m_treePages[0]-&gt;ShowWindow(SW_HIDE);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　　<font face="Times New Roman">m_treePages[1]-&gt;ShowWindow(SW_SHOW);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">}</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">UpdateData(false);</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">　<font face="Times New Roman">*pResult = 0;</font></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;"><br></span><span style="background: #e3e3e3 none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: #353535; font-size: 10.5pt;">}</span></p>
                        </td>
                    </tr>
                </tbody>
            </table>
            </p>
            <p style="margin-top: 0pt; margin-bottom: 0pt;" class="p0"><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">　　最后<font face="Times New Roman">,</font><font face="宋体">我们在 </font><font face="Times New Roman">CMFC_TreeCRTLDlg::OnInitDialog()</font><font face="宋体">初始化函数里调用</font><font face="Times New Roman">InitMytree()</font><font face="宋体">函数。程序运行效果：</font></span><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;"><a  href="http://hiphotos.baidu.com/shongbee2/pic/item/f8498bf01cf06083a50f521d.jpg" target="_blank"><img  src="http://www.cppblog.com/images/cppblog_com/shongbee2/DialogShow1.png" border="0"><br></a></span></p>
            <p style="margin-top: 0pt; margin-bottom: 0pt;" class="p0"><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">图一</span></p>
            <p style="margin-top: 0pt; margin-bottom: 0pt;" class="p0"><span style="color: #353535; font-size: 10.5pt;">（为什么百度会把图片质量变低，该死的缩水图。。。。）<br></span><span style="color: #353535; font-size: 10.5pt;"><br></span><span style="color: #353535; font-size: 10.5pt;">　　到这里为止，我们就把一个<font face="Times New Roman">Dialog</font><font face="宋体">粘贴到了主</font><font face="Times New Roman">Dialog</font><font face="宋体">上了，通过</font><font face="Times New Roman">CTreeCtrl</font><font face="宋体">控件的节点的变化，让不同的</font><font face="Times New Roman">Dialog</font><font face="宋体">交替地粘贴在主</font><font face="Times New Roman">Dialog</font><font face="宋体">上，从而方便于我们只用少数的窗口，调用更多的功能模块，不必再为每个模块都作为弹出窗口，而显得繁杂。 </font></span></p>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<br><img src ="http://www.cppblog.com/shongbee2/aggbug/97096.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-09-24 09:47 <a href="http://www.cppblog.com/shongbee2/archive/2009/09/24/97096.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】OPENFILENAME </title><link>http://www.cppblog.com/shongbee2/archive/2009/07/02/89092.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Thu, 02 Jul 2009 09:27:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/07/02/89092.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/89092.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/07/02/89092.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/89092.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/89092.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: OPENFILENAME&nbsp;&nbsp;The&nbsp;OPENFILENAME&nbsp;structure&nbsp;contains&nbsp;information&nbsp;that&nbsp;the&nbsp;GetOpenFileName&nbsp;and&nbsp;GetSaveFileName&nbsp;functions&nbsp;use&nbsp;to&nbsp...&nbsp;&nbsp;<a href='http://www.cppblog.com/shongbee2/archive/2009/07/02/89092.html'>阅读全文</a><img src ="http://www.cppblog.com/shongbee2/aggbug/89092.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-07-02 17:27 <a href="http://www.cppblog.com/shongbee2/archive/2009/07/02/89092.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】在vc下 output的打印</title><link>http://www.cppblog.com/shongbee2/archive/2009/04/15/80025.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Wed, 15 Apr 2009 08:42:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/04/15/80025.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/80025.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/04/15/80025.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/80025.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/80025.html</trackback:ping><description><![CDATA[<div align="left">转自：http://blog.chinaunix.net/u3/94302/showart_1891797.html<br>1，使用OutputDebugString在win32程序中可以使用函数OutputDebugString输出调试信息。输出的结果可以在vs的集成环境中看到，也可以使用工具DbgView.exe捕捉结果。函数的原形如下：OutputDebugStringThe OutputDebugString function sends a string to the debugger for display.void OutputDebugString(<br>&nbsp; LPCTSTR lpOutputString<br>);<br>Parameters<br>lpOutputString <br>[in] Pointer to the null-terminated string to be displayed. <br>Return Values<br>This function does not return a value<br>因为OutputDebugString的参数是字符串，而我们在实际使用过程中希望能像printf一样支持变参。可以用下面的方法实现这个效果：<br>inline bool MyDbgStr(LPCSTR lpszFormat, ...)<br>{<br>&nbsp;&nbsp;&nbsp; va_list&nbsp;&nbsp; args;<br>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nBuf;<br>&nbsp;&nbsp;&nbsp; TCHAR&nbsp;&nbsp;&nbsp;&nbsp; szBuffer[512];<br>&nbsp;&nbsp;&nbsp; va_start(args, lpszFormat);<br>&nbsp;&nbsp;&nbsp; nBuf = _vsnprintf(szBuffer, sizeof(szBuffer)*sizeof(TCHAR), lpszFormat, args);<br>&nbsp;&nbsp;&nbsp; Assert(nBuf &gt; 0);<br>&nbsp;&nbsp;&nbsp; OutputDebugString(szBuffer);<br>&nbsp;&nbsp;&nbsp; va_end(args);<br>}<br>文章出处：<a href="http://www.diybl.com/course/3_program/c++/cppsl/200866/122894.html">http://www.diybl.com/course/3_program/c++/cppsl/200866/122894.html</a></div>
<br><img src ="http://www.cppblog.com/shongbee2/aggbug/80025.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-04-15 16:42 <a href="http://www.cppblog.com/shongbee2/archive/2009/04/15/80025.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】.reg文件格式</title><link>http://www.cppblog.com/shongbee2/archive/2009/04/08/79248.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Wed, 08 Apr 2009 04:27:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/04/08/79248.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/79248.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/04/08/79248.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/79248.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/79248.html</trackback:ping><description><![CDATA[<div id="blog_text" class="cnt">
<p>转自：http://hi.baidu.com/oumeida/blog/item/119af6dde7e57ce877c638cf.html<br></p>
<p>.reg文件格式 <br>
<br>
原作：j.mostert <br>
翻译：淡月儿 <br>
<br>
1 概述 <br>
注册表编辑器使用.reg文件格式导入、导出注册表设置，支持的操作系统包括windows3.x，windows95/98/nt及以上。尽管注册表的作用和原 <br>
<br>
理十分重要，但本文不打算介绍，你可以通过文末列出的网址，获得相关的信息。同时，windows3.x的.reg文件格式与windows95以上不尽相同 <br>
<br>
，本文将忽略这方面的内容，毕竟windows3.x的注册表已经不太重要。 <br>
<br>
2 详细说明 <br>
.reg文件是ascii码组成的无格式纯文本，每一行以&#8220;cr/lf&#8221;结尾。 <br>
<br>
2.1 文件头 <br>
.reg文件开头是注册表编辑器的版本，windows95/nt下版本是4，你可以使用这样的字符串：regedit4。在执行导入前，注册表编辑器将会检 <br>
<br>
查版本是否正确，并在不匹配时给与提示，这也是注册表编辑器对.reg文件做的唯一检查。一般情况下，注册表编辑器会默默忽略掉错误的文 <br>
<br>
件内容不予导入注册表，更多情况下会把可能导致问题的内容导入注册表，这是微软注册表编辑器的一个缺陷。 <br>
<br>
2.2 键 <br>
键和子键被原样导出至.reg文件，没有顺序差别。 <br>
例如： <br>
hkey_classes_root\clsid键下面有hkey_classes_root\clsid\{21ec2020-3aea-1069-a2dd-08002b30309d}这个子键(这个键的作用是在控制 <br>
<br>
面板上添加一个类声明)，它按如下格式导出： <br>
[hkey_classes_root\clsid] <br>
[hkey_classes_root\clsid\{21ec2020-3aea-1069-a2dd-08002b30309d}] <br>
任何一个有效键值都必须包含完整的路径，因此必定以根键开头，根键包括： <br>
hkey_classes_root <br>
hkey_current_user <br>
hkey_local_machine <br>
hkey_users <br>
hkey_current_config <br>
hkey_dyn_data <br>
键名只可以由ascii码中的可打印字符组成(即ascii码32至127所代表的字符)，键名不可以包含空格、反斜杠( \ )以及通配符( * 和 ? )。 <br>
<br>
每一个键名下紧跟着它的键值，键值列表以空行结束，一个键的键值列表可以就是一个空行。 <br>
例如： <br>
[key-name] <br>
<br>
[second-key-name] <br>
"value1"=something <br>
"value2"=something <br>
<br>
[third-key-name] <br>
假如在文件中指定了一个不存在的键值，那么在导入的时候这个键连同它的根键(假如不存在的话)都将被创建。 <br>
例如： <br>
文件中指定了hkey_users\jeroen\test\subkey这个键； <br>
注册表中只存在hkey_users\jeroen这个键； <br>
当导入以后，hkey_users\jeroen\test这个键会被创建。 <br>
<br>
注意，你只能添加或修改键和键值，而不能删除它们。 <br>
(译者注：事实上可以删除，方法是在键名前面加上 - 号，该键连同其子键将被删除；在指定键值为 - ，可以删除该键值。) <br>
<br>
2.3 键值 <br>
注册表键值可以是三种数据类型：字符串(string)、二进制值(binary value)和双机器字(dword，即32位整数)。键值的名称以引号 " 包含 <br>
<br>
，值紧跟在等号 = 之后。每一个键都包含至少一个字符串类型的键值，这个键值在注册表编辑器中显示为&#8220;默认值&#8221;(default)。你可以通过 <br>
<br>
指定名称为 @ 的值来修改默认值。 <br>
例如： <br>
@="this is the default value." <br>
<br>
2.3.1 字符串 <br>
字符串可以是任意长度的，用引号 " 包含起来的由ascii码字符组成的值。字符 " 和 \ 也可以包含在字符串中，不过需要用 \" 和 \\ 进 <br>
<br>
行转义。同时，注册表编辑器可以导入导出除换行符(以及新行符，即ascii码10所指定的字符)以外的非acsii码字符。 <br>
当一个字符串值中包含换行符，在导出的时候会被输出成两行，但是再次导入时，只能导入第一行，第二行将被忽略。因此请牢记：不要在 <br>
<br>
字符串值中包含换行符。 <br>
例如： <br>
"foo"="bar" <br>
"foopath"="c:\\windows\\system" <br>
"foomessage"="this/nmessage/nactually/nconsists/nof/one/nlong/nline." <br>
<br>
2.3.2 二进制值 <br>
在字符串和双字不适用的场合，可以使用二进制值。二进制值可以用来储存任意类型的数据，其格式为 hex:xx,yy,zz 等，其中xx、yy、zz <br>
<br>
是用16进制值表示的单字节值，二进制值可以是任意长度的。 <br>
较长的二进制值可以用c语言多行符 \ 分割成多行显示。 <br>
例如： <br>
"bar"=hex:48,00,00,00,01,00,00,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,\ <br>
00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,\ <br>
0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,0a,00,00,00,00,00,c4,ac,01,\ <br>
00 <br>
请记住，\ 符只能够应用在二进制值当中。另外，微软声明一个二进制值不可以存储超过2k的资料，这也是值得注意的。 <br>
二进制值的例子： <br>
"foo"=hex:00,de,ca,de,12,34 <br>
<br>
2.3.2.1 特定二进制类型 <br>
除了常规的二进制值，还有若干特定类型的二进制值。我们可以这样指定： <br>
"foobar"=hex(type):xx,xx,xx,xx,... <br>
这些类型由 0 到 10 这些数字代表，具体如下： <br>
0 reg_none <br>
1 reg_sz <br>
2 reg_expand_sz <br>
3 reg_binary <br>
4 reg_dword, reg_dword_little_endian <br>
5 reg_dword_big_endian <br>
6 reg_link <br>
7 reg_multi_sz <br>
8 reg_resource_list <br>
9 reg_full_resource_descriptor <br>
10 reg_resource_requirements_list <br>
<br>
2.3.2.1.1 reg_none类型 <br>
默认的二进制值类型，应用在无特殊要求的场合。 <br>
<br>
2.3.2.1.2 reg_sz类型 <br>
以'\0'结尾的字符串。这是用二进制值来指定的字符串值，以下两种表达方法是一样的： <br>
"barfoo"=hex(1):41,42,43,44,00 <br>
"barfoo"="abcd" <br>
参见2.3.1，字符串。 <br>
<br>
2.3.2.1.3 reg_expand_sz类型 <br>
包含隐含串的字符串，一般是对环境变量的引用。当一个应用程序读到这样字符串，系统将把引用串转换为正确的环境变量值。 <br>
下面的例子表示字符串"%path%;something"，当这个值被引用的时候，"%path%"会被转化为当前系统的 path 值。 <br>
"forbaa"=hex(2):25,50,41,54,48,25,3b,53,6f,6d,65,74,68,69,6e,67,00 <br>
<br>
2.3.2.1.4 reg_dword, reg_dword_little_endian类型 <br>
小段对齐，是通常的双字数据类型，在这种格式下存储，高位字节在前，低位字节在后。 <br>
<br>
2.3.2.1.5 reg_dword_big_endian类型 <br>
大段对齐，是苹果机的双字数据类型，在这种格式下存储，低位字节在前，高位字节在后。 <br>
<br>
2.3.2.1.6 reg_link类型 <br>
unicode符号连接。 <br>
<br>
2.3.2.1.7 reg_multi_sz <br>
多字节字符串集，以连续两个'\0'结束，例如： <br>
"farboo"=hex(7):41,42,43,44,00,45,46,47,48,00,00 <br>
表示"abcd"和"efgh"两个字符串。 <br>
<br>
2.3.2.1.8 reg_resource_list <br>
设备驱动程序资源列表。 <br>
<br>
2.3.2.1.9 reg_full_resource_descriptor <br>
微软保留数据类型，用于辅助设备驱动程序。 <br>
<br>
2.3.2.1.10 reg_resource_requirements_list <br>
微软保留数据类型，用于辅助设备驱动程序。 <br>
<br>
2.3.3. 双字数据类型 <br>
双字数据类型，即32位整数，表示为 dword:xxxxxxxx，其中 x 是一个表示4位二进制的16进制值。 <br>
例如： <br>
"foo"=dword:00decade <br>
<br>
3 结语 <br>
本文简要介绍了.reg文件的格式，由于作者水平有限，错漏之处在所难免，假如您发现了错误，请不吝赐教. <br>
我的email:j.mostert@oke.nl。 <br>
<br>
4 参考资料 <br>
以下是关于注册表知识的网址，希望对大家有所帮助。 <br>
<br>
<br>
(译者注：由于这些链接都是1997年4月以前的，因此不再翻译)<br>
参考资料：<a target="_blank" href="http://www.cn-doc.com/_soft_ect_doc/2005_08_18_23/20050818234403397.htm">http://www.cn-doc.com/_soft_ect_doc/2005_08_18_23/20050818234403397.htm</a></p>
<p> </p>
<p>我在网上看到REG文件对注册表的操作可以不受注册表编辑器被禁用的限制，我就试了一下，我把注册表禁用了，然后想把解除注册表禁用的REG文件导
入注册表，可是导不进去，还是提示&#8220;注册编缉已被管理员停用&#8221;，不是说REG文件对注册表的操作可以不受注册表编辑器被禁用的限制吗，怎么我却导入不进
去！</p>
<div class="f14 wr">
<p><strong> 问题补充：</strong> 在DOS下好像是一样的</p>
<p>用记事本 <br>
REGEDIT4 <br>
[HKEY-CURRENT-USER\Software\Microsoft\Windows\CurrentVer- <br>
sion\Policies\System] <br>
\〃DisableRegistryTools\〃=dword:00000000 <br>
保存为C:\reg.reg <br>
然后打开 <br>
试试吧</p>
</div>
</div>
<br><img src ="http://www.cppblog.com/shongbee2/aggbug/79248.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-04-08 12:27 <a href="http://www.cppblog.com/shongbee2/archive/2009/04/08/79248.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】vs.net 2005,win32应用程序没有找到MSVCR80D.dll的解决方案</title><link>http://www.cppblog.com/shongbee2/archive/2009/04/05/79001.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Sun, 05 Apr 2009 04:12:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/04/05/79001.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/79001.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/04/05/79001.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/79001.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/79001.html</trackback:ping><description><![CDATA[转自：<a href="http://hi.baidu.com/ahnniu/blog/item/826db1de12500b5095ee3744.html">http://hi.baidu.com/ahnniu/blog/item/826db1de12500b5095ee3744.html</a><br><br>问题描述：大部分的vs.net 2005的用户在新建&#8220;win32项目－windows应用程序&#8221;的时候，新建的工程都通不过去，出现如下提示：<br>Solution to &#8220;MSVCR80D.dll not found&#8221; by hua.<br>&#8220;没有找到MSVCR80D.dll，因此这个应用程序未能启动。重新安装应用程序可能会修复此问题。&#8221;的完美解决方案^_^感觉偶做的还不错<br><br>问题所在：由于vs.net 2005 采用了一种新的DLL方案，搞成一个exe还要配有一个manifest文件（一般在嵌入文件里了，所以看不到，不过也可以不嵌入，这样会生产一个&lt;程序名&gt;.exe.manifest的文件，没它exe自己就转不了了：）这是个新功能，微软弄了个新工具（mt.exe），结果不好用，好像是fat32下时间戳有问题（在ntfs下这个问题就没有了），搞得manifest有时嵌入不到exe中（默认配置是嵌入的，所以就报错找不到dll了。<br><br>解决方案（3个都可以，由以第3个最帅，我做的：）：<br>1．&nbsp;&nbsp;&nbsp;&nbsp; 微软对于这个问题应该也有处理，不过感觉不是很人性化。在&#8220;属性-&gt;配置属性-&gt;清单工具-&gt;常规(先打开属性窗口，在右键打开属性页)&#8220;下有一个&#8221;使用FAT32解决办法，把它选成是，就可以了。（注意：一定要先配置这个选项，然后再编译工程，要不然还是不好用：）<br>2．&nbsp;&nbsp;&nbsp;&nbsp; 找到你的工程的文件夹，如（myproject），找到其下的myproject\myproject\Debug\ myproject.rec，把它删掉（删掉整个Debug目录也可以），重新编译，搞定！<br>3．&nbsp;&nbsp;&nbsp;&nbsp; 本解决方案是俺独创的，感觉爽多了，可以直接再应用向导中配置，严重符合高级人机界面要求：）好，<br>1）&nbsp;&nbsp;&nbsp;&nbsp; 首先找到你的vs.net安装目录（如我的是E:\Program Files\Microsoft Visual Studio 8），定位到Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application文件夹，备份这个Application文件夹，不然一会你自己改咂了我可不管啊：）。<br>2）&nbsp;&nbsp;&nbsp;&nbsp; 打开html\2052，看到两个文件了吧，就那个AppSettings.htm了，这个管着你的那个配置向导的界面，用UE(不要告诉我你不知道ue啥东西，baidu it)打开，在266行&#8220;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/SPAN&gt;&#8221;后回车，然后插入一下内容：<br>&lt;!-- this (hua)section is added by HUA. --&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span class="itemTextTop" id="FILE_SYSTEM_SPAN" title=""&gt;选择你所使用的文件系统:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;P CLASS="Spacer"&gt;　&lt;/P&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;INPUT TYPE="radio" CLASS="Radio" checked onPropertyChange="" NAME="filesystem" ID="FAT32" ACCESSKEY="F" TITLE="FAT32"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;DIV CLASS="itemTextRadioB" ID="FAT32_DIV" TITLE="FAT32"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LABEL FOR="FAT32" ID="FAT32_LABEL"&gt;FAT32(&lt;U&gt;F&lt;/U&gt;)&lt;/LABEL&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/DIV&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;BR&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;INPUT TYPE="radio" CLASS="Radio" onPropertyChange="" NAME="filesystem" ID="NTFS" ACCESSKEY="N" TITLE="NTFS"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;DIV CLASS="itemTextRadioB" ID="NTFS_DIV" TITLE="NTFS"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LABEL FOR="NTFS" ID="NTFS_LABEL"&gt;NTFS(&lt;U&gt;N&lt;/U&gt;)&lt;/LABEL&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/DIV&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/span&gt;<br>&lt;!-- end of (hua)section --&gt;<br>好，保存关闭，这个改完了，准备下一个。<br><br>3）&nbsp;&nbsp;&nbsp;&nbsp; 打开scripts\2052，这里就一个文件，ue打开它，找到138行&#8220;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var bATL = wizard.FindSymbol("SUPPORT_ATL");&#8221;其后回车，插入如下内容：<br>// this (hua)section is added by HUA.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var MFTool = config.Tools("VCManifestTool");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MFTool.UseFAT32Workaround = true;<br>// end of (hua)section&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 好，继续找到210行(源文件的210，你加了上边的语句就不是210了：)&#8220;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; config = proj.Object.Configurations.Item("Release");&#8221;注意这次要在这行&#8220;前边&#8221;加如下内容：<br>// this (hua)section is added by HUA.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(bFAT32)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var MFTool = config.Tools("VCManifestTool");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MFTool.UseFAT32Workaround = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>// end of (hua)section&nbsp;&nbsp;&nbsp;&nbsp;<br>好了，终于都改完了，打开你的vs.net 2005新建一个win32应用程序看看吧，效果还不错吧：）为了这个问题，耽误了我一天的考研复习时间，希望大家能用的上。<br>另外附个国外的bbs：http://forums.microsoft.com/MSDN/default.aspx?SiteID=1<br>Msdn的，肯定不错了，上边有vs.net的开发人员活动，都是很官方的东西，大家可以看看，不过英语要够好哦：）<br><br>转载者：谢谢他提供的解决方案，我只用了第一种，真的不错。其他还没有试呵呵。 
<img src ="http://www.cppblog.com/shongbee2/aggbug/79001.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-04-05 12:12 <a href="http://www.cppblog.com/shongbee2/archive/2009/04/05/79001.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>GUID介绍</title><link>http://www.cppblog.com/shongbee2/archive/2009/04/02/78689.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Thu, 02 Apr 2009 07:26:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/04/02/78689.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/78689.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/04/02/78689.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/78689.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/78689.html</trackback:ping><description><![CDATA[今天学GUID，发现网上资料很多，就转载了一些：<br>GUID介绍：http://zhidao.baidu.com/question/3912210.html<br>GUID(Globally Unique IDentifier) 也称作 UUID(Universally Unique IDentifier).
<br>特点：
<br>GUID/UUID是通过特定算法产生的一个二进制长度为128位的数字，
在空间上和时间上具有唯一性，保证同一时间不同地方产生的数字不同，
在公元3400年以前产生的UUID/GUID与任何其他产生过的UUIDs/GUIDs都不相同。在需要GUID的时候，可以完全由算法自动生成，不需要一个权威机构来管理。
GUID的长度固定，并且相对而言较短小，非常适合于排序、标识和存储。<br>用途：
<br>标识特定的组件、程序、文件、数据、用户等，并可以在网络中使用。
<br>。。。。省略N字<br><br>用API来生成GUID：<br>http://www.cnblogs.com/wubiyu/archive/2008/12/03/1346348.html<br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008000;">//</span><span style="color: #008000;">--生成GUID的代码<br></span><span style="color: #008000;">//</span><span style="color: #008000;">--相关程序/微软guidgen.exe</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">stdafx.h</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">objbase.h</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br>#include&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">stdio.h</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"><br><br></span><span style="color: #008000;">//</span><span style="color: #008000;">--生成GUID</span><span style="color: #008000;"><br></span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;newGUID()<br>{<br>&nbsp;</span><span style="color: #0000ff;">static</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">&nbsp;buf[</span><span style="color: #000000;">64</span><span style="color: #000000;">]&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;{</span><span style="color: #000000;">0</span><span style="color: #000000;">};<br>&nbsp;GUID&nbsp;guid;<br>&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(S_OK&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;::CoCreateGuid(</span><span style="color: #000000;">&amp;</span><span style="color: #000000;">guid))<br>&nbsp;{<br>&nbsp;&nbsp;_snprintf(buf,&nbsp;</span><span style="color: #0000ff;">sizeof</span><span style="color: #000000;">(buf)<br>&nbsp;&nbsp;&nbsp;,&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">{%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}</span><span style="color: #000000;">"</span><span style="color: #000000;"><br>&nbsp;&nbsp;&nbsp;,&nbsp;guid.Data1<br>&nbsp;&nbsp;&nbsp;,&nbsp;guid.Data2<br>&nbsp;&nbsp;&nbsp;,&nbsp;guid.Data3<br>&nbsp;&nbsp;&nbsp;,&nbsp;guid.Data4[</span><span style="color: #000000;">0</span><span style="color: #000000;">],&nbsp;guid.Data4[</span><span style="color: #000000;">1</span><span style="color: #000000;">]<br>&nbsp;&nbsp;&nbsp;,&nbsp;guid.Data4[</span><span style="color: #000000;">2</span><span style="color: #000000;">],&nbsp;guid.Data4[</span><span style="color: #000000;">3</span><span style="color: #000000;">],&nbsp;guid.Data4[</span><span style="color: #000000;">4</span><span style="color: #000000;">],&nbsp;guid.Data4[</span><span style="color: #000000;">5</span><span style="color: #000000;">]<br>&nbsp;&nbsp;&nbsp;,&nbsp;guid.Data4[</span><span style="color: #000000;">6</span><span style="color: #000000;">],&nbsp;guid.Data4[</span><span style="color: #000000;">7</span><span style="color: #000000;">]<br>&nbsp;&nbsp;&nbsp;);<br>&nbsp;}<br>&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">)buf;<br>}<br><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;main(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;argc,&nbsp;</span><span style="color: #0000ff;">char</span><span style="color: #000000;">*</span><span style="color: #000000;">&nbsp;argv[])<br>{<br>&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">--COM</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;CoInitialize(NULL);<br>&nbsp;<br>&nbsp;printf(newGUID());<br>&nbsp;printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">\r\n</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">--COM</span><span style="color: #008000;"><br></span><span style="color: #000000;">&nbsp;CoUninitialize();<br>&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}<br></span></div>
<br> <img src ="http://www.cppblog.com/shongbee2/aggbug/78689.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-04-02 15:26 <a href="http://www.cppblog.com/shongbee2/archive/2009/04/02/78689.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】cmd命令行大全</title><link>http://www.cppblog.com/shongbee2/archive/2009/04/02/78639.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Thu, 02 Apr 2009 01:51:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/04/02/78639.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/78639.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/04/02/78639.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/78639.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/78639.html</trackback:ping><description><![CDATA[<p>转自：http://hi.baidu.com/zgq666/blog/item/93cd87d4094f1e00a08bb770.html
<br></p>
<p>net use ipipc$ " " /user:" " 建立IPC空链接 <br>net use ipipc$ "密码" /user:"用户名" 建立IPC非空链接 <br>net use h: ipc$ "密码" /user:"用户名" 直接登陆后映射对方C：到本地为H: <br>net use h: ipc$ 登陆后映射对方C：到本地为H: <br>net use ipipc$ /del 删除IPC链接 <br>net use h: /del 删除映射对方到本地的为H:的映射 <br>net user 用户名　密码　/add 建立用户 <br>net user guest /active:yes 激活guest用户 <br>net user 查看有哪些用户 <br>net user 帐户名 查看帐户的属性 <br>net localgroup administrators 用户名 /add 把&#8220;用户&#8221;添加到管理员中使其具有管理员权限,注意：administrator后加s用复数 <br>net start 查看开启了哪些服务 <br>net start 服务名　 开启服务；(如:net start telnet， net start schedule) <br>net stop 服务名 停止某服务 <br>net time 目标ip 查看对方时间 <br>net time 目标ip /set 设置本地计算机时间与&#8220;目标IP&#8221;主机的时间同步,加上参数/yes可取消确认信息 <br>net view 查看本地局域网内开启了哪些共享 <br>net view ip 查看对方局域网内开启了哪些共享 <br>net config 显示系统网络设置 <br>net logoff 断开连接的共享 <br>net pause 服务名 暂停某服务 <br>net send ip "文本信息" 向对方发信息 <br>net ver 局域网内正在使用的网络连接类型和信息 <br>net share 查看本地开启的共享 <br>net share ipc$ 开启ipc$共享 <br>net share ipc$ /del 删除ipc$共享 <br>net share c$ /del 删除C：共享 <br>net user guest 12345 用guest用户登陆后用将密码改为12345 <br>net password 密码 更改系统登陆密码 <br>netstat -a 查看开启了哪些端口,常用netstat -an <br>netstat -n 查看端口的网络连接情况，常用netstat -an <br>netstat -v 查看正在进行的工作 <br>netstat -p 协议名 例：netstat -p tcq/ip 查看某协议使用情况（查看tcp/ip协议使用情况） <br>netstat -s 查看正在使用的所有协议使用情况 <br>nbtstat -A ip 对方136到139其中一个端口开了的话，就可查看对方最近登陆的用户名（03前的为用户名）-注意：参数-A要大写 <br>tracert -参数 ip(或计算机名) 跟踪路由（数据包），参数：&#8220;-w数字&#8221;用于设置超时间隔。 <br>ping ip(或域名) 向对方主机发送默认大小为32字节的数据，参数：&#8220;-l[空格]数据包大小&#8221;；&#8220;-n发送数据次数&#8221;；&#8220;-t&#8221;指一直ping。 <br>ping -t -l 65550 ip 死亡之ping(发送大于64K的文件并一直ping就成了死亡之ping) <br>ipconfig (winipcfg) 用于windows NT及XP(windows 95 98)查看本地ip地址，ipconfig可用参数&#8220;/all&#8221;显示全部配置信息 <br>tlist -t 以树行列表显示进程(为系统的附加工具，默认是没有安装的，在安装目录的Support/tools文件夹内) <br>kill -F 进程名 加-F参数后强制结束某进程(为系统的附加工具，默认是没有安装的，在安装目录的Support/tools文件夹内) <br>del
-F 文件名
加-F参数后就可删除只读文件,/AR、/AH、/AS、/AA分别表示删除只读、隐藏、系统、存档文件，/A-R、/A-H、/A-S、/A-A表示删
除除只读、隐藏、系统、存档以外的文件。例如&#8220;DEL/AR *.*&#8221;表示删除当前目录下所有只读文件，&#8220;DEL/A-S
*.*&#8221;表示删除当前目录下除系统文件以外的所有文件</p>
<p> </p>
<p> </p>
<p>del /S /Q 目录 或用：rmdir /s /Q 目录 /S删除目录及目录下的所有子目录和文件。同时使用参数/Q 可取消删除操作时的系统确认就直接删除。（二个命令作用相同） <br>move 盘符路径要移动的文件名　存放移动文件的路径移动后文件名 移动文件,用参数/y将取消确认移动目录存在相同文件的提示就直接覆盖 <br>fc one.txt two.txt &gt; 3st.txt 对比二个文件并把不同之处输出到3st.txt文件中，"&gt; "和"&gt; &gt;" 是重定向命令 <br>at id号 开启已注册的某个计划任务 <br>at /delete 停止所有计划任务，用参数/yes则不需要确认就直接停止 <br>at id号 /delete 停止某个已注册的计划任务 <br>at 查看所有的计划任务 <br>at ip time 程序名(或一个命令) /r 在某时间运行对方某程序并重新启动计算机 <br>finger username @host 查看最近有哪些用户登陆 <br>telnet ip 端口 远和登陆服务器,默认端口为23 <br>open ip 连接到IP（属telnet登陆后的命令） <br>telnet 在本机上直接键入telnet 将进入本机的telnet <br>copy 路径文件名1　路径文件名2 /y 复制文件1到指定的目录为文件2，用参数/y就同时取消确认你要改写一份现存目录文件 <br>copy c:srv.exe ipadmin$ 复制本地c:srv.exe到对方的admin下 <br>cppy 1st.jpg/b+2st.txt/a 3st.jpg 将2st.txt的内容藏身到1st.jpg中生成3st.jpg新的文件，注：2st.txt文件头要空三排，参数：/b指二进制文件，/a指ASCLL格式文件 <br>copy ipadmin$svv.exe c: 或:copyipadmin$*.* 复制对方admini$共享下的srv.exe文件（所有文件）至本地C： <br>xcopy 要复制的文件或目录树　目标地址目录名 复制文件和目录树，用参数/Y将不提示覆盖相同文件 <br>tftp
-i 自己IP(用肉机作跳板时这用肉机IP) get server.exe c:server.exe
登陆后，将&#8220;IP&#8221;的server.exe下载到目标主机c:server.exe 参数：-i指以二进制模式传送，如传送exe文件时用，如不加-i
则以ASCII模式（传送文本文件模式）进行传送 <br>tftp -i 对方IP　put c:server.exe 登陆后，上传本地c:server.exe至主机 <br>ftp ip 端口 用于上传文件至服务器或进行文件操作，默认端口为21。bin指用二进制方式传送（可执行文件进）；默认为ASCII格式传送(文本文件时) <br>route print 显示出IP路由，将主要显示网络地址Network addres，子网掩码Netmask，网关地址Gateway addres，接口地址Interface <br>arp 查看和处理ARP缓存，ARP是名字解析的意思，负责把一个IP解析成一个物理性的MAC地址。arp -a将显示出全部信息 <br>start 程序名或命令 /max 或/min 新开一个新窗口并最大化（最小化）运行某程序或命令 <br>mem 查看cpu使用情况 <br>attrib 文件名(目录名) 查看某文件（目录）的属性 <br>attrib 文件名 -A -R -S -H 或 +A +R +S +H 去掉(添加)某文件的 存档，只读，系统，隐藏 属性；用＋则是添加为某属性 <br>dir 查看文件，参数：/Q显示文件及目录属系统哪个用户，/T:C显示文件创建时间，/T:A显示文件上次被访问时间，/T:W上次被修改时间 <br>date /t 、 time /t 使用此参数即&#8220;DATE/T&#8221;、&#8220;TIME/T&#8221;将只显示当前日期和时间，而不必输入新日期和时间 <br>set 指定环境变量名称=要指派给变量的字符 设置环境变量 <br>set 显示当前所有的环境变量 <br>set p(或其它字符) 显示出当前以字符p(或其它字符)开头的所有环境变量 <br>pause 暂停批处理程序，并显示出：请按任意键继续.... <br>if 在批处理程序中执行条件处理（更多说明见if命令及变量） <br>goto 标签 将cmd.exe导向到批处理程序中带标签的行（标签必须单独一行，且以冒号打头，例如：&#8220;：start&#8221;标签） <br>call 路径批处理文件名 从批处理程序中调用另一个批处理程序 （更多说明见call /?） </p>
<p> </p>
<p><br>for 对一组文件中的每一个文件执行某个特定命令（更多说明见for命令及变量） <br>echo on或off 打开或关闭echo，仅用echo不加参数则显示当前echo设置 <br>echo 信息 在屏幕上显示出信息 <br>echo 信息 &gt;&gt; pass.txt 将"信息"保存到pass.txt文件中 <br>findstr "Hello" aa.txt 在aa.txt文件中寻找字符串hello <br>find 文件名 查找某文件 <br>title 标题名字 更改CMD窗口标题名字 <br>color 颜色值 设置cmd控制台前景和背景颜色；0＝黑、1＝蓝、2＝绿、3＝浅绿、4＝红、5＝紫、6＝黄、7=白、8=灰、9=淡蓝、A＝淡绿、B=淡浅绿、C=淡红、D=淡紫、E=淡黄、F=亮白 <br>prompt 名称 更改cmd.exe的显示的命令提示符(把C:、D:统一改为：EntSky )</p>
<p>ver 在DOS窗口下显示版本信息 <br>winver 弹出一个窗口显示版本信息（内存大小、系统版本、补丁版本、计算机名） <br>format 盘符 /FS:类型 格式化磁盘,类型:FAT、FAT32、NTFS ,例：Format D: /FS:NTFS <br>md　目录名 创建目录 <br>replace 源文件　要替换文件的目录 替换文件 <br>ren 原文件名　新文件名 重命名文件名 <br>tree 以树形结构显示出目录，用参数-f 将列出第个文件夹中文件名称 <br>type 文件名 显示文本文件的内容 <br>more 文件名 逐屏显示输出文件 <br>doskey 要锁定的命令＝字符<br>doskey 要解锁命令= 为DOS提供的锁定命令(编辑命令行，重新调用win2k命令，并创建宏)。如：锁定dir命令：doskey dir=entsky (不能用doskey dir=dir)；解锁：doskey dir= <br>taskmgr 调出任务管理器 <br>chkdsk /F D: 检查磁盘D并显示状态报告；加参数/f并修复磁盘上的错误 <br>tlntadmn telnt服务admn,键入tlntadmn选择3，再选择8,就可以更改telnet服务默认端口23为其它任何端口 <br>exit 退出cmd.exe程序或目前，用参数/B则是退出当前批处理脚本而不是cmd.exe <br>path 路径可执行文件的文件名 为可执行文件设置一个路径。 <br>cmd 启动一个win2K命令解释窗口。参数：/eff、/en 关闭、开启命令扩展；更我详细说明见cmd /? <br>regedit /s 注册表文件名 导入注册表；参数/S指安静模式导入，无任何提示； <br>regedit /e 注册表文件名 导出注册表 <br>cacls
文件名　参数 显示或修改文件访问控制列表（ACL）——针对NTFS格式时。参数：/D 用户名:设定拒绝某用户访问；/P 用户名:perm
替换指定用户的访问权限；/G 用户名:perm 赋予指定用户访问权限；Perm 可以是: N 无，R 读取， W 写入， C 更改(写入)，F
完全控制；例：cacls D: est.txt /D pub 设定d: est.txt拒绝pub用户访问。 <br>cacls 文件名 查看文件的访问用户权限列表 <br>REM 文本内容 在批处理文件中添加注解 <br>netsh 查看或更改本地网络配置情况</p>
<br><img src ="http://www.cppblog.com/shongbee2/aggbug/78639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-04-02 09:51 <a href="http://www.cppblog.com/shongbee2/archive/2009/04/02/78639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】DLL的简单介绍</title><link>http://www.cppblog.com/shongbee2/archive/2009/04/02/78635.html</link><dc:creator>shongbee2</dc:creator><author>shongbee2</author><pubDate>Thu, 02 Apr 2009 01:22:00 GMT</pubDate><guid>http://www.cppblog.com/shongbee2/archive/2009/04/02/78635.html</guid><wfw:comment>http://www.cppblog.com/shongbee2/comments/78635.html</wfw:comment><comments>http://www.cppblog.com/shongbee2/archive/2009/04/02/78635.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/shongbee2/comments/commentRss/78635.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/shongbee2/services/trackbacks/78635.html</trackback:ping><description><![CDATA[转自：http://baike.baidu.com/view/4373.htm
<br><br><br>DLL文件(Dynamic Linkable Library 即动态链接库文件)，是一种不能单独运行的文件，它允许程序共享执行特殊任务所必需的代码和其他资源<br>
比较大的应用程序都由很多模块组成，这些模块分别完成相对独立的功能，它们彼此协作来完成整个
软件系统的工作。可能存在一些模块的功能较为通用，在构造其它软件系统时仍会被使用。在构造软件系统时，如果将所有模块的源代码都静态编译到整个应用程序
EXE
文件中，会产生一些问题：一个缺点是增加了应用程序的大小，它会占用更多的磁盘空间，程序运行时也会消耗较大的内存空间，造成系统资源的浪费；另一个缺点
是，在编写大的 EXE 程序时，在每次修改重建时都必须调整编译所有源代码，增加了编译过程的复杂性，也不利于阶段性的单元测试。<br>
Windows
系统平台上提供了一种完全不同的较有效的编程和运行环境，你可以将独立的程序模块创建为较小的 DLL
文件，并可对它们单独编译和测试。在运行时，只有当 EXE 程序确实要调用这些 DLL
模块的情况下，系统才会将它们装载到内存空间中。这种方式不仅减少了 EXE 文件的大小和对内存空间的需求，而且使这些 DLL
模块可以同时被多个应用程序使用。Windows 自己就将一些主要的系统功能以 DLL 模块的形式实现。<br>
一般来说，DLL 是一种磁盘文件，以.dll、.DRV、.FON、.SYS 和许多以
.EXE 为扩展名的系统文件都可以是
DLL。它由全局数据、服务函数和资源组成，在运行时被系统加载到调用进程的虚拟空间中，成为调用进程的一部分。如果与其它 DLL
之间没有冲突，该文件通常映射到进程虚拟空间的同一地址上。DLL 模块中包含各种导出函数，用于向外界提供服务。DLL
可以有自己的数据段，但没有自己的堆栈，使用与调用它的应用程序相同的堆栈模式；一个 DLL 在内存中只有一个实例；DLL
实现了代码封装性；DLL 的编制与具体的编程语言及编译器无关。<br>
在 Win32
环境中，每个进程都复制了自己的读/写全局变量。如果想要与其它进程共享内存，必须使用内存映射文件或者声明一个共享数据段。DLL
模块需要的堆栈内存都是从运行进程的堆栈中分配出来的。Windows 在加载 DLL 模块时将进程函数调用与 DLL
文件的导出函数相匹配。Windows 操作系统对 DLL 的操作仅仅是把 DLL 映射到需要它的进程的虚拟地址空间里去。DLL
函数中的代码所创建的任何对象（包括变量）都归调用它的线程或进程所有。<br>
调用方式：<br>
1、静态调用方式：由编译系统完成对 DLL 的加载和应用程序结束时 DLL
卸载的编码（如还有其它程序使用该 DLL，则 Windows 对 DLL 的应用记录减1，直到所有相关程序都结束对该 DLL
的使用时才释放它，简单实用，但不够灵活，只能满足一般要求。<br>
隐式的调用：需要把产生动态连接库时产生的 .LIB 文件加入到应用程序的工程中，想使用
DLL 中的函数时，只须说明一下。隐式调用不需要调用 LoadLibrary() 和 FreeLibrary()。程序员在建立一个 DLL
文件时，链接程序会自动生成一个与之对应的 LIB 导入文件。该文件包含了每一个 DLL
导出函数的符号名和可选的标识号，但是并不含有实际的代码。LIB 文件作为 DLL 的替代文件被编译到应用程序项目中。<br>
当程序员通过静态链接方式编译生成应用程序时，应用程序中的调用函数与 LIB 文件中导出符号相匹配，这些符号或标识号进入到生成的 EXE 文件中。LIB 文件中也包含了对应的 DL L文件名（但不是完全的路径名），链接程序将其存储在 EXE 文件内部。<br>
当应用程序运行过程中需要加载 DLL 文件时，Windows 根据这些信息发现并加载
DLL，然后通过符号名或标识号实现对 DLL 函数的动态链接。所有被应用程序调用的 DLL 文件都会在应用程序
EXE　文件加载时被加载在到内存中。可执行程序链接到一个包含 DLL
输出函数信息的输入库文件(.LIB文件)。操作系统在加载使用可执行程序时加载 DLL。可执行程序直接通过函数名调用 DLL
的输出函数，调用方法和程序内部其 它的函数是一样的。<br>
2、动态调用方式：是由编程者用 API 函数加载和卸载 DLL 来达到调用 DLL 的目的，使用上较复杂，但能更加有效地使用内存，是编制大型应用程序时的重要方式。<br>
显式的调用：<br>
是指在应用程序中用 LoadLibrary 或 MFC 提供的
AfxLoadLibrary 显式的将自己所做的动态连接库调进来，动态连接库的文件名即是上面两个函数的参数，再用
GetProcAddress()
获取想要引入的函数。自此，你就可以象使用如同本应用程序自定义的函数一样来调用此引入函数了。在应用程序退出之前，应该用 FreeLibrary
或 MFC 提供的 AfxFreeLibrary 释放动态连接库。直接调用 Win32 的 LoadLibary 函数，并指定 DLL
的路径作为参数。LoadLibary 返回 HINSTANCE 参数，应用程序在调用 GetProcAddress
函数时使用这一参数。GetProcAddress 函数将符号名或标识号转换为 DLL 内部的地址。程序员可以决定 DLL
文件何时加载或不加载，显式链接在运行时决定加载哪个 DLL 文件。使用 DLL
的程序在使用之前必须加载（LoadLibrary）加载DLL从而得到一个DLL模块的句柄，然后调用 GetProcAddress
函数得到输出函数的指针，在退出之前必须卸载DLL(FreeLibrary)。<br>
正因为DLL 有占用内存小，好编辑等的特点有很多电脑病毒都是DLL格式文件。但不能单独运行。 <br>
动态链接库通常都不能直接运行，也不能接收消息。它们是一些独立的文件，其中包含能被可执行程序或其它DLL调用来完成某项工作的函数。只有在其它模块调用动态链接库中的函数时，它才发挥作用。
<br><img src ="http://www.cppblog.com/shongbee2/aggbug/78635.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/shongbee2/" target="_blank">shongbee2</a> 2009-04-02 09:22 <a href="http://www.cppblog.com/shongbee2/archive/2009/04/02/78635.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>