procedure TForm1.ToRecycle(AHandle: THandle; const ADirName: string);<br>var<br> SHFileOpStruct: TSHFileOpStruct;<br> DirName: PChar;<br> BufferSize: Cardinal;<br>begin<br> BufferSize := Length(ADirName) + 1 + 1;<br> GetMem(DirName, BufferSize);<br> try<br> FillChar(DirName^, BufferSize, 0);<br> StrCopy(DirName, PChar(ADirName));<br><br> with SHFileOpStruct do<br> begin<br> Wnd := AHandle;<br> wFunc := FO_DELETE;<br> pFrom := DirName;<br> pTo := nil;<br> fFlags := FOF_NOCONFIRMATION;<br><br> fAnyOperationsAborted := False;<br> hNameMappings := nil;<br> lpszProgressTitle := nil;<br> end;<br><br> if SHFileOperation(SHFileOpStruct) <> 0 then<br> RaiseLastWin32Error;<br> finally<br> FreeMem(DirName, BufferSize);<br> end;<br>end;<br>