请问,能不能在VC程序中获得本机上网后的动态IP地址,如果可以,请问,如何实现呢
解决方案 »
- 如何修改一个delphi 编写的程序中的数据库连接字符串
- 一个关于 _variant_t类型 的问题,高手救救急!!!
- 本人闲的无聊做了一个小软件 可免费下载电影, 欢迎大家过来测试
- vc忽略了异常规范,能让他不忽略吗?
- 请教:如何在自定义的类中往滚动视窗上写文字?急!急!急!急!立即结帐!谢谢!
- 怎样改变LISTCTRL中的字体?为什么我找不到ON_WM_ERASEBKGND这条消息!
- DCOM为什么会拒绝服务呀~我都快疯了!!!!!!!
- 实现U盘初始化流程。
- 请问如何在列表控件中画直线?
- 请教一下关于制作DLL的一个问题
- 请问当我输入数字时, 为什么程序会输出"not digital"?
- 8。13终于向经理说辞职了,两年来对这个公司真有点佘不得,,而前面的道路有不太明亮。。。。
The GetIpAddrTable function retrieves the interface–to–IP address mapping table.DWORD GetIpAddrTable(
PMIB_IPADDRTABLE pIpAddrTable, // buffer for mapping table
PULONG pdwSize, // size of buffer
BOOL bOrder // sort the table
);MIB_IPADDRTABLE
The MIB_IPADDRTABLE structure contains a table of IP address entries.typedef struct _MIB_IPADDRTABLE {
DWORD dwNumEntries; // number of entries in the table
MIB_IPADDRROW table[ANY_SIZE]; // array of IP address entries
} MIB_IPADDRTABLE, *PMIB_IPADDRTABLE;MIB_IPADDRROW
The MIB_IPADDRROW specifies information for a particular IP address.typedef struct _MIB_IPADDRROW {
DWORD dwAddr; // IP address
DWORD dwIndex; // interface index
DWORD dwMask; // subnet mask
DWORD dwBCastAddr; // broadcast address
DWORD dwReasmSize; // rassembly size
unsigned short unused1; // not currently used
unsigned short unused2; // not currently used
} MIB_IPADDRROW, *PMIB_IPADDRROW;
{
char name[100];
::gethostname (name,100);
hostent *host=gethostbyname((const char *)name);
if(host==NULL)//dns查询错误
{
return "";
}
else
{
in_addr addr;
memcpy((void*)&addr.S_un .S_addr ,*host->h_addr_list,sizeof(in_addr));
return CString(inet_ntoa (addr));
}
}