Skip to content

Instantly share code, notes, and snippets.

@Bumboobee
Last active April 10, 2023 20:08
Show Gist options
  • Save Bumboobee/97f7a341080a84517ac3522c782f48fd to your computer and use it in GitHub Desktop.
Save Bumboobee/97f7a341080a84517ac3522c782f48fd to your computer and use it in GitHub Desktop.
Delete delphi dcus runtime files πŸ‘Œ{put it right on close form event}
procedure TfrmYourForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
SearchRec : TSearchRec;
dcuDirectory: string;
begin
try
dcuDirectory := ExtractFilePath(Application.ExeName);
FindFirst(dcuDirectory + '*.dcu', faAnyFile, SearchRec);
repeat
DeleteFile(dcuDirectory + SearchRec.name);
until FindNext(SearchRec) <> 0;
finally
FindClose(SearchRec);
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment