1.关于
演示环境: win10+VS2017
2.支持
需要下面的库支持:
ws2_32.lib
需要下面的宏
,添加到项目属性-> c/c++ -> 预处理器定义
_WINSOCK_DEPRECATED_NO_WARNINGS
3.ipv4查询
int net_adapter_helper::get_ipv4_win(std::list<std::string>& out_list_ip4)
{
int error_id = 0;
WORD sock_ver;
WSADATA wsaData;
int ret_val = 0;
sock_ver = MAKEWORD(2, 2);
ret_val = WSAStartup(sock_ver, &wsaData);
if (0 != ret_val)
{
error_id = GetLastError();
return error_id;
}
if ( 2 != LOBYTE(wsaData.wVersion) ||
2 !=HIBYTE(wsaData.wVersion) )
{
WSACleanup();
error_id = GetLastError