procedure TFMForm.Properties1Click(Sender: TObject);
var
  Attributes, NewAttributes: Word;
begin
  with FileAttrForm do
  begin
    FileDirName.Caption := FileList.Items[FileList.ItemIndex];
    { set box caption }
    PathName.Caption := FileList.Directory;
    { show directory name }
    ChangeDate.Caption := 
      DateTimeToStr(FileDateToDateTime(FileAge(FileList.FileName)));
    Attributes := FileGetAttr(FileDirName.Caption);
    { read file attributes }
    ReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;
    Archive.Checked := (Attributes and faArchive) = faArchive;
    System.Checked := (Attributes and faSysFile) = faSysFile;
    Hidden.Checked := (Attributes and faHidden) = faHidden;
    if ShowModal <> id_Cancel then { execute dialog box }
    begin
      NewAttributes := Attributes;
      { start with original attributes }
      if ReadOnly.Checked then
        NewAttributes := NewAttributes or faReadOnly
      else 
        NewAttributes := NewAttributes andnot faReadOnly;
      if Archive.Checked then
        NewAttributes := NewAttributes or faArchive
      else 
        NewAttributes := NewAttributes andnot faArchive;
      if System.Checked then 
        NewAttributes := NewAttributes or faSysFile
      else 
        NewAttributes := NewAttributes andnot faSysFile;
      if Hidden.Checked then 
        NewAttributes := NewAttributes or faHidden
      else 
        NewAttributes := NewAttributes andnot faHidden;
      if NewAttributes <> Attributes then { if anything changed... }
        FileSetAttr(FileDirName.Caption, NewAttributes);
         { ...write the new values }
    end;
  end;
end;

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);var
       f: file of Byte;
       size: Longint;
       S: string;
       y: Integer;
    begin
      if OpenDialog1.Execute then
      begin
        AssignFile(f, OpenDialog1.FileName);
        Reset(f);
        try
          size := FileSize(f);
          S := 'File size in bytes: ' + IntToStr(size);
          y := 10;
          Canvas.TextOut(5, y, S);
          y := y + Canvas.TextHeight(S) + 5;
          S := 'Seeking halfway into file...';
          Canvas.TextOut(5, y, S);      y := y + Canvas.TextHeight(S) + 5;
          Seek(f, size div 2);
          S := 'Position is now ' + IntToStr(FilePos(f));
          Canvas.TextOut(5, y, S);
        finally
          CloseFile(f);
        end;
      end;
    end;
      

  2.   

    这都是Delphi已经申明好的类型:
      TSearchRec = record
        Time: Integer;
        Size: Integer;
        Attr: Integer;
        Name: TFileName;
        ExcludeAttr: Integer;
        FindHandle: THandle;
        FindData: TWin32FindData;
      end;  TWin32FindDataA = _WIN32_FIND_DATAA;
      TWin32FindData = TWin32FindDataA;  _WIN32_FIND_DATAA = record
        dwFileAttributes: DWORD;      
        ftCreationTime: TFileTime;    //文件创建的时间
        ftLastAccessTime: TFileTime;  
        ftLastWriteTime: TFileTime;   //最后一次修改文件的时间    nFileSizeHigh: DWORD;         //文件字节数的高32位
        nFileSizeLow: DWORD;          //文件字节数的低32位
        dwReserved0: DWORD;
        dwReserved1: DWORD;
        cFileName: array[0..MAX_PATH - 1] of AnsiChar;
        cAlternateFileName: array[0..13] of AnsiChar;
      end;简要代码:
    var
      SearchRec: TSearchRec;
      RetVal: Integer;
    begin
      RetVal := FindFirst(Directory+'\test.txt', faAnyFile, SearchRec);
      {
      your codes;
      }
    end;应该明白了吧
      

  3.   

    C:\program Files\Borland\Delphi6\Demos\Virtual Listview\VListView.pas