Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Updating Existing Resources

The following steps are required to update a resource:

  1. Instantiate a CTResource object by calling one of the CTResource constructors. You should pass at least the resource type and number. The resource name is optional. If you use a CTResource constructor that does not take the resource type and number, you need to call CTResource::SetType() and CTResource::SetNumber() to set the resource type and number before you add a new resource.
  2. Call CTResource::Update() method passing the resource data and the size in bytes of the resource data.
  3. Once the CTResource object is no longer needed, destroy the object to release any system resources.

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

void Update(pVOID data, VRLEN size);

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 indicate the number of bytes occupied by data.

Example

void UpdateMyResource(const CTTable& hTable, ULONG type, ULONG number, pVOID data, VRLEN size)

{

CTResource* hRes = new CTResource(hTable, type, number);

try

{

hRes->Update(data, size);

}

catch (CTException &err)

{

printf("Error %d - %s\n", err.GetErrorCode(), err.GetErrorMsg());

}

delete hRes;

}

TOCIndex