The initialization section of the units is normally not a speed problem (unless you have some database-related stuff in there).
What could be slow is the TForm loading from resources.
It's always better to have the TForm created on the fly, only when it's necessary:
- Go to "Project" menu, then select "Options", then the "Forms" tab.
- Put all not mandatory forms from left list to the right "available" list.
- Create the forms on request, by some code.
The unit remains the same:
type
TOneForm = class(TForm)
....
end;
var
OneForm: TOneForm;
But you can use the following code to create the form on request:
Instead of your former
OneForm.ShowModal;
uses this kind of code
if OneForm=nil then
OneForm := TOneForm.Create(Application);
OneForm.ShowModal;
You'll find the loading of the application much faster.
Note:
I just read out that the problem was before form loading.
So the above trick won't work for this particular problem.
I keep the answer because it could be useful to others.
I'll read better next time. :(
In all cases, having a lot of code run from the initialization is not a good design.
It sounds like a lot of global objects or variables... refactoring could make sense here... :)