PA_GetResourceSize

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_GetResourceSize (resFile; kind; resID) long

ParameterTypeDescription
resFileshortFile reference number of the file to access
kindunsigned longKind (4 Bytes type) of resource to access
resIDshortUnique resource ID
Function resultlongSize of the resource in bytes

Description

The routine PA_GetResourceSize returns the size of the resource of type kind in bytes and the unique ID resID in the file referenced by resFile.

If the resource does not exist or if resFile is an invalid file reference number, the routine returns 0 (zero), and PA_GetLastError returns -5 ("Resource not found").

This routine can be useful in pre-allocating buffers before loading the resource into memory.

Example

Loading a resource in a buffer.

   char *MyGetResource(short resFile, unsigned long kind, short ID)
   {
      char   *resData;
      long   size = PA_GetResourceSize(resFile, kind, ID);
      if( long && (PA_GetLastError() == eER_NoErr )
      {
         resData = malloc(size);
         size = PA_GetResource(resFile, kind, ID, resData);
      }

      return resData;
   // Use PA_GetLastError() in the calling routine
   }

See Also

PA_GetResource.

Error Handling

Use PA_GetLastError to see if an error occurred


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next