|
네이버에 찾아보니깐 virus 나 다른것들 때문에 오류가 난다고 하는데...
혹시나 몰라 한번 여쭤봅니다. 소스중에 이상한부분이나 잘못쓰고 있는점 있으면 지적해주세요
타이머로 3초마다 한번씩 실행시키는데 어느정도(2,3시간?) 켜노면
응용프로그램 오류가 뜨네요..
void __fastcall TForm1::Timer9Timer(TObject *Sender)
{
int i,j;
bool flag;
HANDLE hwrite, hread;
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = true;
flag = CreatePipe(&hread, &hwrite, &sa, 0);
STARTUPINFO si;
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdOutput = hwrite;
si.hStdError = hwrite;
PROCESS_INFORMATION pi;
flag = CreateProcess(NULL, "route print", NULL, NULL,True, DETACHED_PROCESS,
NULL, NULL, &si, &pi);
CloseHandle(hwrite);
char buffer[512];
DWORD BytesRead;
AnsiString ResultString;
char IP_Gateway[30];
int IP_Index;
while(ReadFile(hread, buffer, sizeof(buffer)-1, &BytesRead, NULL) && BytesRead)
{
buffer[BytesRead] = '\0';
ResultString = ResultString + buffer;
}
CloseHandle(hread);
IP_Index = ResultString.AnsiPos("Default Gateway:");
memcpy(IP_Gateway,&ResultString[IP_Index+22],30);
j=3;
for( i=0;i<30;i++)
{
if(IP_Gateway[i] == '.' )
{
j--;
}
if( j == 0 )
{
j = i +1 ;
break ;
}
}
memset(&IP_Gateway[j],0,(30 - j) );
if(strstr(Label8->Caption.c_str(),IP_Gateway)!=NULL)
{
Network = 1;
}
else if(strstr(Label9->Caption.c_str(),IP_Gateway)!=NULL)
{
Network = 2;
}
else if(strstr(Label10->Caption.c_str(),IP_Gateway)!=NULL)
{
Network = 3;
}
else if(strstr(Label11->Caption.c_str(),IP_Gateway)!=NULL)
{
Network = 4;
}
else
{
Network = 0;
}
}
|