Recent

Author Topic: FileVersionInfo did not work with a DLL  (Read 4374 times)

af0815

  • Hero Member
  • *****
  • Posts: 1289
FileVersionInfo did not work with a DLL
« on: July 12, 2018, 02:39:16 pm »
I have created a library with lazarus under windows with added Versions Info. The Windows explorer show this, but if i want to read the Versions Info from a programm with Lazarus i got the exception

Quote
... raised exeption class 'EResourceReaderNotFound' with message Cannot find resource reader for extension dll.
How can i solve this ?

Edit: the winpeimagereader should can handle this, but did not work.
« Last Edit: July 12, 2018, 02:49:55 pm by af0815 »
regards
Andreas

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: FileVersionInfo did not work with a DLL
« Reply #1 on: July 12, 2018, 02:56:25 pm »
I have created a library with lazarus under windows with added Versions Info. The Windows explorer show this, but if i want to read the Versions Info from a programm with Lazarus i got the exception

Quote
... raised exeption class 'EResourceReaderNotFound' with message Cannot find resource reader for extension dll.
How can i solve this ?

Edit: the winpeimagereader should can handle this, but did not work.

Are you using the FPC fileinfo unit? That reads version info resource data from an executable.

You can see how it's used in the VersInfoList unit that's part of LazXProj:

https://macpgmr.github.io/MacXPlatform/LazXProj.html


af0815

  • Hero Member
  • *****
  • Posts: 1289
Re: FileVersionInfo did not work with a DLL
« Reply #2 on: July 12, 2018, 03:19:43 pm »
Yes, i am using the fileinfo unit from FPC under Windows.

in winpeimagereader there is the definition on the end of the file
Quote
initialization
  TResources.RegisterReader('.exe',TWinPEImageResourceReader);
  TResources.RegisterReader('.dll',TWinPEImageResourceReader);
  TResources.RegisterReader('.bpl',TWinPEImageResourceReader);
end.
So it should be possible to work with a dll too.

The header of the dll looks ok. The MZ and PE Signature is ok. The PE Signature is starting on $80. No diffence to a exe file.

I am working on a Windows10/64 PC.

Code: Pascal  [Select][+][-]
  1. uses
  2.   FileUtil, fileinfo;  
  3.  
  4. ......
  5.   TDllInfo = class(TObject)
  6.     FileName : String;
  7.     ModulName : String;
  8.     Info : string;
  9.   end;
  10.  
  11. .......
  12.  
  13. procedure FindModules(const aDir: string; var aList: TstringList);
  14. var
  15.   i: Integer;
  16.   FileVerInfo:TFileVersionInfo;
  17.   FileName, ModulName: String;
  18.   aDllInfo : TDllInfo;
  19. begin
  20.   FileVerInfo:= TFileVersionInfo.Create(nil);
  21.   try
  22.     with FindAllFiles(aDir,'*.dll', false) do begin
  23.       for i:= 0 to Count-1 do begin
  24.         FileName := Strings[i];
  25. //        FileName := paramstr(0);  //ChangeFileExt(FileName,'.exe');
  26.         FileVerInfo.FileName:= FileName;
  27.         try
  28.           FileVerInfo.ReadFileInfo;
  29.           ModulName:= FileVerInfo.VersionStrings.Values['InternalName'];
  30.           if ModulName <> '' then begin
  31.             aDllInfo := TDllInfo.Create;
  32.             aDllInfo.FileName:= Strings[i];
  33.             aDllInfo.ModulName:= ModulName;
  34.             aDllInfo.Info:= FileVerInfo.VersionStrings.Values['FileDescription'];
  35.             aList.AddObject(aDllInfo.FileName,aDllInfo);
  36.           end;
  37.         finally
  38.           ; // nothing to do
  39.         end;
  40.       end;
  41.     end;
  42.   finally
  43.     FileVerInfo.Free;
  44.   end;
  45. end;
  46.  

« Last Edit: July 12, 2018, 03:37:14 pm by af0815 »
regards
Andreas

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: FileVersionInfo did not work with a DLL
« Reply #3 on: July 12, 2018, 06:27:52 pm »

af0815

  • Hero Member
  • *****
  • Posts: 1289
Re: FileVersionInfo did not work with a DLL
« Reply #4 on: July 13, 2018, 06:26:39 am »
I have found the soloution for MY Prablem - for the records:  8-)

If you use the unit fileinfo there is a different between local using - eg. for the same file - and using for other files (exe,dll).

Local - only fileinfo in uses nesserary, no reader have to declared
Other files - you have to define the readers for the files you expected - in my enviroment winpeimagereader ( found in fpcsrc/packages/fcl-res/src)

The soloution for me is, i have to add winpeimagereader in the uses line.   :)
regards
Andreas

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: FileVersionInfo did not work with a DLL
« Reply #5 on: July 18, 2018, 05:12:12 pm »
Also see this thread.   I experienced this problem as well, and the fix was already applied to truck...

https://forum.lazarus.freepascal.org/index.php/topic,41174.msg285219.html#msg285219
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

 

TinyPortal © 2005-2018