Jump to content
Registration disabled at the moment Read more... ×
Freeeee

executing code at startup?

Recommended Posts

Is there any way of running code at program start up.

right now it looks like code only runs when you click on a control on the form.

Is there any way of running code before you get to that point

Example

ap creates and Ini.file that records where you were at in the 

last time you used it.   is it possible to read the ini file 

without having to click on something in the form when the form appears??

If so, where do you place that code?

Does it need to be a procedure? 

Does it have to have a 'special' name?

 

Share this post


Link to post

If you need to run code that is related to your UI, you can use your MainForm's OnCreate event. 

 

If you need to run code sooner than that, then you can add code in your project's .dpr file before Application.Run() is called. Or, you can put code in the initialization section of any .pas file in your project.

Edited by Remy Lebeau

Share this post


Link to post

Let's assume you are asking about Windows and a GUI app.

 

One place to start looking is the form OnCreate method, see: https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Forms.TForm.OnCreate

Share this post


Link to post
40 minutes ago, DelphiUdIT said:

Or you can create a Thread, where you can run every code you need without UI interactions.

That's a little overkill just for loading an ini file. And you'd still need startup code to start the thread. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×