Windows Mobile 6.5 C ++ - 确定Internet连接

时间:2011-09-15 16:56:26

标签: c++ networking windows-mobile

我的应用程序需要每隔30分钟发送一些数据包,但我不想通过GPRS / EDGE /等收费服务发送...我想只在WiFi / ActiveSync启动时发送。

我如何找出:

  • 目前有无线网络用作网络
  • 目前有GPRS / EDGE / UMTS ......用作网络
  • 目前使用Active Sync

1 个答案:

答案 0 :(得分:0)

<强>分辨

好的,发现工作:

void TEST()
{
  CONNMGR_CONNECTION_DETAILED_STATUS *StatusBuffer;
  CONNMGR_CONNECTION_DETAILED_STATUS *StatusBufferTemp;
  DWORD               pcbBufferSize = 0;

  ConnMgrQueryDetailedStatus(NULL, &pcbBufferSize);
  StatusBuffer = (CONNMGR_CONNECTION_DETAILED_STATUS *)new BYTE[pcbBufferSize];
  ConnMgrQueryDetailedStatus(StatusBuffer, &pcbBufferSize);
  StatusBufferTemp = StatusBuffer;

  while(StatusBufferTemp != NULL)
  {
    if(StatusBufferTemp->dwConnectionStatus == CONNMGR_STATUS_CONNECTED)
    {
      if(StatusBufferTemp->dwType == CM_CONNTYPE_NIC)
      {
        switch(StatusBufferTemp->dwSubtype)
        {
         case CM_CONNSUBTYPE_NIC_WIFI :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_NIC_WIFI"),MB_OK);
          break;

          case CM_CONNSUBTYPE_NIC_ETHERNET :
          break;
        }
      }

      if(StatusBufferTemp->dwType == CM_CONNTYPE_CELLULAR)
      {
        switch(StatusBufferTemp->dwSubtype)
        {
        case CM_CONNSUBTYPE_CELLULAR_CSD :
          break;

        case CM_CONNSUBTYPE_CELLULAR_GPRS :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_GPRS"),MB_OK);
          break;

        case CM_CONNSUBTYPE_CELLULAR_1XRTT :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_1XRTT"),MB_OK);
          break;

        case CM_CONNSUBTYPE_CELLULAR_1XEVDO :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_1XEVDO"),MB_OK);
          break;

        case CM_CONNSUBTYPE_CELLULAR_1XEVDV :
          break;

        case CM_CONNSUBTYPE_CELLULAR_EDGE :
        MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_EDGE"),MB_OK);
          break;

        case CM_CONNSUBTYPE_CELLULAR_UMTS :
            MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_UMTS"),MB_OK);
          break;

        case CM_CONNSUBTYPE_CELLULAR_VOICE :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_VOICE"),MB_OK);
          break;

        case CM_CONNSUBTYPE_CELLULAR_PTT :
          break;

        case CM_CONNSUBTYPE_CELLULAR_HSDPA :
            MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_CELLULAR_HSDPA"),MB_OK);
            break;
        }
      }

      if(StatusBufferTemp->dwType == CM_CONNTYPE_PROXY)
      {
        switch(StatusBufferTemp->dwSubtype)
        {
        case CM_CONNSUBTYPE_PROXY_WAP :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_PROXY_WAP"),MB_OK);
          break;

        case CM_CONNSUBTYPE_PROXY_HTTP :
         MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_PROXY_HTTP"),MB_OK);
          break;
        }
      }

      if(StatusBufferTemp->dwType == CM_CONNTYPE_PC)
      {
        switch(StatusBufferTemp->dwSubtype)
        {
        case CM_CONNSUBTYPE_PC_DESKTOPPASSTHROUGH :
          MessageBox(0,TEXT(""),_T("CM_CONNSUBTYPE_PC_DESKTOPPASSTHROUGH"),MB_OK);
          break;

        case CM_CONNSUBTYPE_PC_UNKNOWN :
          break;
        }
      }

    }
    StatusBufferTemp = StatusBufferTemp->pNext;
  }

  delete StatusBuffer; 
}