Hello
I need a help to create a function to get the creation date of a file (executable * .exe, created by Lazarus) and compare it with the creation date if the person takes an unauthorized copy of this * .exe file from Lazarus, so the program copy will not run
I have this code in delphi
function FileAgeCreate(const FileName: string): Integer;
var
Handle: THandle;
FindData: TWin32FindData;
LocalFileTime: TFileTime;
begin
Handle := FindFirstFile(PChar(FileName), FindData);
if Handle <> INVALID_HANDLE_VALUE then
begin
Windows.FindClose(Handle);
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin
FileTimeToLocalFileTime(FindData.ftCreationTime, LocalFileTime);
if FileTimeToDosDateTime(LocalFileTime, LongRec(Result).Hi,
LongRec(Result).Lo) then Exit;
end;
end;
Result := -1;
end;
procedure TForm1.FormShow(Sender: TObject);
var
FlDt: Integer;
begin
FlDt := FileAgeCreate(ParamStr(0));
Label1.Caption := DateToStr(FileDateToDateTime(FlDt));
FlDt := FileAge(ParamStr(0));
Label2.Caption := DateToStr(FileDateToDateTime(FlDt));
end;