Loads a resource into memory from resource pack or disk file.

void *Resource_Load(
  const char *filename,
  DWORD *size = 0


Resource file name.
Pointer to a DWORD to store the resource size to. If = 0 or omitted, Resource_Load will not return the resource size.

Return value

If successful, returns pointer to a memory allocated for the resource and stores resource size to a DWORD addressed by size parameter. Otherwise returns 0.


If filename specifies relative path, resource file is first searched within all resource packs attached with Resource_AttachPack, then in the application disk folder. If filename specifies absolute disk path, resource file is loaded directly from disk.

If the function fails, you may obtain error message with System_GetErrorMessage function. Also if HGE_LOGFILE system state was set, the error message is written to log.

When the resource isn't needed longer, you must free the allocated memory with the Resource_Free call.


Header: hge.h
Import library: hge.lib

See also