To remove the application from the Windows registry, you can use the TRegistry class in Delphi and delete the key that you created earlier. Here are the steps in detail:
- In your Delphi project, add the “Registry” unit to the uses clause of your main form’s unit.
- In the FormClose event of your main form, add the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
begin with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey(‘\Software\Microsoft\Windows\CurrentVersion\Run’, False) then begin DeleteValue(‘YourApp’); CloseKey; end; finally Free; end; end; |
This code opens the Run key in the Windows registry and deletes the value that you created earlier, which corresponds to your application.
- Run the application once, it will delete the registry key and your application will no longer start automatically when the user logs in.
Alternatively, you can delete the key manually, by opening the registry editor (pressing “Windows+R” and typing “regedit”) and navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run and delete the key ‘YourApp’
It’s important to note that in order to delete a key in the Windows registry, the user must have administrative privileges.
In case of scheduled task, you can use the command prompt or the windows task scheduler to delete the task.
1 |
schtasks.exe /delete /tn “YourApp” |
In case of windows service, you can use the command prompt or the services.msc to delete the service.
1 |
sc delete “YourApp” |
In summary, you can remove your Delphi application from startup by deleting the corresponding shortcut from the Startup folder, delete the registry key, delete the scheduled task or delete the windows service.
Leave a Reply