Function TForm1.et(str:String):TDateTime;
var
h:Thandle;
ofs:TOfstruct;
int:Integer;
begin
h:=OpenFile(Pchar(str),ofs,OF_SHARE_DENY_NONE);
Try
if h<>HFILE_ERROR then
begin
int:=FileGEtDate(h);
Result:=FileDateToDateTime(int);
end;
Finally
_lclose(h);
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Edit2.Text:=DateTimeToStr(et(str));
end;
《我的意思是不要函数调用了,把上边的代码写下来啊!但是int:=FileGEtDate(h);
Result:=FileDateToDateTime(int); 啊 。写上下面这样啊,编译不过,分不清了类型。
int:=FileGEtDate(h);
int:=FileDateToDateTime(int); 》
var
h:Thandle;
ofs:TOfstruct;
int:Integer;
begin
h:=OpenFile(Pchar(str),ofs,OF_SHARE_DENY_NONE);
Try
if h<>HFILE_ERROR then
begin
int:=FileGEtDate(h);
Result:=FileDateToDateTime(int);
end;
Finally
_lclose(h);
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Edit2.Text:=DateTimeToStr(et(str));
end;
《我的意思是不要函数调用了,把上边的代码写下来啊!但是int:=FileGEtDate(h);
Result:=FileDateToDateTime(int); 啊 。写上下面这样啊,编译不过,分不清了类型。
int:=FileGEtDate(h);
int:=FileDateToDateTime(int); 》
var
h:Thandle;
ofs:TOfstruct;
int:Integer;
begin
h:=OpenFile(Pchar(str),ofs,OF_SHARE_DENY_NONE);
Try
if h <>HFILE_ERROR then
begin
int:=FileGEtDate(h);
Result:=FileDateToDateTime(int);
end;
Finally
_lclose(h);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
h:Thandle;
ofs:TOfstruct;
int:Integer;
begin
h:=OpenFile(Pchar(str),ofs,OF_SHARE_DENY_NONE);
Try
if h <>HFILE_ERROR then
begin
int := FileGEtDate(h);
Edit2.Text := DateTimeTostr( FileDateToDateTime(int));
end;
Finally
_lclose(h);
end;
end;
没看懂你! 我不想要函数 调用啊。
你还用个函数啊!
另外
Try
.
.
Except
end;是出现错误。释放内存吗。那它和用 Finally 的区别呢? 以前记得。现在忘了,所以问下了
procedure TForm1.Button2Click(Sender: TObject);
var
h: Thandle;
ofs: TOfstruct;
int: Integer;
begin
h:=OpenFile(Pchar(str),ofs,OF_SHARE_DENY_NONE);
Try
if h <> HFILE_ERROR then
begin
int := FileGEtDate(h);
Edit2.Text := DateTimeToStr(FileDateToDateTime(int));
end;
Finally
_lclose(h);
end;
end;
.
.
Except
end;
是捕获错误,当出现错误是,执行你自己的动作,在except后写Try
.
.
Finally
end;
是不管Try后的代码执行如何,最后都要执行finally后的代码,常用于释放