盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

改变文件的属性

时间:2025/1/6作者:未知来源:盾怪网教程人气:

[摘要]想要读取一个文件的属性,就要用FileGetAttr函数调用文件名,即将文件属性返回到一指定文件。例如,添加一个Tbutton和Tlabel组件到窗体并添加如下代码:var attr:Intege...
想要读取一个文件的属性,就要用FileGetAttr函数调用文件名,即将文件属性返回到一指定文件。例如,添加一个Tbutton和Tlabel组件到窗体并添加如下代码:

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);
---------------------------
//另外,为了改变文件属性,可以使用下面的返回值。
     +----------------------------------+
     

关键词:改变文件的属性




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版