Bueno, yo crearia una funcion como esta:
Código Delphi
[-]
const
DE_SAMEFILE = $71;
DE_MANYSRC1DEST = $72;
DE_DIFFDIR = $73;
DE_ROOTDIR = $74;
DE_OPCANCELLED = $75;
DE_DESTSUBTREE = $76;
DE_ACCESSDENIEDSRC = $78;
DE_PATHTOODEEP = $79;
DE_MANYDEST = $7A;
DE_INVALIDFILES = $7C;
DE_DESTSAMETREE = $7D;
DE_FLDDESTISFILE = $7E;
DE_FILEDESTISFLD = $80;
DE_FILENAMETOOLONG = $81;
DE_DEST_IS_CDROM = $82;
DE_DEST_IS_DVD = $83;
DE_DEST_IS_CDRECORD = $84;
DE_FILE_TOO_LARGE = $85;
DE_SRC_IS_CDROM = $86;
DE_SRC_IS_DVD = $87;
DE_SRC_IS_CDRECORD = $88;
DE_ERROR_MAX = $B7;
DE_UNKHOWN = $402;
ERRORONDEST = $10000;
function SHCheck(Value: Integer): Boolean;
var
Error: EOSError;
begin
if Value <> 0 then
begin
Result:= FALSE;
case Value of
DE_SAMEFILE: Error:= EOSError.Create('The source and destination files are the same file.');
DE_MANYSRC1DEST: Error:= EOSError.Create('Multiple file paths were specified in the source buffer, but only one destination file path.');
DE_DIFFDIR: Error:= EOSError.Create('Rename operation was specified but the destination path is a different directory. Use the move operation instead.');
DE_ROOTDIR: Error:= EOSError.Create('The source is a root directory, which cannot be moved or renamed.');
DE_OPCANCELLED: Error:= EOSError.Create('The operation was cancelled by the user, or silently cancelled if the appropriate flags were supplied to SHFileOperation.');
DE_DESTSUBTREE: Error:= EOSError.Create('The destination is a subtree of the source.');
DE_ACCESSDENIEDSRC: Error:= EOSError.Create('Security settings denied access to the source.');
DE_PATHTOODEEP: Error:= EOSError.Create('The source or destination path exceeded or would exceed MAX_PATH.');
DE_MANYDEST: Error:= EOSError.Create('The operation involved multiple destination paths, which can fail in the case of a move operation.');
DE_INVALIDFILES: Error:= EOSError.Create('The path in the source or destination or both was invalid.');
DE_DESTSAMETREE: Error:= EOSError.Create('The source and destination have the same parent folder.');
DE_FLDDESTISFILE: Error:= EOSError.Create('The destination path is an existing file.');
DE_FILEDESTISFLD: Error:= EOSError.Create('The destination path is an existing folder.');
DE_FILENAMETOOLONG: Error:= EOSError.Create('The name of the file exceeds MAX_PATH.');
DE_DEST_IS_CDROM: Error:= EOSError.Create('The destination is a read-only CD-ROM, possibly unformatted.');
DE_DEST_IS_DVD: Error:= EOSError.Create('The destination is a read-only DVD, possibly unformatted.');
DE_DEST_IS_CDRECORD: Error:= EOSError.Create('The destination is a writable CD-ROM, possibly unformatted.');
DE_FILE_TOO_LARGE: Error:= EOSError.Create('The file involved in the operation is too large for the destination media or file system.');
DE_SRC_IS_CDROM: Error:= EOSError.Create('The source is a read-only CD-ROM, possibly unformatted.');
DE_SRC_IS_DVD: Error:= EOSError.Create('The source is a read-only DVD, possibly unformatted.');
DE_SRC_IS_CDRECORD: Error:= EOSError.Create('The source is a writable CD-ROM, possibly unformatted.');
DE_ERROR_MAX: Error:= EOSError.Create('MAX_PATH was exceeded during the operation.');
DE_UNKHOWN : Error:= EOSError.Create('An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Microsoft Windows Vista and later.');
ERRORONDEST: Error:= EOSError.Create('An unspecified error occurred on the destination.');
DE_ROOTDIR or ERRORONDEST: Error:= EOSError.Create('Destination is a root directory and cannot be renamed.');
else
Error:= EOSError.Create('Error desconocido');
end;
Error.ErrorCode:= Value;
raise Error;
end else
Result:= TRUE;
end;
Y modificaría tu función de la siguiente manera:
Código Delphi
[-]
function MoverCarpeta(const carpetaOrigen,
carpetaDestion: string) : boolean;
var
FileOp: TSHFileOpStruct;
begin
FillChar(FileOp, SizeOf(FileOp),#0);
with FileOp do begin
wFunc := FO_MOVE;
Wnd := GetActiveWindow();
pTo := PChar(carpetaOrigen);
pFrom := PChar(carpetaDestion+#0#0);
fFlags := FOF_NOCONFIRMATION or FOF_SILENT
or FOF_ALLOWUNDO or FOF_NOERRORUI;
end;
Result:= FALSE;
if SHCheck(ShFileOperation(FileOp)) then
Result := not FileOp.fAnyOperationsAborted;
end;
Ahora para dejarlo bonito deberías traducir los mensajes de error
