﻿<?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>BlogJava-有心就有翼 有梦就会飞-文章分类-Delphi,C++</title><link>http://www.blogjava.net/mc/category/1141.html</link><description>------------------By MC</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2007 04:11:27 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2007 04:11:27 GMT</pubDate><ttl>60</ttl><item><title>Delphi里删除目录的函数</title><link>http://www.blogjava.net/mc/articles/26668.html</link><dc:creator>有心就有翼 有梦就会飞</dc:creator><author>有心就有翼 有梦就会飞</author><pubDate>Thu, 05 Jan 2006 02:50:00 GMT</pubDate><guid>http://www.blogjava.net/mc/articles/26668.html</guid><wfw:comment>http://www.blogjava.net/mc/comments/26668.html</wfw:comment><comments>http://www.blogjava.net/mc/articles/26668.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/mc/comments/commentRss/26668.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/mc/services/trackbacks/26668.html</trackback:ping><description><![CDATA[其实网上已经有很多的例子了，不过对于和我一样的初学者来说难免会遇到问题，我试过win32Api函数，也试过用removeDirectory，但都删不掉指定目录，分析了一下，很显然，是这些函数只是单纯的删除空文件夹，非空文件夹删不了的。也不知是不是我用的不对，总之用了下面这个函数挺灵的，帖出来大家分享下。<BR><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"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">function&nbsp;TMainForm</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">DeleteDirectory(NowPath</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;string)</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;Boolean;&nbsp;</SPAN><SPAN style="COLOR: #000000">//</SPAN><SPAN style="COLOR: #000000">删除整个目录<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>var<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;search</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TSearchRec;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;ret</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;integer;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;key</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;string;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>begin<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;NowPath[</SPAN><SPAN style="COLOR: #0000ff">Length</SPAN><SPAN style="COLOR: #000000">(NowPath)]&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">\</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">&nbsp;then<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;NowPath&nbsp;</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;NowPath&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">\</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;key&nbsp;</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;Nowpath&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">*.*</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;ret&nbsp;</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;findFirst(key</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">&nbsp;faanyfile</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">&nbsp;search);<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">&nbsp;ret&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #800000">0</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">do</SPAN><SPAN style="COLOR: #000000">&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;((search</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Attr&nbsp;and&nbsp;fadirectory)&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;faDirectory)<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(Search</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Name&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">.</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">)&nbsp;and&nbsp;(Search</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">name&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">..</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">)&nbsp;then<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DeleteDirectory(NowPath&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;Search</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">name);<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;</SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000">&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;((search</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">attr&nbsp;and&nbsp;fadirectory)&nbsp;</SPAN><SPAN style="COLOR: #000000">&lt;&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;fadirectory)&nbsp;then&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deletefile(NowPath&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;search</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">name);<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;end;<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;FindNext(search);<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;end;<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;findClose(search);<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;removedir(NowPath);<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;result&nbsp;</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;True;<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>end;<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.blogjava.net/mc/aggbug/26668.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/mc/" target="_blank">有心就有翼 有梦就会飞</a> 2006-01-05 10:50 <a href="http://www.blogjava.net/mc/articles/26668.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Delphi里随机函数的应用</title><link>http://www.blogjava.net/mc/articles/26475.html</link><dc:creator>有心就有翼 有梦就会飞</dc:creator><author>有心就有翼 有梦就会飞</author><pubDate>Tue, 03 Jan 2006 14:48:00 GMT</pubDate><guid>http://www.blogjava.net/mc/articles/26475.html</guid><wfw:comment>http://www.blogjava.net/mc/comments/26475.html</wfw:comment><comments>http://www.blogjava.net/mc/articles/26475.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/mc/comments/commentRss/26475.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/mc/services/trackbacks/26475.html</trackback:ping><description><![CDATA[<PRE>在Delphi中，有一随机函数，是这样定义的：
function Random [ ( Range: Integer) ];
其中，参数Range为一整数，
该函数返回值其范围为：
0&lt; =Random(Range)&lt; Range   (指定Range)
0&lt; =Random&lt; 1   (不带参数Range)</PRE>
<P><FONT face="Courier New">下面的过程for循环里第一条语句：在屏幕上输出九九表内乘法的随机题；<BR>第二条语句：在屏幕上输出一百以内的加法随机题。<BR>稍加修改，增加一些条件语句你即可得到得减法、除法及四则混合运算的随机题。</FONT><BR></P><PRE><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"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">procedure&nbsp;TForm1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Button1Click(Sender</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TObject);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>var<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>I</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;Integer;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>begin<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><FONT style="BACKGROUND-COLOR: #ffff00">Randomize;<BR></FONT></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">&nbsp;I&nbsp;</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #800000">1</SPAN><SPAN style="COLOR: #000000">&nbsp;to&nbsp;</SPAN><SPAN style="COLOR: #800000">10</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">do</SPAN><SPAN style="COLOR: #000000">&nbsp;begin<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Canvas</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">TextOut(</SPAN><SPAN style="COLOR: #800000">20</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">I</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #800000">20</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>IntToStr(<FONT style="BACKGROUND-COLOR: #ffff00">Random(</FONT></SPAN><FONT style="BACKGROUND-COLOR: #ffff00"><SPAN style="COLOR: #800000">9</SPAN><SPAN style="COLOR: #000000">)</SPAN></FONT><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #800000">1</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">×</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">IntToStr(Random(</SPAN><SPAN style="COLOR: #800000">9</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #800000">1</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">=</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Canvas</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">TextOut(</SPAN><SPAN style="COLOR: #800000">220</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">I</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #800000">20</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>IntToStr(Random(</SPAN><SPAN style="COLOR: #800000">100</SPAN><SPAN style="COLOR: #000000">))</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">+</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">IntToStr(Random(</SPAN><SPAN style="COLOR: #800000">100</SPAN><SPAN style="COLOR: #000000">))</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">=</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>end;<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>end;<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></PRE><img src ="http://www.blogjava.net/mc/aggbug/26475.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/mc/" target="_blank">有心就有翼 有梦就会飞</a> 2006-01-03 22:48 <a href="http://www.blogjava.net/mc/articles/26475.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Delphi与FLASH通过SOCKET通信</title><link>http://www.blogjava.net/mc/articles/24976.html</link><dc:creator>有心就有翼 有梦就会飞</dc:creator><author>有心就有翼 有梦就会飞</author><pubDate>Wed, 21 Dec 2005 10:27:00 GMT</pubDate><guid>http://www.blogjava.net/mc/articles/24976.html</guid><wfw:comment>http://www.blogjava.net/mc/comments/24976.html</wfw:comment><comments>http://www.blogjava.net/mc/articles/24976.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/mc/comments/commentRss/24976.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/mc/services/trackbacks/24976.html</trackback:ping><description><![CDATA[Delphi编写的服务器端代码（部分）：<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"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">procedure&nbsp;TForm1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ServerSocket1ClientRead(Sender</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TObject;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">Socket</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TCustomWinSocket);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>begin<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Memo1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Lines</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Add(</SPAN><SPAN style="COLOR: #0000ff">Socket</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ReceiveText);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ServerSocket1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #0000ff">Socket</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Connections[</SPAN><SPAN style="COLOR: #800000">0</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">SendText(</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">OK!</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #008000">#</SPAN><SPAN style="COLOR: #008000">0);</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">end;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>procedure&nbsp;TForm1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ServerSocket1ClientConnect(Sender</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TObject;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">Socket</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TCustomWinSocket);<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>begin<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Memo1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Lines</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Clear;<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>end;<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>procedure&nbsp;TForm1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ServerSocket1Accept(Sender</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TObject;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">Socket</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TCustomWinSocket);<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>begin<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Memo1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Lines</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Clear;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Memo1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Lines</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Add(</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">Connected</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ServerSocket1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #0000ff">Socket</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Connections[</SPAN><SPAN style="COLOR: #800000">0</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">SendText(</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">OK!</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #008000">#</SPAN><SPAN style="COLOR: #008000">0);</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">end;<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>procedure&nbsp;TForm1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">FormCreate(Sender</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">&nbsp;TObject);<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>begin<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;Form1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">ShockwaveFlash1</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Movie</SPAN><SPAN style="COLOR: #000000">:=</SPAN><SPAN style="COLOR: #000000">&nbsp;ExtractFilePath(Application</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">Exename)</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">client.swf</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>end;</SPAN></DIV>Flash实现客户端代码（部分）：<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"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;mySocket&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;XMLSocket();<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">mySocket.connect(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">127.0.0.1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #000000">3000</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_111_266_Open_Image onclick="this.style.display='none'; Codehighlighter1_111_266_Open_Text.style.display='none'; Codehighlighter1_111_266_Closed_Image.style.display='inline'; Codehighlighter1_111_266_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_111_266_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_111_266_Closed_Text.style.display='none'; Codehighlighter1_111_266_Open_Image.style.display='inline'; Codehighlighter1_111_266_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top>mySocket.onConnect&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">(success)&nbsp;</SPAN><SPAN id=Codehighlighter1_111_266_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_111_266_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_127_221_Open_Image onclick="this.style.display='none'; Codehighlighter1_127_221_Open_Text.style.display='none'; Codehighlighter1_127_221_Closed_Image.style.display='inline'; Codehighlighter1_127_221_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_127_221_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_127_221_Closed_Text.style.display='none'; Codehighlighter1_127_221_Open_Image.style.display='inline'; Codehighlighter1_127_221_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(success)&nbsp;</SPAN><SPAN id=Codehighlighter1_127_221_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_127_221_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lists.text&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Connect&nbsp;Ok!</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">mySocket.send("guest");</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection.setFocus(input_txt);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_228_264_Open_Image onclick="this.style.display='none'; Codehighlighter1_228_264_Open_Text.style.display='none'; Codehighlighter1_228_264_Closed_Image.style.display='inline'; Codehighlighter1_228_264_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_228_264_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_228_264_Closed_Text.style.display='none'; Codehighlighter1_228_264_Open_Image.style.display='inline'; Codehighlighter1_228_264_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_228_264_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_228_264_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lists.text&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">connect&nbsp;failed</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_299_317_Open_Image onclick="this.style.display='none'; Codehighlighter1_299_317_Open_Text.style.display='none'; Codehighlighter1_299_317_Closed_Image.style.display='inline'; Codehighlighter1_299_317_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_299_317_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_299_317_Closed_Text.style.display='none'; Codehighlighter1_299_317_Open_Image.style.display='inline'; Codehighlighter1_299_317_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top>mySocket.onData&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">(s)&nbsp;</SPAN><SPAN id=Codehighlighter1_299_317_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_299_317_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;lists.text</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">s;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_347_389_Open_Image onclick="this.style.display='none'; Codehighlighter1_347_389_Open_Text.style.display='none'; Codehighlighter1_347_389_Closed_Image.style.display='inline'; Codehighlighter1_347_389_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_347_389_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_347_389_Closed_Text.style.display='none'; Codehighlighter1_347_389_Open_Image.style.display='inline'; Codehighlighter1_347_389_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top>mySocket.onClose</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">()</SPAN><SPAN id=Codehighlighter1_347_389_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_347_389_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;lists.text</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Server&nbsp;has&nbsp;been&nbsp;closed.</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #008000"><IMG id=Codehighlighter1_425_454_Open_Image onclick="this.style.display='none'; Codehighlighter1_425_454_Open_Text.style.display='none'; Codehighlighter1_425_454_Closed_Image.style.display='inline'; Codehighlighter1_425_454_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_425_454_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_425_454_Closed_Text.style.display='none'; Codehighlighter1_425_454_Open_Image.style.display='inline'; Codehighlighter1_425_454_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">bn_send.onRelease&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">()&nbsp;</SPAN><SPAN id=Codehighlighter1_425_454_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_425_454_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;sendMsg(input_txt.text);&nbsp;&nbsp;&nbsp;&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_479_556_Open_Image onclick="this.style.display='none'; Codehighlighter1_479_556_Open_Text.style.display='none'; Codehighlighter1_479_556_Closed_Image.style.display='inline'; Codehighlighter1_479_556_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_479_556_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_479_556_Closed_Text.style.display='none'; Codehighlighter1_479_556_Open_Image.style.display='inline'; Codehighlighter1_479_556_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;sendMsg(str)&nbsp;</SPAN><SPAN id=Codehighlighter1_479_556_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.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_479_556_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mySocket.send(str);<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;input_txt.text&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;Selection.setFocus(input_txt);<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR><A href="http://20268.vicp.net/mcweb/downloads/test.rar">源文件下载</A><img src ="http://www.blogjava.net/mc/aggbug/24976.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/mc/" target="_blank">有心就有翼 有梦就会飞</a> 2005-12-21 18:27 <a href="http://www.blogjava.net/mc/articles/24976.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Delphi获取完整路径</title><link>http://www.blogjava.net/mc/articles/24882.html</link><dc:creator>有心就有翼 有梦就会飞</dc:creator><author>有心就有翼 有梦就会飞</author><pubDate>Tue, 20 Dec 2005 15:17:00 GMT</pubDate><guid>http://www.blogjava.net/mc/articles/24882.html</guid><wfw:comment>http://www.blogjava.net/mc/comments/24882.html</wfw:comment><comments>http://www.blogjava.net/mc/articles/24882.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/mc/comments/commentRss/24882.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/mc/services/trackbacks/24882.html</trackback:ping><description><![CDATA[Delphi 从文件名中得到路径名，可用下面的两个函数，这两个函数有一点点微小的差别：
<P align=left><SPAN class=p2 style="LINE-HEIGHT: 17pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExtractFilePath(FileName:String) 该函数返回路径名，其结尾字符总是“\”&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN class=p2 style="LINE-HEIGHT: 17pt">ExtractFileDir(FileName:String) 该函数同样返回路径名，但不包括结尾的字符“\”，除非返回的路径是根目录。　</SPAN></P>
<P align=left><SPAN class=p2 style="LINE-HEIGHT: 17pt">样例代码：<BR>&nbsp;<BR></SPAN><SPAN class=p1 style="LINE-HEIGHT: 17pt">　&nbsp;&nbsp;&nbsp;&nbsp;ShowMessage(ExtractFileDir(Application.Exename)); &nbsp; // 如: c:\temp <BR>　　ShowMessage(ExtractFilePath(Application.Exename)); // 如: c:\temp\ 　　<BR></SPAN></P><img src ="http://www.blogjava.net/mc/aggbug/24882.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/mc/" target="_blank">有心就有翼 有梦就会飞</a> 2005-12-20 23:17 <a href="http://www.blogjava.net/mc/articles/24882.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>成为编程高手的八大奥秘</title><link>http://www.blogjava.net/mc/articles/5951.html</link><dc:creator>有心就有翼 有梦就会飞</dc:creator><author>有心就有翼 有梦就会飞</author><pubDate>Sun, 12 Jun 2005 12:40:00 GMT</pubDate><guid>http://www.blogjava.net/mc/articles/5951.html</guid><wfw:comment>http://www.blogjava.net/mc/comments/5951.html</wfw:comment><comments>http://www.blogjava.net/mc/articles/5951.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/mc/comments/commentRss/5951.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/mc/services/trackbacks/5951.html</trackback:ping><description><![CDATA[转载::文/《中国电脑教育报》张军&nbsp; 
<P></P>
<P>&nbsp;　　软件业在国内热了起来，程序员也抢手了，越来越多的人加入程序员行列。程序员的经历也是很多准程序员们急于想知道的，本文介绍了一个“过来人”的经验和感悟，或许对准程序员们有一定的启发。&nbsp;</P>
<P>&nbsp;　　不知不觉做软件已经做了十年，有成功的喜悦，也有失败的痛苦，但总不敢称自己是高手，因为和我心目中真正的高手们比起来，还差得太远。世界上并没有成为高手的捷径，但一些基本原则是可以遵循的。&nbsp;</P>
<P>&nbsp;　　1、扎实的基础&nbsp;</P>
<P>&nbsp;　　数据结构、离散数学、编译原理，这些是所有计算机科学的基础，如果不掌握它们，很难写出高水平的程序。程序人人都会写，但当你发现写到一定程度很难再提高的时候，就应该想想是不是要回过头来学学这些最基本的理论。不要一开始就去学OOP，即使你再精通OOP，遇到一些基本算法的时候可能也会束手无策。因此多读一些计算机基础理论方面的书籍是非常有必要的。&nbsp;</P>
<P>&nbsp;　　2、丰富的想像力&nbsp;</P>
<P>&nbsp;　　不要拘泥于固定的思维方式，遇到问题的时候要多想几种解决问题的方案，试试别人从没想过的方法。丰富的想像力是建立在丰富的知识的基础上，除计算机以外，多涉猎其他的学科，比如天文、物理、数学等等。开阔的思维对程序员来说很重要。&nbsp;</P>
<P>&nbsp;　　3、最简单的是最好的&nbsp;</P>
<P>&nbsp;　　这也许是所有科学都遵循的一条准则，复杂的质能转换原理在爱因斯坦眼里不过是一个简单得不能再简单的公式：E=mc2。简单的方法更容易被人理解，更容易实现，也更容易维护。遇到问题时要优先考虑最简单的方案，只有简单方案不能满足要求时再考虑复杂的方案。&nbsp;</P>
<P>&nbsp;　　4、不钻牛角尖&nbsp;</P>
<P>&nbsp;　　当你遇到障碍的时候，不妨暂时远离电脑，看看窗外的风景，听听轻音乐，和朋友聊聊天。当我遇到难题的时候会去玩游戏，当负责游戏的那部分大脑细胞极度亢奋的时候，负责编程的那部分大脑细胞就得到了充分的休息。当重新开始工作的时候，我会发现那些难题现在竟然可以迎刃而解。&nbsp;</P>
<P>&nbsp;　　5、对答案的渴求&nbsp;</P>
<P>&nbsp;　　人类自然科学的发展史就是一个渴求得到答案的过程，即使只能知道答案的一小部分也值得我们去付出。只要你坚定信念，一定要找到问题的答案，你才会付出精力去探索，即使最后没有得到答案，在过程中你也会学到很多东西。&nbsp;</P>
<P>&nbsp;　　6、多与别人交流&nbsp;</P>
<P>&nbsp;　　三人行必有我师，也许在一次和别人不经意的谈话中，就可以迸出灵感的火花。多上上网，看看别人对同一问题的看法，会给你很大的启发。&nbsp;</P>
<P>&nbsp;　　7、良好的编程风格&nbsp;</P>
<P>&nbsp;　　注意养成良好的习惯，代码的缩进编排，变量的命名规则要始终保持一致。大家都知道如何排除代码中错误，却往往忽视了对注释的排错。注释是程序的一个重要组成部分，它可以使你的代码更容易理解，而如果代码已经清楚地表达了你的思想，就不必再加注释了，如果注释和代码不一致，那就更加糟糕。&nbsp;</P>
<P>&nbsp;　　8、韧性和毅力&nbsp;</P>
<P>&nbsp;　　这也许是“高手”和一般程序员最大的区别。高手们并不是天才，他们是在无数个日日夜夜中磨炼出来的。成功能给我们带来无比的喜悦，但过程却是无比的枯燥乏味。你不妨做个测试，找个10000以内的素数表，把它们全都抄下来，然后再检查三遍，如果能够不间断地完成这一工作，你就可以满足这一条。<BR></P><img src ="http://www.blogjava.net/mc/aggbug/5951.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/mc/" target="_blank">有心就有翼 有梦就会飞</a> 2005-06-12 20:40 <a href="http://www.blogjava.net/mc/articles/5951.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>