[AccessD] VBA and DOS Question

Jürgen Welz jwelz at hotmail.com
Tue Feb 7 14:22:16 CST 2006


Jeremy:

No need for the procedure to be private.  As long as the API calls are in 
the same module as your wrapper function, the API declares can remain 
private.  This is typical VB usage with a routine named 'Main' and is scoped 
to work only within the example routine.


Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: Jeremy Toves <itsame2000 at sbcglobal.net>
>
>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





More information about the AccessD mailing list