Hola de nuevo
estoy tratando de copiar unas imágenes de una carpeta compartida en red a una carpeta en disco local y uso este código pero me sale el mensaje "Acceso Denegado"
los componentes son:
Button1 - Iniciar
Button2 - Cancelar
ProgressBar1 - componente
funcion ProgressRoutine
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ExtCtrls, Buttons, ComCtrls;
type
TImageForm = class(TForm)
Button1: TButton;
Button2: TButton;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
ImageForm: TImageForm;
Cancel: boolean;
implementation
{$R *.dfm}
function ProgressRoutine(TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred: LARGE_INTEGER; dwStreamNumber,
dwCallbackReason: DWORD; hSourceFile, hDestinationFile: THandle; lpData: Pointer): DWORD; stdcall;
begin
Application.ProcessMessages();
if(dwCallbackReason = CALLBACK_CHUNK_FINISHED) then
ImageForm.ProgressBar1.Position:= (int64(TotalBytesTransferred) * 100) div int64(TotalFileSize);
Result:= PROGRESS_CONTINUE;
end;
procedure TImageForm.Button1Click(Sender: TObject);
begin
Cancel:= false;
CopyFileEx('\\Sistemas\e\Usuario\Escritorio\catalogo','C:\catalogo1', @ProgressRoutine, nil, @Cancel, 0);
ShowMessage(SysErrorMessage(GetLastError()));
end;
procedure TImageForm.Button2Click(Sender: TObject);
begin
Cancel:= true;
end;
end.