unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DateUtils, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function SetFileDate(
const FileName:
string; NewDate: TDateTime): boolean;
var FileDate, FileHandle: Integer;
begin
Result:= false;
FileDate:= DateTimeToFileDate(NewDate);
FileHandle:= FileOpen(FileName, fmOpenReadWrite
or fmShareDenyWrite);
if FileHandle > 0
then
begin
if FileSetDate(FileHandle, FileDate)= 0
then Result:= true;
FileClose(FileHandle);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenDialog1.Execute;
if SetFileDate(OpenDialog1.FileName, EncodeDateTime(2016,4,4,15,30,0,0))
then
ShowMessage('
OK!')
else
ShowMessage('
Fehler!');
end;
end.