delphi 去掉文件只读属性


本文整理自网络,侵删。

 uses FileCtrl;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with OpenDialog1 do
if Execute then
if FileSetAttr(filename, faArchive)=0 then
Caption:='attribute was changed'
else
Caption:='attribute was not changed';
end;


Delphi 设置文件属性

请在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 任意文件

相关阅读 >>

dbgrideh 组件在borland开发工具中应用全攻略

Delphi 判断指定字符串是否开头 startstext用法

Delphi 之 标签组件(tlabel组件)

Delphi中怎么判断一个文件夹是否为空

Delphi webbrowser.oleobject属性

Delphi�⒆执�传入到windows目前窗口cursor所在位置

Delphi 自动关闭弹出的窗口

Delphi 获取网络图片在webbrowser显示 android/osx/ios/win的最佳方式

Delphi 调用外部 dll 中的函数(2. 晚绑定)

Delphi字符串隐藏一法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...