Module:
VB Code:
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Const STILL_ACTIVE = &H103 Const PROCESS_QUERY_INFORMATION = &H400 Sub Shell32Bit(ByVal jobtodo As String) Dim hProcess As Long Dim RetVal As Long 'captures process ID hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(jobtodo, 0)) Do 'Get the status of the process GetExitCodeProcess hProcess, RetVal 'Sleep command recommended as well as DoEvents DoEvents: Sleep 100 'Loop while the process is active Loop While RetVal = STILL_ACTIVE End Sub
usage:
VB Code:
Call Shell32Bit("C:\ExsternalApp.exe")




Reply With Quote