鹿我所录的博客

记录我在学习C#中的点点滴滴,记录下以备后来人借鉴。

 

VC++ 将IP字符串转为 DWORD值

CString strIP="192.168.1.184";   

DWORD dwAddress= ntohl( inet_addr(strIP));   

m_IPAddr.SetAddress(dwAddress);
//---------------------------------------

DWORD dwMainServerIP;  
m_MainServerIPCtrl.GetAddress(dwMainServerIP);  
strMainServerIP.Format(_T("%d.%d.%d.%d"),   
(dwMainServerIP>>24)&0xff,   
(dwMainServerIP>>16)&0xff,   
(dwMainServerIP>>8)&0xff,   
dwMainServerIP&0xff ) ;

posted on 2015-08-27 09:54  鹿我所录  阅读(959)  评论(0编辑  收藏  举报

导航