if(FAILED(CoInitialize(NULL)))
{
MessageBox(_T("初始化COM库失败"),MB_OK);
return 0;
} while(iZhangMi<iHangshu)
{
CComQIPtr<IHTMLDocument3> spDoc3=m_Web.get_Document();
IHTMLElement *pInput = NULL; spDoc3->getElementById(L"usrid",&pInput); VARIANT vValue ;
vValue.vt = VT_BSTR;
vValue.bstrVal = _bstr_t(strZhanghao[iZhangMi]);
pInput->setAttribute(L"value",vValue); spDoc3->getElementById(L"passwd",&pInput); vValue.vt = VT_BSTR;
vValue.bstrVal = _bstr_t(strMima[iZhangMi]);
pInput->setAttribute(L"value",vValue); spDoc3->getElementById(L"PMANG_LOGIN",&pInput);
pInput->click(); spDoc3.Release();
pInput->Release(); SetTimer(1,10000,NULL);
while(GetMessage(&msg,NULL,0,0))
{
if(bXunHuan)
{
bXunHuan=false;
KillTimer(1);
break;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} m_Web.Navigate(L"http://fifaonline.pmang.com/gamepub/component/gamepub_get_character_info.nwz?ssn=321&isMain=M",NULL,NULL,NULL,NULL); SetTimer(1,5000,NULL);
while(GetMessage(&msg,NULL,0,0))
{
if(bXunHuan)
{
bXunHuan=false;
KillTimer(1);
break;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} m_Web.Navigate(L"http://www.pmang.com/logout.nwz",NULL,NULL,NULL,NULL);
//SetTimer(1,5000,NULL);
while(GetMessage(&msg,NULL,0,0))
{
if(m_Web.get_ReadyState()==READYSTATE_COMPLETE)
break;
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
iZhangMi++;
} CoUninitialize();WEB控件里的网页为什么老卡住,有时候登录2个号就卡,有时候3个或不一定几个,反正总卡住,就是执行到这里pInput->click();就卡那不动了,不知道为什么,大仙们帮我看看

解决方案 »

  1.   

    if(FAILED(CoInitialize(NULL)))
    {
    MessageBox(_T("初始化COM库失败"),MB_OK);
    return 0;
    } while(iZhangMi<dwHangshu)
    {
    CComQIPtr<IHTMLDocument3> spDoc3=m_Web.get_Document();
    IHTMLElement *pInput = NULL; spDoc3->getElementById(L"usrid",&pInput); VARIANT vValue ;
    vValue.vt = VT_BSTR;
    vValue.bstrVal = _bstr_t(strZhanghao[iZhangMi]);
    pInput->setAttribute(L"value",vValue); spDoc3->getElementById(L"passwd",&pInput); vValue.vt = VT_BSTR;
    vValue.bstrVal = _bstr_t(strMima[iZhangMi]);
    pInput->setAttribute(L"value",vValue); spDoc3->getElementById(L"PMANG_LOGIN",&pInput);
    pInput->click(); spDoc3.Release();
    pInput->Release(); SetTimer(1,10000,NULL);
    while(GetMessage(&msg,NULL,0,0))
    {
    if(bXunHuan)
    {
    bXunHuan=false;
    KillTimer(1);
    break;
    }
    else
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    } m_Web.Navigate(L"http://fifaonline.pmang.com/gamepub/component/gamepub_get_character_info.nwz?ssn=321&isMain=M",NULL,NULL,NULL,NULL); SetTimer(1,5000,NULL);
    while(GetMessage(&msg,NULL,0,0))
    {
    if(bXunHuan)
    {
    bXunHuan=false;
    KillTimer(1);
    break;
    }
    else
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    } m_Web.Navigate(L"http://www.pmang.com/logout.nwz",NULL,NULL,NULL,NULL);
    //SetTimer(1,5000,NULL);
    while(GetMessage(&msg,NULL,0,0))
    {
    if(m_Web.get_ReadyState()==READYSTATE_COMPLETE)
    break;
    else
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }
    iZhangMi++;
    } CoUninitialize();WEB控件里的网页为什么老卡住,有时候登录2个号就卡,有时候3个或不一定几个,反正总卡住,就是执行到这里pInput->click();就卡那不动了,不知道为什么,大仙们帮我看看
      

  2.   

    多线程函数定义:DWORD WINAPI ThreadFun(LPVOID lParam)
    {
        for(;;)
        {
            if (WorkerID<MAXWORKERID)
            {
                WorkerID +=1;
                printf("ThreadTwo print out: %i \n",WorkerID);
                Sleep(1000);
            }
        }
        return 0;
    }
    多线程启动:HANDLE hThread;
    hThread = ::CreateThread(NULL,0,ThreadFun,NULL,0,NULL);
    不用多线程就算每次只登录一个也可能出现问题,比如退出的时候有些资源没有释放,总之之前的登录会影响后来的登录。卡住是指没有响应了吗?你卡住的时候看下CPU占用率多少?如果你是双核的CPU,占用50%就说明你的程序陷入了死循环,单核的100%就是死循环啦。那就是你while的判断有问题了。
      

  3.   

    WEB控件里的网页没反映,就是停在按登录按钮那个界面。  单核CPU,占用2%-5%,不应该是陷入死循环了