Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Starting on Windows Logon

Posted on 2003-11-12
1
Medium Priority
?
221 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
1 Comment
 
LVL 6

Accepted Solution

by:
DaFox earned 80 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

772 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