madTools: GetFileVersion

delphi package - madRes, madTools, madStrings, ...

madTools: GetFileVersion

Postby Nicka » Mon Jan 18, 2010 1:48 pm

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);
Nicka
 
Posts: 6
Joined: Mon Jan 18, 2010 11:26 am

Postby madshi » Fri Jan 22, 2010 10:08 am

Thanks, I'll add that to my to do list.
madshi
Site Admin
 
Posts: 9273
Joined: Sun Mar 21, 2004 5:25 pm

Postby Nicka » Thu Aug 12, 2010 3:46 pm

Hi
What about implementation function GetFileVersionInfoStr ?
In the next release?
When? :)
Nicka
 
Posts: 6
Joined: Mon Jan 18, 2010 11:26 am

Postby madshi » Thu Aug 12, 2010 4:14 pm

Could you please upload a sample dll which has no version number but only a string? That would help!
madshi
Site Admin
 
Posts: 9273
Joined: Sun Mar 21, 2004 5:25 pm

Postby Nicka » Fri Aug 13, 2010 6:43 am

I sent a sample file to you by email.
Nicka
 
Posts: 6
Joined: Mon Jan 18, 2010 11:26 am

Re: madTools: GetFileVersion

Postby madshi » Mon Nov 22, 2010 3:16 pm

The latest beta build should contain this now:

http://madshi.net/madCollectionBeta.exe
madshi
Site Admin
 
Posts: 9273
Joined: Sun Mar 21, 2004 5:25 pm


Return to madBasic

Who is online

Users browsing this forum: No registered users and 2 guests