Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wait Exe
Message
 
To
12/08/1998 10:15:52
Ramakrishna Mellachervu
Visualsoft(India) Limited.
Hyderabad, India
General information
Forum:
Visual Basic
Category:
Other
Title:
Miscellaneous
Thread ID:
00126009
Message ID:
00126053
Views:
23
Here is the answer.

Copy this code on a form with a command button to test it.


Option Explicit

Private Declare Function WaitForSingleObject _
Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess _
Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Private Const INFINITE = &HFFFF

Private Sub Command1_Click()
WaitForProcessToEnd "CALC.EXE"
End Sub

Private Function WaitForProcessToEnd(ByVal pstrExecute As String) As Boolean
'**********************************************************************
'*** Execute a process an wait for it to end before continuing here ***
'**********************************************************************
Dim lngHandle As Long
Dim lngProcessID As Long
Dim lngReturnValue As Long

On Error GoTo ErrorHandler

WaitForProcessToEnd = False

lngProcessID = Shell(pstrExecute)
lngHandle = OpenProcess(&H100000, True, lngProcessID)
lngReturnValue = WaitForSingleObject(lngHandle, INFINITE)

MsgBox "Here is the proof that I was waiting!!!"

WaitForProcessToEnd = True

GoHere:
Exit Function

ErrorHandler:
Select Case Err.Number
Case 53 'File not found
MsgBox pstrExecute & " cannot be found.", vbOKOnly + vbCritical
Resume GoHere
Case Else
MsgBox Err.Number & " : " & Err.Description
Resume GoHere
End Select
End Function


>I have created an EXE which is developed in PowerBuilder and i am used in VisualBasic 5.0. At the time of exe execution, i want to stop or wait the VB execution. Tell me the answer. Here my EXE is executing their own way and vb exe is executing their own way.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform