Senin, 09 April 2012

APLIKASI OPERASI FILE DINAMIS MENGGUNAKAN DELPHI 7



LISTING PROGRAM>>


unit U_operasifile;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    DirectoryListBox1: TDirectoryListBox;
    FileListBox1: TFileListBox;
    DriveComboBox1: TDriveComboBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FileListBox1Change(Sender: TObject);
    procedure BitBtn3Click(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.FileListBox1Change(Sender: TObject);
begin
BitBtn1Click(Self);
end;

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

end.

Tidak ada komentar:

Posting Komentar