如何判断一个程序是否执行完毕?

如何判断一个程序是否执行完毕?不是通过取TITLE的方式啊
[29 byte] By [xiaobzg-小兵张嘎] at [2007-12-12]
# 1
FUNCTION ulong FindWindowEx(ulong hWnd1,ulong hWnd2,ref string lpsz1,ref string lpsz2) LIBRARY "user32.dll" ALIAS FOR "FindWindowExA"
FUNCTION ulong GetWindowText(ulong hwnd,ref string lpString,ulong cch) LIBRARY "user32.dll" ALIAS FOR "GetWindowTextA"

string ls_title_app2find //欲查找的窗口标题
long ll_winhandle //句柄
string ls_classname,ls_windowname //窗口类及窗口名称
string ls_null
boolean lb_running=false //是否运行标识

setnull(ls_null)
ls_windowname=space(256)

ls_classname='FNWND360'

/*窗口类名称,对于PB窗口,如果是Popup型或Response型,则
ls_classname='FNWNS360'
其他类型则为'FNWND360'
PB8则为'FNWNS380'及'FNWND380'
*/

ll_winhandle=findwindowex(0,ll_winhandle,ls_classname,ls_null)

do
getwindowtext(ll_winhandle,ls_windowname,255)

if ls_windowname=ls_title_app2find then
lb_running=true
exit
end if
ll_winhandle=findwindowex(0,ll_winhandle,ls_classname,ls_null)
loop while ll_winhandle>0

return lb_running