#2
asade2014-08-18 17:21
|
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
RichEdit1->Visible=true;
int iFileHandle;
int iFileLength;
//int iBytesRead;
char *pszBuffer;
iFileHandle=FileOpen(SaveDialog1->FileName,fmOpenRead);
iFileLength=FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
pszBuffer=new char[iFileLength];
FileRead(iFileHandle,pszBuffer,iFileLength);
FileClose(iFileHandle);
RichEdit1->Text=pszBuffer;[/color]
delete [] pszBuffer;
RichEdit1->Visible=False;
int length,line;
length=(RichEdit1->Text).Length();
line=RichEdit1->FindText(Edit1->Text,0,length,TSearchTypes()<<stMatchCase);
if(line==-1)
ShowMessage("该用户不存在!");
else
{
if(Edit2->Text=="abc")
{
ShowMessage("登录成功!");
Form2->Show();
}
else
ShowMessage("密码错误!");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Edit3->Visible=true;
Button2->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(Edit3->Text!="")
{
RichEdit1->Visible=true;
RichEdit1->Text=RichEdit1->Text+Edit3->Text+" ";
this->RichEdit1->PlainText=true;
this->RichEdit1->Lines->SaveToFile(this->SaveDialog1->FileName);
RichEdit1->Visible=False;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
中的
iFileHandle=FileOpen(SaveDialog1->FileName,fmOpenRead);
iFileLength=FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
pszBuffer=new char[iFileLength];
FileRead(iFileHandle,pszBuffer,iFileLength);
FileClose(iFileHandle);
RichEdit1->Text=pszBuffer;[/color]
delete [] pszBuffer;
是什么意思!???