今天在写一个获取网络连接的程序,其中用到了GetTcpTable函数,这个函数的声明在Iphlpapi.h
#include <Iphlpapi.h>
#include <Winsock2.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
我是这样包含Iphlpapi.h,在编译的时候提示
-------------------Configuration: EnumTcpTable - Win32 Debug--------------------
Compiling...
EnumTcpTable.cpp
c:/program files/microsoft sdks/windows/v5.0/include/ras.h(61) : error C2065: 'HRASCONN' : undeclared identifier
c:/program files/microsoft sdks/windows/v5.0/include/ras.h(61) : error C2501: 'DECLARE_HANDLE' : missing storage-class or type specifiers
c:/program files/microsoft sdks/windows/v5.0/include/ras.h(74) : error C2146: syntax error : missing ';' before identifier 'dwSize'
..........................................................
乱七八糟的错误。。。
弄了半天才搞定,原来要把Winsock2.h声明到Iphlpapi.h的上面。
#include <Winsock2.h>
#include <Iphlpapi.h>