Recent

Author Topic: [SOLVED] Delete to recycle bin  (Read 730 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 939
[SOLVED] Delete to recycle bin
« on: February 06, 2022, 05:25:59 pm »
How can I delete to the recycle bin?
« Last Edit: February 06, 2022, 06:17:17 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

rvk

  • Hero Member
  • *****
  • Posts: 4676
Re: Delete to recycle bin
« Reply #1 on: February 06, 2022, 05:58:50 pm »
Code: Pascal  [Select][+][-]
  1. uses ShellApi;
  2.  
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. begin
  5.   SHEmptyRecycleBin(Self.Handle, '', SHERB_NOCONFIRMATION);
  6. end;

Possible flags:
  SHERB_NOCONFIRMATION
  SHERB_NOPROGRESSUI
  SHERB_NOSOUND

pcurtis

  • Hero Member
  • *****
  • Posts: 939
Re: Delete to recycle bin
« Reply #2 on: February 06, 2022, 06:09:17 pm »
How to DELETE TO not empty, but also good to know.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

rvk

  • Hero Member
  • *****
  • Posts: 4676
Re: Delete to recycle bin
« Reply #3 on: February 06, 2022, 06:14:52 pm »
How to DELETE TO not empty, but also good to know.
Ah, ok, I misread.

Code: Pascal  [Select][+][-]
  1. uses ShellApi;
  2.  
  3. procedure DeleteFileToRecycleBin(aFile: PChar);
  4. var
  5.   fileOpStruct : TSHFileOpStruct;
  6. begin
  7.   fileOpStruct.Wnd := 0;
  8.   fileOpStruct.wFunc := FO_DELETE;
  9.   fileOpStruct.pFrom := aFile;
  10.   fileOpStruct.fFlags := FOF_ALLOWUNDO + FOF_NOCONFIRMATION;
  11.   SHFileOperation(fileOpStruct);
  12. end;

pcurtis

  • Hero Member
  • *****
  • Posts: 939
Re: Delete to recycle bin
« Reply #4 on: February 06, 2022, 06:16:26 pm »
Thanks.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018