boot

TForm1.SetAutoRun Procedure (OK: Boolean);
var
Reg: TRegistry; // first define a variable of type TRegistry Reg
the begin
Reg: = TRegistry.Create;
the try // create a new key
Reg.RootKey: = HKEY_LOCAL_MACHINE; // will root key is set to HKEY_LOCAL_MACHINE
Reg.OpenKey ( 'Software \ in the Microsoft \ Windows \ CurrentVersion \ the Run', to true); // open a key
IF the ok the then
the begin
Reg.WriteString ( 'the SMS service', ExpandFileName (ParamStr (0) )) ; // write in this Reg key data name and data value
ShowMessage ( 'registered successfully!');
End
the else
the begin
Reg.DeleteValue ( 'the SMS service');
ShowMessage ( 'deleted successfully!')
End;
Reg.CloseKey ; // close bond
a finally
Reg.Free;
End;

end;

Guess you like

Origin www.cnblogs.com/maweiwei/p/11898235.html