1,314
社区成员




NewAPI *thread= new NewAPI(true,CloseStatus,"tid");
thread->FreeOnTerminate=true;
thread->ComStyle="TBPCGet";
thread->Resume();
while(WaitForSingleObject((void* )thread-> Handle,100)==WAIT_TIMEOUT)
{
Application->ProcessMessages();
}
NewAPI *thread= new NewAPI(true,CloseStatus,"tid");
thread->FreeOnTerminate=true;
thread->ComStyle="xxxxx";
thread->Resume();
while(WaitForSingleObject((void* )thread-> Handle,100)==WAIT_TIMEOUT)
{
Application->ProcessMessages();
}
void __fastcall NewAPI::Execute()
{
if (ComStyle=="xxxxx")
{
DDGetError=false;
TXMLDocument *XMLDDDetail=new TXMLDocument(NULL);
XMLDDDetail->Active=False;
XMLDDDetail->XML->Clear();
TIdHTTP *IdCS1=new TIdHTTP(NULL);
IdCS1->ConnectTimeout=20000;
IdCS1->ReadTimeout=20000;
IdCS1->ProtocolVersion=pv1_1;
IdCS1->AllowCookies=True;
IdCS1->ProxyParams->BasicAuthentication=false;
IdCS1->HTTPOptions<<hoInProcessAuth<<hoKeepOrigProtocol<<hoForceEncodeParams;
IdCS1->HandleRedirects=false;
try
{
XMLDDDetail->LoadFromXML(IdCS1->Get(DDGetURL));
IdCS1->Disconnect();
}
catch(...)
{
bool linkerror=true;
for (int i = 0; i < 3; i++)
{
TIdHTTP *IdCS=new TIdHTTP(NULL);
IdCS->ConnectTimeout=20000;
IdCS->ReadTimeout=20000;
IdCS->ProtocolVersion = pv1_1;
IdCS->AllowCookies = True;
IdCS->ProxyParams->BasicAuthentication=false;
IdCS->HTTPOptions<<hoInProcessAuth<<hoKeepOrigProtocol<<hoForceEncodeParams;
IdCS->HandleRedirects=false;
XMLDDDetail->Active=False;
XMLDDDetail->XML->Clear();
try
{
XMLDDDetail->LoadFromXML(IdCS->Get(DDGetURL));
IdCS->Disconnect();
delete IdCS;
linkerror=false;
break;
}
catch(...)
{
delete IdCS;
}
}
if (linkerror==true)
{
delete IdCS1;
delete XMLDDDetail;
DDGetError=true;
return;
}
}
delete IdCS1;
Form_Main->XMLDD->XML->Text=XMLDDDetail->XML->Text;
delete XMLDDDetail;
}
}