廣告

2024 年 3 月
 123
45678910
11121314151617
18192021222324
25262728293031

彙整

DELPHI下使用FileSetDate()函式修改檔案的”修改日期”

Delphi下使用function FileSetDate(Handle: Integer; Age: Integer): Integer; overload;函式修改檔案的”修改日期”:

參考:http://delphi.ktop.com.tw/board.php?cid=30&fid=70&tid=37667

procedure TForm1.Button1Click(Sender: TObject);
Var
    FileHandle : Integer;
    Str : String;
begin
    FileHandle := FileOpen(‘D:\prog\1.txt’, fmOpenReadWrite);
    if FileHandle = -1 then
      ShowMessage(‘開啟檔案失敗’)
    else
    begin
      Str := ‘檔案原來日期時間: ‘+ DateTimeToStr(FileDateToDateTime(FileGetDate(FileHandle)))+#10#13;
      if FileSetDate(FileHandle, FileAge(‘D:\prog\AMS.exe’)) = 0 then
        Str := Str+DateTimeToStr(FileDateToDateTime(FileAge(‘D:\prog\AMS.exe’)))
      else
        Str := Str+’新的日期時間設定失敗’;
      ShowMessage(Str);
    end;
    FileClose(FileHandle);
end;

讀者也會看的其它文章:

    Comments are closed.