Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   Access violation at address 006052F2 (https://www.clubdelphi.com/foros/showthread.php?t=95165)

LACV 22-04-2021 23:20:01

Access violation at address 006052F2
 
Buena tarde;

no encuentro el por que me genera este error

Access violation at address 006052F2


Código Delphi [-]
procedure TFrmUpdateCopy.BtnIniciarClick(Sender: TObject);
var
  Fuente, Destino, nameC: string;
  sPath: String;
  SR: TSearchRec;
begin

  Fuente := PChar(ExtractFilePath(Application.ExeName) + 'data\c\temp\update\');
  Destino := PChar(ExtractFilePath(Application.ExeName) + 'prueba\');

  sPath := Fuente;
  if sPath[Length(sPath)] <> '\' then
    sPath := sPath + '\';
  begin
    if FindFirst(sPath + '*.*', faAnyFile, SR) = 0 then
    begin
      repeat
        if (SR.Attr <> faDirectory) then
        begin
          Memo1.Lines.Add(SR.Name);
          Memo1.Lines.Add('Origen: ' + Fuente + SR.Name);
          Memo1.Lines.Add('Destino: ' + Destino + SR.Name);
          Memo1.Lines.Add(#13);

          Cancel := false;
          CopyFileEx(PChar(Fuente + SR.Name), PChar(Destino + SR.Name),
            @ProgressRoutine, nil, @Cancel, COPY_FILE_RESTARTABLE or
            COPY_FILE_NO_BUFFERING);
          ShowMessage(SysErrorMessage(GetLastError()));
        end;
      until FindNext(SR) <> 0;
      FindClose(SR);

    end;
  end;

end;
modifique el codigo de esta forma para copiar diversos archivos del directorio, pero no logro entender el por que me arroja el error de Access violation at address 006052F2

mRoman 23-04-2021 21:06:03

Cita:

Empezado por LACV (Mensaje 540695)
Buena tarde;

no encuentro el por que me genera este error

Access violation at address 006052F2


Código Delphi [-]
procedure TFrmUpdateCopy.BtnIniciarClick(Sender: TObject);
var
  Fuente, Destino, nameC: string;
  sPath: String;
  SR: TSearchRec;
begin

  Fuente := PChar(ExtractFilePath(Application.ExeName) + 'data\c\temp\update\');
  Destino := PChar(ExtractFilePath(Application.ExeName) + 'prueba\');

  sPath := Fuente;
  if sPath[Length(sPath)] <> '\' then
    sPath := sPath + '\';
  begin
    if FindFirst(sPath + '*.*', faAnyFile, SR) = 0 then
    begin
      repeat
        if (SR.Attr <> faDirectory) then
        begin
          Memo1.Lines.Add(SR.Name);
          Memo1.Lines.Add('Origen: ' + Fuente + SR.Name);
          Memo1.Lines.Add('Destino: ' + Destino + SR.Name);
          Memo1.Lines.Add(#13);

          Cancel := false;
          CopyFileEx(PChar(Fuente + SR.Name), PChar(Destino + SR.Name),
            @ProgressRoutine, nil, @Cancel, COPY_FILE_RESTARTABLE or
            COPY_FILE_NO_BUFFERING);
          ShowMessage(SysErrorMessage(GetLastError()));
        end;
      until FindNext(SR) <> 0;
      FindClose(SR);

    end;
  end;

end;
modifique el codigo de esta forma para copiar diversos archivos del directorio, pero no logro entender el por que me arroja el error de Access violation at address 006052F2

Exactamente en que linea te lo marca??. Creo q será un error de acceso a una dirección de memoria, pero hay q estar seguros, asi que coméntanos -para darte una respuestas mas cercana a lo exacto-, que versión de Delphi usas, que componentes, base de datos, etc.

Saludos.


La franja horaria es GMT +2. Ahora son las 16:34:47.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi