C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[54749] 장시간 켜노니깐 응용프로그램 오류가 나는데 소스 어떤부분이 이상한지좀 봐주세요..
번외편 [wifemylove] 1156 읽음    2008-10-03 17:03
네이버에 찾아보니깐 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;
        }       
}

+ -

관련 글 리스트
54749 장시간 켜노니깐 응용프로그램 오류가 나는데 소스 어떤부분이 이상한지좀 봐주세요.. 번외편 1156 2008/10/03
54760     Re:장시간 켜노니깐 응용프로그램 오류가 나는데 소스 어떤부분이 이상한지좀 봐주세요.. 장성호 1680 2008/10/05
54801         감사합니다 ^^ 번외편 1267 2008/10/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.