Forum > General
Help with tsearchrec
Thaddy:
The functions KodeZwerg wrote are superfluous, since https://www.freepascal.org/docs-html/rtl/sysutils/filedatetodatetime.html and the likes are already in sysutils and also take time into account.
But for correct info, indeed better to read the EXIF data (if any) as Marcov wrote.
In case there maybe a small issue with your last line of code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- created := FileDateToDateTime(SearchRec.FindData.ftLastWriteTime); means the exact same thing as in Delphi.
If it is not there in sysutils, I will provide a patch for an alias.
( I don't think you want just the time information and throw the date part away! and even that is easily fixed.)
marcov:
I tried, but no, it doesn't work that way. I converted the filetime to a quad using part of Kodezwerg's code, and then used filedatetodatetime, but apparently that is not the same.
Stranger though, SteveSS' code is not compiled by Delphi either. It doesn't know filetimetodatetime either.
GetMem:
Try something like this(not tested):
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses windows; function GetFileTime(AFileTime: TFileTime; out ADateTime: TDateTime): Boolean;var LocalFileTime: TFileTime; SystemTime: TSystemTime;begin Result := False; if FileTimeToLocalFileTime(AFileTime, LocalFileTime) then begin if FileTimeToSystemTime(LocalFileTime, SystemTime) then begin ADateTime:= SystemTimeToDateTime(SystemTime); Result := True; end; end;end; procedure TForm1.Button1Click(Sender: TObject);var DateTime: TDateTime; SR: TSearchRec;begin if FindFirst('d:\test\SomeFile.txt', faAnyFile, SR) = 0 then //<- change it here if GetFileTime(SR.FindData.ftLastWriteTime, DateTime) then ShowMessage(FormatDateTime('YYYY.MM.DD hh:mm:ss', DateTime));end;
Thaddy:
--- Quote from: marcov on March 21, 2023, 02:06:53 pm ---I tried, but no, it doesn't work that way. I converted the filetime to a quad using part of Kodezwerg's code, and then used filedatetodatetime, but apparently that is not the same.
Stranger though, SteveSS' code is not compiled by Delphi either. It doesn't know filetimetodatetime either.
--- End quote ---
Again, stranger is that the example code in the manual (Ex13.pp) alone is enough to fix Steve's problem.
Hartmut:
Hello Steve,
you are on Windows, correct?
Which FPC-Version do you use? Date-Time-things in 'tsearchrec' have changed during the last versions.
Navigation
[0] Message Index
[#] Next page
[*] Previous page