Unit 'versionresource' Package
[Overview][Types][Classes][Index] [#fcl-res]

TVersionResource

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Version information resource type

Declaration

Source position: versionresource.pp line 44

type TVersionResource = class(TAbstractResource)

protected

  function GetType; override;

  function GetName; override;

  function ChangeDescTypeAllowed(); override;

  function ChangeDescValueAllowed(); override;

  procedure NotifyResourcesLoaded; override;

public

  constructor Create();

  

Creates a new version information resource

  destructor Destroy; override;

  procedure UpdateRawData; override;

  property FixedInfo: TVersionFixedInfo; [r]

  

Language independent part of version information

  property StringFileInfo: TVersionStringFileInfo; [r]

  

Language dependent part of version information

  property VarFileInfo: TVersionVarFileInfo; [r]

  

List of supported languages

end;

Inheritance

TVersionResource

  

Version information resource type

|

TAbstractResource

  

Base abstract resource class

|

TObject

Description

This class represents a resource of type RT_VERSION.

A resource of this type provides version information for a Microsoft Windows executable or dll, which is shown when checking properties of a file in Windows Explorer.

Information is stored in FixedInfo, StringFileInfo and VarFileInfo.

Remark: This class doesn't allow its type to be changed to anything else than RT_VERSION, and its name to be different from 1. Attempts to do so result in a EResourceDescChangeNotAllowedException.
Remark: If you need to access RawData after you modified something, be sure to call UpdateRawData first. This isn't needed however when resource is written to a stream, since TResources takes care of it.

Sample code

This code creates a version information resource

const
  myVersion : TFileProductVersion = (1,2,0,0);

var
  resources : TResources;
  aRes : TVersionResource;
  st : TVersionStringTable;
  ti : TVerTranslationInfo;
begin
  aRes:=TVersionResource.Create(nil,nil); //it's always RT_VERSION and 1 respectively
  resources:=TResources.Create;
  resources.Add(aRes);

  aRes.FixedInfo.FileVersion:=myversion;
  aRes.FixedInfo.ProductVersion:=myversion;
  aRes.FixedInfo.FileFlagsMask:=VS_FFI_FILEFLAGSMASK;
  aRes.FixedInfo.FileFlags:=0;
  aRes.FixedInfo.FileOS:=VOS_NT_WINDOWS32;
  aRes.FixedInfo.FileType:=VFT_APP;
  aRes.FixedInfo.FileSubType:=0;
  aRes.FixedInfo.FileDate:=0;

  st:=TVersionStringTable.Create('041004B0'); //Italian, unicode codepage
  st.Add('CompanyName','Foo Corporation');
  st.Add('FileDescription','Foo suite core program');
  st.Add('FileVersion','1.2');
  st.Add('ProductVersion','1.2');
  aRes.StringFileInfo.Add(st);

  ti.language:=$0410; //Italian
  ti.codepage:=$04B0; //Unicode codepage
  aRes.VarFileInfo.Add(ti);

  resources.WriteToFile('myresource.res');
  resources.Free; //destroys aRes as well.
end;

See also

TVersionResource.FixedInfo

  

Language independent part of version information

TVersionResource.StringFileInfo

  

Language dependent part of version information

TVersionResource.VarFileInfo

  

List of supported languages


Documentation generated on: Nov 22 2024