private: // User declarations
DWORD temp_Size;
HANDLE temp_Handle;
bool __fastcall handle_True(HANDLE value);
TForm1 *Form1;
SECURITY_ATTRIBUTES sec_Atr={sizeof(SECURITY_ATTRIBUTES),NULL,TRUE};
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
bool __fastcall TForm1::handle_True(HANDLE value)
{
if(value!=INVALID_HANDLE_VALUE)
return true;
else
return false;
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
DirectoryListBox1->FileList=FileListBox1;
DriveComboBox1->DirList=DirectoryListBox1;
FileListBox1->FileEdit=Edit1;
Label1->Caption=DateToStr(Date())+" "+TimeToStr(Time());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileListBox1Change(TObject *Sender)
{
int a;
char buff[64*64];
memset(buff,0,sizeof(buff)-1);
AnsiString temp_Text=FileListBox1->FileName;
temp_Handle=CreateFile(temp_Text.c_str(),GENERIC_READ,FILE_SHARE_READ,&sec_Atr,
OPEN_EXISTING,0,NULL);
if(handle_True(temp_Handle))
ReadFile(temp_Handle,&buff,sizeof(buff),&temp_Size,NULL);
Memo1->Text=buff;
CloseHandle(temp_Handle);
}