时间: 2021-07-31 作者:daque
想要读取一个文献的属性,就要用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); --------------------------- //其余,为了变换文献属性,不妨运用底下的归来值。 +----------------------------------+ | 归来值 | 文献属性 | +----------------------------------+ | 128 | normal | | 1 | read only | | 2 | hidden | | 4 | system | | 32 | archive | +--------------+-------------------+ 挪用示例:咱们将用到如次代码filesetattr('c:\autoexec.bat',2);{湮没} filesetattr('c:\autoexec.bat',3);{湮没、只读。filegetattr 归来值3}