# Re: 如何判断程式结束？

Posted by cww on March 26, 1998 at 17:27:30:

In Reply to: 如何判断程式结束？ posted by Roland on March 25, 1998 at 18:31:25:

如果使用WaitForSingleObject会等待该process结束才release出控制权。
那除了用吴站长所说的FindWindow()外或许使用以下方式也可以

Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ALIVE = &H103

pid = shell(....)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While ExitCode = STILL_ALIVE

因使用doEvents所以会不时Check是否有其他的讯息待处理而先处理
，我想这应不会hand住了，试试看

Follow Ups:

- 非常感谢！但另一个问题...... Roland 19:06:40 3/26/98 (1)
  - Re: 似乎快没办法了 cww 19:22:01 3/27/98 (0)