Wersja pliku DLL c.d.

0

Witam!

Wypróbowałem następujący kod:

function TForm1.GetVersionString(VerStr, AppName: string): string;
var
  FileName: string;
  Size    : DWORD;
  Handle  : DWORD;
  Len     : UINT;
  Buffer  : PChar;
  Value   : PChar;
  TransNo : PLongInt;
  SFInfo  : string;
begin
  Result := '';
  FileName := AppName;
  Size := GetFileVersionInfoSize(PChar(FileName), Handle);

  if Size > 0 then
  begin
    Buffer := AllocMem(Size);

    try
     GetFileVersionInfo(PChar(FileName), 0, Size, Buffer);
     VerQueryValue(Buffer, PChar('VarFileInfoTranslation'), Pointer(TransNo), Len);
     SFInfo := Format('%s%.4x%.4x%s%s%', ['StringFileInfo', LoWord(TransNo^), HiWord(Transno^), '', VerStr]);
     if VerQueryValue(Buffer, PChar(SFInfo), Pointer(Value), Len) then
      Result := Value;
    finally
      if Assigned(Buffer) then
       FreeMem(Buffer, Size);
    end;
  end;
end;

Niestety, otrzymuję Access Violation. Wywołuję tą funkcję w następujący sposób:

Edit1.Text := GetVersionString('File Version', 'xxx.dll');

Może tu robię coś nie tak :|
Kto się orientuje, do czego w powyższym przykładzie służy zmienna 'VerStr'?

Dzięki.

0

Źle korzystasz z tej funkcji

FileVersion

Poczytaj w pomocy SDK o VerQueryValue, tam na dole strony masz podane który co mozesz podać

CompanyName FileDescription FileVersion InternalName LegalCopyright OriginalFilename ProductName ProductVersion

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