OWL NExt - Knowledge Base

[ Home | Contents | Search | Next | Previous | Up ]

Programmatically sending files to the recycle-bin

Date: 12/1/99
Time: 10:06:41 PM

Question:

How do I send a file to the recycle bin from a OWL program and have the animation thingie?

Answer:

There is a Win32 ShellAPI function for this. It's called SHFileOperation(), the following code deletes the file 'tmp2' from the directory 'c:\tc'. Note that it requires a double null terminate. And also note that if you use wildcards, the files will get deleted, but they won't show up in the recycle-bin.

Using Win32 API

SHFILEOPSTRUCT op;
ZeroMemory(&op,sizeof(op));
op.hwnd=Handle;
op.wFunc=FO_DELETE;
op.pFrom="c:\\tc\\tmp2\0"; // double null terminate
op.fFlags=FOF_ALLOWUNDO;
SHFileOperation(&op);

Or using OWL class TShellItem, advised method:

TShellItem("c:\\tc\\tmp2",true,Handle).Delete(FOF_ALLOWUNDO);

 

Last changed: July 14, 2001