我的要求是c:\test.exe已经调用成功,主程序后面的代码才继续执行

解决方案 »

  1.   

    是调用成功是吧?不是运行结束吧。
    shell "para"
    doevents
      

  2.   

    if shell ("C:\test")=0 then exit sub
      

  3.   

    Option ExplicitPrivate Declare Function WaitForSingleObject Lib "Kernel32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
    Private Declare Function CreateProcessA Lib "Kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As LongPrivate Type PROCESS_INFORMATION
        hProcess    As Long
        hThread     As Long
        dwProcessID As Long
        dwThreadID  As Long
    End TypePrivate Type STARTUPINFO
        cb              As Long
        lpReserved      As Long
        lpDesktop       As Long
        lpTitle         As Long
        dwX             As Long
        dwY             As Long
        dwXSize         As Long
        dwYSize         As Long
        dwXCountChars   As Long
        dwYCountChars   As Long
        dwFillAttribute As Long
        dwFlags         As Long
        wShowWindow     As Integer
        cbReserved2     As Integer
        lpReserved2     As Long
        hStdInput       As Long
        hStdOutput      As Long
        hStdError       As Long
    End TypePrivate Sub Command1_Click()
        Dim start As STARTUPINFO, proc As PROCESS_INFORMATION
        
        CreateProcessA 0&, "C:\Program Files\Microsoft Office\Office\WINWORD.EXE", 0&, 0&, 1&, _
              0, 0&, 0&, start, proc
        WaitForSingleObject proc.hProcess, -1
        
        MsgBox "OK"
    End Sub
      

  4.   

    这是调用的WORD,只有WORD执行完之后关闭了,才显示 OK,你试一下吧~~