有个ini配置文件void CTDlg::OnButton2() {CString str;str = str的内容是从ini文件读取的然后AfxMessageBox("update t_temp  set newaccname=concat(newaccname,'" + cstr1 + "@game.sohu.com')");然弹出的对话框 里少了 cstr1的内容;
我又单独用AfxMessageBox(cstr1);又显示了内容;最后我直接把赋值 str=“b”;全部都没问题。str = str的内容是从ini文件读取的,为什么这样就会出问题

解决方案 »

  1.   

    CString ming::GetIniString(char *AppName, CString KeyName, CString FileName) //读取ini文件
    {
    CString Rstr;
        GetPrivateProfileString(AppName,KeyName,NULL,Rstr.GetBuffer(MAX_PATH),MAX_PATH,FileName);
    Rstr.ReleaseBuffer();
    return Rstr;
    }Rstr.ReleaseBuffer(); 为什么我在读取INI文件里加了一句这个就解决了那个错误问题
      

  2.   

    If you use the pointer returned by GetBuffer to change the string contents, you must call ReleaseBuffer before using any other CSimpleStringT member methods.