Thursday, April 5, 2012

Aplikasi Operasi File



unit U_operasiFile;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, FileCtrl;


type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    DirectoryListBox1: TDirectoryListBox;
    FileListBox1: TFileListBox;
    DriveComboBox1: TDriveComboBox;
    Bevel1: TBevel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;

    CheckBox3: TCheckBox;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure FileListBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var NamaFile:String;
Atribut:Integer;

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
NamaFile:=edit1.Text;
Atribut:=FileGetAttr(NamaFile);
if Atribut and faReadOnly = faReadOnly then
  checkbox1.Checked:=True
else
  checkbox1.Checked:=False;
if Atribut and faHidden = faHidden then
  checkbox2.Checked:=True
else
  checkbox2.Checked:=False;
if Atribut and faSysFile = faSysFile then
  checkbox3.Checked:=True
else
  checkbox3.Checked:=False;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if checkbox1.Checked=True then
  Atribut:=Atribut or faReadOnly
else
  Atribut:=Atribut and not faReadOnly;
if checkbox2.Checked=True then
  Atribut:=Atribut or faHidden
else
  Atribut:=Atribut and not faHidden;
if checkbox3.Checked=True then
  Atribut:=Atribut or faSysFile
else
  Atribut:=Atribut and not faSysFile;
FileSetAttr(NamaFile,Atribut);

end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Application.Terminate;
end;

procedure TForm1.FileListBox1Change(Sender: TObject);
begin
BitBtn1Click(self);
end;

end.




0 komentar:

Post a Comment