Aktuell macht die Funktion nicht so wie ich es will ....
Was macht sie denn? Überhaupt irgendwas? Oder einfach garnix.
SHFileOperation hat ca. 20 unterschiedliche Rückgabewerte. Du prüfst aber nur, ob kein Fehler aufgetreten ist.
Eventuell fragst Du da ja mal etwas genauer ab, um zu erfahren, was denn da so eventuell schiefgelaufen sein könnte.
https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
Delphi-Quellcode:
function DeleteFiles(
const AFile:
string): boolean;
var
sh: SHFileOpStruct;
begin
Result := false;
ZeroMemory(@sh, SizeOf(sh));
with sh
do
begin
Wnd := Application.Handle;
wFunc := FO_DELETE;
pFrom := PChar(AFile +#0);
fFlags := FOF_SILENT
or FOF_NOCONFIRMATION;
end;
case SHFileOperation(sh)
of
0 : result := True;
$71 : ShowMessage('
The source and destination files are the same file.');
$72 : ShowMessage('
Multiple file paths were specified in the source buffer, but only one destination file path.');
$73 : ShowMessage('
Rename operation was specified but the destination path is a different directory. Use the move operation instead.');
$74 : ShowMessage('
The source is a root directory, which cannot be moved or renamed.');
$75 : ShowMessage('
The operation was canceled by the user, or silently canceled if the appropriate flags were supplied to SHFileOperation.');
$76 : ShowMessage('
The destination is a subtree of the source.');
$78 : ShowMessage('
Security settings denied access to the source.');
$79 : ShowMessage('
The source or destination path exceeded or would exceed MAX_PATH.');
$7A : ShowMessage('
The operation involved multiple destination paths, which can fail in the case of a move operation.');
$7C : ShowMessage('
The path in the source or destination or both was invalid.');
$7D : ShowMessage('
The source and destination have the same parent folder.');
$7E : ShowMessage('
The destination path is an existing file.');
$80 : ShowMessage('
The destination path is an existing folder.');
$81 : ShowMessage('
The name of the file exceeds MAX_PATH.');
$82 : ShowMessage('
The destination is a read-only CD-ROM, possibly unformatted.');
$83 : ShowMessage('
The destination is a read-only DVD, possibly unformatted.');
$84 : ShowMessage('
The destination is a writable CD-ROM, possibly unformatted.');
$85 : ShowMessage('
The file involved in the operation is too large for the destination media or file system.');
$86 : ShowMessage('
The source is a read-only CD-ROM, possibly unformatted.');
$87 : ShowMessage('
The source is a read-only DVD, possibly unformatted.');
$88 : ShowMessage('
The source is a writable CD-ROM, possibly unformatted.');
$B7 : ShowMessage('
MAX_PATH was exceeded during the operation.');
$402 : ShowMessage('
An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Windows Vista and later.');
$10000 : ShowMessage('
An unspecified error occurred on the destination.');
$10074 : ShowMessage('
Destination is a root directory and cannot be renamed.');
end;
end;