描述:
我的接口函数如下:
STDMETHODIMP UdpChat::SendChatMsg(BSTR IpAddress, LONG port, BSTR Msg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
//将要发送的内容转换成ANSI字符串
_bstr_t bstrMsg = Msg;
char* lpszMsg = bstrMsg;
//发送
m_sSocket.SendTo(lpszMsg,(int)strlen(lpszMsg),port,IpAddress);
return S_OK;
}
其中SendTo的第4 个参数的类型上报错误:
error C2664: 'int __thiscall CAsyncSocket::SendTo(const void *,int,unsigned int,const char *,int)' : cannot convert parameter 4 from 'unsigned short *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
SendTo的第4 个参数是LPCTSTR类型的 请教大侠我该做如何转换才可以啊?????
解决方案1:
#pragma comment(lib,"comsupp.lib")