RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.InitProc Variable

InitProc is the last installed initialization procedure.

Pascal
InitProc: Pointer;
C++
void * InitProc;

System

Assign a value to InitProc to specify a procedure that you want to execute when the application starts up. The value of InitProc is a procedure with no parameters. For example: 

In Delphi, the assignment can be made in the initialization section of a unit:

procedure MyInitProcedure;
...
initialization
  InitProc = @MyInitProcedure;
begin
end;

In C++, the assignment is most easily made in the project source file. This example is for Windows. On Linux applications, the code is similar.

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  try
  {
    // Note that call must precede call to Application->Initialize();
    System.InitProc = MyInitProcedure;
    Application->Initialize();
    Application->CreateForm(__classid(TForm1), &Form1);
    Application->Run();
  }
  catch (Exception &exception)
  {
    Application->ShowException(&exception);
  }
  catch (...)
  {
    try
    {
      throw Exception("");
    }
    catch (Exception &exception)
    {
      Application->ShowException(&exception);
    }
  }
  return 0;
}

Only one initialization procedure can be assigned to the InitProc variable. If your application defines more than one initialization procedure, only the last assignment to InitProc executes. To allow other initialization procedures to execute, you must "chain" the procedures together, calling the previously assigned value of InitProc from the new value. 

 

TApplication 

ExitProcessProc

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!