Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

loading a program at startup

Posted on 1999-07-26
7
Medium Priority
?
162 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:jocas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1391260
 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;

0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1391261
Sorry,
Wrong Answer.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1391262
not easy, but yes, there is a way :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:rpo
ID: 1391263
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.
0
 
LVL 17

Accepted Solution

by:
inthe earned 400 total points
ID: 1391264
Hi,
Here is what's left from what I got from borland some time ago.
The DDEClient is a component you drop on the form (System, DdeClientItem).


Var Macro : String;
Var Cmd: array[0..255] of Char;
NewPrg,Desc : String;
Begin
    { Create the group, does nothing if it existst }
    Name := 'StartUp';
    Macro := Format('[CreateGroup(%s)]', [Name]) + #13#10;
    StrPCopy (Cmd, Macro);
    DDEClient.OpenLink;
    if not DDEClient.ExecuteMacro(Cmd, False) then
      MessageDlg(<ErrorMsg>, mtInformation, [mbOK], 0);

    { Then you add you program }
    NewPrg := 'C:\HELLO.EXE';      {Full path of the program you}
    Desc := 'Say Hello';           {Description that appears under the icon|    

    Macro := '[AddItem('+NewPrg+','+Desc+')]'+ #13#10;
    StrPCopy (Cmd, Macro);
    if not f1_.DDEClient.ExecuteMacro(Cmd, False) then
      MessageDlg(<errorMsg>,mtInformation, [mbOK], 0);

    { To make sure the group is saved }

    StrPCopy (Cmd,'[ShowGroup(nonexist,1)]');
    DDEClient.ExecuteMacro(Cmd, False);


     { Now... this part doesn't work and I don't know why but it not to important anyway its supposed to be for reboot or somethin}
   { StrPCopy (Cmd,'[reload()]');
    DDEClient.ExecuteMacro(Cmd, False);}


     { and close the link }
    DDEClient.CloseLink;
End;

Regards Barry

0
 

Expert Comment

by:jsexton
ID: 1391265
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.
0
 

Expert Comment

by:jsexton
ID: 1391266
oops sorry Barry I didn't see your post
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question