Delphi 测试磁盘是否具有写访问权限


本文整理自网络,侵删。

 


 function CanWrite(drive: string): boolean;
    var
        OldMode: Cardinal;
    begin
        OldMode := SetErrorMode(SEM_FAILCRITICALERRORS);
        try
            with TStringList.Create do
                try
                    SaveToFile(drive + ':\file.txt');
                    result := true;

                    try
                        deletefile(drive + ':\file.txt');
                    except
                    end;
                except
                    result := false;
                end;
        finally
            SetErrorMode(OldMode);
        end;
end;




调用

 if CanWrite('g') = true then
    begin
        showmessage('可以写');
    end
    else
    begin
        showmessage('不能写');
end;

来源:http://www.xuexidashi.vip/h-nd-1629.html#_np=125_826

相关阅读 >>

tidhttpresponseinfo 中文乱码问题解决

Delphi搜索字符串在流中的位置

Delphi之完美splash方案

建议大家使用fastmm

Delphi json

Delphi mediaplayer 左声道右声道

Delphi concat 字符串函数

Delphi获取13位格林治时间实现方法

Delphi 万能模糊查询

Delphi readprocessmemory 输入进程id 输入读取地址

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



打赏

取消

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

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

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

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

评论

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