Page 1 of 1

madTools: GetFileVersion

PostPosted: Mon Jan 18, 2010 1:48 pm
by Nicka
Hi
GetFileVersion returns the result only if there are only numbers fileversion
But some program\library does not contain VersionInfo, but contain String VersionInfo (oracleclient.dll)
Maybe add function GetFileVersionInfoStr
Code: Select all
function GetFileVersionStr(const AFileName: String) : String;
var
  P: Pointer;
  Value: Pointer;
  Len: DWORD;
  FHandle: DWORD;
  FBuffer: String;
  VerInt64: Int64;
begin
  VerInt64 := GetFileVersion(AFileName);
  if VerInt64 > 0 then
    Result := FileVersionToStr(VerInt64)
  else begin
    P := nil;
    Len := GetFileVersionInfoSize(PAnsiChar(AFileName), FHandle);
    if Len > 0 then
      SetLength(FBuffer, Len);
      if GetFileVersionInfo(PAnsiChar(AFileName), FHandle, Len, Pointer(FBuffer)) and
        VerQueryValue(Pointer(FBuffer), '\VarFileInfo\Translation', P, Len) and (P <> nil) then begin
        VerInt64 := MakeLong(HiWord(Longint(P^)), LoWord(Longint(P^)));
        if VerQueryValue(Pointer(FBuffer), PAnsiChar('\StringFileInfo\' +
          CopyR(IntToHexEx(VerInt64, 8), 8) + '\FileVersion'), Value, Len) then
          Result := PAnsiChar(Value);
      end;
  end;
end;


and Call this function in madExcept.pas and madListModules.pas

code
Code: Select all
        i64 := GetFileVersion(filePath);
        if i64 <> 0 then
          version := string(FileVersionToStr(i64));


replaced by
Code: Select all
  version := GetFileVersionStr(filePath);

PostPosted: Fri Jan 22, 2010 10:08 am
by madshi
Thanks, I'll add that to my to do list.

PostPosted: Thu Aug 12, 2010 3:46 pm
by Nicka
Hi
What about implementation function GetFileVersionInfoStr ?
In the next release?
When? :)

PostPosted: Thu Aug 12, 2010 4:14 pm
by madshi
Could you please upload a sample dll which has no version number but only a string? That would help!

PostPosted: Fri Aug 13, 2010 6:43 am
by Nicka
I sent a sample file to you by email.

Re: madTools: GetFileVersion

PostPosted: Mon Nov 22, 2010 3:16 pm
by madshi
The latest beta build should contain this now:

http://madshi.net/madCollectionBeta.exe