From RAD Studio API Documentation
Jump to: navigation, search


procedure RegisterClass(AClass: TPersistentClass);


extern DELPHI_PACKAGE void __fastcall RegisterClass(TPersistentClass AClass);


Type Visibility Source Unit Parent
System.Classes System.Classes


Registers a class of persistent object so that its class type can be retrieved.

Call RegisterClass to register a class with the streaming system. Form classes and component classes that are referenced in a form declaration (instance variables) are automatically registered. Any other classes used by an application must be explicitly registered by calling RegisterClass if instances are to be saved.

Once classes are registered, they can be loaded or saved by the component streaming system. IdentToInt returns nil (Delphi) or NULL (C++) when passed the class name of an unregistered class, and FindClass raises an exception for unregistered classes.

The AClass parameter is the class that is descended from TPersistent. Put the call to RegisterClass in a Register procedure. In Delphi, you can also put the call in the initialization section of the unit in which the class is defined. In C++, the call can also go in the namespace of the compilation unit that defines the class.

If the class is already registered, RegisterClass does nothing. If a different class with the same name is already registered, RegisterClass raises an EFilerError exception.

Note: Registering a component using the RegisterNoIcon or RegisterComponents method does not automatically register the class. It is still necessary to call RegisterClass for components.

See Also

Code Examples