Акжан в сети - На уровень вверхКак исправить проблемы с русскими шрифтами *.TTF в Delphi + Windows NT?

Можно так:

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
      Dest := FileCreate(Destination); { create output file; overwrite existing }
      if Dest < 0 then raise EFCreateError.Create(FmtLoadStr(SFCreateError, [Destination]));
      try
        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 }

{        SetFileTimeStamp(Destination, TimeStamp);} { clone source's time stamp }{!!!}
      end;
    finally
      FileClose(Source); { close the source file }
    end;
  finally
    FreeMem(CopyBuffer, ChunkSize); { free the buffer }
  end;
  FileSetDate(Dest,FileGetDate(Source));
end;

Anton Kartamyshev

(2:5020/211.15)

Хм. IMHO кpутовато будет такие функции писать, когда в большинстве случаев достаточно что-нубудь типа нижепpиводимого, пpичем оно даже гибче, так как позволяет скопиpовать как весь файл пpи From и Count = 0, так и пpоизвольный его кусок.

function CopyFile( InFile,OutFile: String; From,Count: Longint ): Longint;
var
  InFS,OutFS: TFileStream;
begin
  InFS  := TFileStream.Create( InFile,  fmOpenRead );
  OutFS := TFileStream.Create( OutFile, fmCreate   );
  InFS.Seek( From, soFromBeginning );
  Result := OutFS.CopyFrom( InFS, Count );
  InFS.Free;
  OutFS.Free;
end;

try..except pасставляются по вкусу, а навоpоты вpоде установки атpибутов,даты и вpемени файла и т.п. для ясности удалены, да и не нужны они в основном никогда.

Dimus Gremyakoff

dimus57@chat.ru
dimus.g@usa.net
(2:5020/768.57)

Конечно, под Win32 имеет смысл использовать функции CopyFile, SHFileOperation.