Link to home
Start Free TrialLog in
Avatar of jocas
jocas

asked on

loading a program at startup

I'm using Delphi 1.0, and I'd like programmatically add a program to Program Manager's (or the Start Menu's) Startup group.  Is there an easy way to do this?
Avatar of CalvinDay
CalvinDay

 fRun:='C:\windows\MyProgram.EXE';

  with TRegIniFile.Create('') do
    begin
    RootKey:=HKEY_LOCAL_MACHINE;
    WriteString('Software\Microsoft\Windows\CurrentVersion\Run'+#0,'MyProgram',fRun);
    Free;
    end;

Sorry,
Wrong Answer.
not easy, but yes, there is a way :)
You can write into win.ini file :
[windows]
run = Previous.EXE(s) YourProgram.EXE

This way both Previous.EXE (can be more than one) and your EXE file will be loaded automatically by Win 3.11 and Win 9x (i'm not sure about NT).

To write into win.ini use TIniFile.

Do not forget to preserve previous settings (by first reading them using IniFile.ReadString.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Look for the STARTUP.GRP file in the Windows directory (possibly Windows\system?  I can't remember which).  I believe the GRP file has the same layout as an INI file.  If so you can add a line in it that will start your program.
oops sorry Barry I didn't see your post