Gustav Brock
gustav at cactus.dk
Thu Apr 22 11:39:08 CDT 2004
Hi Steven Here's an example: <code> Public Function ShellExecute( _ ByVal strPathname As String, _ Optional lngAppWinStyle As Long = vbHide) _ As Boolean ' Start other application and wait for it to finish. ' lngAppWinStyle: ' ' vbHide 0 ' vbNormalFocus 1 ' vbMinimizedFocus 2 ' vbMaximizedFocus 3 ' vbNormalNoFocus 4 ' vbMinimizedNoFocus 6 Const cbInheritHandles As Long = 1 Dim proc As PROCESS_INFORMATION Dim Start As STARTUPINFO Dim lngReturn As Long On Error GoTo Err_ShellExecute ' Initialize the STARTUPINFO structure: With Start .cb = Len(Start) .dwFlags = STARTF_USESHOWWINDOW .wShowWindow = lngAppWinStyle End With ' Load the shelled application. lngReturn = CreateProcessA(0, strPathname, 0, 0, cbInheritHandles, NORMAL_PRIORITY_CLASS, 0, 0, Start, proc) ' Wait for the shelled application to finish. lngReturn = WaitForSingleObject(proc.hProcess, INFINITE) With proc lngReturn = WaitForSingleObject(.hProcess, INFINITE) ' Close both Process and Thread to prevent memory leak. lngReturn = CloseHandle(.hProcess) And CloseHandle(.hThread) End With ShellExecute = True Exit_ShellExecute: Exit Function Err_ShellExecute: MsgBox "Shell Error: " & Err.Number & ". " & Err.Description, vbCritical, Err.Source Resume Exit_ShellExecute End Function </code> Watch for line breaks. /gustav