home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sibdemo3.zip / SAMPLES.DAT / SAMPLES / FILEINFO / FILEU1.PAS < prev   
Pascal/Delphi Source File  |  1997-07-08  |  2KB  |  70 lines

  1. unit fileu1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Classes, Forms, Graphics, FileCtrl, Buttons, StdCtrls, LED;
  7.  
  8. type
  9.   TForm1 = class (TForm)
  10.     DriveComboBox1: TDriveComboBox;
  11.     Led1: TLed;
  12.     Led2: TLed;
  13.     Led3: TLed;
  14.     Led4: TLed;
  15.     Label1: TLabel;
  16.     Label2: TLabel;
  17.     Label3: TLabel;
  18.     Label4: TLabel;
  19.     DirectoryListBox1: TDirectoryListBox;
  20.     FileListBox1: TFileListBox;
  21.     Edit1: TEdit;
  22.     Edit2: TEdit;
  23.     Edit3: TEdit;
  24.     procedure Edit1OnChange (Sender: TObject);
  25.   private
  26.     {Insert private declarations here}
  27.   public
  28.     {Insert public declarations here}
  29.   end;
  30.  
  31. var
  32.   Form1: TForm1;
  33.  
  34. implementation
  35.  
  36. procedure TForm1.Edit1OnChange (Sender: TObject);
  37. var
  38.   S: string;
  39.   Info: TSearchRec;
  40. begin
  41.   S := Edit1.Text;
  42.   if S[Length(S)] = '\' then
  43.   begin
  44.     { New drive or directory selected - don't show stats }
  45.     Edit2.Caption := '';
  46.     Edit3.Caption := '';
  47.     LED1.LEDCondition := False;
  48.     LED2.LEDCondition := False;
  49.     LED3.LEDCondition := False;
  50.     LED4.LEDCondition := False;
  51.   end
  52.   else
  53.   begin
  54.     { File selected - show stats }
  55.     FindFirst(Edit1.Text, faAnyFile, Info);
  56.     Edit2.Text := ToStr(Info.Size) + ' bytes';
  57.     Edit3.Text := DateTimeToStr(FileDateToDateTime(Info.Time));
  58.     LED1.LEDCondition := (Info.Attr and faArchive <> 0);
  59.     LED2.LEDCondition := (Info.Attr and faHidden <> 0);
  60.     LED3.LEDCondition := (Info.Attr and faReadOnly <> 0);
  61.     LED4.LEDCondition := (Info.Attr and faSysFile <> 0);
  62.     FindClose(Info);
  63.   end;
  64. end;
  65.  
  66. initialization
  67.   RegisterClasses ([TForm1, TDriveComboBox, TDirectoryListBox, TFileListBox,
  68.     TEdit, TLed, TLabel]);
  69. end.
  70.