Thank you.
Conax
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
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 Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
'---------------------------------------------------------------------------
----------------------------
Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal
lpApplicationName As String, ByVal lpCommandLine As String, ByVal
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal
bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As
Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO,
lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long,
ByVal dwMilliSeconds As Long) As Long
'---------------------------------------------------------------------------
----------------------------
Function ExecuteApplication(ByVal strApplication As String, Optional ByVal
strCommandLine As String, Optional ByVal bWait As Boolean = True) As Long
Dim udtStartup As STARTUPINFO
Dim udtProcess As PROCESS_INFORMATION
Dim lPID As Long
lPID = CreateProcess(strApplication, strCommandLine, 0, 0, False, 0,
ByVal 0&, vbNullString, udtStartup, udtProcess)
If lPID <> 0 Then
CloseHandle udtProcess.hThread
If bWait Then
WaitForInputIdle udtProcess.hProcess, &HFFFF
End If
End If
ExecuteApplication = lPID
End Function
'---------------------------------------------------------------------------
----------------------------
To use:
ExecuteApplication "myapp.exe"
Conax <con...@olympic.co.nz> wrote in message
news:01be5f8a$1da83100$8664a8c0@conwaynew...