EVC检测GPRS链接代码

BOOL CRasMonitor::CheckConnectState()

{

    DWORD m_con_cnt = 0;

    RASCONN m_ras_conn;

    m_ras_conn.dwSize = sizeof( RASCONN );

    DWORD dwSize = sizeof( RASCONN );

    DWORD m_ret = RasEnumConnections( &m_ras_conn, &dwSize, &m_con_cnt );

    if ( (0 != m_ret) || (m_con_cnt <= 0) )

        return FALSE;



    RASCONNSTATUS m_ras_state;

    memset( &m_ras_state, 0, sizeof( RASCONNSTATUS ) );

    m_ras_state.dwSize = sizeof( RASCONNSTATUS );

    if ( 0 != RasGetConnectStatus( m_ras_conn.hrasconn, &m_ras_state ) )

        return FALSE;



    return ( m_ras_state.rasconnstate == RASCS_Connected );

}

 

在WM5上工作很好很正常,在WM6上RasEnumConnections返回的值都是0

RasGetConnectStatus()是用来监测RAS拨号后的状态,要查GPRS连接的状态还是用connmgr.h里面提供的API好一些

你可能感兴趣的:(代码)