当前位置: 代码迷 >> VC >> VS2005程序未处理AccessViolationException的异常,请大家帮小弟我看看
  详细解决方案

VS2005程序未处理AccessViolationException的异常,请大家帮小弟我看看

热度:5408   发布时间:2013-02-25 00:00:00.0
VS2005程序未处理AccessViolationException的错误,请大家帮我看看
在VS2005下编译没有问题,但是执行程序时出错:
“未处理AccessViolationException。尝试读取或写入受保护的内存。这通常指示其他内存已损坏。” 
测试样例是用一个按钮点击,创建一个进程。代码拷贝的MSDN: 
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) 
  STARTUPINFO si; 
  PROCESS_INFORMATION pi; 
  ZeroMemory( &si, sizeof(si) ); 
  si.cb = sizeof(si); 
  ZeroMemory( &pi, sizeof(pi) ); 
  // Start the child process. 
  if( !CreateProcess( NULL, // No module name (use command line). 
  TEXT("MyChildProcess"), // Command line. 
  NULL, // Process handle not inheritable. 
  NULL, // Thread handle not inheritable. 
  FALSE, // Set handle inheritance to FALSE. 
  0, // No creation flags. 
  NULL, // Use parent's environment block. 
  NULL, // Use parent's starting directory. 
  &si, // Pointer to STARTUPINFO structure. 
  &pi ) // Pointer to PROCESS_INFORMATION structure. 
  ) 
  { 
  printf( "CreateProcess failed (%d).\n", GetLastError() ); 
  return; 
  } 

  // Wait until child process exits. 
  WaitForSingleObject( pi.hProcess, INFINITE ); 

  // Close process and thread handles. 
  CloseHandle( pi.hProcess ); 
  CloseHandle( pi.hThread ); 

请大侠们指点小弟,多谢了!!

------解决方案--------------------------------------------------------
先看代码调试等,看出错的代码是哪一行...
------解决方案--------------------------------------------------------
看不出来是什么地方的问题,你RebuildAll试一下,也许是别的地方的问题
  相关解决方案