AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Get file version - something wrong

Ein Thema von WojTec · begonnen am 13. Aug 2014 · letzter Beitrag vom 14. Aug 2014
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Get file version - something wrong

  Alt 13. Aug 2014, 10:41
Delphi-Version: XE5
I want to get version info from executable, so I checked MSDN and wrote something like this:

Delphi-Quellcode:
  Size := GetFileVersionInfoSize(PChar(AFileName), hWnd);
  if Size > 0 then
  begin
    GetMem(Buffer, Size);
    try
      if GetFileVersionInfo(PChar(AFileName), hWnd, Size, Buffer) then
      begin
        if VerQueryValue(Buffer, '\', Pointer(FixedFileInfo), L) then
        begin
          if VerQueryValue(Buffer, PChar('\VarFileInfo\Translation'), Pointer(pD), L) then
          begin
            Translation := IntToHex(pD^, 8);
            Temp := Copy(Translation, 5, 4);
            if StrToIntDef('$' + Temp, 0) = 0 then
              Temp := IntToHex(1033, 4)
            ;
            Translation := Temp + Copy(Translation, 1, 4);
          end
          else
            Translation := '040904E4'
          ;

          // Here query for values
I checked on 16, 32 and 64 bit files and working well in most cases, but not for all For example for firefox.exe returns nulls (but query for translation passes) What's wrong with this?

Geändert von WojTec (13. Aug 2014 um 10:45 Uhr)
  Mit Zitat antworten Zitat
Der schöne Günther

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Get file version - something wrong

  Alt 13. Aug 2014, 10:46
You already know of a scenario that is going to fail. And you have the might of the debugger at your fingertips. What's stopping you from first finding out which call returns NULL?
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: AW: Get file version - something wrong

  Alt 13. Aug 2014, 11:39
So, I told

VerQueryValue(Buffer, PChar('\VarFileInfo\Translation')...

is success. Problem is with

VerQueryValue(Buffer, PChar('\StringFileInfo\' + Translation + '\(specified entries in table here)')

- here it fails on some files, looks like can't access, because wrong translation code
  Mit Zitat antworten Zitat
Whookie

Registriert seit: 3. Mai 2006
Ort: Graz
441 Beiträge
 
Delphi 10.3 Rio
 
#4

AW: Get file version - something wrong

  Alt 13. Aug 2014, 21:50
Heres an example how I'm doing it (see attachement).. its ripped from my component library and displays some of the version info in a memo.
Angehängte Dateien
Dateityp: 7z VersionInfo.7z (4,0 KB, 71x aufgerufen)
Whookie

Software isn't released ... it is allowed to escape!
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: Get file version - something wrong

  Alt 14. Aug 2014, 13:32
Nice, thanks! It woreking very well.

I did something wrong with translation I see.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:37 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz