Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Updating existing resources

The following steps are required to update a resource:

Instantiate a TCtResource object by calling one of the TCtResource constructors. You should pass at least the resource type and number. The resource name is optional. If you use a TCtResource constructor that does not take the resource type and number, you need to set the TCtResource.TypeID and TCtResource.Number properties before you add a new resource.

Call TCtResource.Update() method passing the resource data and the size in bytes of the resource data.

Once the TCtResource object is no longer needed, destroy the object to release any system resources.

An existing resource can be updated by calling the following TCtResource method:

procedure TCtResource.Update(data : pointer; size : integer); virtual;

The Resource data is any collection of data that you wish to store as a Resource. It can be a character string, a structure, or any variable type. size indicates the number of bytes occupied by data.

Example


procedure UpdateMyResource(hTable : TCtTable);

var

hRes : TCtResource;

str : string;


begin

Writeln('Updating my resource of table ', hTable.Table);

str := 'this is my UPDATED resource data';

hRes := TCtResource.Create(hTable, $10001, 0, 'MyResource');

try

// update the resource

hRes.Update(pointer(pchar(str)), Length(str) + 1);

except

on err: ECtError do Writeln('Error ', err.Message);

end;

hRes.Free;

end;


TOCIndex