Newsgroup: it.comp.lang.delphi
Titolo: Version Info

Esiste una classe con imlementate le informazioni sul progetto (tipo la
Versione), in modo da poterle visualizzare senza doverle cambiare ad ogni
versione?
ciao Raf

 versione?
Sia su Torry che su DSP trovi diversi componenti che fanno al caso tuo... in
genere sono anche dei derivati da TLabel per cui imposti solo cosa vuoi
vedere a runtime ed hai finito! :)
HTH
 Marco

 versione?
C'è né una nella RXlib.
Oppure usa questa unit che avevo scritto prima di scoprirle:
unit RLVersInfo;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
Dialogs;
const
  MaxStdVerInfoNames = 9;
  StdVerInfoNames: array[0..MaxStdVerInfoNames] of string = (
    'CompanyName',
    'FileDescription',
    'FileVersion',
    'InternalName',
    'LegalCopyright',
    'LegalTademarks',
    'OriginalFilename',
    'ProductName',
    'ProductVersion',
    'Comments');
type
  TVersionInfo = class(TComponent)
  private
    FActive: Boolean;
    FFileName: string;
    FLangCharset: string;
    function GetCustomInfo(KeyName: string): string;
    procedure SetActive(const Value: Boolean);
    procedure SetFileName(const Value: string);
    function GetStdInfo(Index: integer): string;
    { Private declarations }
  protected
    { Protected declarations }
    VerInfoBuffer: string;
    FFixedInfo: PVSFixedFileInfo;
    procedure ReadVersionInfo;
  public
    { Public declarations }
    property Key[KeyName: string]: string read GetCustomInfo; default;
    property FixedInfo: PVSFixedFileInfo read FFixedInfo;
  published
    { Published declarations }
    property Active: Boolean read FActive write SetActive;
    property FileName: string read FFileName write SetFileName;
    property LangCharset: string read FLangCharset;
    property CompanyName: string
      index 0 read GetStdInfo;
    property FileDescription: string
      index 1 read GetStdInfo;
    property FileVersion: string
      index 2 read GetStdInfo;
    property InternalName: string
      index 3 read GetStdInfo;
    property LegalCopyright: string
      index 4 read GetStdInfo;
    property LegalTademarks: string
      index 5 read GetStdInfo;
    property OriginalFilename: string
      index 6 read GetStdInfo;
    property ProductName: string
      index 7 read GetStdInfo;
    property ProductVersion: string
      index 8 read GetStdInfo;
    property Comments: string
      index 9 read GetStdInfo;
  end;
procedure Register;
implementation
procedure Register;
begin
  RegisterComponents('RL Misc', [TVersionInfo]);
end;
{ TVersionInfo }
function TVersionInfo.GetCustomInfo(KeyName: string): string;
var
  SubBlock: string;
  Res: PChar;
  Len: Cardinal;
begin
  SubBlock := Format('\StringFileInfo\%s\%s', [LangCharset, KeyName]);
  Win32Check(VerQueryValue(Pointer(VerInfoBuffer), PChar(SubBlock),
    Pointer(Res), Len));
  Result := Res;
end;
function TVersionInfo.GetStdInfo(Index: integer): string;
begin
  // ---- check ----
  assert(Index >= 0);
  assert(Index <= MaxStdVerInfoNames);
  // ---- body ----
  Result := Key[StdVerInfoNames[Index]];
end;
procedure TVersionInfo.ReadVersionInfo;
var
  Len: DWORD;
  Handle: DWORD;
  InfoBuf: PCharsetInfo;
  InfoLength: Cardinal;
begin
  VerInfoBuffer := ''; // clear buffer
  Len := GetFileVersionInfoSize(PChar(FFileName), Handle);
  if Len = 0 then
    RaiseLastWin32Error;
  SetLength(VerInfoBuffer, Len + 1);
  if GetFileVersionInfo(PChar(FFileName), Handle, Len,
    Pointer(VerInfoBuffer)) then begin
    Win32Check(VerQueryValue(Pointer(VerInfoBuffer), '\VarFileInfo
\Translation',
      Pointer(InfoBuf), InfoLength));
    FLangCharset := Format('%.4x%.4x', [LoWord(InfoBuf^.ciCharset),
      HiWord(InfoBuf^.ciCharset)]);
    Win32Check(VerQueryValue(Pointer(VerInfoBuffer), '\', Pointer
(FFixedInfo),
      InfoLength));
  end
  else
    RaiseLastWin32Error;
end;
procedure TVersionInfo.SetActive(const Value: Boolean);
begin
  FActive := Value;
  if FActive then begin
    if FFileName = '' then begin
      FFileName := ParamStr(0); // TODO: cosa succede per le DLLs?
      try
        ReadVersionInfo;
      except
        on EWin32Error do begin
          VerInfoBuffer := '';
          FLangCharset := '';
          FFixedInfo := nil;
          raise;
        end;
      end;
    end else begin
      VerInfoBuffer := '';
      FLangCharset := '';
      FFixedInfo := nil;
    end;
  end;
end;
procedure TVersionInfo.SetFileName(const Value: string);
begin
  FFileName := Value;
end;
end.
-- 
Roberto Lupi
http://www.lupi.ws/



Ce ne sono un bel po' nelle librerie JCL (
www.delphi-jedi.org
)
Ciao
--
Piero Bonanno
bop...@libero.it
pie...@tiscalinet.it
bpie...@hotmail.com
______________________________________________
"Madame, lei ha tra le gambe uno strumento
che puo' offrire piacere a migliaia di persone,
e tutto quello che sa fare e' grattarlo"
- Sir Thomas Beechan a una violoncellista