Главная страница | назад





Article #17525: Programmatically sending files to the recycle-bin

 Question and Answer Database
FAQ2525C.txt Programmatically sending files to the recycle-bin
Category :Windows API
Platform :All
Product :C++Builder ALL
Question:
How do I send a file to the recycle bin from a BCB
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.
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);
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99