معرفة خصائص ملف
#1
كود :
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 ;
الرد
#2
مافي مشكلة أخي الكريم سأضع المثال الذي يوضح ذلك بالمرفقات وعلى جميع النواحي:
1- أفتح مشروع جديد.
2- ضع على الفورم العنصر TFileListBox الموجود في الصفحة Win 3.1 .
3-ضع على الفورم أربع عناصر TCheckBox وقم بإعادة تسميتها لتصبح :
ReadOnly;
Archive;
System;
Hidden;
4 - ضع ثلاثة عناصر TLabel وقم بتسميتها كما يلي:
FileDirName;
PathName;
ChangeDate;
5- ضع على الفورم عنصر TButton وقم بإعادة تسميته ليصبح:
Properties1
ضع في حدث ال onClick له الإجرائية .
شغل تطبيقك وأضغط على اسم الملف الموجود في عنصر TFileListBox وسوف يقوم البرنامج بإعطاءك خصائصه قم بتغيير الخصائص عن طريق العناصر TCheckBox و أضغط بعدها على الزر وسوف تجد بأنها تغيرت . وفقك الله والجميع.


الملفات المرفقة
.rar   خصائص ملف.rar (الحجم : 3.05 ك ب / التحميلات : 117)
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم