Windows Mobile 6.5 C++ - 确定互联网连接

发布于 2024-12-04 13:08:50 字数 204 浏览 0 评论 0原文

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

如何查明是否:

  • 当前有 Wifi 用作网络
  • 当前有 GPRS/EDGE/UMTS... 用作网络
  • 当前有 Active Sync 使用

My application needs to send some packets every 30 minutes, but I don't want to send via charged services like GPRS/EDGE/... I would like to send only if a WiFi / ActiveSync is UP.

How do I find out if:

  • There is currently Wifi used as network
  • There is currently GPRS/EDGE/UMTS... used as network
  • There is currently Active Sync used

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最美的太阳 2024-12-11 13:08:50

已解决

好的,发现可以工作:

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; 
}

RESOLVED

Ok, found that working :

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; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文