在写MFC程序时候,有时候会遇到类型转换的问题,尤其是CStrig到其他类型的转换。

今天我就遇到了CString 到 char[]数组的转换问题---->原来VC6.0里面的在VS2010中出错。

CString-->char[]

char sendBuf[100];
CString m_send_message;
CStringA strTmp;
strTmp=m_send_message;          
strcpy(sendBuf,strTmp);

 

LPARAM-->CString

vc6中可以直接使用:

CString str = (char *)lParam;

而VS2010中必须改为下面的:

CString str = (TCHAR*)lParam;

 

记录一个IP地址的使用方法:

DWORD dwIP;
((CIPAddressCtrl*)GetDlgItem(IDC_IPADDRESS))>GetAddress(dwIP);

很简单~~

相关文章:

  • 2022-12-23
  • 2021-08-22
  • 2022-01-21
  • 2022-01-13
  • 2022-12-23
  • 2021-07-16
  • 2021-09-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-01-24
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案