procedure CopyFile(
const FileName, DestName: TFileName);
var
CopyBuffer: Pointer;
{ buffer for copying }
TimeStamp, BytesCopied: Longint;
Source, Dest: Integer;
{ handles }
Destination: TFileName;
{ holder for expanded destination name }
const
ChunkSize: Longint = 8192;
{ copy in 8K chunks }
begin
Destination := ExpandFileName(DestName);
{ expand the destination path }
if HasAttr(Destination, faDirectory)
then { if destination is a directory... }
Destination := Destination + '
\' + ExtractFileName(FileName);
{ ...clone file name }
TimeStamp := FileAge(FileName);
{ get source's time stamp }
GetMem(CopyBuffer, ChunkSize);
{ allocate the buffer }
try
Source := FileOpen(FileName, fmShareDenyWrite);
{ open source file }
if Source < 0
then raise EFOpenError.Create(FmtLoadStr(SFOpenError, [FileName]));
try
[COLOR="Red"]
// Compilerfehlermeldung: undeklarierter Bezeichner SFOpenError [/COLOR]
Dest := FileCreate(Destination);
{ create output file; overwrite existing }
if Dest < 0
then
raise
EFCreateError.Create(FmtLoadStr(SFCreateError[Destination]));
try
[COLOR="Red"]
// Compilerfehlermeldun: [/COLOR]
repeat
BytesCopied := FileRead(Source, CopyBuffer^, ChunkSize);
{ read chunk }
if BytesCopied > 0
then { if we read anything... }
FileWrite(Dest, CopyBuffer^, BytesCopied);
{ ...write chunk }
until BytesCopied < ChunkSize;
{ until we run out of chunks }
finally
FileClose(Dest);
{ close the destination file }
end;
finally
FileClose(Source);
{ close the source file }
end;
finally
FreeMem(CopyBuffer, ChunkSize);
{ free the buffer }
end;
end;
PROCEDURE TMainForm.FormCreate(Sender: TObject);
[COLOR="Red"]
// E2009 ; erwartet aber . gefunden [/COLOR]
var pw :
file;
i, z : integer;
laenge : byte;
BEGIN
(* Variable mit Pfad der Anwendung initialisieren *)
MainIniPath := ExtractFilePath(ParamStr(0));
(* Variable mit der AnwendungsDatei initialisieren *)
IniPfad := MainForm.MainIniPath + '
MDI-Haupt.ini';
(* Instanz einer IniDatei erzeugen *)
MyIni := TIniFile.Create (IniPfad);
(* Hilfshinweise aktivieren *)
Application.OnHint := ShowHint;
(* Instanz einer HistList erzeugen *)
FileList := THistoryList.Create ;
(* HistList aus IniDatei lesen *)// Operator ode
FileList.LoadFromIni (IniPfad,'
Files');
[COLOR="Red"]
// Operator oder Semikolon fehlt [/COLOR]
(* HistList an Menü anhängen *)
FileList.MenuItem := Datei;
[COLOR="Red"]
// Operator oder Semikolon fehlt[/COLOR]
(* CAN geschlossen *)
CanAktiv := FALSE;
END;