5 replies
by sl-campbell
Go to this site in VB-World:
http://161.58.186.98/tips/tip5.html
by msi
by peyison
The code below will do this:
Public Sub ShellAndWait(asCommand As String, asCommandLine As String)
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
lPid = Shell(asCommand & " " & asCommandLine)
If lPid <> 0 Then
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, INFINITE)
CloseHandle (lHnd)
End If
End If
End Sub
---------------------
Put the following in the declarations section of a module:
Public 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
-------------------------
To use it, just pass the name of the program you want to execute:
ShellAndWait "c:\mydosapp.exe"
Hope this helps.
by msi
by msi
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending