![]() |
|
#1
|
|||
|
|||
![]() здравствуйте!помогите!!!надо скопировать один файл(текстовый) в другой с атрибутами только для чтения используя функции:
CreateFile CloseHandle ReadFile WriteFile могу ли я просто его скопировать, а потом у второго файла просто -поменять атрибут???? вот что - то сделала... Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure SetAttribut( Path: string; r, h, s, a: char ); var At: integer; begin At := FileGetAttr( Path ); if r = '+' then At := At or faReadOnly; if h = '-' then At := At or faHidden; if s = '+' then At := At or faSysFile; if a = '+' then At := At or faArchive; FileSetAttr( Path, At ); end; procedure TForm1.Button1Click(Sender: TObject); var f: TextFile; begin if copyfile('c:1.txt','c:2.txt',true) then showmessage('Файл успешно скопирован!') else showmessage('Неудача!'); end; procedure TForm1.Button2Click(Sender: TObject); var At: integer; begin SetAttribut( 'c:\2.txt', '+', '-', ' ', ' ' ); end; end. |