1. Under Unicode encoding, the characters in CString are declared as wide words and should be obtained using the following method char*
CString Cstrip = strIp; // Convert CString to char* under Unicode int n = cstrip.getlength (); int len = WideCharToMultiByte (CP_ACP,0, Cstrip,cstrip.getlength (), NULL,0, null,null) ; Char New Char [len+1]; WideCharToMultiByte (CP_ACP,00;
View Code
2. Convert the IP address described by char* to Wdord
DWORD Dwip = inet_addr (p);
View Code
3. Assigning a DWORD value to a CIPAddressCtrl control
//get the Dwordip address from low to high, such as 127.0.0.1, will get 0x0100007f//need to be convertedm_host_ip. Setaddress ((Dwip&0xFF),//get 0~7 bit(Dwip &0xff00) >>8,//get 15~8 bit(Dwip &0xFF0000) >> -,//get 23~16 bit(Dwip &0xff000000) >> -);//get 31~24 bit
View Code
As above is all the code, if you have a more simple way, welcome advice ~
Under MFC Unicode encoding, get the IP address described by CString and assign it to the CIPAddressCtrl control