?
Solved

Automatically Start

Posted on 1999-07-08
3
Medium Priority
?
229 Views
Last Modified: 2010-04-06
How to register myapplication.exe into registry, make
it automatically start when each time windows start up.
(don't use put it into startup group solution)

Thanks & Rgds

Shekou
0
Comment
Question by:shekou
[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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
thomasphlips earned 100 total points
ID: 1387240
*** autostartup ***

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 StdCtrls, registry;

type
 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
   procedure RunOnStartup(sProgTitle, sCmdLine: string; bStartup: boolean );
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
 Form1.RunOnStartup('', ParamStr(0), False);
end;

procedure TForm1.RunOnStartup(sProgTitle, sCmdLine: string; bStartup: boolean );
var
 sKey: string;
 reg : TRegIniFile;

begin
 sKey := ''; //sKey := 'Once' if you wish it to only run on the next time you startup.
 if bStartup = false then  //If value passed is false, then value deleted from Registry.
 begin
 try
 reg := TRegIniFile.Create( '' );
 reg.RootKey := HKEY_LOCAL_MACHINE;
 reg.DeleteKey(
   'Software\Microsoft'
   + '\Windows\CurrentVersion\Run'
   + sKey + #0,
   sProgTitle);
 reg.Free;
 exit;
 except //Using Try Except so that if value can not be placed in registry, it
 //will not give and error.
 end;
 end;

 try
 reg := TRegIniFile.Create( '' );
 reg.RootKey := HKEY_LOCAL_MACHINE;
 reg.WriteString(
   'Software\Microsoft'
   + '\Windows\CurrentVersion\Run'
   + sKey + #0,
   sProgTitle,
   sCmdLine );
 reg.Free;
 except
 end;

end;


0
 
LVL 1

Expert Comment

by:thomasphlips
ID: 1387241
and ... does it work????
0
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1387242
Same thing - Short form:
  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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

719 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