//uses SHELLAPI;
function MyDelTree(SourceName:String): Boolean;
var
F:TShFileOpStruct;
begin
F.wnd:=0;
F.wFunc:=FO_DELETE;
F.pFrom:=PChar(SourceName+#0#0);
F.pTo:=PChar(''+#0#0);
F.fFlags:=FOF_SILENT or FOF_NOCONFIRMATION;
result:= ShFileOperation(F)=0;
end;
procedure TForm1.deleteClick(Sender: TObject);
//把d:\sybase目录下所有文件发送到回收站
var
sourcefile:STRING;
lpfileop:TSHFILEOPSTRUCT;
begin
sourcefile:= 'd:\sybase\*.*'+#0#0;
fillchar(lpfileop,sizeof(lpfileop),0);
with lpfileop do
begin
wnd:=form1.handle;
wFunc:=FO_DELETE;
pFrom:=pchar(sourcefile);
fflags:= FOF_ALLOWUNDO;
end;
if SHFileoperation(lpfileop)<>NOERROR then
if lpfileop. FAnyOperationsAborted then
showmessage('删除文件被终止')
else
showmessage('删除文件出错');
end;