涉及到程序更新的问题:
A启动B,B自身需要更新,在B退出时再调用A,进行将B替换成新文件的工作,但这时A进行文件操作,不法替换B,用任务管理器看了下,A在替换B时,B似乎并未退出,但是我就是在B即将退出的时候才再次启动A,而且在A中会循环尝试,不致于一次也没成功呀!?
疑惑,是否用WinExec启动的程序,有某种所属关系,造成了B启动A,A尝试用新版本替换B时,B并未退出?
简单表示:
A->B,B->A (替换B,这时不成功,B似乎并未退出?)年前的最后一个问题,解决了就放假,谢谢大家!

解决方案 »

  1.   

    疑惑,是否用WinExec启动的程序,有某种所属关系,造成了B启动A,A尝试用新版本替换B时,B并未退出? 
    ==========
    应该没有这回事,子进程启动不会影响到父进程的退出的
      

  2.   

    我在B的CWinApp析构里调用WinExec,启动A,这时B都被析构掉了呀
      

  3.   

    给我的感觉是,WinExec这时变成了阻塞操作的函数,只有A退出,B才退出,晕!!!
      

  4.   

    MSDN:
    The WinExec function returns when the started process calls the GetMessage function or a time-out limit is reachedTo avoid waiting for the time out delay, call the GetMessage function as soon as possible in any process started by a call to WinExec.
      

  5.   

    另外,现在使用WinExec不是很合适了(This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.)
    最好改成CreateProcess
      

  6.   

    WinExec确实是阻塞操作,只有子进程调用了GetMessage或超时才返回。这个问题可以调用CreateProcess解决