Hi zusammen,
ich habe jetzt folgende Funktionen getestet:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| function DelDir(Dir : String): Boolean; var FileOption : TSHFileOpStruct; begin ZeroMemory(@FileOption,SizeOf(FileOption)); with FileOption do begin wFunc := FO_DELETE; fFlags := FOF_SILENT or FOF_NOCONFIRMATION or FOF_ALLOWUNDO; pFrom := PChar(Dir + #0); end; Result := (ShFileOperation(FileOption) = 0); end; |
und
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| function DeleteFile(const AFile: string): boolean; var sh: SHFileOpStruct; begin ZeroMemory(@sh, sizeof(sh)); with sh do begin Wnd := Application.Handle; wFunc := fo_Delete; pFrom := PChar(AFile +#0); fFlags := fof_Silent or fof_NoConfirmation or FOF_WANTMAPPINGHANDLE or FOF_SIMPLEPROGRESS or FOF_NOCONFIRMMKDIR; end; result := SHFileOperation(sh) = 0; end; |
aber beides mal, wenn ich einen Netzwerkordner löschen wollte, ist von Windows immer die Meldung gekommen, ob ich einen solchen Ordner wirklich löschen will. Ich will diese Meldung aber unterdrücken! Hat da jemand Tipps?
Ach ja: wenn ich
RemoveDir verwende, meldet er False zurück, bei
RmDir tritt eine Exception auf.