前天刚从<a href="http://www.nease.net/~liyaping">边缘软件工作室</a>拉回来的例子,借花献佛!<br> 可以使用 SHFileOperation(), 值得注意的是档名 list 中是以 #0 分隔, 最後一个项目必须以双 #0 字元结束,<br> 以下分别是删除""个目录(含字目录) 与档案的用法示例: <br> // Test for delete a folder and move files into Recycle Bin<br> // Change the APath variable as you need. // <br> uses ..., ShellAPI;<br> procedure TForm1.Button1Click(Sender: TObject); <br> var<br> APath : AnsiString; <br> lpFileOp: TSHFileOpStruct; <br> begin<br> APath := 'D:/temp/test123'#0#0; // must end with double-#0<br> with lpFileOp do <br> begin <br> Wnd := Self.Handle;<br> wFunc := FO_DELETE; <br> pFrom := pchar(APath);<br> pTo := nil;<br> fFlags := FOF_ALLOWUNDO;<br> hNameMappings := nil;<br> lpszProgressTitle := nil;<br> fAnyOperationsAborted := True;<br> end;<br> if SHFileOperation(lpFileOp) = 0 then<br> ShowMessage('SHFileOperation OK.')<br> else<br> ShowMessage('SHFileOperation Fail!!'); <br>end; <br> 档案s 删除并送至资源回收筒?<br> procedure TForm1.Button1Click(Sender: TObject);<br> var<br> APath : AnsiString; <br> lpFileOp: TSHFileOpStruct;<br> begin<br> // must end with double-#0 <br> APath :='D:/temp/test123/l.txt'#0'D:/temp/test123/l3.txt'#0#0;<br> with lpFileOp do <br> begin<br> Wnd := Self.Handle;<br> wFunc := FO_DELETE; <br> pFrom := pchar(APath);<br> pTo := nil;<br> fFlags := FOF_ALLOWUNDO; <br> hNameMappings := nil;<br> lpszProgressTitle := nil; <br> fAnyOperationsAborted := True;<br> end;<br> if SHFileOperation(lpFileOp) = 0 then<br> ShowMessage('SHFileOperation OK.')<br> else<br> ShowMessage('SHFileOperation Fail!!'); <br>end;<br>Good Luck!<br><br>