弹出的错误提示为:
Debug Error!
Program:D:\vc\vc6cn\MyProjects\Panda000\Debug\Panda.exe
DAMAGE:after Normal block (#287) at 0x0038F690.下面是出现错误的代码段:
       if(0==f_process.string[i].CompareNoCase("explorer.exe"))
{

     CString st(a);
                     LPTSTR b=st.GetBufferSetLength(10);
 strcat(b,"\\explorer.exe");
 MessageBox(b);
   
 if((0==f_process.CmdPath[i].Compare("suspicious/Small Path.")) 
 || (0==f_process.CmdPath[i].Compare("suspicious/Invalide Path."))
 || (0==f_process.CmdPath[i].Compare("Virus Process!")))
 {
 }
 else if(0!=f_process.CmdPath[i].CompareNoCase(b))          //判断路径
      f_process.CmdPath[i].Format("Virus Process!");
 else if((0!=f_process.string[i].Compare("explorer.exe"))     //判断名称
 && (0!=f_process.string[i].Compare("EXPLORER.EXE"))
 && (0!=f_process.string[i].Compare("Explorer.EXE")))   
      f_process.CmdPath[i].Format("Virus Process!");
}错误在哪里?

解决方案 »

  1.   

    LPTSTR b=st.GetBufferSetLength(10);
    strcat(b,"\\explorer.exe");
    MessageBox(b); 
    内存分配的太少了。"\\explorer.exe"本身长为13个字节。
    所以应该是
    LPTSTR b=st.GetBufferSetLength(14);//最好是为它多分配一个用于存“\0”
    strcat(b,"\\explorer.exe");
    MessageBox(b); 
      

  2.   

    strcat(b,"\\explorer.exe")越界了,b指向的缓冲区长度只有10。你可以用st+="\\explorer.exe";
      

  3.   

    GetBuffer之后一定要ReleaseBuffer,否则CString不能收回内存的管理权,其它的访问操作都属违法。
    实在看不懂你代码的意思。
      

  4.   


    请问是GetBuffer 调用后 马上ReleaseBuffer 还是cstring 用完后再ReleaseBuffer 
    要是N次GetBuffer 是一次ReleaseBuffer 还是N次?
    不太经常用cstring 嘿嘿
      

  5.   

    每次GetBuffer之后要马上ReleaseBuffer,一一对应