Solved

Starting on Windows Logon

Posted on 2003-11-12
1
218 Views
Last Modified: 2010-04-05
Hey,

I have a checkbox how would I make it that if I click on the checkbox and it checks that the program will start up on windows logon.

And also how do I make the program remember that the checkbox has been checked and keep it checked so you dont have to keep on checking it for each time you want to start the program on windows logon,

Cheers,

Computer Programer
0
Comment
Question by:computerprogramer
[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
1 Comment
 
LVL 6

Accepted Solution

by:
DaFox earned 20 total points
ID: 9736234
Hi,

> I have a checkbox how would I make it that if I click on the checkbox and it checks that the program
> will start up on windows logon.

uses Registry;

procedure TForm1.Button1Click(Sender: TObject);
// register application
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  Reg.RootKey := HKEY_CURRENT_USER;
  Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', True);
  Reg.WriteString('nameOfApplication', ParamStr(0));
  Reg.Destroy;
end;

procedure TForm1.Button2Click(Sender: TObject);
// delete application from autostart
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  Reg.RootKey := HKEY_CURRENT_USER;
  Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run', True);
  Reg.DeleteValue('nameOfApplication');
  Reg.Destroy;
end;

>> And also how do I make the program remember that the checkbox has been checked and keep
>> it checked so you dont have to keep on checking it for each time you want to start the program
>> on windows logon,

Use IniFiles or the registry! Sth. like:

// ...
var
  ini: TIniFile;
begin
  ini := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  try
    ini.WriteBool('Options', 'doAutostart', CheckBox.Checked);
  finally
    FreeAndNil(ini); //Datei Schliessen/Freigeben
  end;
// ...

// ...
  CheckBox.Checked := ini.ReadBool('Options', 'doAutostart', false);
// ...

If you want to use the registry it's more or less the same as above.

Markus
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month3 days, 15 hours left to enroll

630 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