//dbf文件头结构
//这是C定义
struct dbf_head { /* DBF文件头结构 */
char vers; /* 版本标志*/
unsigned char yy,mm,dd; /* 最后更新年、月、日 */
unsigned long no_recs; /* 文件包含的总记录数 */
unsigned short head_len,rec_len; /* 文件头长度,记录长度 */
char reserved[20]; /* 保留 */
};//这是我在Delphi中定义的
type
Tdbf_head = record
vers : char ; //版本标志
yy,mm,dd :char; // 最后更新年、月、日
no_recs : longword ; // 文件包含的总记录数;
head_len,rec_len : word; //文件头长度,记录长度
reserved : array[0..19] of char ;
end;问题1 :
不知转换成Delphi定义的正不正确?问题2:
读DBF文件头信息;
var
f : File;
p : ^Tdbf_head;
no_Recs,head_len,rec_len,Rec_Count : Integer;
begin
AssignFile(f,'e.dbf');
Reset(f);
try
p := AllocMem(sizeof(Tdbf_head));
BlockRead(f,P^,Sizeof(file_head));
//记录总数 获得值为6208
no_Recs := P^.no_recs;
//头文件长度;获得值为1032
head_len := P^.head_len ;
//记录长度;获得值为137
rec_len := P^.rec_len;
//计算字段总数;获得值为23
Rec_Count := (head_len -296) div 32 ; Edit1.Text := IntToStr(no_Recs) +' ' + IntToStr(head_len) +' '+ IntToStr(rec_len) +' '+IntToStr(Rec_Count) ; //这句出错了,请问是什么原因呢?
finally
FreeMem(P);
CloseFile(f);
end;
//这是C定义
struct dbf_head { /* DBF文件头结构 */
char vers; /* 版本标志*/
unsigned char yy,mm,dd; /* 最后更新年、月、日 */
unsigned long no_recs; /* 文件包含的总记录数 */
unsigned short head_len,rec_len; /* 文件头长度,记录长度 */
char reserved[20]; /* 保留 */
};//这是我在Delphi中定义的
type
Tdbf_head = record
vers : char ; //版本标志
yy,mm,dd :char; // 最后更新年、月、日
no_recs : longword ; // 文件包含的总记录数;
head_len,rec_len : word; //文件头长度,记录长度
reserved : array[0..19] of char ;
end;问题1 :
不知转换成Delphi定义的正不正确?问题2:
读DBF文件头信息;
var
f : File;
p : ^Tdbf_head;
no_Recs,head_len,rec_len,Rec_Count : Integer;
begin
AssignFile(f,'e.dbf');
Reset(f);
try
p := AllocMem(sizeof(Tdbf_head));
BlockRead(f,P^,Sizeof(file_head));
//记录总数 获得值为6208
no_Recs := P^.no_recs;
//头文件长度;获得值为1032
head_len := P^.head_len ;
//记录长度;获得值为137
rec_len := P^.rec_len;
//计算字段总数;获得值为23
Rec_Count := (head_len -296) div 32 ; Edit1.Text := IntToStr(no_Recs) +' ' + IntToStr(head_len) +' '+ IntToStr(rec_len) +' '+IntToStr(Rec_Count) ; //这句出错了,请问是什么原因呢?
finally
FreeMem(P);
CloseFile(f);
end;
解决方案 »
- 有没有比TJPEGImage更高的压缩算法?
- 我想找份delphi的工作,合肥。
- 请问各位高人,在图形图像方面有哪些功能强大的第三方控件
- 请教各位:你们连接数据库用 TDatabase 还是 TADOConnection ,她们各有什么优缺点?
- 数据库还原问题!
- 大家给个思路吧
- 主板坏掉了,散100分!
- 关于DLL的函数读去!
- 有谁用DELPHI结合softSENTRY(sseval、Sentry)做过共享软件,请问如何建立DLL及调用?
- 各位:DELPHI 6 中使用 FILTERCOMBOBOX控件时,编译提示WARNING: FILECTRL UNIT IS SPESIFIC TO FLATFORM
- 接口函数调用: 客户端频繁调用应用服务器的接口函数,客户端系统死掉是什么问题???请各位兄弟指点!
- Delphi 与Crystal Reports 水晶报表如何关联
type
Tdbf_head = packed record
vers : char ; //版本标志
yy,mm,dd :char; // 最后更新年、月、日
no_recs : longword ; // 文件包含的总记录数;
head_len,rec_len : word; //文件头长度,记录长度
reserved : array[0..19] of char ;
end;
也不对
fontain() 谢谢!谢谢高人指点。
f : File;
p : ^Tdbf_head;
no_Recs,head_len,rec_len,Rec_Count : Integer;
buf : PChar ;
Read_COunt : Integer;
i : Integer;
begin
AssignFile(f,'e.dbf');
Reset(f,1);
try
p := AllocMem(sizeof(Tdbf_head));
BlockRead(f,P^,Sizeof(file_head));
//记录总数
no_Recs := P^.no_recs;
//头文件长度;
head_len := P^.head_len ;
//记录长度;
rec_len := P^.rec_len;
//计算字段总数;
Rec_Count := (head_len -296) div 32 ;
//移dbf数据开始位置
Seek(f,P^.head_len+1);
//分配一条记录长度的内存;
buf := AllocMem(rec_len);
//从文件中读取一条记录的内容放入buf中;
BlockRead(f,buf,rec_len,read_count); //这条语句读 出错,
...
finally
FreeMem(P);
FreeMem(buf);
CloseFile(f);
end;--
注:DBF文件中的数据全是以ASCIC码保存的请问我在什么地方写错了????