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 Applications / Opening and Closing Components


OpenDefaultComponent

The OpenDefaultComponent function allows your application to gain access to the services provided by a component. Your application must open a component before it can call any component functions. You specify the component type and subtype values of the component to open. The Component Manager searches for a component that meets those criteria. If you want to exert more control over the selection process, you can use the FindNextComponent and OpenComponent functions.

FUNCTION OpenDefaultComponent (componentType: OSType; 
                               componentSubType: OSType)
                               : ComponentInstance;
componentType
A four-character code that identifies the type of component. All components of a particular type support a common set of interface routines. Your application uses this field to search for components of a given type.
componentSubType
A four-character code that identifies the subtype of the component. Different subtypes of a component type may support additional features or provide interfaces that extend beyond the standard routines for a
given component type. For example, the subtype of an image compressor component indicates the compression algorithm employed by the compressor.
Your application can use the componentSubType field to perform a more specific lookup operation than is possible using only the componentType field. For example, you may want your application to use only components of a certain component type ('draw') that also have a specific subtype ('oval'). Set this parameter to 0 to select a component with any subtype value.
DESCRIPTION
The OpenDefaultComponent function searches its list of registered components for a component that meets the search criteria. If it finds a component that matches the search criteria, OpenDefaultComponent opens a connection to the component and returns a component instance. The returned component instance identifies your application's connection to the component. You must supply this component instance whenever you call the functions provided by the component. When you close the component, you must also supply this component instance to the CloseComponent function.

If more than one component in the list of registered components meets the search criteria, OpenDefaultComponent opens the first one that it finds in its list.

If it cannot open the specfied component, the OpenDefaultComponent function returns a function result of NIL.

SEE ALSO
For an example that opens a component using the OpenDefaultComponent function, see "Opening a Connection to a Default Component" beginning on page 6-7.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996