Delphi function to Detect if file is ReadOnly


function IsReadOnly(const FileName: string): Boolean;
var
  sr: TSearchRec;
begin
  (* Assume not read only *)
  Result := False;

  if FindFirst(FileName, faAnyFile, sr) = 0 then
  begin
    Result := (sr.Attr and faReadOnly) <> 0;
    FindClose(sr);
  end;
end;

No comments:

Post a Comment