資源簡介
Mfc獲取本機 IP地址!

代碼片段和文件信息
#include??
#include??
#pragma?comment(lib“ws2_32.lib“)?
void?main()?
{?
WSADATA?wsadata;?
WORD?dwVersionRequested;?
int?err;?
err=WSAStartup(dwVersionRequested&wsadata);?
char?hostname[128];?
if(gethostname(hostname128)==0)?
{?
printf(“%s\n“hostname);//計算機名字?
}?
struct?hostent?*pHost?=?gethostbyname(hostname);?
for?(int?i?=?0;?pHost?!=?NULL?&&?pHost->h_addr_list[i]?!=?NULL;?i++)?
{?
printf(“%s\n“inet_ntoa(*(struct?in_addr?*)pHost->h_addr_list[i]));?
}?
WSACleanup();?
}?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????172098??2010-08-19?23:14??獲取本機IP\Debug\IP.exe
?????文件??????12510??2010-08-19?23:14??獲取本機IP\Debug\IP.obj
?????文件?????345088??2010-08-19?23:14??獲取本機IP\Debug\IP.pdb
?????文件??????77824??2010-08-19?23:14??獲取本機IP\Debug\vc60.pdb
?????文件????????531??2010-08-19?23:14??獲取本機IP\IP.cpp
?????文件???????3353??2010-08-19?23:14??獲取本機IP\IP.dsp
?????文件????????512??2010-08-19?23:16??獲取本機IP\IP.dsw
?????文件??????33792??2010-08-19?23:16??獲取本機IP\IP.ncb
?????文件??????48640??2010-08-19?23:16??獲取本機IP\IP.opt
?????文件???????1260??2010-08-19?23:14??獲取本機IP\IP.plg
?????目錄??????????0??2011-01-10?11:59??獲取本機IP\Debug
?????目錄??????????0??2011-01-10?11:59??獲取本機IP
-----------?---------??----------?-----??----
???????????????695608????????????????????12
- 上一篇:source insight 配置文件超好
- 下一篇:c語言連接sql server
評論
共有 條評論