System.InitProc
Delphi
InitProc: Pointer; { Last installed initialization procedure }
C++
extern DELPHI_PACKAGE void *InitProc;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
variable | public | System.pas System.hpp |
System | System |
Description
InitProc is the last installed initialization procedure.
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; end.
- In C++, the assignment is most easily made in the project source file.
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.