Relevant structures and declares are :
Private Const STARTF_USESHOWWINDOW = &H1
Private Const STARTF_USESIZE = &H2
Private Const STARTF_USEPOSITION = &H4
Private Const STARTF_USECOUNTCHARS = &H8
Private Const STARTF_USEFILLATTRIBUTE = &H10
Private Const STARTF_RUNFULLSCREEN = &H20
Private Const STARTF_FORCEONFEEDBACK = &H40
Private Const STARTF_FORCEOFFFEEDBACK = &H80
Private Const STARTF_USESTDHANDLES = &H100
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
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 Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Declare Function CreateProcess Lib "kernel32" _
Alias "CreateProcessA" _
(ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
lpProcessAttributes As SECURITY_ATTRIBUTES, _
lpThreadAttributes As SECURITY_ATTRIBUTES, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
lpEnvironment As Any, _
ByVal lpCurrentDriectory As String, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
There's lots on MSDN and elsewhere about using these.
You can start your app with :
Dim l_uStartInfo As STARTUPINFO
Dim l_uProcInfo As PROCESS_INFORMATION
Dim l_uSecurity As SECURITY_ATTRIBUTES
Dim l_lReturnValue As Long
With l_uStartInfo
.lpDesktop = vbNullString
.lpTitle = vbNullString
.lpReserved = vbNullString
.cbReserved2 = 0
.dwX = 0
.dwY = 0
.dwXSize = <a value in pixels>
.dwYSize = <a value in pixels>
.dwFillAttribute = 0
.dwFlags = STARTF_USESIZE + STARTF_USEPOSITION
.cb = Len(l_uStartInfo)
End With
l_uSecurity.nLength = Len(l_uSecurity)
l_lReturnValue = CreateProcess(vbNullString, <CommandString>, l_uSecurity, l_uSecurity, 0, 0, 0, vbNullString, l_uStartInfo, l_uProcInfo)
l_lReturnValue = WaitForSingleObject(l_uProcInfo.hProcess, 1000) ' Wait up to 5 secs for process to start
This always returns a process id and handle.
If the other apps are yours, you could get them to send you a message on exiting. Otherwise, find the main window of the app using EnumWindows and then poll it (eg with SendMessage) to detect when it disappears!