* * *

Author Topic: how to get the original filedate not date modifyed  (Read 3911 times)

ASerge

  • Hero Member
  • *****
  • Posts: 749
Re: how to get the original filedate not date modifyed
« Reply #15 on: November 09, 2017, 10:58:51 pm »
But Windows stores this date in the field: date taken (rightclick on a JPG in explorer --- Properties -- Details  -- Title: Origin) and makes it to its (main)date.  -- or look at my printscreen above.
Get any property from the shell!
Code: Pascal  [Select]
  1. {$APPTYPE CONSOLE}
  2. program Project1;
  3.  
  4. uses Windows, SysUtils, ActiveX, ShlObj;
  5.  
  6. function GetShellFolder2(const Dir: UnicodeString; out Intf: IShellFolder2): Boolean;
  7. var
  8.   DesktopFolder: IShellFolder;
  9.   DirPIDL: PItemIDList = nil;
  10. begin
  11.   Result := Succeeded(SHGetDesktopFolder(DesktopFolder)) and
  12.     Succeeded(DesktopFolder.ParseDisplayName(0, nil, PWideChar(Dir),
  13.       ULONG(nil^), DirPIDL, ULONG(nil^))) and
  14.     Succeeded(DesktopFolder.BindToObject(DirPIDL, nil, IID_IShellFolder2, Intf));
  15.   CoTaskMemFree(DirPIDL);
  16. end;
  17.  
  18. function GetFileProperty(const FileName: string; const Column: SHColumnID;
  19.   out Value: OleVariant): Boolean;
  20. var
  21.   DirFolder: IShellFolder2;
  22.   FilePIDL: PItemIDList = nil;
  23.   WFileName: UnicodeString;
  24. begin
  25.   WFileName := Utf8Decode(FileName);
  26.   Result := False;
  27.   if GetShellFolder2(ExtractFileDir(WFileName), DirFolder) then
  28.   begin
  29.     Result := Succeeded(DirFolder.ParseDisplayName(0, nil,
  30.       PWideChar(ExtractFileName(WFileName)),
  31.         ULONG(nil^), FilePIDL, ULONG(nil^))) and
  32.       Succeeded(DirFolder.GetDetailsEx(FilePIDL, Column, @Value));
  33.     CoTaskMemFree(FilePIDL);
  34.   end;
  35. end;
  36.  
  37. const
  38.   CFileName = 'c:\Path\Your favorite file.JPG';
  39.   // All available values see in propkey.h in SDK
  40.   CColumnPhotoDateTaken: SHColumnID = ( // PKEY_Photo_DateTaken
  41.     fmtid: '{14B81DA1-0135-4D31-96D9-6CBFC9671A99}'; // FMTID_ImageProperties
  42.     pid: 36867);
  43. var
  44.   Value: OleVariant;
  45. begin
  46.   CoInitialize(nil);
  47.   if GetFileProperty(CFileName, CColumnPhotoDateTaken, Value) then
  48.   begin
  49.     Writeln('Photo Date Taken at UTC: ', Value);
  50.   end;
  51.   Readln;
  52. end.

ratmalwer

  • New member
  • *
  • Posts: 41
Re: how to get the original filedate not date modifyed
« Reply #16 on: November 10, 2017, 12:01:06 am »
hello molly

you where right GlobalSkipIfNoLeaks is not known by lazarus-1.6.4-fpc-3.0.2-win64.exe.

Even it is the latest Version on official Lazarus-Site. So I searched the net and found:

Lazarus-1.8  RC5  (i did not try)
Lazarus-1.9-56259_fpc-3.1.1-37548M_20171103-1327.7z (google)  -> this i unzipped and messed up my installation. (compiler missing and so on...)

Now I just removed my installation.

So how do I get a installation that is up to date? Or is there one coming on official site soon?

ratmalwer

  • New member
  • *
  • Posts: 41
Re: how to get the original filedate not date modifyed
« Reply #17 on: November 10, 2017, 12:04:22 am »
hi mai

i just found this one: Linux / Re: new kernel function fstatx() in Kern 4.11

Can you be a little more specific - Im rather new at Lazarus and pascal and working with Windows 7.

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: how to get the original filedate not date modifyed
« Reply #18 on: November 10, 2017, 12:35:32 am »
hello molly

