怎样获取ip地址和子网掩码设置ip地址和子网掩码


//GetIPMask.cpp:Definestheentrypointfortheconsoleapplication.//

#include"stdafx.h"#include#include#include

typedefstruct_sockaddr_gen{sockaddr_inAddressIn;BYTEfiller[8];}sockaddr_gen;

typedefstruct_INTERFACE_INFO{u_longiiFlags;sockaddr_geniiAddress;sockaddr_geniiBroadcastAddress;sockaddr_geniiNetmask;}INTERFACE_INFO,*PINTERFACE_INFO;

intmain(intargc,char*argv[]){WSADATAbWsaData;WORDwVerisionRequested;SOCKETbSocket;intiRetValue=0;INTERFACE_INFObInterfaceInfo[10];DWORDdlByteReturn=0;intiNumOfInterface=0;