unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure SetModifyDate(fName, fDate: string);
var
Age, FHandle: integer;
LocalFileTime, FileTime: TFileTime;
FileBuf: File;
begin
if FileExists(fName) then
begin
AssignFile(FileBuf, fName);
Reset(FileBuf);
try
Age := DateTimeToFileDate(StrToDateTime(fDate));
FHandle := TFileRec(FileBuf).Handle;
DosDateTimeToFileTime(LongRec(Age).Hi, LongRec(Age).Lo, LocalFileTime);
LocalFileTimeToFileTime(LocalFileTime, FileTime);
// º¯°æÇÑ ³¯Â¥
SetFileTime(FHandle, nil, nil, @FileTime);
// ÀÛ¼ºÇÑ ³¯Â¥
SetFileTime(FHandle, @FileTime, nil, nil);
// »ç¿ëÇÑ ³¯Â¥
SetFileTime(FHandle, nil, @FileTime, nil);
finally
CloseFile(FileBuf);
end;
end
else
MessageDlg('ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù: ' + fName, mtError, [mbOK], 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
SetModifyDate(OpenDialog1.FileName, '1999-12-25 ¿ÀÈÄ 02:49:23');
end;
end. |
|