改变文件属性?(50分)

  • 主题发起人 主题发起人 netboy328
  • 开始时间 开始时间
N

netboy328

Unregistered / Unconfirmed
GUEST, unregistred user!
请问高手,如何通过编程改变一个文件的属性??多谢大家了!
 
delphi自己的函数<br>FileSetAttr
 
FileSetAttr(文件路径,faarchive);<br>faReadOnly $00000001 Read-only files<br>faHidden $00000002 Hidden files<br>faSysFile $00000004 System files<br>faVolumeID $00000008 Volume ID files<br>faDirectory$00000010 Directory files<br>faArchive $00000020 Archive files<br>faAnyFile $0000003F Any file
 
procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; FileSetAttr('c:/test.txt', faReadOnly or faHidden);<br>end;
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; Attributes: Word;<br>begin<br>&nbsp; Attributes:= FileGetAttr('c:/AUTOEXEC.BAT');<br>&nbsp; if Attributes and faReadOnly &lt;&gt;0 then<br>&nbsp; &nbsp; FileSetAttr('c:/AUTOEXEC.BAT', Attributes - faReadOnly);<br>end;
 
&nbsp;f:=FileSetAttr ('Unit1.pas',faReadOnly);<br>&nbsp; if f=0 then showmessage('Unit1.pas设为只读文件');<br>&nbsp; <br>&nbsp; {<br>&nbsp; faReadOnly $00000001 Read-only files<br>&nbsp; faHidden $00000002 Hidden files<br>&nbsp; faSysFile $00000004 System files<br>&nbsp; faVolumeID $00000008 Volume ID files<br>&nbsp; faDirectory $00000010 Directory files<br>&nbsp; faArchive $00000020 Archive files<br>&nbsp; faAnyFile $0000003F Any file<br>&nbsp; }<br>
 
后退
顶部