Search code examples
delphidelphi-2010procedure

What is the purpose of "procedure Register;" in delphi?


I got a code in one of the old project in Delphi.

In that there is a statement procedure Register; in definition block (i.e. Before Implementation Block started) of delphi.

As I know the both procedure and Register are keywords in delphi.

I am bit curious about the working of this type of declaration.

Can anyone tell me what is impact of this statement procedure Register;?

The statement is declared as follows:

unit TestProj
interface
  uses
    .
  type 
    .
    . // some other declarations
    .
    .
  procedure Register;
implementation
  . 
  .  // Implementation part of all classes and functions
end.

Thanks in Advanced..


Solution

  • If the unit is included in a designtime-package and this package is installed in the IDE the Register-procedure is called when the package is loaded by the IDE. It is used to register components, wizards or other IDE-extensions like property-editors to the IDE.
    Typically you find calls of RegisterComponents() in the implementation of the procedure. This method is used to register a component to the component-palette of the IDE.