Starting the Program Automatically at Windows Boot
If you are writing a Windows-only application and want to make changes to the structure of the system Registry, you can use System.Win.Registry.TRegistry. On the contrary, TRegistryIniFile uses the same properties and management of other ini file components, its properties and methods correspond more directly to the TRegistry system's registry structure. HKEY_CURRENT_USER using TRegistryIniFile as root key. In addition to opening, closing, saving, moving, copying and deleting keys, TRegistry allows you to specify the level of access you want to use. For example, if you want your program to run automatically at Windows startup by adding to the registry, here is the Delphi source code that provides this:
uses Registry;
procedure writeStartUp;
var
ARegistry: TRegistry;
begin
ARegistry: = TRegistry.Create;
//Create an instance of TRegistry
with ARegistry do
begin
RootKey: = HKEY—LOCAL—MACHINE;
if OpenKey (′ Software\Microsoft\Windows\CurrentVersion\Run ′, True) then
WriteString (′ delphi ′, ′ C:\Program Files\borland\delphi3\bin\delphi32.exe ′);
CloseKey;
Destroy;
end;
end;