我已经把头文件包进去了!
1.定义(thread.cpp)的线程:
#inclde "infoMain.h"
//---------------------------------------------------------------------------
__fastcall infoTJ::infoTJ(int Number,AnsiString bh,AnsiString Buf,AnsiString URL,AnsiString flag,bool CreateSuspended)
: TThread(CreateSuspended)
{
ThreadNumber=Number;
FBuf=Buf;
FURL=URL;
BH=bh;
fflag=flag;
Success=TRUE;
}
//---------------------------------------------------------------------------
void __fastcall infoTJ::Execute()
{
Datain=new TMemoryStream;
Dataout=new TMemoryStream;
HttpCli=new THttpCli(NULL);
FreeOnTerminate=True;
Datain->Clear();
Dataout->Clear();
HttpCli->MultiThreaded=True;
Synchronize(Proxy);
Dataout->Write(FBuf.c_str(),FBuf.Length());
Dataout->Seek(0, soFrombegin
ning);
HttpCli->SendStream=Dataout;
HttpCli->RcvdStream=Datain;
HttpCli->URL=FURL;
try
{
HttpCli->Post();
Success=True;
}
catch(...)
{
Success=False;
}
Synchronize(UpdateStatus);
Dataout->Free();
Datain->Free();
HttpCli->Free();
//---- Place thread code here ----
}
//---------------------------------------------------------------------------
void __fastcall infoTJ:
roxy()
{
if(Form2->FlatEdit14->Text!="")
{
HttpCli->Proxy=Form2->FlatEdit14->Text;
HttpCli->ProxyPort=Form2->FlatEdit15->Text;
HttpCli->ProxyUsername=Form2->FlatEdit16->Text;
HttpCli->ProxyPassword=Form2->FlatEdit17->Text;
}
}
//---------------------------------------------------------------------------
void __fastcall infoTJ::UpdateStatus()
{
if(Success)
{
Datain->Seek(0,0);
Form1->FlatMemo2->Text="";
Form1->FlatMemo2->Lines->LoadFromStream(Datain);
}
Form1->ProcessResults(ThreadNumber,Success,BH,fflag);
}
//---------------------------------------------------------------------------
2.在主线程的头文件(infoMain.h)中我的定义为:
#include "thread.h"
然后
infoTJ *ThreadsObjects[10];//*****这时出错了!*****