Você está na página 1de 2

Copiar arquivos usando a ShellApi do Windows

15/02/2015 Leave a reply


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function ProcessArquivo(const Origem, Destino : string; Operacao, Modo:Integer)
: Boolean;
// Requer a unit ShellApi na clausula uses da unit
Const
Aborted : Boolean = False;
var
shfo : TSHFileOpStruct;
begin
FillChar(shfo,SizeOf(shfo),$0);
with shfo do
begin
if Operacao > 2 then
begin
operacao := 2;
end;
if Modo > 5 then
begin
modo := 1;
end;
case operacao of
1: wFunc := FO_MOVE;
2: wFunc := FO_COPY;
end;

pFrom := Pchar(Origem);
pTo := Pchar(Destino);
case Modo of
1: fFlags := FOF_SILENT;
2: fFlags := FOF_ALLOWUNDO or FOF_FILESONLY;
3: fFlags := FOF_RENAMEONCOLLISION;
4: fFlags := FOF_NOCONFIRMATION;
5: fFlags := FOF_SIMPLEPROGRESS;
end;
end;
Result := (SHFileOperation(shfo)= 0) and (not Aborted);
end;

Você também pode gostar