GetCtResource Get Resource record from data file. Short Name GETRES() Type Low-level data file resource function Declaration LONG GetCtResource(COUNT datno, pVOID resptr, pVOID bufptr, VRLEN bufsiz, COUNT resmode) Description GetCtResource() retrieves a Resource from data file datno, returns a long integer corresponding to the byte offset of the Resource, and places the value of the Resource in the buffer pointed to by bufptr. bufsiz is the size of the buffer area. The buffer will contain the entire Resource Data Block. See AddCtResource() for information. resmode specifies the method of searching for the Resource. resptr points to the identifying information used in the search. The resmode choices are:
Return If no error occurs, GetCtResource() returns the byte offset for the Resource record. On RBUF_ERR (404), GetCtResource() returns the required buffer size and sets uerr_cod to 404. Otherwise, GetCtResource() returns a zero and uerr_cod is set as follows:
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example: 1 RES_NAME struct { /* Resource Data Block structure */
ULONG resource_type; ULONG resource_number; TEXT variable_info[1016]; /* This holds the */ } my_resource; /* Resource Name and Data */
my_resource.resource_number = 0xffffffffL; /* c-tree Plus assigns number*/
strcpy(my_resource.variable_info+12,"Actual Resource Data");
(VRLEN)(8 + 12 + strlen(my_resource.variable_info+12))) == 0) {
printf("\nThe resource has been assigned number %ld",
my_resource.resource_number); printf("\nThe resource is located at byte offset %ld.",
GetCtResource(datno, "MY!resource", &my_resource, 1024L, RES_NAME)); } else printf("\nCould not add resource. Error #%d",uerr_cod);
Example 2: RES_LENGTH struct {
ULONG resource_type; ULONG resource_number; TEXT variable_info[504]; } sample;
sample.resource_number = 0xffffffffL; /* c-tree Plus assigned number */ strcpy(sample.variable_info,"SAMPLE1!resource"); /* assign resource name */ strcpy(sample.variable_info+18, "This is the first resource record.");
(VRLEN)(8 + 18 + strlen(sample.variable_info+18))) != 0) printf("\nError adding first resource!, error = %d", uerr_cod);
else printf("\nSuccessful addition of first Resource Record");
/* assign resource name */ strcpy(sample.variable_info+18, "This is the second resource record.");
(VRLEN)(8 + 18 + strlen(sample.variable_info+18))) != 0) printf("\nError adding second resource!, error = %d", uerr_cod);
else printf("\nSuccessful addition of second Resource Record");
/* assign resource name */ strcpy(sample.variable_info+18, "This is the third resource record.");
(VRLEN)(8 + 18 + strlen(sample.variable_info+18))) != 0) printf("\nError adding third resource!, error = %d", uerr_cod);
else printf("\nSuccessful addition of third Resource Record");
RES_NAME | RES_LENGTH)) != 0) {
cpybuf(&ret,sample.variable_info, sizeof(LONG)); printf("\nFirst resource name is %ld bytes long",ret);
} else printf("\n\nError on First resource length = %d",uerr_cod);
Example 3: RES_NEXT if ((ret = GetCtResource(datno, "SAMPLE1!resource", &sample, 512, RES_NAME)) !=0) printf("\nFirst resource is %s",sample.variable_info);
else printf("\n\nError on First resource = %d",uerr_cod);
printf("\nNext resource is %s",sample.variable_info);
else printf("\n\nError on Next resource = %d",uerr_cod);
See also LockCtData(), LockISAM(), ctSetHgh(), ctGetHgh(), UpdateCtResource(), AddCtResource(), DeleteCtResource() |
|||||||||||||||||||||||||||||||||||||||||||||||||