you where right GlobalSkipIfNoLeaks is not known by lazarus-1.6.4-fpc-3.0.2-win64.exe.
Eh... that's weird  %)

FPC 3.0.2 should be enough (i use that version as well).


Quote
So how do I get a installation that is up to date? Or is there one coming on official site soon?
The 1.8 release should become a final release pretty soon. But somehow everything related to this release seems to be a bit ... well ... out of the ordinary. So, please don't hold that against me in case it will take another year before reaching final release :D

You should be good to go with your initial installation of lazarus-1.6.4-fpc-3.0.2-win64.exe. I would recommend to verify this with someone else first as i'm unable to verify myself at the moment.

I apologize for recommending to upgrade. I more or less expected that you would mention your current version first, before actually performing an upgrade. In hindsight that seem to have caused more trouble than you bargained for  :-[

Are you able to remove your current installation and re-install lazarus-1.6.4-fpc-3.0.2-win64.exe ? If not then please feel free to mention the errors you are encountering, so that we're able to solve them for you.

ratmalwer

  • New member
  • *
  • Posts: 41
Re: how to get the original filedate not date modifyed
« Reply #19 on: November 10, 2017, 03:18:08 am »
HEUREKA

... I found it.... I placed the directive in the project as shown....

Code: Pascal  [Select]
  1. program BaseSample;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms, ureadexif
  11.   { you can add units after this };
  12.  
  13. {$R *.res}
  14.  
  15. begin
  16.   RequireDerivedFormResource:=True;
  17.   Application.Initialize;
  18.   Application.CreateForm(TForm1, Form1);
  19.   Application.Run;
  20.   GlobalSkipIfNoLeaks := true;
  21.   UseHeapTrace := false;
  22. end.
  23.  


still hoping to get an examle of some (any) API-Call to windows and where to place it, so I could try to get the datetaken property of windows

(I am still a newbee but try to improove)

molly

  • Hero Member
  • *****
  • Posts: 2345
Re: how to get the original filedate not date modifyed
« Reply #20 on: November 10, 2017, 03:57:34 am »
HEUREKA
Glad that you was able to find it.

Quote
still hoping to get an examle of some (any) API-Call to windows and where to place it, so I could try to get the datetaken property of windows
Look at reply #15 from ASerge. That is using activeX shell object api to retrieve the (column) information.

ratmalwer

  • New member
  • *
  • Posts: 41
Re: how to get the original filedate not date modifyed
« Reply #21 on: November 10, 2017, 05:15:12 am »
Thanks all for your help.... Reading though the web and asking on other platforms it seems I am wrong with my oppinion that the datetaken is a property witch can be accessed directly by API / NTFS... In other words, it ist actually needed to open each file to get its Exif... as I was told earlyer...
so i declare this thead as closed....

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1183
Re: how to get the original filedate not date modifyed
« Reply #22 on: November 11, 2017, 08:33:24 pm »
Last time I read EXIF I was a Delphi programmer.  Back then I used the dEXIF library which I was quite happy with.  Looking around I see this has been translated to Lazarus...

https://github.com/cutec-chris/dexif
Lazarus Trunk/FPC Trunk on Linux & Windows [7, 8.1]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3368
  • I like bugs.
Re: how to get the original filedate not date modifyed
« Reply #23 on: November 11, 2017, 10:22:29 pm »
https://github.com/cutec-chris/dexif
The ReadMe says the license was switched to LGPL with author's permission.
The Copyright.txt however explains a very different license. Somebody should tell them to update it.

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1183
Re: how to get the original filedate not date modifyed
« Reply #24 on: November 11, 2017, 10:28:21 pm »
At the top of Copyright.txt
Quote
----------------------------------
This port of dEXIF to Lazarus/Freepascal is accepted in July 2017 by the Copyright-Owner
----------------------------------
Hello Andreas ,
  It is possible, all I ask is attribution somewhere in your documentation or source. 
  I will indeed look at updating the license terms but wanted to let you know it's OK to proceed so you don't have to wait.
Thanks,   

Gerry McGuire dEXIF author.

---------------------------------

So, it looks like Gerry is aware of this and updating the license is already on his TODO.
Lazarus Trunk/FPC Trunk on Linux & Windows [7, 8.1]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus