首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

本地连接的网络连接状态怎么获取

2012-07-31 
本地连接的网络连接状态如何获取数据包的发送数,接收数。换句话接收怎么获取这个值。[解决办法]C/C++ code//

本地连接的网络连接状态如何获取
数据包的发送数,接收数。换句话接收怎么获取这个值。

[解决办法]

C/C++ code
// GetIfTable.cpp // A sample try to get the speed of a modem by using GetIfTable() func #include <windows.h> #include <iphlpapi.h> #include <stdio.h> #pragma comment ( lib, "iphlpapi.lib" ) int main( void ) {     MIB_IFTABLE *pIfTable = NULL;     ULONG dwSize = 0;         DWORD dwRet;         printf( "This program try to get the speed of a modem by using GetIfTable()\n" );         dwRet = GetIfTable( pIfTable, &dwSize, TRUE );     if ( dwRet == ERROR_INSUFFICIENT_BUFFER )     {         pIfTable = ( MIB_IFTABLE * ) new char[dwSize];                 if ( pIfTable != NULL )         {             dwRet = GetIfTable( pIfTable, &dwSize, TRUE );             if ( dwRet == NO_ERROR )             {                 printf( "dwNumEntries = %u\n", pIfTable->dwNumEntries );                                 for ( int i=0; i<pIfTable->dwNumEntries; i++ )                 {                     printf( "table[%1d].dwIndex = %u\n",                         i,                         (pIfTable->table[i]).dwIndex );                     printf( " dwType = %u\n",                         (pIfTable->table[i]).dwType );                     printf( " dwSpeed = %u\n",                         (pIfTable->table[i]).dwSpeed );                 }             }             else             {                 printf( "Some error occured!\n" );             }         }         else         {             printf( "Memory allocate failue\n" );         }     }     else     {         printf( "Some error occured!\n" );     }         getchar();    return 0; } 

热点排行