TForm1 *Form1;
SECURITY_ATTRIBUTES s_Attr={sizeof(SECURITY_ATTRIBUTES),NULL,TRUE};
private: // User declarations
AnsiString aFiles[4];
TSearchRec SR;
DWORD bytes_Size;
char buff[1024*1024];
HANDLE ident_File;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
aFiles[0]="Archive";
aFiles[1]="ReadOnly";
aFiles[2]="Hidden";
aFiles[3]="SysFile";
DirectoryListBox1->FileList=FileListBox1;
DriveComboBox1->DirList=DirectoryListBox1;
FileListBox1->FileEdit=Edit1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileListBox1Change(TObject *Sender)
{
AnsiString value=Edit1->Text;
int i;
SR.Name=value;
SR.Attr=FileGetAttr(SR.Name);
char* temp=FileListBox1->FileName.c_str();
ident_File=CreateFile(temp,GENERIC_READ,FILE_SHARE_READ,&s_Attr,
OPEN_EXISTING,0,NULL);
if((SR.Attr & faArchive)==faArchive)
Label2->Caption=aFiles[0];
if((SR.Attr & faReadOnly)==faReadOnly)
Label2->Caption=aFiles[1];
if((SR.Attr & faHidden)==faHidden)
Label2->Caption=aFiles[2];
if((SR.Attr & faSysFile)==faSysFile)
Label2->Caption=aFiles[3];
if(ident_File!=INVALID_HANDLE_VALUE)
ReadFile(ident_File,&buff,sizeof(buff),&bytes_Size,NULL);
for(i=0;i<sizeof(buff)-1;i++)
if(buff[i]==NULL)
buff[i]='\n';
Memo1->Text=buff;
CloseHandle(ident_File);
}