问一个CTP平台问题

Discussion in 'CTP' started by warmcrack, Jun 2, 2011.

  1. (1)正常注册登录CTP平台,行情交易查询都没有问题。
    在程序退出时死机,下面的代码在执行到pUserMapi->Release();
    pUserTapi->Release();时程序退不出来了。
    (2)如何正常退出CTP平台?????????



    CThostFtdcUserLogoutField pLogout;
    memset(&pLogout,0,sizeof(struct CThostFtdcUserLogoutField));
    strcpy(pLogout.BrokerID,BROKER_ID);
    strcpy(pLogout.UserID, INVESTOR_ID);
    pUserMapi->ReqUserLogout(&pLogout,++iRequestID);
    pUserTapi->ReqUserLogout(&pLogout,++iRequestID);
    ::Sleep(DELAYS);
    if (pUserMapi)
    {
    pUserMapi->RegisterSpi(NULL);
    pUserMapi->Release();
    pUserMapi = NULL;
    }
    if (pUserTapi) //交易
    {
    pUserTapi->RegisterSpi(NULL);
    pUserTapi->Release();
    pUserTapi = NULL;
    }
     
  2. Api不需要释放,将Spi释放就可以了。没有发现资源泄露的现象