|
-
Sep 21st, 2000, 09:21 AM
#1
Thread Starter
Fanatic Member
When I shell an app, how can I tell when it's completed?
Thanks in advance
-
Sep 21st, 2000, 11:39 AM
#2
_______
<?>
Code:
this is the code for trythis.exe
Private Sub Form_Load()
Dim x As Integer, y As Integer
Randomize
For x = 1 To 4000
y = x * Int(Rnd * 10) + 1
Next x
Unload Me
End Sub
'this is the code for Project1
Private Sub Command1_Click()
Shell ("C:\myApp.exe")
DoEvents
MsgBox "Done"
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 21st, 2000, 12:44 PM
#3
Thread Starter
Fanatic Member
Thanks (But)
You know.. I am shelling a DOS prog... (not my prog) to uncompress a set of files... I have no know way of knowing
when the uncompress is done so that I can proceed with
files resulting from the uncompress...
My prog needs to know that...
Hope I am a bit clearer...
Any help is appreciated
-
Sep 21st, 2000, 01:38 PM
#4
Try this:
Code:
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
'JobtoDo - Program to run
'frm - Form
'You can do anything after the loop..shell another program if that program is close, load another version of your app, etc.
Sub Shell32Bit(ByVal JobToDo As String, frm As Form)
Dim hProcess As Long
Dim RetVal As Long
'The next line launches JobToDo as icon,
'captures process ID
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1))
Do
'Get the status of the process
GetExitCodeProcess hProcess, RetVal
'Sleep command recommended as well as DoEvents
DoEvents: Sleep 100
'Loop while the process is active
Loop While RetVal = STILL_ACTIVE
'Put your code here
'Events here occur when app is unloaded
End Sub
Usage:
Private Sub Command1_Click()
Call Shell32Bit("C:\App\App.exe", Me)
End Sub
-
Sep 21st, 2000, 03:09 PM
#5
Thread Starter
Fanatic Member
!!!!
Wow!
Matthew.... That's quite a piece..!
It looks very promising... I will try first, God willing,
first thing tomorrow morning
Thanks a lot...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|