<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>E点废墟 - Linux</title>
	<link>http://xok.la</link>
	<description>别人不看好自己要做好，别人不支持自己要坚持。</description>
	<pubDate>Fri, 03 Feb 2012 09:05:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>DEDECMS(织梦)5.6系统支持文档权重weight排序-栏目文章自定义置顶</title>
		<link>http://xok.la/2012/02/dedecms_v56_weight.html</link>
		<comments>http://xok.la/2012/02/dedecms_v56_weight.html#comments</comments>
		<pubDate>Fri, 03 Feb 2012 09:05:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[程序使用]]></category>

		<guid isPermaLink="false">http://xok.la/2012/02/dedecms_v56_weight.html</guid>
		<description><![CDATA[DEDECMS(织梦)5.6系统支持文档权重weight排序，可以在模板中使用：
{dede:arclist&#160;row='10' titlelen='50' orderby='weight'} •[field:textlink/]&#60;br/&#62; {/dede:arclist}

其中的orderby=’weight’就实现了文档按照权重排序了。这是arclist标签，可以用在任何位置来调用文档列表，然而，在栏目列表页，如果你要使用list标签（实现文档列表分页），也想用权重（weight）排序，
{dede:list&#160;pagesize='10' titlelen='50' orderby='weight'} •[field:textlink/]&#60;br/&#62; {/dede:list}

你会发现，你的列表并没有按照权重（weight）排序，无... ]]></description>
			<content:encoded><![CDATA[<p>DEDECMS(织梦)5.6系统支持文档权重weight排序，可以在模板中使用：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">{</span><span style="color: Blue;">dede</span><span style="color: Gray;">:</span><span style="color: Blue;">arclist</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">row</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">10</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> </span><span style="color: Blue;">titlelen</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">50</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> </span><span style="color: Blue;">orderby</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">weight</span><span style="color: #8b0000;">'</span><span style="color: Olive;">}</span><span style="color: Gray;"> •</span><span style="color: Olive;">[</span><span style="color: Blue;">field</span><span style="color: Gray;">:</span><span style="color: Blue;">textlink</span><span style="color: Gray;">/</span><span style="color: Olive;">]</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">br</span><span style="color: Gray;">/&gt; </span><span style="color: Olive;">{</span><span style="color: Gray;">/</span><span style="color: Blue;">dede</span><span style="color: Gray;">:</span><span style="color: Blue;">arclist</span><span style="color: Olive;">}</span></li>
</ol></div>
<p>其中的orderby=’weight’就实现了文档按照权重排序了。这是arclist标签，可以用在任何位置来调用文档列表，然而，在栏目列表页，如果你要使用list标签（实现文档列表分页），也想用权重（weight）排序，</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">{</span><span style="color: Blue;">dede</span><span style="color: Gray;">:</span><span style="color: Green;">list</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">pagesize</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">10</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> </span><span style="color: Blue;">titlelen</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">50</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> </span><span style="color: Blue;">orderby</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">weight</span><span style="color: #8b0000;">'</span><span style="color: Olive;">}</span><span style="color: Gray;"> •</span><span style="color: Olive;">[</span><span style="color: Blue;">field</span><span style="color: Gray;">:</span><span style="color: Blue;">textlink</span><span style="color: Gray;">/</span><span style="color: Olive;">]</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">br</span><span style="color: Gray;">/&gt; </span><span style="color: Olive;">{</span><span style="color: Gray;">/</span><span style="color: Blue;">dede</span><span style="color: Gray;">:</span><span style="color: Green;">list</span><span style="color: Olive;">}</span></li>
</ol></div>
<p>你会发现，你的列表并没有按照权重（weight）排序，无论你怎么修改，它的顺序就还是老样子！经过多次测试，发现原来dedecms织梦对权重 weight排序的支持仅arclist标签，并不支持list标签，因此，就开始了对dedecms织梦系统的改造，让它支持list标签权重 weight排序，改造的文件主要是include目录下的arc.listview.class.php文件，打开文件，查找“else if($orderby==”lastpost”) {”语句，大概在609行，在此行前面按下回车健，插入如下语句：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">else</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">weight</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: #00008b;">$ordersql</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;"> order by arc.weight </span><span style="color: #00008b;">$orderWay</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">; </span><span style="color: Olive;">}</span></li>
</ol></div>
<p>成为这样：<br />
//排序方式</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #00008b;">$ordersql</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">''</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">senddate</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> || </span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">id</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: #00008b;">$ordersql</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;"> order by arc.id </span><span style="color: #00008b;">$orderWay</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">else</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">hot</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> || </span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">click</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: #00008b;">$ordersql</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;"> order by arc.click </span><span style="color: #00008b;">$orderWay</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">else</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">lastpost</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: #00008b;">$ordersql</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&nbsp; order by arc.lastpost </span><span style="color: #00008b;">$orderWay</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">else</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: #00008b;">$orderby</span><span style="color: Gray;">==</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">weight</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: #00008b;">$ordersql</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&nbsp; order by arc.weight </span><span style="color: #00008b;">$orderWay</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">else</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: #00008b;">$ordersql</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;"> order by arc.sortrank </span><span style="color: #00008b;">$orderWay</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">}</span></li>
</ol></div>
<p>继续查找</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">ereg</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">hot|click|lastpost</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #00008b;">$orderby</span><span style="color: Olive;">))</span></li>
</ol></div>
<p>语句，修改为：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">ereg</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">hot|click|weight|lastpost</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #00008b;">$orderby</span><span style="color: Olive;">))</span></li>
</ol></div>
<p>修改完成后，保存，如果目标里面已经使用了weight排序，生成一下，就可以看到，文档列表已经安装weight排序<br />
后记：<br />
进行了上面的修改，可以实现按照权重weight排序，但是，如果不在模板中写明orderway=”asc”，无法实现权重越小越靠前，<br />
解决方案1：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">{</span><span style="color: Blue;">dede</span><span style="color: Gray;">:</span><span style="color: Green;">list</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">pagesize</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">10</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> </span><span style="color: Blue;">orderby</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">weight</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> </span><span style="color: Blue;">orderway</span><span style="color: Gray;">=</span><span style="color: #8b0000;">'</span><span style="color: Red;">asc</span><span style="color: #8b0000;">'</span><span style="color: Olive;">}</span><span style="color: Gray;"> •</span><span style="color: Olive;">[</span><span style="color: Blue;">field</span><span style="color: Gray;">:</span><span style="color: Blue;">textlink</span><span style="color: Gray;">/</span><span style="color: Olive;">]</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">br</span><span style="color: Gray;">/&gt; </span><span style="color: Olive;">{</span><span style="color: Gray;">/</span><span style="color: Blue;">dede</span><span style="color: Gray;">:</span><span style="color: Green;">list</span><span style="color: Olive;">}</span></li>
</ol></div>
<p>要实现越重越大越靠前，只需要将上述代码中的“orderway=’asc’”去掉就可以了。</p>
]]></content:encoded>
			<wfw:commentRss>http://xok.la/2012/02/dedecms_v56_weight.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>微软无线鼠标失灵解决办法</title>
		<link>http://xok.la/2011/09/microsoft_wireless_laser_mouse_6000_v20.html</link>
		<comments>http://xok.la/2011/09/microsoft_wireless_laser_mouse_6000_v20.html#comments</comments>
		<pubDate>Fri, 02 Sep 2011 12:40:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[硬件&amp;网络设备]]></category>

		<guid isPermaLink="false">http://xok.la/2011/09/microsoft_wireless_laser_mouse_6000_v20.html</guid>
		<description><![CDATA[朋友送的微软无线鼠标今天失灵，换了电池灯还可以亮。
型号：Microsoft Wireless Laser Mouse 6000 V2.0
用了几年了，舍不得。考到到刚好是之前启用了手机和笔记本蓝牙，怀疑与信号有点关系，于是上网上搜索了下，解决了。
解决办法如下：
插在电脑上的收发器上有个重置按钮，鼠标电池附近也有个重置按钮。同时按住这2个按钮1－2秒后，鼠标正常工作。... ]]></description>
			<content:encoded><![CDATA[<p>朋友送的微软无线鼠标今天失灵，换了电池灯还可以亮。</p>
<p>型号：Microsoft Wireless Laser Mouse 6000 V2.0</p>
<p>用了几年了，舍不得。考到到刚好是之前启用了手机和笔记本蓝牙，怀疑与信号有点关系，于是上网上搜索了下，解决了。</p>
<p><strong>解决办法如下：</strong></p>
<p>插在电脑上的收发器上有个重置按钮，鼠标电池附近也有个重置按钮。同时按住这2个按钮1－2秒后，鼠标正常工作。</p>
]]></content:encoded>
			<wfw:commentRss>http://xok.la/2011/09/microsoft_wireless_laser_mouse_6000_v20.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>打开&#8221;我的电脑&#8221;慢的解决办法</title>
		<link>http://xok.la/2011/09/mycomputer_slow.html</link>
		<comments>http://xok.la/2011/09/mycomputer_slow.html#comments</comments>
		<pubDate>Thu, 01 Sep 2011 18:30:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[基本功]]></category>

		<guid isPermaLink="false">http://xok.la/2011/09/mycomputer_slow.html</guid>
		<description><![CDATA[打开“我的电脑”则出现一个小手电筒图标，需要等待&#8230; 
修改注册表可以解决此问题： 
解决办法 
1 点击“开始”→“运行”，在运行对话框中输入“Regedit”，点击“确定”，打开注册表编辑器，依次展开如下子键： HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver，在其右侧窗口中新建一个名为“Maxworkitems”的DWORD值，然后双击它，在弹出的“编辑DWORD值”对话框中，根据计算机的内存容量来确定该键的键值，如果计算机内存小于512MB，请键入“256”；如果内存大于512MB，请设置... ]]></description>
			<content:encoded><![CDATA[<p><span class="Apple-style-span" style="color: #000000; font-family: Helvetica,Tahoma,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: #ffffff">打开“我的电脑”则出现一个小手电筒图标，需要等待&#8230;<span class="Apple-converted-space"> </span><br />
修改注册表可以解决此问题：<span class="Apple-converted-space"> </span></p>
<p>解决办法<span class="Apple-converted-space"> </span></p>
<p>1 点击“开始”→“运行”，在运行对话框中输入“Regedit”，点击“确定”，打开注册表编辑器，依次展开如下子键： HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver，在其右侧窗口中新建一个名为“Maxworkitems”的DWORD值，然后双击它，在弹出的“编辑DWORD值”对话框中，根据计算机的内存容量来确定该键的键值，如果计算机内存小于512MB，请键入“256”；如果内存大于512MB，请设置为“1024”。完成操作后，退出注册表编辑器，重新启动计算机即可生效。<span class="Apple-converted-space"> </span></p>
<p>2 把HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MYcomputer删了</span></p>
<p>注意，我使用的方法一，效果不明显。使用方法2后，打开我的电脑速度很快，但是以前&#8221;我的文档&#8221;、&#8221;共享文档&#8221;这些图标就没有显示了。</p>
]]></content:encoded>
			<wfw:commentRss>http://xok.la/2011/09/mycomputer_slow.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>ThinkPad R400 双系统以及显卡驱动设置(避免多次装驱动)</title>
		<link>http://xok.la/2011/08/thinkpad_r400_display.html</link>
		<comments>http://xok.la/2011/08/thinkpad_r400_display.html#comments</comments>
		<pubDate>Mon, 29 Aug 2011 14:47:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[笔记本]]></category>

		<guid isPermaLink="false">http://xok.la/2011/08/thinkpad_r400_display.html</guid>
		<description><![CDATA[问题：
2个磁盘，一个装了XP，一个装了WIN7。
一旦进入WIN7后，下次进入XP就要重装显卡驱动，之前的驱动丢失。
解决办法是，禁止BIOS显卡切换，指定都使用独立显卡。
开机后按F1进入BIOS
接着选择Config
进入配置界面
选择Display
第一项Default Primary Video Device(默认主显示设备)
PCI Express(独立选他)/Internal(集成)这里选择PCI Express
第三项Graphics Device（显卡设备）这里选择Discrete GraphicsIntergrated Graphics（集成显卡）/Discrete Graphics(独立显卡)/Swichable Graphics(可切换显卡)
OS Detection for Swichable Graphics(操作系... ]]></description>
			<content:encoded><![CDATA[<p>问题：</p>
<p>2个磁盘，一个装了XP，一个装了WIN7。</p>
<p>一旦进入WIN7后，下次进入XP就要重装显卡驱动，之前的驱动丢失。</p>
<p>解决办法是，禁止BIOS显卡切换，指定都使用独立显卡。</p>
<p>开机后按F1进入BIOS<br />
接着选择Config<br />
进入配置界面<br />
选择Display<br />
第一项Default Primary Video Device(默认主显示设备)<br />
PCI Express(独立选他)/Internal(集成)<font color="#ff0000">这里选择PCI Express<br />
</font>第三项Graphics Device（显卡设备）这里选择Discrete GraphicsIntergrated Graphics（集成显卡）/<font color="#ff0000">Discrete Graphics(独立显卡</font>)/Swichable Graphics(可切换显卡)<br />
OS Detection for Swichable Graphics(操作系统检测可切换显卡功能)<font color="#ff0000">这里选择Disabled<br />
</font>Disabled（禁用）/Enabled（启用）</p>
<p>总共设置3个地方。这样就可以解决问题了。</p>
]]></content:encoded>
			<wfw:commentRss>http://xok.la/2011/08/thinkpad_r400_display.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>C++如何获得U盘的盘符以及U盘相关属性的代码</title>
		<link>http://xok.la/2011/08/get_removable_disk.html</link>
		<comments>http://xok.la/2011/08/get_removable_disk.html#comments</comments>
		<pubDate>Sat, 20 Aug 2011 18:41:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://xok.la/2011/08/get_removable_disk.html</guid>
		<description><![CDATA[&#19979;&#36733;: xok.la.appchar diskPath[5] = { 0 };
&#160;&#160; &#160;DWORD allDisk = GetLogicalDrives(); //返回一个32位整数，将他转换成二进制后，表示磁盘,最低位为A盘
&#160;
&#160;&#160; &#160;if (allDisk!=0)
&#160;&#160; &#160;{
&#160;&#160; &#160; &#160; &#160;for (int i=0;i&#60;11;i++)&#160; &#160; &#160;//假定最多有10个磁盘
&#160;&#160; &#160; &#160; &#160;{
&#160;&#160; &#160; &#160; &#160; &#160; &#160;if ((allDisk &#38; 1)==1)
&#160;&#160; &#160; &#160; &#160; &#160; &#160;{
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;sprintf( diskPath, &#34;%c&#34;, 'C'+i );
&#160;&#160; &#160; &... ]]></description>
			<content:encoded><![CDATA[<div class="hl-title">&#19979;&#36733;: <a href="http://xok.la/wp-content/plugins/coolcode/coolcode.php?p=644&amp;download=xok.la.app">xok.la.app</a></div><div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">char diskPath[5] = { 0 };</li>
<li>&nbsp;&nbsp; &nbsp;DWORD allDisk = GetLogicalDrives(); //返回一个32位整数，将他转换成二进制后，表示磁盘,最低位为A盘</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp;if (allDisk!=0)</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for (int i=0;i&lt;11;i++)&nbsp; &nbsp; &nbsp;//假定最多有10个磁盘</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((allDisk &amp; 1)==1)</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sprintf( diskPath, &quot;%c&quot;, 'C'+i );</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strcat( diskPath, &quot;:\\&quot; );</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( GetDriveType(diskPath)==DRIVE_REMOVABLE )</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//AfxMessageBox( &quot;检测到U盘&quot;, MB_OK );</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//AfxMessageBox( diskPath, MB_OK );</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if( GetVolumeInformation(diskPath,0,0,0,0,0,0,0) ) //判断驱动是否准备就绪</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AfxMessageBox( &quot;U盘就绪&quot;, MB_OK );</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;allDisk = allDisk&gt;&gt;1;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp;if ((allDisk &amp; 1)!=1) //未检测到U盘</li>
<li>&nbsp;&nbsp; &nbsp;{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;AfxMessageBox( &quot;未检测到U盘,请插入U盘&quot;, MB_OK);</li>
<li>&nbsp;&nbsp; &nbsp;}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://xok.la/2011/08/get_removable_disk.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>BSTR、char* 和 CString 之间的转换</title>
		<link>http://xok.la/2011/08/bstr_char_cstring.html</link>
		<comments>http://xok.la/2011/08/bstr_char_cstring.html#comments</comments>
		<pubDate>Fri, 19 Aug 2011 12:05:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://xok.la/2011/08/bstr_char_cstring.html</guid>
		<description><![CDATA[
BSTR、char* 和 CString 之间的转换
　　(1) char*转换成CString
　　若将char*转换成CString，除了直接赋值外，还可使用CString::Format进行。例如：
char chArray[] = &#34;This is a test&#34;; 
char * p = &#34;This is a test&#34;;
　　或
LPSTR p = &#34;This is a test&#34;;
　　或在已定义Unicode应的用程序中
TCHAR * p = _T(&#34;This is a test&#34;);
　　或
LPTSTR p = _T(&#34;This is a test&#34;); 
CString theString = chArray; 
theString.Format(_T(&#34;%s&#34;), chArray); 
theString = p;
　　(2) CString转换成char*
　　若将CString类转换成char*(LPSTR)类型，常常使用下列三种... ]]></description>
			<content:encoded><![CDATA[<p>
BSTR、char* 和 CString 之间的转换</p>
<p>　　<b>(1) char*转换成CString</b><br />
　　若将char*转换成CString，除了直接赋值外，还可使用CString::Format进行。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">char chArray[] = &quot;This is a test&quot;; </li>
<li>char * p = &quot;This is a test&quot;;</li></ol></div>
<p>　　或</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LPSTR p = &quot;This is a test&quot;;</li></ol></div>
<p>　　或在已定义Unicode应的用程序中</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">TCHAR * p = _T(&quot;This is a test&quot;);</li></ol></div>
<p>　　或</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LPTSTR p = _T(&quot;This is a test&quot;); </li>
<li>CString theString = chArray; </li>
<li>theString.Format(_T(&quot;%s&quot;), chArray); </li>
<li>theString = p;</li></ol></div>
<p>　　<b>(2) CString转换成char*</b><br />
　　若将CString类转换成char*(LPSTR)类型，常常使用下列三种方法：<br />
　　方法一，使用强制转换。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CString theString( &quot;This is a test&quot; ); </li>
<li>LPTSTR lpsz =(LPTSTR)(LPCTSTR)theString;</li></ol></div>
<p>　　方法二，使用strcpy。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CString theString( &quot;This is a test&quot; ); </li>
<li>LPTSTR lpsz = new TCHAR[theString.GetLength()+1]; </li>
<li>_tcscpy(lpsz, theString);</li></ol></div>
<p>　　需要说明的是，strcpy(或可移值Unicode/MBCS的_tcscpy)的第二个参数是 const wchar_t* (Unicode)或const char* (ANSI)，系统编译器将会自动对其进行转换。<br />
　　方法三，使用CString::GetBuffer。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CString s(_T(&quot;This is a test &quot;)); </li>
<li>LPTSTR p = s.GetBuffer();</li></ol></div>
<p>// 在这里添加使用p的代码 </p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">if(p != NULL) *p = _T('\0'); </li>
<li>s.ReleaseBuffer();</li></ol></div>
<p>// 使用完后及时释放，以便能使用其它的CString成员函数<br />
　　<b>(3) BSTR转换成char*</b><br />
　　方法一，使用ConvertBSTRToString。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#include </li>
<li>#pragma comment(lib, &quot;comsupp.lib&quot;) </li>
<li>int _tmain(int argc, _TCHAR* argv[]){ </li>
<li>BSTR bstrText = ::SysAllocString(L&quot;Test&quot;); </li>
<li>char* lpszText2 = _com_util::ConvertBSTRToString(bstrText); </li>
<li>SysFreeString(bstrText); // 用完释放 </li>
<li>delete[] lpszText2; </li>
<li>return 0; </li>
<li>}</li></ol></div>
<p>　　方法二，使用_bstr_t的赋值运算符重载。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">_bstr_t b = bstrText; </li>
<li>char* lpszText2 = b;</li></ol></div>
<p>　　<b>(4) char*转换成BSTR</b><br />
　　方法一，使用SysAllocString等API函数。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">BSTR bstrText = ::SysAllocString(L&quot;Test&quot;); </li>
<li>BSTR bstrText = ::SysAllocStringLen(L&quot;Test&quot;,4); </li>
<li>BSTR bstrText = ::SysAllocStringByteLen(&quot;Test&quot;,4)</li></ol></div>
<p>;<br />
　　方法二，使用COleVariant或_variant_t。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">//COleVariant strVar(&quot;This is a test&quot;); </li>
<li>_variant_t strVar(&quot;This is a test&quot;); </li>
<li>BSTR bstrText = strVar.bstrVal;</li></ol></div>
<p>　　方法三，使用_bstr_t，这是一种最简单的方法。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">BSTR bstrText = _bstr_t(&quot;This is a test&quot;);</li></ol></div>
<p>　　方法四，使用CComBSTR。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">BSTR bstrText = CComBSTR(&quot;This is a test&quot;);</li></ol></div>
<p>　　或</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CComBSTR bstr(&quot;This is a test&quot;); </li>
<li>BSTR bstrText = bstr.m_str;</li></ol></div>
<p>　　方法五，使用ConvertStringToBSTR。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">char* lpszText = &quot;Test&quot;; </li>
<li>BSTR bstrText = _com_util::ConvertStringToBSTR(lpszText);</li></ol></div>
<p>　　<b>(5) CString转换成BSTR</b><br />
　　通常是通过使用CStringT::AllocSysString来实现。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CString str(&quot;This is a test&quot;); </li>
<li>BSTR bstrText = str.AllocSysString();</li>
<li>&nbsp;</li>
<li>SysFreeString(bstrText); // 用完释放</li></ol></div>
<p>　　<b>(6) BSTR转换成CString</b><br />
　　一般可按下列方法进行：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">BSTR bstrText = ::SysAllocString(L&quot;Test&quot;); </li>
<li>CStringA str; </li>
<li>str.Empty(); </li>
<li>str = bstrText;</li></ol></div>
<p>　　或</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CStringA str(bstrText);</li></ol></div>
<p>　　<b>(7) ANSI、Unicode和宽字符之间的转换</b><br />
　　方法一，使用MultiByteToWideChar将ANSI字符转换成Unicode字符，使用WideCharToMultiByte将Unicode字符转换成ANSI字符。<br />
　　方法二，使用“_T”将ANSI转换成“一般”类型字符串，使用“L”将ANSI转换成Unicode，而在托管C++环境中还可使用S将ANSI字符串转换成String*对象。例如：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">TCHAR tstr[] = _T(&quot;this is a test&quot;); </li>
<li>wchar_t wszStr[] = L&quot;This is a test&quot;; </li>
<li>String* str = S&quot;This is a test&quot;;</li></ol></div>
<p>　　方法三，使用ATL 7.0的转换宏和类。ATL7.0在原有3.0基础上完善和增加了许多字符串转换宏以及提供相应的类，它具有如图3所示的统一形式：<br />
　　其中，第一个C表示“类”，以便于ATL 3.0宏相区别，第二个C表示常量，2表示“to”，EX表示要开辟一定大小的缓冲。SourceType和DestinationType可以是A、T、W和OLE，其含义分别是ANSI、Unicode、“一般”类型和OLE字符串。例如，CA2CT就是将ANSI转换成一般类型的字符串常量。下面是一些示例代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LPTSTR tstr= CA2TEX&lt;16&gt;(&quot;this is a test&quot;); </li>
<li>LPCTSTR tcstr= CA2CT(&quot;this is a test&quot;); </li>
<li>wchar_t wszStr[] = L&quot;This is a test&quot;; </li>
<li>char* chstr = CW2A(wszStr);</li></ol></div>
<p>　　六、结语<br />
　　几乎所有的程序都要用到字符串，而Visual C++.NET由于功能强大、应用广泛，因而字符串之间的转换更为频繁。本文几乎涉及到目前的所有转换方法。当然对于.NET框架来说，还可使用Convert和Text类进行不同数据类型以及字符编码之间的相互转换。</p>
]]></content:encoded>
			<wfw:commentRss>http://xok.la/2011/08/bstr_char_cstring.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

