我删除文件夹用的API的函数为: (即使该文件夹下面还有子文件夹或者文件都一样删除)
function DeleteDirectory(dir: string): boolean;
var
fos: TSHFileOpStruct;
begin
ZeroMemory(@fos, SizeOf(fos));
with fos do
begin
wFunc := FO_DELETE;
fFlags := FOF_SILENT or FOF_NOCONFIRMATION;
pFrom := pchar(dir + #0);
end;
Result := (0 = SHFileOperation(fos));
end;