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