procedure TForm1.Button1Click(Sender: TObject);
var
APath: AnsiString;
lpFileOp: TSHFileOpStruct;
begin
APath:='d:/temp'#0#0;//指定目录
with lpFileOp do
begin
wnd:=self.handle;
wFunc:=FO_Delete;
pFrom:=PChar(APath);
pTo:=nil;
fFlags:=FOF_AllowUndo;
hNameMappings:=nil;
lpszProgressTitle:=nil;
fAnyOperationsAborted:=true;
end;
if SHFileOperation(lpFileOp)=0 then
ShowMessage('删除成功!')
else
ShowMessage('删除失败!');
end;