* * *

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

af0815

  • Full Member
  • ***
  • Posts: 157
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: 2749
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

  • Full Member
  • ***
  • Posts: 157
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: 898
Re: FileVersionInfo did not work with a DLL
« Reply #3 on: July 12, 2018, 06:27:52 pm »

af0815

  • Full Member
  • ***
  • Posts: 157
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

  • Jr. Member
  • **
  • Posts: 78
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
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 1.8.4 + FPC 3.0.4 (32-bit w/64-bit cross-compile)
Occasional testing of NewPascal
Windows 10 Pro x64, Version 1803 (Build 17134.228)

(Technically, I logon to these forums from multiple versions of Windows Pro/Enterprise...)

 

Recent

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