标签归档:Delphi

TIdFTP的DirectoryListing使用问题

IdFTP1.List;
ShowMessage(IntToStr(IdFTP1.ListResult.Count));
ShowMessage(IntToStr(IdFTP1.DirectoryListing.Count));

前者是正确的数值,后者是0。
看了一下网上的代码都是List完了就直接用,DirectoryListing会自动解析ListResult

放狗搜了半天,终于找到原因,原来是Indy10的一个设计上的变化,以下引用官网内容:

TIdFTP.DirectoryListing is returning nothing for my FTP server. Why?

We restructured the way FTP directory listing is done. The code is now a plug in system with various parsers in their own units which register themselves into a framework. To add support for a particular type of FTP server, you simply add the parser unit to one of your program unit’s uses clause.

To add the Unix directory list parser, add IdFTPListParseUnix to your unit’s clause. To add support for Microsoft Windows NT IIS FTP server, add IdFTPListParseWindowsNT to your uses clause. You can also add many other parsers we include in the Indy packages. By convention, they are named IdFTPListParser followed by the server type. You do not need to add IdFTPListParseBase to your uses clause because IdFTP uses that unit. If you wish to use all of Indy’s FTP List parser classes, just add the IdAllFTPListParsers unit to your uses clause.

We admit this new design is not as intuitive as the older one but this has many advantages for us such as:

• The FTP list parsing code is now much easier to maintain than the same code in a non-modular design in one unit which would be at least 150KB total.

• You now can add support for only the FTP servers you want your program support to support.

• You can now write your own custom parser classes and plug those into the standard FTP parsing list framework.

搜了一下IdFTPListParse有关的unit,有一大坨,要写个比较通用的FTP Client估计都得引进去吧……
idftplistparse.JPG

TWebBrowser显示自定义Html内容


uses
ActiveX, MSHtml;

var
Document: IHtmlDocument2;
V: OleVariant;
begin
WebBrowser1.Navigate(‘about:blank’);
Document := WebBrowser1.Document as IHtmlDocument2;
V := VarArrayCreate([0, 0], varVariant);
V[0] := ‘Hello World’;
Document.Write(PSafeArray(TVarData(v).VArray));
end;

TTreeView的使用

先说一下我要达到的目的,一个Form分成两个Panel,左边放置TTreeView,右边根据TTreeView的不同选择切换不同的Frame或Form。

首先定义一个数据结构来保存每一个TTreeNode的数据,可以根据需要放更多的数据进去:

其中InstanceClass字段用来保存每个TTreeNode所对应的Frame或Form。

以如下定义为例:

开始创建TTreeView,在Form的OnCreate中创建:

响应TTreeView的OnChange事件,根据每个TTreeNode的Data定义显示不同的Frame或Form:

这样当需要添加新的Node时只需要更改很少的代码。

PS:相比于在Design视图上点来点去,还是更喜欢自己写代码来实现……

Delphi 2007 for Win32企业版安装方法

安装前提是你已经下载了Delphi 2007 for Win32的ISO。
Delphi 2007安装程序根据不同的序列号(许可文件)来判断安装版本,一般ISO中自带的许可文件是专业版的。
企业版和专业版的许可文件下载:delphi2007_slip.zip

C++ Builder 2007的企业版许可文件(slip file for C++ Builder 2007):cb2007_ent.zip

新装方法:
1、下载D2007。
2、删除D2007中的delphi2007.slip文件,将这里下载的d2007_Ent.slip直接拷入目录内(建议使用UltraISO编辑镜像)。
3、完成后就可以运行setup.exe文件开始安装了!安装过程中需要联网下载文件,请保持联网状态。
4、安装完成后用D2007Tweaks移除协议检测。
5、现在可以开始爽了!
6、查看Source目录里是否为六个目录,对照下面的Runtime Packages表格,查看企业版所包含的几个文是否装上(dbxasa30.dll、dbxase30.dll、dbxdb230.dll 、dbxinf30.dll、dbxmss30.dll、dbxora30.dll、dsnap100.bpl、dsnapcon100.bpl、 dsnapent100.bpl、dss100.bpl、webdsnap100.bpl、websnap1 00.bpl这些文件分布在System32及Bin目录内),以上两点满足就已经算是企业版了!

如果安装时提示“Invalid Serial Number”,有两种可能:
1、将文件解压缩到硬盘上安装了,推荐用Daemon虚拟光驱安装
2、原先已经安装过Delphi 2007,这时候应该先将原有信息删除:

if you got Invalid Serial Number message during install
delete folders
%ALL_USERS%\Application Data\CodeGear
%ALL_USERS%\Application Data\{AB3EC276-D261-4943-A921-1CC1C6799AED}
then run setup again

安装了企业版以后使用dbExpress连接Oracle就不会报缺少DLL了,但是实际发现连接MySql的时候还是会提示文件缺失……