Forum > General
Help with tsearchrec
SteveSS:
I am trying to convert some Delphi code to Lazarus. It uses tsearchrec.finddata.ftlastwritetime. This does not compile - the error message for the line is 'got filetime expected tdatetime'.
I have looked at the documentation but can't find any help (probably looking in the wrong place as usual). Any help for this please? What I am really looking for its the Date Taken value - I am dealing with digital photographs - .jpg format.
Steve
KodeZwerg:
--- 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";}};} ---type ULONGLONG = UInt64; ULARGE_INTEGER = record case byte of 0: (LowPart : DWORD; HighPart : DWORD); 1: (QuadPart : ULONGLONG); end; FILETIME = record dwLowDateTime : DWORD; dwHighDateTime : DWORD; end; function FileTimeToDateTime(AFileTime: FILETIME): TDateTime;var li: ULARGE_INTEGER;const OA_ZERO_TICKS = UInt64(94353120000000000); TICKS_PER_DAY = UInt64(864000000000);begin li.LowPart := AFileTime.dwLowDateTime; li.HighPart := AFileTime.dwHighDateTime; Result := (Real(li.QuadPart) - OA_ZERO_TICKS) / TICKS_PER_DAY;end; function DateTimeToFileTime(ADateTimeUTC: TDateTime): FILETIME;var li: ULARGE_INTEGER;const OA_ZERO_TICKS = UInt64(94353120000000000); TICKS_PER_DAY = UInt64(864000000000);begin li.QuadPart := Round(ADateTimeUtc*TICKS_PER_DAY + OA_ZERO_TICKS); Result.dwLowDateTime := li.LowPart; Result.dwHighDateTime := li.HighPart;end;
Does that help you?
SteveSS:
Thanks for the reply but it doesn't really help. Just to give a bit more detail of what I am trying to do, I download photos from my digital camera into a standard directory. These are called IMG_1234, IMG_1235 etc. What the software needs to do is access each file in turn and re-name the file to Dddmmss.jpg where ddmmss is the date/time the photo was taken. The file is then saved to a pre-determined directory
C:\Photos\yyyy\month e.g \2023\03-March where they will appear in date/time taken order.
All I need is the tsearchrec field name available to get hold of the date / time taken. If you right click on a jpg file the date time taken is in the details tab.
Steve
marcov:
The date taken field is not necessarily the lastmodified time.
Such extended properties are only determined by examining the file (looking inside the JPG), and not part of the directory structure.
So while the explorer retrieves it via other systems, the base windows api does not.
The easiest is to load this from the EXIF metadata with libraries like fpexif
SteveSS:
Thanks markov but I wouldn't have a clue where to start with that. I think we are getting over complicated -
the delphi code is :
created := FileTimeToDateTime(SearchRec.FindData.ftLastWriteTime);
created is a tdatetime.
All I want is the lazarus equivalent but preferably with fttimetaken (if it exists).
Steve
Navigation
[0] Message Index
[#] Next page