winsock2.h在最开始include
ip的一些工具函数在Iphlpapi.h,
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#pragma comment(lib, "Ws2_32.lib")
windows.h默认加载winsock版本1.
winsock2.h默认加windows.h
不得不加windows.h时候记得加宏WIN32_LEAN_AND_MEAN
#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> #include <iphlpapi.h> #include <stdio.h> #pragma comment(lib, "Ws2_32.lib") int main() { return 0; }