16,742
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button1Click(Sender: TObject);
var
FileRec:TSearchrec;
s:String;
begin
s:='E:\FWGL\data.mdb';
findfirst(S,faAnyfile,FileRec);
ShowMessage(S+'的属性值为:'+inttostr(FileRec.Attr)); //显示32
ShowMessage('常量 aDirectory 的值为:'+inttostr(faDirectory)); //16
if ((FileRec.Attr and faDirectory) = 0) then
ShowMessage('按位与值:'+inttostr(FileRec.Attr and faDirectory)+' '+S+' 是一个文件.')
else
showMessage('按位与值:'+inttostr(FileRec.Attr and faDirectory)+' '+s+' 是一个文件夹');
end;
TSearchRec = record
private
function GetTimeStamp: TDateTime;
public
{$IFDEF MSWINDOWS}
Time: Integer platform deprecated;
{$ENDIF MSWINDOWS}
{$IFDEF POSIX}
Time: time_t platform;
{$ENDIF POSIX}
Size: Int64;
Attr: Integer;//看这里,看到了吗,就是一个整数。
Name: TFileName;
ExcludeAttr: Integer;
{ File attribute constants }
faInvalid = -1;
faReadOnly = $00000001;//这不就是1吗,32+1不就是33吗?
faHidden = $00000002 platform; // 如果加上这个属性,就是32+2啊,就是34.
faSysFile = $00000004 platform; // on POSIX system files are not regular files and not directories
faVolumeID = $00000008 platform deprecated; // not used in Win32
faDirectory = $00000010;//这不就是16吗?
faArchive = $00000020 platform;//这不就是32吗?
faNormal = $00000080;
faTemporary = $00000100 platform;
faSymLink = $00000400 platform; // Available on POSIX and Vista and above
faCompressed = $00000800 platform;
faEncrypted = $00004000 platform;
faVirtual = $00010000 platform;
faAnyFile = $000001FF;