un pequeño ejemplo completo de como modificar las propiedades de los archivos.. y carpetas
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, FileCtrl, ExtCtrls;
type
TForm1 = class(TForm)
DriveComboBox1: TDriveComboBox;
DirectoryListBox1: TDirectoryListBox;
FileListBox1: TFileListBox;
Memo1: TMemo;
Edit1: TEdit;
Button1: TButton;
Panel1: TPanel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
Button2: TButton;
procedure DriveComboBox1Change(Sender: TObject);
procedure DriveComboBox1DblClick(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
procedure DirectoryListBox1Click(Sender: TObject);
procedure DirectoryListBox1DblClick(Sender: TObject);
procedure FileListBox1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.DriveComboBox1Change(Sender: TObject);
begin
DirectoryListBox1.Drive:=DriveComboBox1.Drive;
end;
procedure TForm1.DriveComboBox1DblClick(Sender: TObject);
begin
DirectoryListBox1.Drive:=DriveComboBox1.Drive;
end;
procedure TForm1.DirectoryListBox1Change(Sender: TObject);
begin
FileListBox1.Directory:=DirectoryListBox1.Directory;
end;
procedure TForm1.DirectoryListBox1Click(Sender: TObject);
begin
FileListBox1.Directory:=DirectoryListBox1.Directory;
end;
procedure TForm1.DirectoryListBox1DblClick(Sender: TObject);
begin
FileListBox1.Directory:=DirectoryListBox1.Directory;
end;
procedure TForm1.FileListBox1Change(Sender: TObject);
begin
memo1.Lines.Add(IntToStr(FileGetAttr(FileListBox1.FileName)));
edit1.Text:=FileListBox1.FileName;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Clear;
memo1.clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Attr:integer;
begin
attr:=0;
if CheckBox1.Checked then
attr:=attr+faReadOnly;
if CheckBox2.Checked then
attr:=attr+faHidden;
if CheckBox3.Checked then
attr:=attr+faSysFile;
FileSetAttr(edit1.text,attr);
memo1.Lines.Add(IntToStr(FileGetAttr(edit1.Text)));
end;
end.