орі» endbegin.FormStyle:=fsnormal;. Caption:=«Base»;;
end; TFBase.OnTop1Click (Sender: TObject);
close;
end;
end.
/ / Текст файлу додаткового модуля
unit Modulepas; SysUtils, Windows, Classes, Consts;=class (EStreamError);=class (EStreamError); CopyFile (const FileName, DestName: string); MoveFile (const FileName, DestName: string) ; GetFileSize (const FileName: string): LongInt; FileDateTime (const FileName: string): TDateTime; HasAttr (const FileName: string; Attr: Word): Boolean; ExecuteFile (const FileName, Params, DefaultDir: string;: Integer): THandle; Forms, ShellAPI;=«Destination% s does not exist»;=«Cannot move file% s»;
procedure CopyFile (const FileName, DestName: string);: Pointer; {Buffer for copying}: Longint;, Dest: Integer; {Handles}: Integer;: TFileName; {Holder for expanded destination name}: Longint=8192; {Copy in 8K chunks}:=ExpandFileName (DestName); {Expand the destination path} HasAttr (Destination, faDirectory) then {if destination is a directory ...}:=Length (Destination); Destination [Len]=« 'then:=Destination + ExtractFileName (FileName) {. .. clone file name}:=Destination + » '+ ExtractFileName (FileName); {... Clone file name}; (CopyBuffer, ChunkSize); {Allocate the buffer}:=FileOpen (FileName, fmShareDenyWrite); {Open source file} Source < 0 then raise EFOpenError.CreateFmt (SFOpenError, [FileName]);:=FileCreate (Destination); {Create output file; overwrite existing} Dest < 0 then raise EFCreateError.CreateFmt (SFCreateError, [Destination]);:=FileRead (Source, CopyBuffer ^, ChunkSize); {Read chunk} BytesCopied> 0 then {if we read anything ...} (Dest, CopyBuffer ^, BytesCopied); {... Write chunk} BytesCopied < ChunkSize; {Until we run out of chunks} (Dest); {Close the destination file}; (Source); {Close the source file}; (CopyBuffer, ChunkSize); {Free the buffer};
end;
{MoveFile procedure}
{Moves the file passed in FileName to the directory specified in DestDir.to just rename the file. If that fails, try to copy the file andthe original.
an exception if the source file is read-only, and therefore cannotdeleted / moved.}
procedure MoveFile (const FileName, DestName: string);: string;:=ExpandFileName (DestName); {Expand the destination path} not RenameFile (FileName, Destination) then {try just renaming} HasAttr (FileName, faReadOnly) then {if it «s read-only ...} EFCantMove.Create (Format (SFCantMove, [FileName]) ); {We wouldn »t be able to delete it} (FileName, Destination); {Copy it over to destination ...} (Pchar (FileName)); {... And delete the original};
end;
{GetFileSize function}
{Returns the size of the named file without opening the file. If the file't exist, returns - 1.}
function GetFileSize (const FileName: string): LongInt;: TSearchRec; FindFirst (ExpandFileName (FileName), faAnyFile, SearchRec)=0 then:=SearchRec.SizeResult:= - 1;. FindClose (SearchRec);;
end; FileDateTime (const FileName: string): System.TDateTime;:=FileDateToDateTime (FileAg...