//服务器地址信息
SOCKADDR_IN addrSock;
addrSock.sin_addr.S_un.S_addr=inet_addr(m_ServerIP);
addrSock.sin_family=AF_INET;
2.addrSock.sin_port=htons(_ttoi(m_ServerPort));
其中红色字体m_ServerIP和m_ServerPort为CString类型。利用CStingA 和_ttoi分别转换为const char* 和int型
3.CString 与 void *类型转换
(1)CString 转换成 void *
CString str;
void *p;
p = (void*)str.GetBuffer(str.GetLength());
(2)void * 转换成CString
CString str;
void *p;
str.format("%S",(char*)p);
4.CString转换为LPWSTR
CString str;
LPWSTR pstr = (LPWSTR)(LPCWSTR)str;