为什么传送文字时就是识别不了啊。MSDN上说可以用TCHAR代替char.我加了"TCHAR.H"头文件后,用TCHAR代替char.但是还是乱码请大虾帮忙。
部分程序如下:
void CSCommTestDlg::OnFilestart()
{
CFile file;
CFileStatus filestatus;
// int flag1=1;//标记
CString string;
CString str="";
CString filestring;
CString sendstring="";
if(m_sendfile=="No File!")
MessageBox("请输入正确的文件名和路径!","错误",MB_ICONERROR);
else
{
if(CFile::GetStatus(m_sendfile,filestatus))
{
char *pfile=m_sendfile.GetBuffer(0);
file.Open(pfile,CFile::modeRead,NULL);
file.SeekToBegin();
TCHAR pedit;//这里有问题
int leng=file.GetLength();
for(int j=0;j<leng;j++)
{
file.Rea(&pedit,1);///////////从文件中逐个读取字
}
file.SeekToBegin();
filestring="";
for (int m=0;m<leng;m++)
{
file.Read(&pedit,1);
filestring+=pedit;
}
char *str=filestring.GetBuffer(0);
long k=strlen(filestring);
for( int filecount=0;filecount<k;filecount=filecount+2)
{
int ij=filecount;
sendstring=str[ij];
sendstring+=str[ij+1]
m_ctrlComm.SetOutput(COleVariant(sendstring));
}
}
}
}