Archive for the 'delphi' Category



ZEOSDBO在Delphi7的安装和连接postgresql8.4的注意

自从兴高采烈换了新机后,也再vmware虚拟机装上postgresql8.4后,那就要试试用delphi7连接postgresql8.4了,那控件就用zeosdbo了,原来现在zeosdbo控件可以到 http://sourceforge.net/projects/zeoslib/ 下载了.

至于zeosdbo控件在delphi7的安装就参考 http://blog.csdn.net/CHUANGHUI/archive/2009/12/15/5012904.aspx

不过要连接postgresql8.4 , 还是需要注意些东西,就是要把以下的dll文件复制到windows\system32 下。
comerr32.dll
libeay32.dll
ssleay32.dll
libintl-2.dll
libiconv-2.dll
krb5_32.dll
这样才能连接到postgresql8.4去,这些dll文件可以在安装pqadmin III后的目录下有,安装pqadmin III到
http://www.pgadmin.org/download/windows.php 下载吧!

还有就是zeosdbo控件连接到postgresql会乱码的,需要在控件的zeosdbo控件的Properties加上一句
codepage=GBK
或者
在程序的开头加上一句: ZConnection.Properties.Add(‘codepage=GBK’);

看起来都几麻烦是吧,不过搞程序就是折腾人生,没办法呢,哈哈!

Tag:, ,

delphi的链表排序方法

用delohi编程,用到tlist链表的排序,从大富翁www.delphibbs.com哪里找来的,经自己改进。
原来的是

function mycp(tp1,tp2: FMyList): Integer;
begin
if (tp1^.fa1 > tp2^.fa1) then
Result := 1
else if (tp1^.fa1 = tp2^.fa1) then
Result := 0
else
Result := -1;
end;

用这代码后,排序有问题:
输出结果:
//排序前输出
5 11
1 115
5 5
3 10
3 2
*********
//排序后输出
1 115
3 10
3 2
5 11
5 5

为了令第二行也能排序,于是改进如下:
function mycp(tp1,tp2: FMyList): Integer;
begin
if (tp1^.fa1 > tp2^.fa1) then
Result := 1
else if (tp1^.fa1 = tp2^.fa1) then
begin
if (tp1^.fa2 > tp2^.fa2) then
result:=1
else if (tp1^.fa2 = tp2^.fa2) then
Result := 0
else
result:=-1;
end
else
Result := -1;
end;

这次排序后:
1 115
3 2
3 10
5 5
5 11

调用: biaolist.Sort(@mycp);
biaolist是我定义的tlist

参考网址: http://www.delphibbs.com/delphibbs/dispq.asp?lid=1463137

Tag:, ,