Da es nur 1 "Papierkorb" gibt, ist das Löschen einfach:
.
Delphi-Quellcode:
Procedure EmptyRecycleBin ;
Const
SHERB_NOCONFIRMATION = $00000001;
SHERB_NOPROGRESSUI = $00000002;
SHERB_NOSOUND = $00000004;
Type
TSHEmptyRecycleBin = Function(Wnd: HWND; LPCTSTR: PChar; DWORD: Word): Integer; StdCall;
Var
SHEmptyRecycleBin: TSHEmptyRecycleBin;
LibHandle: THandle;
Begin
LibHandle:=LoadLibrary(PChar('Shell32.dll'));
If LibHandle <> 0 Then
@SHEmptyRecycleBin:=GetProcAddress(LibHandle, 'SHEmptyRecycleBinA')
Else Begin
MessageDlg('Failed to load Shell32.dll.', mtError, [mbOK], 0);
Exit;
End;
If @SHEmptyRecycleBin <> Nil Then
SHEmptyRecycleBin(Application.Handle, '', SHERB_NOCONFIRMATION Or SHERB_NOPROGRESSUI Or SHERB_NOSOUND);
FreeLibrary(LibHandle);
@SHEmptyRecycleBin:=Nil;
End ;