OpenResFile
OpenResFile
Open resource file by name; get reference number ConstStr255Param fileName ; address of length-prefixed filename
returns reference number of the file (or -1 if an
error)
into memory and returns a file reference number for that file. The specified
file becomes the current active resource file (unless it is already open).
fileName is the address of a Pascal-style length-prefixed filename identifying
the file containing the resources you want to access. fileName may
contain volume and directory names; if omitted, the working
directory is assumed.
Returns: an integer; -1 indicates an error. Otherwise, it is the file reference number which must be used in subsequent resource file
operations.
Notes: OpenResFile is needed when you want to access resources in a file other than the system resource file or your application resource file (both of
which are already open when your application starts up).
The file becomes the current resource file, so resource requests will
search it first.
Exception: if the file is already open when you make this call, it
DOES NOT become the active file. You may wish to use UseResFile for insurance.
If the return value is -1, the function failed. Use ResError to find out why.
Use OpenRF if you just want to open the file for direct access (e.g., for file-copying operations), without reading its resource map into memory. Use OpenRFPerm if you wish to set the read/write permission for the file. HOpenRF traps where they check an attribute bit in the pointer to the string name to see if it is a de referenced handle. If the pointer has the
_RecoverHandle on it. The workaround is to call StripAddress on the string before passing it to the trap. Note that this bug will only happen if
the string is stored inside the code segment. Although this is not the default
for most compilers, calling StripAddress will not hurt and it is a good idea to always call it before using one of the traps mentioned above.