導航:首頁 > 文件教程 > delphi設置文件時間

delphi設置文件時間

發布時間:2023-06-29 01:42:17

⑴ delphi獲取當前日期,包括年份月份星期時間。

1、打開Delphi7集成開發環境,在Diaglog面板,向默認工程的Form1窗體放一個Opendiag1控制項。

⑵ delphi idftp 獲取修改時間

獲取文件的修改時間你看看下面的方法能不能用:
Windows 提供一個函數 GetFileTime 做此項操作,在 Delphi 中可方便地調用,示例如下:

procere GetFileLastAccessTime(FileName: PChar);
var
CreateFT, LastAccessFT, LastWriteFT: TFileTime;
ST: TSystemTime;
F: Integer;
begin
{ 首先要用Windows的標准API函數以讀方式打開文件 }
F := CreateFile(FileName, GENERIC_READ, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if F=INVALID_HANDLE_VALUE then
begin
ShowMessage(』Can not open file!』);
Exit;
end;
{ 取文件時間 }
if GetFileTime(F, @CreateFT, @LastAccessFT, @LastWriteFT) then
begin
{ 轉換為系統時間並顯示 }
FileTimeToSystemTime(LastAccessFT, ST);
Label1.Caption := Format(』%d-%d-%d, %d:%d:%d』,
[ST.wYear, ST.wMonth, ST.wDay, ST.wHour, ST.wMinute,ST.wSecond]);
end;
CloseHandle(F); { 記住關閉文件 }
end;

⑶ delphi中如何抓取文件夾的修改日期

如下代碼
uses
comctrls, ShellAPI, commctrl;

{...}

const
FL_FOLDER = 1;
FL_FILE = FL_FOLDER + 1;
{ 文件日期類型 }
FD_CREATED = 1;
FD_ACCESSED = FD_CREATED + 1;
FD_MODIFIED = FD_ACCESSED + 1;

type
FileInfoPtr = ^FileInfoRec;
FileInfoRec = record
fName : string;
typ : byte;
Modified : TDateTime;
end;

function GetFileTimes(FileName : ShortString; typ : byte; var fDate : TDateTime) : Boolean;
var
fHandle : Integer;
fTimeC,
fTimeA,
fTimeM : TFileTime;
lTime : TFileTime;
sTime : TSystemTime;
begin { GetFileTimes }
fHandle := FileOpen(FileName, fmShareDenyNone);
fDate := 0.0;
result := (fHandle >= 0);
if result
then begin GetFileTime(fHandle, @fTimeC, @fTimeA, @fTimeM);
FileClose(fHandle);
case typ of
FD_CREATED : FileTimeToLocalFileTime(fTimeC, lTime);
FD_ACCESSED : FileTimeToLocalFileTime(fTimeA, lTime);
FD_MODIFIED : FileTimeToLocalFileTime(fTimeM, lTime);
end;
if FileTimeToSystemTime(lTime, sTime)
then fDate := EncodeDate(sTime.wYear, sTime.wMonth, sTime.wDay) + EncodeTime(sTime.wHour, sTime.wMinute, sTime.wSecond, sTime.wMilliSeconds);
end;
end; { of GetFileTimes }

⑷ 用delphi如何修改FTP伺服器上文件的修改時間

自己寫一個 FTP SERVER, 上傳文件的時候把時間也帶上

閱讀全文

與delphi設置文件時間相關的資料

熱點內容
sw編程是什麼 瀏覽:881
網路眾籌有哪些特點 瀏覽:896
有哪些不需要會員的看動漫的app 瀏覽:533
不喜歡的網站強盜如何刪除 瀏覽:7
蘋果手機攝像注意 瀏覽:380
c語言直接生成可執行文件 瀏覽:968
壓縮文件為什麼還不變 瀏覽:617
驗證文件系統失敗 瀏覽:129
為什麼文件裝訂要在紅頭以下 瀏覽:886
coreldraw教程02 瀏覽:807
什麼app可以提高立體感 瀏覽:469
qq群消息撤回功能 瀏覽:709
孕期適用app有哪些 瀏覽:680
QQ的文件存到微雲怎麼 瀏覽:47
網路上的表情是什麼意思 瀏覽:819
exosshow哪個app好 瀏覽:691
clr資料庫程序集優點 瀏覽:919
手機編輯sql文件 瀏覽:355
裝了w8系統d盤文件沒了 瀏覽:509
殺毒軟體刪除的文件怎麼找回 瀏覽:853

友情鏈接