超级版主
注册日期: 04-03
帖子: 18592
精华: 36
现金: 249466 标准币
资产: 1080358888 标准币
|
【转帖】请问怎么样把一个CString类型的变量转换成BYTE类型,逆向的呢?
//第一种 CString To LPBYTE
CString strTemp="test";
BYTE* pTemp=(LPBYTE)strTemp.GetBuffer(0);
//第二种 CString To LPBYTE
CString strTemp2="test2";
BYTE byTemp[50];
memcpy(byTemp,strTemp2,strTemp2.GetLength());
byTemp[strTemp2.GetLength()]='\0';
//第三种 CString To LPBYTE
CString strTemp3="test3";
LPBYTE pTemp2=new BYTE[strTemp3.GetLength()];
memcpy(pTemp2,strTemp3,strTemp3.GetLength());
pTemp2[strTemp3.GetLength()]='\0';
//...............................................
//第一种 LPBYTE to CString
CString strTemp4;
strTemp4.Format("%s",(LPCSTR)pTemp2);
//第二种 LPBYTE to CString
CString strTemp5;
strTemp5=(LPCSTR)pTemp2;
以上5种相互转换方式够你用的了。
Good Luck
__________________
借用达朗贝尔的名言:前进吧,你会得到信心!
[url="http://www.dimcax.com"]几何尺寸与公差标准[/url]
|