我写了一段写入注册表的代码:
         TCHAR TempPath[MAX_SIZE];
         CString temp;
::GetSystemDirectory(TempPath,MAX_SIZE);
temp=TempPath;
temp+=_T("\\FourHours.exe");
int len=temp.GetLength();
LPBYTE lpb=new BYTE[len];
for(int j=0;j<len;j++)
{
lpb[j]=TempPath[j];
}
lpb[len]=0;
HKEY hKey;
LPCTSTR data_set="SoftWare\\MicroSoft\\Windows\\CurrentVersion\\Run";
::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_set,0,KEY_WRITE,&hKey);
::RegSetValueEx(hKey,"FourHours",NULL,REG_SZ,lpb,len);
::RegCloseKey(hKey);
         delete []lpb;
按道理说,我在内存new了一片字节数组的指针,应该匹配的delete它,但是只要我将delete[]lpb加入程序,都会提示我未处理异常:用户断点的错我。我想请问,new和delete不应该是匹配的用的吗?到底有什么问题呢?