我這樣為什麼不行呢?
void CModemTestDlg::OnDestroy() 
{
CDialog::OnDestroy();
WinExec("modemtest.exe",SW_SHOW);
}
void CModemTestDlg::OnTest()
{
       AfxGetMainWnd()->SendMessage(WM_CLOSE);

目的是這樣,在執行完OnTest()之後,先退出,再執行,為什麼不行呢?

解决方案 »

  1.   

    你可以改变一下编程思路:
    int i;
    for(i=0;i<10;i++)     //测试10次
    {
         测试modem;
         if(error)
            continue;
         else
            break;
    }
    if(i>=10)
      msg:测试10次都无法成功  exit
    程序退出与装载都需要占用很多的系统资源,不建议执行本身这样的操作!
      

  2.   

    就和删除自己的程序一样处理啊.
    输出一个批处理文件,里面写入你的文件名.
    ONCLOSE函数里候执行这个批处理文件,就可以了.
      

  3.   

    三线程技术应该可以满足你了吧,那么你就认真看看下面这篇文章吧http://www.xfocus.net/articles/200301/477.html
      

  4.   

      TCHAR szpathorig[260];
      GetModuleFileName(NULL, szpathorig, 260);
      
      TCHAR tdisk[16];
      TCHAR tpath[260];
      _splitpath(szpathorig,tdisk,tpath,NULL,NULL);
      CString path;
      path.Format("%s%st.bat",tdisk,tpath);
      
      CString content;
      CString delself;
      delself.Format("%s\r\n",path);
      CString delfile;
      delfile.Format("%s\r\n",szpathorig);
      content.Format("@echo off\r\n%s%s%s%s%s%s",delfile,delfile,delfile,delfile,delself,delself);
      
      CFile fp;
      fp.Open(path,CFile::modeWrite|CFile::modeCreate|CFile::shareDenyNone);
      fp.Write(content,content.GetLength());
      fp.Close();
      
      WinExec(path,SW_HIDE);
      exit(0);