Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 6 - Component Manager / Component Manager Reference
Routines for Components / Registering Components


RegisterComponentResource

The RegisterComponentResource function makes a component available for use by applications (or other clients). Once the Component Manager has registered a component, applications can find and open the component using the standard Component Manager routines. You provide information identifying the component and specifying its capabilities. The Component Manager returns a component identifier that uniquely identifies the component to the system.

Components you register with the RegisterComponentResource function must be stored in a resource file as a component resource (see "The Component Resource" beginning on page 6-77 for a description of the format and content of component resources). If you want to register a component that is in memory, use the RegisterComponent function.

The RegisterComponentResource function does not actually load the code specified by the component resource into memory. Rather, the Component Manager loads the component code the first time an application opens the component. If the code is not in the same file as the component resource or if the Component Manager cannot find the file, the open request fails.

Note that a component registered locally by your application remains registered until your application unregisters it or quits. A component registered globally by your application remains registered until your application unregisters it or until the computer is shut down.

FUNCTION RegisterComponentResource (cr: ComponentResourceHandle; 
                                    global: Integer): Component;
cr
A handle to a component resource that describes the component to be registered. The component resource contains all the information required to register the component.
global
A set of flags that controls the scope of component registration. You can use these flags to specify a value for the global parameter:
registerCmpGlobal = 1;
Specify this flag to indicate that this component should be made available to other applications and clients as well as the one performing the registration. If you do not specify this flag, the component is available for use only by the registering application or component (that is, the component is local to the A5 world of the registering program).
registerCmpNoDuplicates = 2;
Specify this flag to indicate that if a component with identical characteristics to the one being registered already exists, then the new one should not be registered (RegisterComponentResource returns 0 in this situation). If you do not specify this flag, the component is registered even if a component with identical characteristics to the one being registered already exists.
registerCompAfter = 4;
Specify this flag to indicate that this component should be registered after all other components with the same component type. Usually components are registered before others with identical descriptions; specifying this flag overrides that behavior.
DESCRIPTION
The RegisterComponentResource function returns the component
identifier assigned to the component by the Component Manager. If the RegisterComponentResource function could not register the component, it
returns a function result of NIL.

SEE ALSO
For a description of the format and content of component resources, see "Resources" beginning on page 6-77.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996