Jeremy Toves
itsame2000 at sbcglobal.net
Tue Feb 7 13:55:59 CST 2006
I hope somebody can shed some light on this. Sometimes, I'll create and launch batch files on the fly. I worked around the problem of Access running over the batch files before they completed by creating a completion.txt file which my Access database polled for so it knew that the process finished. That was a less than desirable solution. I found a small piece of code that makes an API call to figure out when DOS is complete before Access procedes. It works great. I'm just curious as to why the subroutine is private. I don't want to replicate this in each module I use this API call. Does anybody know why this should be private? Here is the site I code I found. Thanks, Jeremy Toves http://visualbasic.about.com/od/learnvb6/l/bldykvb6dosa.htm?terms=vb+script+close+window Private Declare Function OpenProcess _ Lib "kernel32" ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) _ As Long Private Declare Function WaitForSingleObject _ Lib "kernel32" ( _ ByVal hHandle As Long, _ ByVal dwMilliseconds As Long) _ As Long Private Declare Function CloseHandle _ Lib "kernel32" ( _ ByVal hObject As Long) _ As Long Private Const SYNCHRONIZE = &H100000 Private Const INFINITE = &HFFFF Sub Main() ShellAndWait ("C:\WINDOWS\system32\ping.EXE www.google.com") End Sub Private Sub ShellAndWait(CommandLine As String) Dim ShellId As Long Dim ShellHandle As Long ShellId = Shell(CommandLine, vbNormalFocus) ShellHandle = OpenProcess(SYNCHRONIZE, 0, ShellId) If ShellHandle <> 0 Then WaitForSingleObject ShellHandle, INFINITE CloseHandle ShellHandle End If End Sub