请问有关读文件问题。(在线结贴)

keluos 2003-08-22 03:21:10
当我用findfirst(,,)函数时,它需要传入一个结构
如下:
struct ffblk {
long ff_reserved;
long ff_fsize; /* file size */
unsigned long ff_attrib; /* attribute found */
unsigned short ff_ftime; /* file time */
unsigned short ff_fdate; /* file date */
char ff_name[256]; /* found file name */
};
请问这个结构传回来的ff_ftime,ff_fdate该怎样理解,如果我建立一个文件后马上去读
它,可是返回的ff_fdate个我读Now()的整数部分并不一样,请那位大侠解释一些,谢谢?
...全文
19 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯本 2003-08-22
  • 打赏
  • 举报
回复
试试我的程序,没问题
union {
int ftime;
struct
{
unsigned second2:5;
unsigned minutes:6;
unsigned hours:5;
} ftb;
} ft;
union {
int fdate;
struct
{
unsigned day:5;
unsigned month:4;
unsigned years:7;
} fdb;
} fd;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
struct ffblk fk;
if(findfirst("aaa.bmp",&fk,NULL))
{
ShowMessage("error");
return;
}
String x;
fd.fdate = fk.ff_fdate;
x.printf("%04d:%02d:%02d ",fd.fdb.years+1980,fd.fdb.month,fd.fdb.day);
ft.ftime=fk.ff_ftime;
x.cat_printf("%02d:%02d:%02d",ft.ftb.hours,ft.ftb.minutes,ft.ftb.second2/2);
ShowMessage(x);

}
柯本 2003-08-22
  • 打赏
  • 举报
回复
help里很清楚
ff_ftime:

Bits 0 to 4 The result of seconds divided by 2 (for example 10 here means 20 seconds)
Bits 5 to 10 Minutes
Bits 11 to 15 Hours

ff_fdate:

Bits 0-4 Day
Bits 5-8 Month
Bits 9-15 Years since 1980 (for example 9 here means 1989)

The structure ftime declared in io.h uses time and date bit fields similar in structure to ff_ftime and ff_fdate.

它是C的标准函数,在win32下建议用VCL的
extern PACKAGE int __fastcall FindFirst(const AnsiString Path, int Attr, TSearchRec &F);

或API的

HANDLE FindFirstFile(

LPCTSTR lpFileName, // pointer to name of file to search for
LPWIN32_FIND_DATA lpFindFileData // pointer to returned information
);
keluos 2003-08-22
  • 打赏
  • 举报
回复
我明白了,原来与DOS file date/time value有关

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