﻿<?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>IT博客-而立记事</title><link>http://www.cnitblog.com/toysun/</link><description>我能三十而立？？</description><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 06:00:50 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 06:00:50 GMT</pubDate><ttl>60</ttl><item><title>可配置UI设计设想</title><link>http://www.cnitblog.com/toysun/archive/2010/06/13/66723.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Sun, 13 Jun 2010 11:09:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2010/06/13/66723.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/66723.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2010/06/13/66723.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/66723.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/66723.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cnitblog.com/toysun/archive/2010/06/13/66723.html'>阅读全文</a><img src ="http://www.cnitblog.com/toysun/aggbug/66723.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2010-06-13 19:09 <a href="http://www.cnitblog.com/toysun/archive/2010/06/13/66723.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>系统维护管理小工具集</title><link>http://www.cnitblog.com/toysun/archive/2010/06/12/66663.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Sat, 12 Jun 2010 06:49:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2010/06/12/66663.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/66663.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2010/06/12/66663.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/66663.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/66663.html</trackback:ping><description><![CDATA[<p><a href="http://technet.microsoft.com/zh-cn/sysinternals/bb545027.aspx">http://technet.microsoft.com/zh-cn/sysinternals/bb545027.aspx</a><br>许多系统级别小工具：<br>文件和磁盘实用工具<br>网络实用工具<br>进程实用工具<br>安全实用工具<br>系统信息实用工具<br>其他实用工具</p>
<p>全部工具下载链接<br><a href="http://download.sysinternals.com/Files/SysinternalsSuite.zip">http://download.sysinternals.com/Files/SysinternalsSuite.zip</a></p>
<img src ="http://www.cnitblog.com/toysun/aggbug/66663.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2010-06-12 14:49 <a href="http://www.cnitblog.com/toysun/archive/2010/06/12/66663.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>#pragma once 学习</title><link>http://www.cnitblog.com/toysun/archive/2010/05/30/66446.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Sun, 30 May 2010 01:00:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2010/05/30/66446.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/66446.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2010/05/30/66446.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/66446.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/66446.html</trackback:ping><description><![CDATA[#pragma once 是C/C++的预处理指令，非标准但很常用；主要功能是保证每次编译时候当前文件只包含一次。功能与定义宏来避免重复包含一样。使用举例：<br>grandfather.h<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#pragma&nbsp;once<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;<br><img id=Codehighlighter1_26_44_Open_Image onclick="this.style.display='none'; Codehighlighter1_26_44_Open_Text.style.display='none'; Codehighlighter1_26_44_Closed_Image.style.display='inline'; Codehighlighter1_26_44_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_26_44_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_26_44_Closed_Text.style.display='none'; Codehighlighter1_26_44_Open_Image.style.display='inline'; Codehighlighter1_26_44_Open_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;foo&nbsp;</span><span id=Codehighlighter1_26_44_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cnitblog.com/Images/dot.gif"></span><span id=Codehighlighter1_26_44_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;member;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">;</span></div>
<br>father.h<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">grandfather.h</span><span style="COLOR: #000000">"</span></div>
<br>child.h<br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">grandfather.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">father.h</span><span style="COLOR: #000000">"</span></div>
<br>与宏定义相比，#pragma once加快了编译速度，编码更少，避免宏定义名称冲突；但是有些编译器不支持，用<br><font face=Arial>#pragma once会导致代码移植困难。两种方式同时使用解决这些问题：<br></font>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#pragma&nbsp;once<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>#ifndef&nbsp;GRANDFATHER_H<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000">&nbsp;GRANDFATHER_H</span><span style="COLOR: #000000"><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;foo<br><img id=Codehighlighter1_70_88_Open_Image onclick="this.style.display='none'; Codehighlighter1_70_88_Open_Text.style.display='none'; Codehighlighter1_70_88_Closed_Image.style.display='inline'; Codehighlighter1_70_88_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_70_88_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_70_88_Closed_Text.style.display='none'; Codehighlighter1_70_88_Open_Image.style.display='inline'; Codehighlighter1_70_88_Open_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_70_88_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cnitblog.com/Images/dot.gif"></span><span id=Codehighlighter1_70_88_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;member;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">#endif</span><span style="COLOR: #000000">&nbsp;/*&nbsp;GRANDFATHER_H&nbsp;*/</span></div>
<br>参考：<br><a title=http://en.wikipedia.org/wiki/Pragma_once href="http://en.wikipedia.org/wiki/Pragma_once" target=_blank>http://en.wikipedia.org/wiki/Pragma_once</a><br>
<img src ="http://www.cnitblog.com/toysun/aggbug/66446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2010-05-30 09:00 <a href="http://www.cnitblog.com/toysun/archive/2010/05/30/66446.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>XBMC Architecture Overview</title><link>http://www.cnitblog.com/toysun/archive/2010/05/24/66313.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Mon, 24 May 2010 12:18:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2010/05/24/66313.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/66313.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2010/05/24/66313.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/66313.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/66313.html</trackback:ping><description><![CDATA[<p><img height=768 alt="" src="http://www.cnitblog.com/images/cnitblog_com/toysun/xbmc.JPG" width=708 border=0></p>
<p>&nbsp;</p>
<p><br><br><strong style="FONT-SIZE: 18pt">XBMC Media Center</strong></p>
<p>XBMC Media Center is your ultimate multimedia hub. From the stunning interface, down to <br>the helpful and enthusiastic community, it has everything you need to take your media <br>enjoyment experience to the next level. Under the hood lies an extremely powerful and versatile <br>custom skinning engine which allows skinners to define nearly every aspect of the application <br>and make their wildest dreams a reality. XBMC's library mode will take that mess of media files <br>you have collected over the years and present them to you in immaculate organization. It taps <br>several meta data sources for a plethora of information to enrich your experience. In addition to <br>media on your computer, XBMC can stream content from a multitude of on-line resources for <br>your enjoyment. A python interface lets you customize behavior and adds yet another source of <br>content via scripts and plug-ins. Playback is handled by a pair of in-house players. One for <br>music and another for video, each leveraging the very best of open source codecs ensuring <br>XBMC can handle anything you throw at it. These features and many more make XBMC your <br>best choice in home theater computer software.</p>
<p><strong>Graphical User Interface and Skinning Engine</strong></p>
<p>Dubbed guilib internally, XBMC's skinning engine is one of the most powerful available in the <br>HTPC market. The XBMC core defines a minimum set of controls for each window to do its <br>job but the skin is free to present these and any additional controls as they wish. Skin authors <br>have all of the usual GUI elements at their disposal; labels, buttons, radio buttons, text boxes, <br>spin boxes, sliders, scroll bars, control lists and control groups are all completely customizable. <br>In addition, guilib takes advantage of today's 3D graphics hardware to provide silky smooth, <br>animations and transitions.</p>
<p>Skins are defined by text files formatted in the XML mark-up language and images. There is <br>one XML file to define each window and dialog defined by the core application. In this file, the <br>position, dimensions, visibility, images and navigation details of each control are specified, as <br>well as any animations and transitions for the window. Skins can also add more controls to each </p>
<p><br>window that execute XBMC built-in functions and scripts, raise specific windows, or query <br>player and system information. Control visibility can be conditional based on what the <br>application is doing at the time and can be delayed if need be. There is also the ability for skins <br>to add their own settings to control aspects of the look.</p>
<p>The skin engine also contains several other parts of the interface. There is a window manager <br>which keeps track of view states of each window such as list sort orders and currently selected <br>control. An audio manager plays navigation sounds on cursor movement, click and back <br>actions. XBMC has been translated to dozens of languages. guilib handles all string <br>localization and also lets skins declare their own strings with translations. The last <br>responsibility of guilib is user input, taking events from a remote control, keyboard, mouse or <br>some other device through an event client and passing them on to the application.</p>
<p><strong>Interfaces</strong></p>
<p>XBMC offers several interfaces to control, modify behavior and add content. The built in <br>Python interpreter provides two of these interfaces. The first, scripts, are mini programs <br>designed to stand alone from XBMC. The xbmc and xbmcgui modules define the Python API <br>into XBMC. Functions for controlling players, querying meta data, manipulating settings and <br>the like are all available through the xbmc module. Script graphical interfaces are designed <br>using the xbmcgui module, all of the controls available in the skinning engine can also be used <br>for scripting. Using the WindowXML class in the xbmcgui module, the script can be skinned in <br>an identical fashion to XBMC itself. Scripts can perform their task in the background with no <br>user interactivity at all, or obtain a fully customizable window for a clean graphical interface. </p>
<p>The Python interpreter also provides file system (or directory) plug-ins, commonly referred to <br>simply as &#8220;plugins&#8221;. These are special python scripts designed to fill a directory listing with <br>content which may not be easily described otherwise and fit it in to the normal categories <br>provided by XBMC (music, video, pictures and programs). Plug-ins take their visual queues </p>
<p><br>from the active XBMC skin so no specific skinning is necessary or available. They can also add <br>items to the XBMC context menu when the plug-in is active, as well as define their own <br>settings. File system plug-ins are often used to integrate content from websites (eg. YouTube) <br>into XBMC.</p>
<p>Remote access to XBMC is provided via an embedded web server. It serves a web page <br>offering the ability to browse your media and control the XBMC session from your web <br>browser. The web server also provides the XBMC HTTP-API for developers to add XBMC <br>control to their applications. It exposes full control over XBMC as well as information <br>regarding what is currently playing and querying the library databases. Commands are <br>executed by making a simple HTTP GET request and any information or status codes are <br>returned in HTML format. Adding new functions to this interface is very simple in the XBMC <br>code base.</p>
<p>A recently added interface into XBMC is the Event Server. The aim of this API is to allow <br>developers to add support for various types of input devices. It listens on a UDP socket for <br>Event Clients to connect and send events. The clients run separately from XBMC and can be <br>written in any programming language that supports UDP networking. They commonly leverage <br>other libraries written to handle the target input device. Their main interaction is sending button <br>presses or joystick action to XBMC, but can also send notification messages for events such as <br>battery status. One popular event client adds support for the Sony Playstation 3 bluetooth six <br>axis game pad.</p>
<p>There are two new APIs currently in development branches of XBMC. The first, DLL Add-ons, <br>aims to add features similar to the Python interpreter. The difference will be that the <br>applications will be written in C or C++ and compiled into modules, removing the python <br>interpreter overhead. XBMC can then load and execute them at the user's request. Secondly, <br>PVR Clients, will allow interaction with PVR back end applications such as MythTV and VDR. <br>This will give XBMC OTA, DVB, etc card access without having to actually support any </p>
<p><br>hardware itself. When completed, users will be able to fully control features of supported PVR <br>applications, including; live TV, record timers, time shifting and on-screen guides.</p>
<p><strong>Content Management</strong></p>
<p>In order for content to be visible in XBMC a source must be created to point to it. There are <br>several available sources for media content supported out of box. Locally, any content on the <br>users hard disk, CD-ROM or DVD-ROM can be added. Remote sources, though, are where <br>XBMC really gets interesting. Users can point XBMC at another computer serving their media <br>via SMB (Windows File Sharing), HTTP, FTP, UPnP and DAAP (iTunes 6 sharing). <br>Additionally sources for some service can be configured without support software such as <br>Last.fm and shoutcast radio streams and OTA/DVB TV devices, such as dbox, tuxbox and <br>MythTV live TV, which export the video stream over the local network. </p>
<p>Once a source is added, all of its contents is immediately available via the file view. This view <br>presents media as you would expect in a file browser, with an icon, the file name, and a few <br>other details pertinent to the selected sort order. If source contains static data (ie. the media isn't <br>a stream), it can now be scanned into the library. This involves selecting a content type for <br>videos; one of TV, Movies or Music Videos, selecting a website to scrape meta data from and <br>answering a few questions as to how the files are laid out. XBMC will now read any tags and <br>hunt out meta data on-line, storing this information in a database for quick easy access, later.</p>
<p>Library view is now available, providing a far richer experience. Fanart (backgrounds that <br>relate to the focused media item) will be displayed in some view modes. In the music section, <br>artist biographies and album reviews are available. For videos, you can now see play times, air <br>dates, ratings, season and episode numbers, actors and a multitude of other information. This <br>meta data is then used to organize media files and present them to in a friendly fashion. <br>Another nice feature of the library is smart play lists. These are automatically generate play <br>lists based on user selected values of meta data fields.</p>
<p><br><strong>Player Core</strong></p>
<p>Playback quality is paramount to XBMC's success. To that end, a pair of custom players are <br>employed to ensure the utmost performance. DVDPlayer is used for all video playback. It is <br>based off of the FFMpeg multimedia decoding library and features playback of all popular <br>audio and video codecs, several subtitle formats as well as DVD menu support. Music playback <br>is handled by PAPlayer. It takes advantage of several open source audio codecs and features <br>gap-less playback and cross-fade. There is even a special codec that calls in to DVDPlayer on <br>the off chance that PAPlayer doesn't recognize a file type. PAPlayer also has a facility to export <br>the raw audio samples supporting reactive visualizations.</p>
<p><strong>File Sharing</strong></p>
<p>XBMC provides local network file sharing via a UPnP server. It relies on the library features, <br>and allows for the content and meta-data in the library to be provided to other UPnP clients on <br>your network. The server strives to be DLNA compliant, so it will work with popular clients <br>such as Windows Media Player, Xbox360 and Playstation3 assuming they support the format <br>being requested.</p>
<p><br></p>
<img src ="http://www.cnitblog.com/toysun/aggbug/66313.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2010-05-24 20:18 <a href="http://www.cnitblog.com/toysun/archive/2010/05/24/66313.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>配置 EditPlus 编译C++ （VS2005）</title><link>http://www.cnitblog.com/toysun/archive/2010/05/20/66228.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Thu, 20 May 2010 00:20:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2010/05/20/66228.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/66228.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2010/05/20/66228.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/66228.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/66228.html</trackback:ping><description><![CDATA[

<div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008080; ">1.以下代码保存为bat文件（根据VS安装目录不同需要自定义）</span></div><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><span style="color: #008080; ">1</span>&nbsp;<span style="color: #000000; ">@if&nbsp;/I&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">==</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">c</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;goto&nbsp;IsCorCPP<br></span><span style="color: #008080; ">&nbsp;2</span>&nbsp;<span style="color: #000000; ">@if&nbsp;/I&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%2</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">==</span><span style="color: #000000; ">&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">cpp</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&nbsp;goto&nbsp;IsCorCPP<br></span><span style="color: #008080; ">&nbsp;3</span>&nbsp;<span style="color: #000000; ">@goto&nbsp;error_par<br></span><span style="color: #008080; ">&nbsp;4</span>&nbsp;<span style="color: #000000; "><br></span><span style="color: #008080; ">&nbsp;5</span>&nbsp;<span style="color: #000000; ">:IsCorCPP<br></span><span style="color: #008080; ">&nbsp;6</span>&nbsp;<span style="color: #000000; ">@if&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">==</span><span style="color: #000000; ">""</span><span style="color: #000000; ">&nbsp;goto&nbsp;error_no_par<br></span><span style="color: #008080; ">&nbsp;7</span>&nbsp;<span style="color: #000000; ">@SET&nbsp;VSINSTALLDIR</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; "><br></span><span style="color: #008080; ">&nbsp;8</span>&nbsp;<span style="color: #000000; ">@SET&nbsp;VCINSTALLDIR</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; ">\VC<br></span><span style="color: #008080; ">&nbsp;9</span>&nbsp;<span style="color: #000000; ">@SET&nbsp;FrameworkDir</span><span style="color: #000000; ">=</span><span style="color: #000000; ">C:\WINDOWS\Microsoft.NET\Framework<br></span><span style="color: #008080; ">10</span>&nbsp;<span style="color: #000000; ">@SET&nbsp;FrameworkVersion</span><span style="color: #000000; ">=</span><span style="color: #000000; ">v2</span><span style="color: #000000; ">.0.50727</span><span style="color: #000000; "><br></span><span style="color: #008080; ">11</span>&nbsp;<span style="color: #000000; ">@SET&nbsp;FrameworkSDKDir</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; ">\SDK\v2</span><span style="color: #000000; ">.0</span><span style="color: #000000; "><br></span><span style="color: #008080; ">12</span>&nbsp;<span style="color: #000000; ">@set&nbsp;DevEnvDir</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; ">\Common7\IDE<br></span><span style="color: #008080; ">13</span>&nbsp;<span style="color: #000000; ">@set&nbsp;PATH</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; ">\Common7\IDE</span><span style="color: #008000; ">;</span><span style="color: #008000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\BIN;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\Common7\Tools;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\Common7\Tools\bin;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\PlatformSDK\bin;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\VCPackages;%PATH%</span><span style="color: #008000; "><br></span><span style="color: #008080; ">14</span>&nbsp;<span style="color: #008000; "></span><span style="color: #000000; ">@set&nbsp;INCLUDE</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; ">\VC\ATLMFC\INCLUDE</span><span style="color: #008000; ">;</span><span style="color: #008000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\INCLUDE;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\PlatformSDK\include;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\SDK\v2.0\include;%INCLUDE%</span><span style="color: #008000; "><br></span><span style="color: #008080; ">15</span>&nbsp;<span style="color: #008000; "></span><span style="color: #000000; ">@set&nbsp;LIB</span><span style="color: #000000; ">=</span><span style="color: #000000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;</span><span style="color: #000000; ">8</span><span style="color: #000000; ">\VC\ATLMFC\LIB</span><span style="color: #008000; ">;</span><span style="color: #008000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\LIB;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\PlatformSDK\lib;D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\SDK\v2.0\lib;%LIB%</span><span style="color: #008000; "><br></span><span style="color: #008080; ">16</span>&nbsp;<span style="color: #008000; "></span><span style="color: #000000; ">@set&nbsp;LIBPATH</span><span style="color: #000000; ">=</span><span style="color: #000000; ">C:\WINDOWS\Microsoft.NET\Framework\v2</span><span style="color: #000000; ">.0.50727</span><span style="color: #008000; ">;</span><span style="color: #008000; ">D:\Program&nbsp;Files\Microsoft&nbsp;Visual&nbsp;Studio&nbsp;8\VC\ATLMFC\LIB</span><span style="color: #008000; "><br></span><span style="color: #008080; ">17</span>&nbsp;<span style="color: #008000; "></span><span style="color: #000000; ">@cl&nbsp;%</span><span style="color: #000000; ">1</span><span style="color: #000000; "><br></span><span style="color: #008080; ">18</span>&nbsp;<span style="color: #000000; ">@if&nbsp;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">%3</span><span style="color: #000000; ">"</span><span style="color: #000000; ">==</span><span style="color: #000000; ">""</span><span style="color: #000000; ">&nbsp;goto&nbsp;end<br></span><span style="color: #008080; ">19</span>&nbsp;<span style="color: #000000; ">@echo.&nbsp;<br></span><span style="color: #008080; ">20</span>&nbsp;<span style="color: #000000; ">@echo&nbsp;以下为程序&nbsp;%</span><span style="color: #000000; ">3</span><span style="color: #000000; ">&nbsp;运行结果：<br></span><span style="color: #008080; ">21</span>&nbsp;<span style="color: #000000; ">@%</span><span style="color: #000000; ">3</span><span style="color: #000000; "><br></span><span style="color: #008080; ">22</span>&nbsp;<span style="color: #000000; ">@goto&nbsp;end<br></span><span style="color: #008080; ">23</span>&nbsp;<span style="color: #000000; "><br></span><span style="color: #008080; ">24</span>&nbsp;<span style="color: #000000; ">:error_no_par<br></span><span style="color: #008080; ">25</span>&nbsp;<span style="color: #000000; ">@echo&nbsp;请输入参数。<br></span><span style="color: #008080; ">26</span>&nbsp;<span style="color: #000000; ">@goto&nbsp;end<br></span><span style="color: #008080; ">27</span>&nbsp;<span style="color: #000000; "><br></span><span style="color: #008080; ">28</span>&nbsp;<span style="color: #000000; ">:error_par<br></span><span style="color: #008080; ">29</span>&nbsp;<span style="color: #000000; ">@echo&nbsp;要处理的文件非C/C++文件。<br></span><span style="color: #008080; ">30</span>&nbsp;<span style="color: #000000; ">@goto&nbsp;end<br></span><span style="color: #008080; ">31</span>&nbsp;<span style="color: #000000; ">:end</span></div><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><span style="color: #000000; ">2.EditPlus添加工具：</span></div><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><span style="color: #000000; ">命令行为该bat文件，参数设置为：$(FileName) $(FileExt) $(FileNameNoExt).exe，初始目录设置为：$(FileDir)</span></div><div style="background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><span style="color: #000000; "><br></span></div><img src ="http://www.cnitblog.com/toysun/aggbug/66228.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2010-05-20 08:20 <a href="http://www.cnitblog.com/toysun/archive/2010/05/20/66228.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在hosts里面加上一行174.36.30.71  www.dropbox.com解决dropbox被墙的问题</title><link>http://www.cnitblog.com/toysun/archive/2010/05/20/66227.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Thu, 20 May 2010 00:11:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2010/05/20/66227.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/66227.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2010/05/20/66227.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/66227.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/66227.html</trackback:ping><description><![CDATA[<span  style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 20px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><div>在hosts里面加上一行174.36.30.71&nbsp; www.dropbox.com解决dropbox被墙的问题</div></span><img src ="http://www.cnitblog.com/toysun/aggbug/66227.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2010-05-20 08:11 <a href="http://www.cnitblog.com/toysun/archive/2010/05/20/66227.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Delphi 7 Socket 的封装</title><link>http://www.cnitblog.com/toysun/archive/2009/08/27/61039.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Thu, 27 Aug 2009 06:56:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2009/08/27/61039.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/61039.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2009/08/27/61039.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/61039.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/61039.html</trackback:ping><description><![CDATA[<a title="Delphi 7 Socket 的封装" href="http://www.cnitblog.com/Files/toysun/socket.doc" target=_self>Delphi 7 Socket 的封装</a>
<img src ="http://www.cnitblog.com/toysun/aggbug/61039.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2009-08-27 14:56 <a href="http://www.cnitblog.com/toysun/archive/2009/08/27/61039.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]ATL: Firing Events from Worker Threads</title><link>http://www.cnitblog.com/toysun/archive/2009/08/08/60662.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Sat, 08 Aug 2009 06:15:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2009/08/08/60662.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/60662.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2009/08/08/60662.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/60662.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/60662.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Michael Lindig&nbsp;&nbsp;&nbsp;&nbsp;July 16, 2000&nbsp;In most cases of my work I develop ATL objects with worker threads. In the worker threads there must be often fire events for signalling thre...&nbsp;&nbsp;<a href='http://www.cnitblog.com/toysun/archive/2009/08/08/60662.html'>阅读全文</a><img src ="http://www.cnitblog.com/toysun/aggbug/60662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2009-08-08 14:15 <a href="http://www.cnitblog.com/toysun/archive/2009/08/08/60662.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>接触C++（1） 基本字符串操作</title><link>http://www.cnitblog.com/toysun/archive/2009/06/23/59565.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Tue, 23 Jun 2009 08:17:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2009/06/23/59565.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/59565.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2009/06/23/59565.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/59565.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/59565.html</trackback:ping><description><![CDATA[<p><font color=#002c99>&nbsp;</p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cnitblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main()&nbsp;<br><img id=Codehighlighter1_34_309_Open_Image onclick="this.style.display='none'; Codehighlighter1_34_309_Open_Text.style.display='none'; Codehighlighter1_34_309_Closed_Image.style.display='inline'; Codehighlighter1_34_309_Closed_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_34_309_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_34_309_Closed_Text.style.display='none'; Codehighlighter1_34_309_Open_Image.style.display='inline'; Codehighlighter1_34_309_Open_Text.style.display='inline';" src="http://www.cnitblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_34_309_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cnitblog.com/Images/dot.gif"></span><span id=Codehighlighter1_34_309_Open_Text><span style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;std::wcout.imbue(std::locale(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">chs</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;wchar_t&nbsp;wPortName[</span><span style="COLOR: #000000">13</span><span style="COLOR: #000000">]&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;L</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\\\\.\\COM</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;&nbsp;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;wchar_t&nbsp;wPortNum[</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">];<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;_itow(i,wPortNum,</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">);<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;wcscat(wPortName,wPortNum);<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;std::wcout&nbsp;</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">wPortName</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">&nbsp;std::endl;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;std::wcin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">wPortName;<br><img src="http://www.cnitblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&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><img src="http://www.cnitblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000">&nbsp;</span></div>
<p></font><a href="http://www.cnitblog.com/toysun/"></a>&nbsp;输出、连接字符串、整型转字符串</p>
<img src ="http://www.cnitblog.com/toysun/aggbug/59565.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2009-06-23 16:17 <a href="http://www.cnitblog.com/toysun/archive/2009/06/23/59565.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3 - Winsock 1.1 Resolution (1)</title><link>http://www.cnitblog.com/toysun/archive/2009/06/13/59318.html</link><dc:creator>鸡蛋捞面</dc:creator><author>鸡蛋捞面</author><pubDate>Sat, 13 Jun 2009 07:08:00 GMT</pubDate><guid>http://www.cnitblog.com/toysun/archive/2009/06/13/59318.html</guid><wfw:comment>http://www.cnitblog.com/toysun/comments/59318.html</wfw:comment><comments>http://www.cnitblog.com/toysun/archive/2009/06/13/59318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/toysun/comments/commentRss/59318.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/toysun/services/trackbacks/59318.html</trackback:ping><description><![CDATA[<p><font color=#002c99>&nbsp;&nbsp;&nbsp; With the introduction of Winsock 2, Microsoft provideders with a protocol-independent <br>API that resolves hosts, protocols, and services in a more flexible and powerful way than <br>the services that came with Winsock 1.1. The use of these new functions, though, comes <br>at a price in terms of increased complexity. As with most other Microsoft APIs, the original <br>functions are still valid and simpler to understand. However, it is worthwhile to pick up this <br>technology of protocol-independent functions for the resolving of hosts and services because<br>&nbsp;by using the concept of protocol independence, we can simplify the whole process of<br>&nbsp;resolving host names and services.</font></p>
<p><font color=#002c99>&nbsp;&nbsp;&nbsp;&nbsp; However, before we begin to explorer the new functions, we must lay the foundation by <br>understanding the rudiments of resolving hosts, protocols, and services. With that background, <br>you weill be prepared to master the more complex Winsock 2 resolution functions. Therefore, <br>we'll concentrate on winsock 1.1 resolution functions in this chapter and leave the Winsok 2<br>&nbsp;protocol-indenpent functions to the next chapter. Before dealing with the Winsock 1.1 resolution<br>&nbsp;functions in detail, we'll examine the translation functions that handle byte ordering.</font></p>
<p><font color=#002c99>&nbsp;&nbsp;&nbsp;&nbsp; Before dipping (浸渍) our toes (脚趾) in the unknown waters of Winsock resolution, let's consider <br>this question: What is Winsock 1.1 resolution(解析) ? We'll use a simple analogy(模拟) to discover <br>an answer to this question. You use a telephone directory to look up a telephone number to call your firend. <br>The telephone directory enables&nbsp;&nbsp; you to quickly retrieve your firend's telephone number without having to <br>remember the number. When it comes to host name resolution, the same princi-<br>ple applies. when you want to connect with a host on the Internet, you need to<br>know its IP address, which, if you like, is the equivalent of the telephone num-<br>ber. Hosts on every TCP/IP network, including the Internet, use IP addresses<br>to identify themselves to each other. Unfortunately, the majority of humans (and<br>that includes Delphi developers) cannot remember IP addresses in their raw<br>form. In the early days of the Internet, IP addresses were routinely used but<br>became impossible when the Internet expanded. To resolve (no pun intended)<br>this problem, the mechanism of mapping names (essentially aliases) to IP<br>address came into being. The mapping of these aliases to their IP address is<br>called host name resolution. Because of mapping names that are user friendly,<br>that is, easy to remember, you don't need to know the host's IP address, pro-<br>videdk you know its friendly name.<br>&nbsp; Establishing a mapping of a host name with an IP address is not the end of<br>the equation. Before you can communicate with a TCP/IP host, you need to<br>know the port upon which the host operates the desired service, like FTP and<br>HTTP. Extending the telephone directory analogym, you would either know your<br>firend's extension or speak with the operator to put you through to your friend.<br>Perhaps in your case, you would speak to the operator to get though. This is<br>analogous to what we call service resolution. Added to this equation, we must<br>also resolve service names to their port numbers. Services such as FTP and <br>HTTP are well known to surfers on the Net, but hosts deal in numbers when it <br>comes to providing a service like FTP. Again, service names were invented to<br>make life easier for users. Like host name mapping, it is necessary to map<br>human understandable service names to their ports, which are numbers that <br>hosts can understand.<br>&nbsp; And that's not all. We also need to resolve transport protocols to their proto-<br>col numbers. Hosts require knowning which transport protocols are needed to<br>operate a service. For example, FTP reauires the TCP protocol, which hosts<br>translate as 6. We will continue to use the telephone directory analogy as we<br>examine the Winsock 1.1 resolution functions.</font></p>
<p><font color=#002c99>Translation Function<br>&nbsp; Computers store numbers through byte ordering. There are two ways to repre-<br>sent numbers, little endian and big endian. Intel processors store numbers in<br>little endian format-from the least significant byte to the most significant byte<br>(right to left). On other processors (such as those that run some UNIX sys-<br>tems), numbers are in big-endian format-from the mostsignificant byte to the<br>least significant byte-left to right. Since the Internet is a heterogeneous net-<br>work of different computers, incompatible byte ordering poses a significant<br>obstacle to communication. To overcome this barrier, current network standards<br>specify that ports used for communicating between computers should be in net-<br>work byte order ( otherwise known as big endian format), irrespective of their<br>native byte ordering. That is, network byte order is big endian for use on the<br>TCP/IP network. You mustn't forget that network address, datagram length,<br>and TCP/IP window sizes must also be in network byte order (big endian).<br>&nbsp; Figure 3-1 on the following page shows how little endian and big endian num-<br>bers are stored in memory.<br>&nbsp; So, before using resolution functions and starting communications, your<br>application needs to translate the native host byte (little endian) ordered num-<br>ber (for example, port number of the host on the PC) to network byte ordered<br>number first. That is, you must translate the prot number into network byte<br>order. If this translation is not done, it is very likely that connecting with the<br>service on the host will never occur, even if the host name resolution works.<br>Another problem that can cause you to scratch your head is using the port in<br>host byte order instead of network byte order, which is a common lapse. How-<br>ever, it is not necessary to convert numberical data into network byte order; only<br>prot numbers, services, and IP addresses need to be in network byte order.<br>&nbsp; The following trivial example shows graphically the effect of converting a<br>number in host byte order to network byte order and from network byte order <br>to host byte order:<br>host: 100d-&gt;00000064h<br>network:64000000h=1677721600d</font></p>
<p><font color=#002c99>&nbsp; The following functions are used to convert from host byte order to network<br>byte order, or network byte order to host byte order.</font></p>
<p><font color=#002c99>function htonl Winsock2.pas<br>Syntax<br>&nbsp; htonl(hostlong:u_long):u_long;stdcall;<br>Description<br>&nbsp; This function translates a 32-bit integer from host byte order to network byte<br>&nbsp; order. In other words, it translates an integer in little endian format to big<br>&nbsp; endian format.<br>Parameters<br>&nbsp; hostlong: A 32-bit integer in host byte order<br>Return Value<br>&nbsp; The function will return a value in network byte order.<br>See Also<br>&nbsp; htons, ntohl, ntohs, WSAHtonl, WSAHtons, WSANtohl, WSANtohs<br>Example<br>&nbsp; See Listing 3-1 (program EX31).</font></p>
<p><font color=#002c99>function htons Winsock2.pas<br>Syntax<br>&nbsp; htos(hostshort:u_short):u_short;stdcall;<br>Description<br>&nbsp; This function translates a 16-bit integer from host byte order to network byte<br>&nbsp; order. In other words, it translates an integer in little endian format to big<br>&nbsp; endian format.<br>Parameters<br>&nbsp; hostshort: A 16-bit number in host byte order<br>Return Value<br>&nbsp; The function will return a value in network byte order<br>See Also<br>&nbsp; htonl, ntohl, WSAHtonl, WSAHtons, WSANtohl, WSANtohs<br>Example<br>&nbsp; See Listing 3-1 (program EX31).</font></p>
<p><font color=#002c99>function ntohl Winsock2.pas<br>Syntax<br>&nbsp; ntohl(netlong:u_long):u_long;stdcall;<br>Description<br>&nbsp; This function converts a 32-bit integer form network byte order to host byte<br>&nbsp; order. In other words, it translates an integer in big endian format to little<br>&nbsp; endian format.<br>Parameters<br>&nbsp; netlong: A 32-bit integer in network byte order<br>Return Value<br>&nbsp; The function will return a value in host byte order.<br>See Also<br>&nbsp; htonl, htons, ntohs, WSAHtonl, WSAHtons, WSANtohl, WSANtohs<br>Example<br>&nbsp; See Listing 3-1 (program EX31).</font></p>
<p><font color=#002c99>function ntohs Winsock2.pas<br>Syntax<br>&nbsp; ntohs(netlong:u_short):u_short;stdcall;<br>Description<br>&nbsp; This function converts a 32-bit integer form network byte order to host byte<br>&nbsp; order. In other words, it translates an integer in big endian format to little<br>&nbsp; endian format.<br>Parameters<br>&nbsp; netlong: A 32-bit integer in network byte order<br>Return Value<br>&nbsp; The function will return a value in host byte order.<br>See Also<br>&nbsp; htonl, htons, ntohs, WSAHtonl, WSAHtons, WSANtohl, WSANtohs<br>Example<br>&nbsp; See Listing 3-1 (program EX31).</font></p>
<p><font color=#002c99></font>&nbsp;</p>
<p><font color=#002c99></font>&nbsp;</p>
<p><font color=#002c99></font>&nbsp;</p>
<p><font color=#002c99><br></font><a href="http://www.cnitblog.com/toysun/"><strong></strong></a>&nbsp;</p>
<img src ="http://www.cnitblog.com/toysun/aggbug/59318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/toysun/" target="_blank">鸡蛋捞面</a> 2009-06-13 15:08 <a href="http://www.cnitblog.com/toysun/archive/2009/06/13/59318.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>