[AccessD] [SPAM SUSPECT] VBA and DOS Question

Bobby Heid bheid at appdevgrp.com
Tue Feb 7 14:14:57 CST 2006


There should be no reason that you can't make it public.  Usually, the way
that I program is to make a needed function public, and any helper functions
that the function needs (that are not needed elsewhere) private.

Bobby

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jeremy Toves
Sent: Tuesday, February 07, 2006 2:56 PM
To: AccessD
Subject: [SPAM SUSPECT] [AccessD] VBA and DOS Question
Importance: Low


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