Delphi set up automatic start function specific implementation _delphi

Source: Internet
Author: User
Some programs to set up to boot, so I wrote a function to facilitate later use, for everyone to refer to
Copy Code code as follows:

Procedure Tmainform.setautorun (Ok:boolean);
Var
Reg:tregistry; First, define a tregistry type of variable reg
Begin
Reg:=tregistry.create;
Try//Create a new key
Reg.rootkey:=hkey_local_machine; Set the root key to HKEY_LOCAL_MACHINE
Reg.openkey (' SOFTWARE\Microsoft\Windows\CurrentVersion\Run ', true);//Open a key
If OK then BEGIN
reg.writestring (' SMS Service ', Expandfilename (paramstr (0))); Write data names and data values in Reg this key
ShowMessage (' Registration successful! ');
End
ELSE begin
Reg. DeleteValue (' SMS Service ');
ShowMessage (' Delete succeeded! ')
End
Reg.closekey; Close key
Finally
Reg.free;
End
End

Example:
Setautorun (TRUE); Registration start
Setautorun (FALSE); Delete Startup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.