How to remove registry key using Delphi?

Question

How to remove registry key using Delphi?

Re: How to remove registry key using Delphi?

Here's the Delphi source code for deleting an entry from the Software\Microsoft\Windows\CurrentVersion\Run key, located in the HKEY_LOCAL_MACHINE root key:
procedure RemoveFromRunKey(ApTitle: string);
var
Reg: TRegistry;
TheKey: string;
ListOfEntries: TStringList;
i: integer;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
TheKey := 'Software\Microsoft\Windows\CurrentVersion\Run';
// Check if key exist...
// ...if yes, try to delete the entry for ApTitle
if not Reg.OpenKey(TheKey, False) then
ShowMessage('Key not found')
else begin
if Reg.DeleteValue(ApTitle) then
ShowMessage('Removed: ' + ApTitle)
else
ShowMessage('Not found: ' + ApTitle);
end;
Reg.CloseKey;
Reg.Free;
end;