CTResource::Find
Find a resource by type and number of by name.
Declaration
CTBOOL CTResource::Find(ULONG type, ULONG number, CTBOOL lock) const;
CTBOOL CTResource::Find(const CTString& name, CTBOOL lock) const;
Description
The first overloaded method locates and retrieves a resource in a table based on type and number. Parameters type and number are values that should uniquely identify the resource and lock is used to indicate if the resource should be locked, if it is found.
The second overloaded method locates and retrieves a resource by name. c-tree Plus cannot guarantee unique resource names. Parameter name is the resource name and lock is used to indicate if the resource should be locked, if it is found.
Return
CTResource::Find() return YES if the resource was located and retrieved or NO if the resource could not be found. In case of error, a CTException is thrown.
Example
// display a particular resource
void DisplayResource(const CTTable& hTable, ULONG type, ULONG number)
{
CTResource* hRes = new CTResource(hTable);
try
{
if (hRes->Find(type, number))
{
printf("Resource type: %u, number: %u, name: %s\n",
hRes->GetType(), hRes->GetNumber(),
hRes->GetName().c_str());
}
else
printf("Resource %d,%d not found\n", type, number);
}
catch (CTException &err)
{
printf("Error %d - %s\n", err.GetErrorCode(), err.GetErrorMsg());
}
delete hRes;
}
See Also
CTResource::Add(), CTResource::Delete(), CTResource::Update(), CTResource::First(), CTResource::Next(), CTResource::GetType(), CTResource::SetType(), CTResource::GetNumber(), CTResource::SetNumber(), CTResource::GetName(), CTResource::SetName(), CTResource::GetDataLength(), CTResource::GetData(), CTResource::SetData(), CTResource::Unlock(), CTResource::IsLocked()