Wyświetlanie Version Info Innego programu

0

Witam czy jest możliwość odczytania Version Info innego programu . Dokładnie chodzi mi o te dane:
user image

czy można je odczytać ? jeśli tak to proszę o pomoc , chciałbym wyświetlić : wersję pliku , nazwę produktu , nazwę wewnętrzną oraz firmę/autora

Pozdrawiam i życzę Wesołych Świąt

0

Niedługo zacznę dawać bany pod choinkę... szukajka. Wyciąganie podobnych informacji było wielokrotnie.

0

Dzięki Deus zmotywowałeś mnie ...

znalazłem cześć

function GetVersion(sFileName:string): string;
var
  VerInfoSize: DWORD;
  VerInfo: Pointer;
  VerValueSize: DWORD;
  VerValue: PVSFixedFileInfo;
  Dummy: DWORD;
begin
  VerInfoSize := GetFileVersionInfoSize(PChar(sFileName), Dummy);
  GetMem(VerInfo, VerInfoSize);
  GetFileVersionInfo(PChar(sFileName), 0, VerInfoSize, VerInfo);
  VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
  with VerValue^ do
  begin
    Result := IntToStr(dwFileVersionMS shr 16);
    Result := Result + '.' + IntToStr(dwFileVersionMS and $FFFF);
    Result := Result + '.' + IntToStr(dwFileVersionLS shr 16);
    Result := Result + '.' + IntToStr(dwFileVersionLS and $FFFF);
  end;
  FreeMem(VerInfo, VerInfoSize);
end;
procedure TForm1.Button1Click(Sender: TObject);
 begin
  ShowMessage(GetVersion('c:\aqq.exe'));
end;

pokazuje tylko wersję pliku ..
szukam jeszcze pozostałych informacji o pliku . jak by ktoś mógł pomóc bł bym wdzięczny .

0

Nieznalazłem działającego kodu , przewertowałem około 50 stron ...

0

Eeech, spójrz w ten kod i przejrzyj dokumentację funkcji do pobierania wartości z version info... http://msdn.microsoft.com/en-us/library/ms647464(VS.85).aspx

0
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type
  TFileVersionInfo = record
    fCompanyName,
    fFileDescription,
    fFileVersion,
    fInternalName,
    fLegalCopyRight,
    fLegalTradeMark,
    fOriginalFileName,
    fProductName,
    fProductVersion,
    fComments: string;
  end;
var
  Form1: TForm1;
  FileVersionInfo: TFileVersionInfo;
implementation

{$R *.dfm}
 procedure GetAppVersionInfo(sAppNamePath: string);
var
  VerSize: integer;
  VerBuf: PChar;
  VerBufValue: pointer;
  {$IFDEF Delphi3Below}
  VerHandle: integer;
  VerBufLen: integer;
  {$ELSE}
  VerHandle: cardinal;
  VerBufLen: cardinal;
  {$ENDIF}
  VerKey: string;

  function GetInfo(ThisKey: string): string;
  begin
    Result := '';
    VerKey := '\StringFileInfo\' + IntToHex(loword(integer(VerBufValue^)), 4) +
    IntToHex(hiword(integer(VerBufValue^)), 4) + '\' + ThisKey;
    if VerQueryValue(VerBuf, PChar(VerKey), VerBufValue, VerBufLen) then
      Result := StrPas(VerBufValue);
  end;

  function QueryValue(ThisValue: string): string;
  begin
    Result := '';
    if GetFileVersionInfo(PChar(sAppNamePath), VerHandle, VerSize, VerBuf) and
      VerQueryValue(VerBuf, '\VarFileInfo\Translation', VerBufValue, VerBufLen) then
      Result := GetInfo(ThisValue);
  end;

begin
  if sAppNamePath = '' then
    sAppNamePath := Application.ExeName;
  VerSize := GetFileVersionInfoSize(PChar(sAppNamePath), VerHandle);
  VerBuf := AllocMem(VerSize);
  try
    FileVersionInfo.fCompanyName      := QueryValue('CompanyName');
    FileVersionInfo.fFileDescription  := QueryValue('FileDescription');
    FileVersionInfo.fFileVersion      := QueryValue('FileVersion');
    FileVersionInfo.fInternalName     := QueryValue('InternalName');
    FileVersionInfo.fLegalCopyRight   := QueryValue('LegalCopyRight');
    FileVersionInfo.fLegalTradeMark   := QueryValue('LegalTradeMark');
    FileVersionInfo.fOriginalFileName := QueryValue('OriginalFileName');
    FileVersionInfo.fProductName      := QueryValue('ProductName');
    FileVersionInfo.fProductVersion   := QueryValue('ProductVersion');
    FileVersionInfo.fComments         := QueryValue('Comments');
  finally
    FreeMem(VerBuf, VerSize);
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
    GetAppVersionInfo('C:\AQQ.exe');
    ShowMessage(FileVersionInfo.fFileDescription) ;
end;

end.

działa dla plików *.exe oraz *.dll

0

Odświeżam wątek.

Delphi 10.1 Berlin

funkcja GetInfo jest już niekompatybilna w "StrPas":

 function GetInfo(const sKey: string): string;
 var
  s: string;
 begin
  Result := '';
  s := '\StringFileInfo\' + IntToHex(LoWord(Integer(VerBufValue^)), 4) + IntToHex(HiWord(Integer(VerBufValue^)), 4) + '\' + sKey;

  if VerQueryValue(VerBuf, pChar(s), VerBufValue, VerBufLen) then Result := StrPas(VerBufValue);
 end;

Błąd kompilatora:

E2251 Ambiguous overloaded call to 'StrPas'
  System.SysUtils.pas(11974): Related method: function StrPas(const PAnsiChar): AnsiString;
  System.SysUtils.pas(11980): Related method: function StrPas(const PWideChar): string;

W1057 Implicit string cast from 'AnsiString' to 'string'

Próbowałem już:

Result := SysUtils.StrPas(VerBufValue);
Result := StrPas(PAnsiChar(VerBufValue));
Result := string(StrPas(PAnsiChar(VerBufValue)));
1

Tak powinno być OK w starych i nowych Delphi:

  function GetInfo(ThisKey: string): string;
  begin
    Result:= '';
    VerKey := '\StringFileInfo\' + IntToHex(loword(integer(VerBufValue^)), 4) +
    IntToHex(hiword(integer(VerBufValue^)), 4) + '\' + ThisKey;
    if VerQueryValue(VerBuf, PChar(VerKey), VerBufValue, VerBufLen) then
    begin
      SetLength(result, VerBufLen * SizeOf(Char) + 1);
      CopyMemory(@result[1], VerBufValue, VerBufLen * SizeOf(Char));
    end;
  end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1