改变文件的属性
点击次数:66 次 发布日期:2008-11-09 08:40:51 作者:源代码网
|
源代码网推荐 源代码网推荐 var 源代码网推荐 attr:Integer; 源代码网推荐 s:string; 源代码网推荐 begin 源代码网推荐 attr:=FileGetAttr("c:Autoexec.bat"); 源代码网推荐 if(attr and faHidden)<>0 then s:="Hidden"; 源代码网推荐 if(attr and faReadOnly)<>0 then s:=s "Read-Only"; 源代码网推荐 if(attr and faSysFile)<>0 then s:=s "System"; 源代码网推荐 if(attr and faArchive)<>0 then s:=s "Archive"; 源代码网推荐 Label1.Caption:=s; 源代码网推荐 end; 源代码网推荐 --------------------------- 源代码网推荐 要想设置某个文件的属性,将你想要改变的文件名和要改的属性传递到函数FileSetAttr。每种属性都在SysUtils单元中定义了一个名称。要设置某个文件的属性,请您跟着做下去: 源代码网推荐 源代码网推荐 Attributes := Attributes or faSystem; 源代码网推荐 源代码网推荐 //也可以同时设置几个属性: 源代码网推荐 源代码网推荐 Attributes := Attributes and not (faReadOnly or faHidden); 源代码网推荐 --------------------------- 源代码网推荐 //另外,为了改变文件属性,可以使用下面的返回值。 源代码网推荐 ---------------------------------- 源代码网推荐 | 返回值 | 文件属性 | 源代码网推荐 ---------------------------------- 源代码网推荐 | 128 | Normal | 源代码网推荐 | 1 | Read Only | 源代码网推荐 | 2 | Hidden | 源代码网推荐 | 4 | System | 源代码网推荐 | 32 | Archive | 源代码网推荐 -------------- ------------------- 源代码网推荐 源代码网推荐 调用示例:我们将用到如下代码 源代码网推荐 源代码网推荐 FileSetAttr("C:Autoexec.bat",2);{隐藏} 源代码网推荐 FileSetAttr("C:Autoexec.bat",3);{隐藏、只读。FileGetAttr 返回值3} 源代码网推荐 源代码网供稿. |
