﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Timothy&#039;s Space &#187; file</title>
	<atom:link href="http://www.xiaozhou.net/tag/file/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xiaozhou.net</link>
	<description>君看一叶舟，出没风波里</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Unity 学习笔记(2) — 配置文件的使用</title>
		<link>http://www.xiaozhou.net/dotnetdevelopment/unity-study-notes-2-the-configuration-file-to-use-2009-04-25.htm</link>
		<comments>http://www.xiaozhou.net/dotnetdevelopment/unity-study-notes-2-the-configuration-file-to-use-2009-04-25.htm#comments</comments>
		<pubDate>Sat, 25 Apr 2009 12:24:01 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[.NET开发]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[unity]]></category>
		<category><![CDATA[配置文件]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=218</guid>
		<description><![CDATA[在Unity的配置中，使用配置文件也是一种非常灵活的方式，毕竟能够通过修改配置文件的文本就能达到改动的目的，而不需要对源码进行改动、重新编译。使用配置文件对Unity进行配置，需要增加两个程序集的引用：System.Configuration和Microsoft.Practices.Unity.Configration，并且在代码中用相应的两个命名空间： 1: using System.Configuration; 2: using Microsoft.Practices.Unity.Configuration; 此外，需要修改应用程序的配置文件： 在configSections节点中，加入Unity的section配置信息 ... ... 其中name是section的名称，type就是处理该section的程序类型，Unity提供了UnityConfigurationSection，负责处理配置文件信息，它包含在程序集Microsoft.Practices.Unity.Configuration中 接下来，需要在configuration节点中增加Unity配置节点，格式如下： 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 16: unity的子元素，包含节点大致如上，其宗typeAliases是type别名，能够简化下面types中type的配置。containers节点中可以包含多个container的配置。container主要包含的子元素有types元素，instance元素，types元素可以包含多个type元素，用以添加注册类型，instance主要用来添加实例到容器中。type元素，主要包含四个属性： name：表示注册类型的名称，此属性在配置中可选。 type:注册的源类型 mapto:注册的目标类型 lifetime:设置注册类型的生命周期 此外，还有instances元素，包括name,type,value,typeConverter四个属性。value表示注册实例的初始值，typeConverter是用以转换提供的值到实例的匹配类型的类型转换器。 具体的元素含义，可以参考Unity的帮助文档。 下面我们还是采用Monitor的例子，来实现用配置文件注册类型，配置文件示例： 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 程序代码修改如下： [...]]]></description>
			<content:encoded><![CDATA[<p>在Unity的配置中，使用配置文件也是一种非常灵活的方式，毕竟能够通过修改配置文件的文本就能达到改动的目的，而不需要对源码进行改动、重新编译。使用配置文件对Unity进行配置，需要增加两个程序集的引用：System.Configuration和Microsoft.Practices.Unity.Configration，并且在代码中用相应的两个命名空间：</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">using</span> System.Configuration;</pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">using</span> Microsoft.Practices.Unity.Configuration;</pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>此外，需要修改应用程序的配置文件：</p>
<p>在configSections节点中，加入Unity的section配置信息</p>
<div class="csharpcode">
<pre><span style="font-family: Simsun; white-space: normal; font-size: small;">
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 105px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><configSections></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 105px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">...</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 105px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">
<section name="unity"</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 105px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 105px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"></configSections></div>
<pre><<span style="font-family: Simsun;"><span style="white-space: normal;">configSections></span></span></pre>
<pre><span style="font-family: Simsun;"><span style="white-space: normal;">...</span></span></pre>
<pre><span style="font-family: Simsun;"><span style="white-space: normal;">
<section name="unity"</span></span></pre>
<pre><span style="font-family: Simsun;"><span style="white-space: normal;">type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></span></span></pre>
<pre><span style="font-family: Simsun;"><span style="white-space: normal;"></configSections></span></span></pre>
<p></span></pre>
<pre><span style="font-family: Simsun; white-space: normal; font-size: small;">其中name是section的名称，type就是处理该section的程序类型，Unity提供了UnityConfigurationSection，负责处理配置文件信息，它包含在程序集Microsoft.Practices.Unity.Configuration中</span></pre>
</div>
<p>接下来，需要在configuration节点中增加Unity配置节点，格式如下：</p>
<div class="csharpcode">
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><unity></pre>
<pre><span class="lnum">   2:  </span>    <typeAliases></pre>
<pre class="alt"><span class="lnum">   3:  </span>      <typeAlias alias=<span class="str">""</span> type=<span class="str">""</span> /></pre>
<pre><span class="lnum">   4:  </span>    <typeAliases /></pre>
<pre class="alt"><span class="lnum">   5:  </span>    <containers  ></pre>
<pre><span class="lnum">   6:  </span>      <container></pre>
<pre class="alt"><span class="lnum">   7:  </span>         <types></pre>
<pre><span class="lnum">   8:  </span>           <type type=<span class="str">""</span> mapTo=<span class="str">""</span> /></pre>
<pre class="alt"><span class="lnum">   9:  </span>         </types></pre>
<pre><span class="lnum">  10:  </span>         <instances></pre>
<pre class="alt"><span class="lnum">  11:  </span>           <add name=<span class="str">""</span> type=<span class="str">""</span> <span class="kwrd">value</span>=<span class="str">""</span> /></pre>
<pre><span class="lnum">  12:  </span>         </instances></pre>
<pre class="alt"><span class="lnum">  13:  </span>      </container></pre>
<pre><span class="lnum">  14:  </span>    </containers></pre>
<pre><span class="lnum">  16:  </span></unity></pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>unity的子元素，包含节点大致如上，其宗typeAliases是type别名，能够简化下面types中type的配置。containers节点中可以包含多个container的配置。container主要包含的子元素有types元素，instance元素，types元素可以包含多个type元素，用以添加注册类型，instance主要用来添加实例到容器中。type元素，主要包含四个属性：</p>
<p>name：表示注册类型的名称，此属性在配置中可选。</p>
<p>type:注册的源类型</p>
<p>mapto:注册的目标类型</p>
<p>lifetime:设置注册类型的生命周期</p>
<p>此外，还有instances元素，包括name,type,value,typeConverter四个属性。value表示注册实例的初始值，typeConverter是用以转换提供的值到实例的匹配类型的类型转换器。</p>
<p>具体的元素含义，可以参考Unity的帮助文档。</p>
<p>下面我们还是采用Monitor的例子，来实现用配置文件注册类型，配置文件示例：</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"utf-8"</span> ?></pre>
<pre><span class="lnum">   2:  </span><configuration></pre>
<pre class="alt"><span class="lnum">   3:  </span>  <configSections></pre>
<pre><span class="lnum">   4:  </span>
<section name=<span class="str">"unity"</span> type=<span class="str">"Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"</span> /></pre>
<pre class="alt"><span class="lnum">   5:  </span>  </configSections></pre>
<pre><span class="lnum">   6:  </span></pre>
<pre class="alt"><span class="lnum">   7:  </span>  <unity></pre>
<pre><span class="lnum">   8:  </span>    <containers></pre>
<pre class="alt"><span class="lnum">   9:  </span>      <container></pre>
<pre><span class="lnum">  10:  </span>        <types></pre>
<pre class="alt"><span class="lnum">  11:  </span>          <type type=<span class="str">"UnityDemo.IMonitor,UnityDemo"</span> mapTo=<span class="str">"UnityDemo.Monitor,UnityDemo"</span> /></pre>
<pre><span class="lnum">  12:  </span>          <type type=<span class="str">"UnityDemo.INotify,UnityDemo"</span> mapTo=<span class="str">"UnityDemo.EmailNotify,UnityDemo"</span> /></pre>
<pre class="alt"><span class="lnum">  13:  </span>        </types></pre>
<pre><span class="lnum">  14:  </span>      </container></pre>
<pre class="alt"><span class="lnum">  15:  </span>    </containers></pre>
<pre><span class="lnum">  16:  </span>  </unity></pre>
<pre class="alt"><span class="lnum">  17:  </span></pre>
<pre><span class="lnum">  18:  </span></configuration></pre>
</div>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>程序代码修改如下：</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">using</span> System;</pre>
<pre><span class="lnum">   2:  </span></pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">using</span> Microsoft.Practices.Unity;</pre>
<pre><span class="lnum">   4:  </span><span class="kwrd">using</span> Microsoft.Practices.Unity.Configuration;</pre>
<pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">using</span> System.Configuration;</pre>
<pre><span class="lnum">   6:  </span></pre>
<pre class="alt"><span class="lnum">   7:  </span><span class="kwrd">namespace</span> UnityDemo</pre>
<pre><span class="lnum">   8:  </span>{</pre>
<pre class="alt"><span class="lnum">   9:  </span>    <span class="kwrd">class</span> Program</pre>
<pre><span class="lnum">  10:  </span>    {</pre>
<pre class="alt"><span class="lnum">  11:  </span>        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)</pre>
<pre><span class="lnum">  12:  </span>        {</pre>
<pre class="alt"><span class="lnum">  13:  </span>            IUnityContainer container = <span class="kwrd">new</span> UnityContainer();</pre>
<pre><span class="lnum">  14:  </span>            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection(<span class="str">"unity"</span>);</pre>
<pre class="alt"><span class="lnum">  15:  </span>            section.Containers.Default.Configure(container);</pre>
<pre><span class="lnum">  16:  </span></pre>
<pre class="alt"><span class="lnum">  17:  </span>            IMonitor monitor = container.Resolve<IMonitor>();</pre>
<pre><span class="lnum">  18:  </span>            monitor.Alarm();</pre>
<pre class="alt"><span class="lnum">  19:  </span></pre>
<pre><span class="lnum">  20:  </span>            Console.ReadLine();</pre>
<pre class="alt"><span class="lnum">  21:  </span>        }</pre>
<pre><span class="lnum">  22:  </span>    }</pre>
<pre class="alt"><span class="lnum">  23:  </span>}</pre>
</div>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>编译运行结果：<br />
<img class="alignnone" style="display: block; margin-left: auto; margin-right: auto;" src="/pics/unity/3.jpg" alt="" width="424" height="99" /></p>
<p>使用配置文件，还有许多方便的地方，比如对于程序的扩展而言，新增的模块不再需要修改已编译好的程序，而只需要修改配置文件就可以方便的实现新模块的注册，对于系统的稳定性和可维护性都非常有好处。</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/dotnetdevelopment/unity-study-notes-2-the-configuration-file-to-use-2009-04-25.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>得到指定文件的信息</title>
		<link>http://www.xiaozhou.net/vcdevelopment/information-to-be-specified-file-2004-12-26.htm</link>
		<comments>http://www.xiaozhou.net/vcdevelopment/information-to-be-specified-file-2004-12-26.htm#comments</comments>
		<pubDate>Sun, 26 Dec 2004 12:40:09 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[VC开发]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[specified]]></category>
		<category><![CDATA[信息]]></category>
		<category><![CDATA[文件]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=55</guid>
		<description><![CDATA[char* szFileName = &#8220;C:\\EnochShen.exe&#8221;; DWORD dwSize = GetFileVersionInfoSize(szFileName,NULL); LPVOID pBlock = malloc(dwSize); GetFileVersionInfo(szFileName,0,dwSize,pBlock); char* pVerValue = NULL; UINT nSize = 0; VerQueryValue(pBlock,TEXT(&#8220;\\VarFileInfo\\Translation&#8221;), (LPVOID*)&#038;pVerValue,&#038;nSize); CString strSubBlock,strTranslation,strTemp; strTemp.Format(&#8220;000%x&#8221;,*((unsigned short int *)pVerValue)); strTranslation = strTemp.Right(4); strTemp.Format(&#8220;000%x&#8221;,*((unsigned short int *)&#038;pVerValue[2])); strTranslation += strTemp.Right(4); //080404b0为中文，040904E4为英文 //文件描述 strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\FileDescription&#8221;,strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize); strSubBlock.ReleaseBuffer(); strTemp.Format(&#8220;文件描述: %s&#8221;,pVerValue); AfxMessageBox(strTemp); //内部名称 strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\InternalName&#8221;,strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize); strSubBlock.ReleaseBuffer(); strTemp.Format(&#8220;文件描述: %s&#8221;,pVerValue); AfxMessageBox(strTemp); //合法版权 [...]]]></description>
			<content:encoded><![CDATA[<p>char* szFileName = &#8220;C:\\EnochShen.exe&#8221;;<br />
	DWORD dwSize = GetFileVersionInfoSize(szFileName,NULL);<br />
	LPVOID pBlock = malloc(dwSize);<br />
	GetFileVersionInfo(szFileName,0,dwSize,pBlock);</p>
<p>	char* pVerValue = NULL;<br />
	UINT nSize = 0;<br />
	VerQueryValue(pBlock,TEXT(&#8220;\\VarFileInfo\\Translation&#8221;),<br />
		(LPVOID*)&#038;pVerValue,&#038;nSize);</p>
<p>	CString strSubBlock,strTranslation,strTemp;<br />
	strTemp.Format(&#8220;000%x&#8221;,*((unsigned short int *)pVerValue));<br />
	strTranslation = strTemp.Right(4);<br />
	strTemp.Format(&#8220;000%x&#8221;,*((unsigned short int *)&#038;pVerValue[2]));<br />
	strTranslation += strTemp.Right(4);<br />
	//080404b0为中文，040904E4为英文</p>
<p>	//文件描述<br />
	strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\FileDescription&#8221;,strTranslation);<br />
	VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize);<br />
	strSubBlock.ReleaseBuffer();<br />
	strTemp.Format(&#8220;文件描述: %s&#8221;,pVerValue);<br />
	AfxMessageBox(strTemp);</p>
<p>	//内部名称<br />
	strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\InternalName&#8221;,strTranslation);<br />
	VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize);<br />
	strSubBlock.ReleaseBuffer();<br />
	strTemp.Format(&#8220;文件描述: %s&#8221;,pVerValue);<br />
	AfxMessageBox(strTemp);</p>
<p>	//合法版权<br />
	strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\LegalTradeMarks&#8221;,strTranslation);<br />
	VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize);<br />
	strSubBlock.ReleaseBuffer();<br />
	strTemp.Format(&#8220;合法版权: %s&#8221;,pVerValue);<br />
	AfxMessageBox(strTemp);</p>
<p>	//原始文件名<br />
	strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\OriginalFileName&#8221;,strTranslation);<br />
	VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize);<br />
	strSubBlock.ReleaseBuffer();<br />
	strTemp.Format(&#8220;原始文件名: %s&#8221;,pVerValue);<br />
	AfxMessageBox(strTemp);</p>
<p>	//产品名称<br />
	strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\ProductName&#8221;,strTranslation);<br />
	VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize);<br />
	strSubBlock.ReleaseBuffer();<br />
	strTemp.Format(&#8220;产品名称: %s&#8221;,pVerValue);<br />
	AfxMessageBox(strTemp);</p>
<p>	//产品版本<br />
	strSubBlock.Format(&#8220;\\StringFileInfo\\%s\\ProductVersion&#8221;,strTranslation);<br />
	VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&#038;pVerValue,&#038;nSize);<br />
	strSubBlock.ReleaseBuffer();<br />
	strTemp.Format(&#8220;产品版本: %s&#8221;,pVerValue);<br />
	AfxMessageBox(strTemp);</p>
<p>	free(pBlock);</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/vcdevelopment/information-to-be-specified-file-2004-12-26.htm/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>判断是否为文件夹或者文件</title>
		<link>http://www.xiaozhou.net/vcdevelopment/to-determine-whether-a-folder-or-file-2004-11-29.htm</link>
		<comments>http://www.xiaozhou.net/vcdevelopment/to-determine-whether-a-folder-or-file-2004-11-29.htm#comments</comments>
		<pubDate>Mon, 29 Nov 2004 08:37:50 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[VC开发]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[判断]]></category>
		<category><![CDATA[文件]]></category>
		<category><![CDATA[文件夹]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=47</guid>
		<description><![CDATA[int IsDirectoryOrFile(CString strFileName) { strFileName.TrimLeft(); strFileName.TrimRight(); WIN32_FIND_DATA fd; HANDLE hFind = ::FindFirstFile(strFileName,&#038;fd); ::FindClose(hFind); //不存在同名的文件或文件夹 if (hFind == INVALID_HANDLE_VALUE) { return 0 ; } //判断是否为目录 else if (fd.dwFileAttributes&#038;FILE_ATTRIBUTE_DIRECTORY) { return 2 ; } else//判断为文件 { return 1; } } 声明: 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 本站文章均采用 知识共享署名-相同方式共享3.0 协议进行授权，除非注明，本站文章均为原创，转载请注明转自 Timothy&#039;s Space 并应以链接形式标明本文地址!]]></description>
			<content:encoded><![CDATA[<p>int IsDirectoryOrFile(CString strFileName)<br />
{<br />
	strFileName.TrimLeft();<br />
	strFileName.TrimRight();</p>
<p>	WIN32_FIND_DATA fd;<br />
	HANDLE hFind = ::FindFirstFile(strFileName,&#038;fd);<br />
	::FindClose(hFind);</p>
<p>	//不存在同名的文件或文件夹<br />
	if (hFind == INVALID_HANDLE_VALUE)<br />
	{<br />
		return 0 ;<br />
	}<br />
	//判断是否为目录<br />
	else if (fd.dwFileAttributes&#038;FILE_ATTRIBUTE_DIRECTORY)<br />
	{<br />
		return 2 ;<br />
	}<br />
	else//判断为文件<br />
	{<br />
		return 1;<br />
	}<br />
}</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/vcdevelopment/to-determine-whether-a-folder-or-file-2004-11-29.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>从文件装载图象</title>
		<link>http://www.xiaozhou.net/vcdevelopment/load-images-from-the-file-2004-10-26.htm</link>
		<comments>http://www.xiaozhou.net/vcdevelopment/load-images-from-the-file-2004-10-26.htm#comments</comments>
		<pubDate>Tue, 26 Oct 2004 08:19:12 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[VC开发]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[图像]]></category>
		<category><![CDATA[装载]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=38</guid>
		<description><![CDATA[******************************************************************* * 这是从文件里装放位图 * *******************************************************************/ BOOL CXxxView::OnDraw(CDC* pDC) { HBITMAP bitmap,OldBitmap; bitmap = (HBITMAP)LoadImage(NULL,&#8221;xxx.bmp&#8221;,IMAGE_BITMAP, 0,0,LR_LOADFROMFILE&#124;LR_CREATEDIBSECTION); CDC MemDC; MemDC.CreateCompatibleDC(pDC); OldBitmap=(HBITMAP)MemDC.SelectObject(bitmap); pDC->BitBlt(0,0,400,300,&#038;MemDC,0,0,SRCCOPY); MemDC.SelectObject(OldBitmap); return TRUE; } 声明: 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 本站文章均采用 知识共享署名-相同方式共享3.0 协议进行授权，除非注明，本站文章均为原创，转载请注明转自 Timothy&#039;s Space 并应以链接形式标明本文地址!]]></description>
			<content:encoded><![CDATA[<p>*******************************************************************<br />
 * 这是从文件里装放位图<br />
 *<br />
 *******************************************************************/<br />
BOOL CXxxView::OnDraw(CDC* pDC)<br />
{<br />
   HBITMAP bitmap,OldBitmap;<br />
   bitmap = (HBITMAP)LoadImage(NULL,&#8221;xxx.bmp&#8221;,IMAGE_BITMAP,<br />
                           0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br />
   CDC MemDC;<br />
   MemDC.CreateCompatibleDC(pDC);<br />
   OldBitmap=(HBITMAP)MemDC.SelectObject(bitmap);<br />
   pDC->BitBlt(0,0,400,300,&#038;MemDC,0,0,SRCCOPY);<br />
   MemDC.SelectObject(OldBitmap);<br />
   return TRUE;<br />
}</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/vcdevelopment/load-images-from-the-file-2004-10-26.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

