![]() |
|
معرفة خصائص ملف - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : مصادر دلفي مفتوحة تعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=14) +--- الموضوع : معرفة خصائص ملف (/showthread.php?tid=1385) |
معرفة خصائص ملف - issamdnn - 10-12-2009 كود : procedure TFMForm.Properties1Click(Sender: TObject);
var
Attributes, NewAttributes: Word;
begin
with FileAttrForm do
begin
FileDirName.Caption := FileListBox1.Items[FileListBox1.ItemIndex];
{ set box caption }
PathName.Caption := FileListBox1.Directory;
{ show directory name }
ChangeDate.Caption :=
DateTimeToStr(FileDateToDateTime(FileAge(FileListBox1.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 and not faReadOnly;
if Archive.Checked then
NewAttributes := NewAttributes or faArchive
else
NewAttributes := NewAttributes and not faArchive;
if System.Checked then
NewAttributes := NewAttributes or faSysFile
else
NewAttributes := NewAttributes and not faSysFile;
if Hidden.Checked then
NewAttributes := NewAttributes or faHidden
else
NewAttributes := NewAttributes and not faHidden;
if NewAttributes <> Attributes then { if anything changed... }
FileSetAttr(FileDirName.Caption, NewAttributes);
{ ...write the new values }
end ;
end ;معرفة خصائص ملف - issamdnn - 22-12-2009 مافي مشكلة أخي الكريم سأضع المثال الذي يوضح ذلك بالمرفقات وعلى جميع النواحي: 1- أفتح مشروع جديد. 2- ضع على الفورم العنصر TFileListBox الموجود في الصفحة Win 3.1 . 3-ضع على الفورم أربع عناصر TCheckBox وقم بإعادة تسميتها لتصبح : ReadOnly; Archive; System; Hidden; 4 - ضع ثلاثة عناصر TLabel وقم بتسميتها كما يلي: FileDirName; PathName; ChangeDate; 5- ضع على الفورم عنصر TButton وقم بإعادة تسميته ليصبح: Properties1 ضع في حدث ال onClick له الإجرائية . شغل تطبيقك وأضغط على اسم الملف الموجود في عنصر TFileListBox وسوف يقوم البرنامج بإعطاءك خصائصه قم بتغيير الخصائص عن طريق العناصر TCheckBox و أضغط بعدها على الزر وسوف تجد بأنها تغيرت . وفقك الله والجميع. |