Buscar

Copiando ou movendo arquivos usando a api do windows

Código

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;

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Windows
Adicionada dia: 09/06/03
Por: Felipe Monteiro
Visualizada: 4223 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009