如何用程序获得adsl拨号后的IP地址?急 adsl拨号软件是enternet300,我用GetAdaptersInfo函数获取到所有网络适配器的IP地址,但是无法用程序判断哪个是拨号后的IP地址。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 struct hostent *phost; char ip[20]; char hostname[50]; gethostname(hostname,50); phost=gethostbyname(hostname); char **names; names=phost->h_aliases; char **iplist; iplist=phost->h_addr_list; while(* iplist) { strcpy(ip,inet_ntoa(*(struct in_addr *)*iplist)); iplist++; } CString LocalIp=ip; //if(LocalIp.GetLength()<7) if (!strncmp(LocalIp,"192.168.",8)) AfxMessageBox("得IP失败,可能还没有拔号!"); return LocalIp; typedef struct _IP_ADAPTER_INFO { struct _IP_ADAPTER_INFO* Next; DWORD ComboIndex; char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4]; char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]; UINT AddressLength; BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]; DWORD Index; UINT Type; UINT DhcpEnabled; PIP_ADDR_STRING CurrentIpAddress; IP_ADDR_STRING IpAddressList; IP_ADDR_STRING GatewayList; IP_ADDR_STRING DhcpServer; BOOL HaveWins; IP_ADDR_STRING PrimaryWinsServer; IP_ADDR_STRING SecondaryWinsServer; time_t LeaseObtained; time_t LeaseExpires; } IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;看上面结构中的Type域。 庆升5角,顺便提个建议。 CInternetSession Host变化问题 关于girdview的问题 多个进程要怎么样共享一个缓冲啊> <` 中英文XP下用ADO访问数据库区别? 类似QQ 聊天记录的 .dat文件是如何弄的 视图重绘 请问怎样在程序中直接打开外部文件,比如.exe,.txt,.doc??? 哪位大哥帮我介绍一下tree view控件是怎么用的?? dbgrid控件的数据刷新问题!请赐教。 在线提问送分!!COM在mozilla上支持吗?我要实现通过浏览器对本机串口进行通讯,应该选择什么技术? 同一窗口有多组单选钮,可是每次只有一个选中;正确应是各组都有一个选中,如何设?
char ip[20];
char hostname[50]; gethostname(hostname,50);
phost=gethostbyname(hostname); char **names;
names=phost->h_aliases;
char **iplist;
iplist=phost->h_addr_list;
while(* iplist)
{
strcpy(ip,inet_ntoa(*(struct in_addr *)*iplist));
iplist++;
} CString LocalIp=ip;
//if(LocalIp.GetLength()<7)
if (!strncmp(LocalIp,"192.168.",8))
AfxMessageBox("得IP失败,可能还没有拔号!");
return LocalIp;
struct _IP_ADAPTER_INFO* Next;
DWORD ComboIndex;
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
UINT AddressLength;
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD Index;
UINT Type;
UINT DhcpEnabled;
PIP_ADDR_STRING CurrentIpAddress;
IP_ADDR_STRING IpAddressList;
IP_ADDR_STRING GatewayList;
IP_ADDR_STRING DhcpServer;
BOOL HaveWins;
IP_ADDR_STRING PrimaryWinsServer;
IP_ADDR_STRING SecondaryWinsServer;
time_t LeaseObtained;
time_t LeaseExpires;
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;看上面结构中的Type域。