用DELPHI設置文件的屬性
1. 在interface下的uses中引用filectrl單元
2. 首先取文件屬性
var
attr : integer;
filename : string;
begin
filename := 'myfile';
attr := FileGetAttr(filename);
end;
3. 設置文件屬性(如設置歸檔屬性 -> faArchive )
attr := attr or faArchive;
//如要去掉某一屬性,則如下句
attr := attr and (not faArchive);
//保留其它屬性
if FileSetAttr(filename, attr)=0 then
//成功代碼
else
//失敗代碼
4. 附文件屬性常量
Constant Value Description
faReadOnly $00000001 Read-only files 只讀文件
faHidden $00000002 Hidden files 隱藏文件
faSysFile $00000004 System files 系統文件
faVolumeID $00000008 Volume ID files 卷標文件
faDirectory $00000010 Directory files 目錄
faArchive $00000020 Archive files 歸檔文件
faAnyFile $0000003F Any file 任意文件