TVersionResource class
Version information resource type
Declaration
TVersionResource = class(TAbstractResource)Inheritance
- TVersionResource
- TAbstractResource
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.
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.
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
Properties
FixedInfo | public | Language independent part of version information |
StringFileInfo | public | Language dependent part of version information |
VarFileInfo | public | List of supported languages |
Methods
GetType | protected | Returns the type of the resource |
GetName | protected | Returns the name of the resource |
ChangeDescTypeAllowed | protected | Reports whether changing the type of resource type or name is allowed |
ChangeDescValueAllowed | protected | Reports whether changing the value of resource type or name is allowed |
NotifyResourcesLoaded | protected | Tells the resource that all resources have been loaded |
Create | public | Creates a new version information resource |
Destroy | public | Destroys the object |
UpdateRawData | public | Updates RawData stream. |
Inherited
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
