本文整理自网络,侵删。
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
相关阅读 >>
Delphi 使用 {$include} 或 {$i} 指令管理和调用自定义函数
Delphi ini文件操作 tinifile、tmeminifile
更多相关阅读请进入《Delphi》频道 >>