Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Constructing Resource Objects

Before any operations can be performed on resources, you are required to instantiate a resource object. There are three overloaded CTResource constructors:

CTResource::CTResource(const CTTable& hTable);

Construct a CTResource object with the resource type and number set to zero and the resource name set to NULL.

CTResource(const CTTable& hTable, ULONG type, ULONG number);

Construct a CTResource object passing the resource type and number. The resource name is set to NULL.

CTResource(const CTTable& hTable, ULONG type, ULONG number, const CTString& name);

Construct a CTResource object passing the resource type and number, as well as the resource name.

Example

void DisplayAllResources(const CTTable& hTable)

{

CTResource* hRes = new CTResource(hTable);

try

{

// get the first resource

if (hRes->First())

{

do

{

// display resource type, number and name

printf("Resource type: %u, number: %u",

hRes->GetType(), hRes->GetNumber());

}

while (hRes->Next());

}

}

catch (CTException &err)

{

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

}

delete hRes;

}

TOCIndex