Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

星期四, 9月 20, 2007

傳回及設定檔案的日期及時間


procedure TForm1.Button1Click(Sender: TObject);
begin
// FileAge (傳回檔案的日期時間)
// function FileAge(const FileName : string) : Integer;
ShowMessage(DateTimeToStr(FileDateToDateTime(FileAge('c:\test.dat'))));
end;

procedure TForm1.Button2Click(Sender: TObject);
var
FileHandle : Integer;
begin
// FileSetDate (設定檔案的日期及時間)
// function FileSetDate(Handle : Integer; Age : Integer) : Integer;
FileHandle := FileOpen('c:\test.dat', fmOpenReadWrite);
if FileHandle = -1 then
ShowMessage('開啟檔案失敗')
else begin
if FileSetDate(FileHandle, FileGetDate(FileHandle))=0 then
ShowMessage('檔案日期時間設定成功')
else
ShowMessage('檔案日期時間設定失敗')
end;
FileClose(FileHandle);
end;

沒有留言: