Recent

Author Topic: Compare date of creation of Lazarus * .exe with the unauthorized copy  (Read 1144 times)

aacs

  • New member
  • *
  • Posts: 7
 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;


sstvmaster

  • Sr. Member
  • ****
  • Posts: 306
greetings Maik

Windows 10,
- Lazarus 4.4 (stable) + fpc 3.2.2 (stable)
- Lazarus 4.99 (trunk) + fpc 3.3.1 (main/trunk)

 

TinyPortal © 2005-2018