Solved

Delete files to the Recycle Bin?

Posted on 1998-09-20
1
383 Views
Last Modified: 2010-04-06
how do I delete files to the recycle bin? Does delphi provide a way or do I have to get the recycle bin dir from windows and then just move files there?
0
Comment
Question by:ripcord
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
Edo082297 earned 50 total points
ID: 1340375
program del;

uses ShellApi;

//function SHFileOperation(const lpFileOp: TSHFileOpStruct): Integer; stdcall;
Var
  T:TSHFileOpStruct;    
  P:String;
begin  
  P:='C:\Windows\System\EL_CONTROL.CPL';
  With T do  
  Begin    
    Wnd := 0;    
    wFunc := FO_DELETE;    
    pFrom:=Pchar(P);
    fFlags:=FOF_ALLOWUNDO  
  end;  
  SHFileOperation(T);

End.

1) Give the complete path to the file

2) MS has a documentation correction about the pFrom member. It says that for multiple files, each filename is seperated by a NULL (#0) character, and the whole thing is terminated by double NULLs. You need the double NULL whether or not you are passing multiple filenames. Sometimes it will work correctly without them, but often not. That's because sometimes you get lucky and the memory following the end of your string has a NULL there.

An example of how to do this would be:

var
  FileList: string;
  FOS: TShFileOpStruct;
begin
  FileList := 'c:\delete.me'#0'c:\windows\temp.$$$'#0#0;
  { if you were using filenames in string variables: }
  FileList := Filename1 + #0 + Filename2 + #0#0;

  FOS.pFrom := PChar(FileList);

  // blah blah blah
end;


Thanks to Brad Stowers (ZifNab ?) and UDDF for this information, whose help file may be obtained from

http://www.gnomehome.demon.nl/uddf/uddf.arj 


Regards,
Edo


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month3 days, 19 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question