Results 1 to 2 of 2

Thread: To wait till the shell has executed:

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    To wait till the shell has executed:

    Module:
    VB Code:
    1. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    2. Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    3. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    4. Const STILL_ACTIVE = &H103
    5. Const PROCESS_QUERY_INFORMATION = &H400
    6.  
    7. Sub Shell32Bit(ByVal jobtodo As String)
    8.          Dim hProcess As Long
    9.          Dim RetVal As Long
    10.           'captures process ID
    11.          hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(jobtodo, 0))
    12.              
    13.          Do
    14.  
    15.              'Get the status of the process
    16.              GetExitCodeProcess hProcess, RetVal
    17.  
    18.              'Sleep command recommended as well as DoEvents
    19.              DoEvents: Sleep 100
    20.                    
    21.  
    22.          'Loop while the process is active
    23.          Loop While RetVal = STILL_ACTIVE
    24. End Sub

    usage:
    VB Code:
    1. Call Shell32Bit("C:\ExsternalApp.exe")

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147
    Sorry pressed the wrong button was trying to reply to another thred.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width