分类：电脑/网络-程序设计
问题：vb中的shell我想用VB写个程序:用shell运行另一个会自 
我想用写个程序:用shell运行另一个会自动结束的程序,并且测出它被运行的时间.   换句话说就是:用shell运行了某exe后,怎样知道这个exe是否结束.
回答：'有多种方法可以实现这个需求,下面提供一种方法,供参考:Optn ExplicitPrivate Const WAIT_INFINITE = -1&Private Const SYNCHRONIZE = &H100000Private Declare Function OpenProcess Lib "kernel32" _  (ByVal dwDesiredAccess As Long, _   ByVal bInheritHandle As Long, _   ByVal dwProcessId As Long) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" _  (ByVal hHandle As Long, _   ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" _  (ByVal hObject As Long) As LongPrivate Sub Command1_Click()   Dim hProcess As Long   Dim taskId As Long   Dim cmdline As String   cmdline = "notepad.exe"   taskId = Shell(cmdline, vbNormalFocus)   hProcess = OpenProcess(SYNCHRONIZE, True, taskId)   Call WaitForSingleObject(hProcess, WAIT_INFINITE)   CloseHandle hProcess   MsgBox "调用记事本程序结束."End Sub